Exemplo n.º 1
0
static A_Err MDLIO_InitInSpecFromFile(
	AEIO_BasicData		*basic_dataP,
	const A_UTF16Char	*file_pathZ,
	AEIO_InSpecH		specH )
{
	/*	Read the file referenced by the path. Use the
	file information to set all fields of the AEIO_InSpecH.
	*/

	AEGP_SuiteHandler suites( basic_dataP->pica_basicP );
	Menge::Logger logger( basic_dataP->msg_func );

	AEIO_Handle optionsH = NULL;
	suites.MemorySuite1()->AEGP_NewMemHandle( basic_dataP->aegp_plug_id,
		"MDLOptions",
		sizeof( Menge::MDLOptions ),
		AEGP_MemFlag_CLEAR,
		&optionsH );

	Menge::MDLOptions * headerP = NULL;
	suites.MemorySuite1()->AEGP_LockMemHandle( optionsH, reinterpret_cast<void **>(&headerP) );

	if( headerP == NULL )
	{
		return A_Err_GENERIC;
	}

	Menge::MDLRender * render = (Menge::MDLRender *)basic_dataP->aegp_refconPV;

	bool successful = true;

	std::wstring ptc = (const wchar_t *)file_pathZ;
	successful = s_InitInSpecFromFile( logger, headerP, render, ptc );

	if( successful == true )
	{
		AEIO_Handle old_optionsH = NULL;
		suites.IOInSuite4()->AEGP_SetInSpecOptionsHandle( specH,
			optionsH,
			reinterpret_cast<void **>(&old_optionsH) );

		suites.IOInSuite4()->AEGP_SetInSpecDepth( specH, 32 );

		suites.IOInSuite4()->AEGP_SetInSpecDuration( specH, &headerP->duration );
		suites.IOInSuite4()->AEGP_SetInSpecDimensions( specH, headerP->width, headerP->height );

		A_Fixed	native_fps = FLOAT2FIX( 29.97 );
		suites.IOInSuite4()->AEGP_SetInSpecNativeFPS( specH, native_fps );
	}

	suites.MemorySuite1()->AEGP_UnlockMemHandle( optionsH );

	if( successful == false )
	{
		return A_Err_GENERIC;
	}

	return A_Err_NONE;
}
Exemplo n.º 2
0
uint8_t *reg_DefaultValue(uint_t nID, uint8_t *pBuf)
{
	uint32_t *pInt = (uint32_t *)pBuf;

	switch (nID) {
#if 0
	case 0x0103://终端等待从动站响应的超时时间
	case 0x0104://终端作为启动站允许发送重发次数	
	case 0x1211://轮显时间
	case 0x1241://文件系统碎片整理阀值
		*pInt = 10;
		break;
	case 0x0125://公网通讯模块工作方式 
	case 0x0152://终端地址
	case 0x0170://是否允许终端与主站通话
	case 0x0171://是否允许终端主动上报		
	case 0x01A3://RS232停止位
	case 0x01B3://红外停止位
	case 0x0414://终端停电标志
	case 0x2217://电表通信停止位
	case 0x2761://CT
	case 0x2762://PT
		*pInt = 1;
		break;
	case 0x0102://终端作为启动站允许发送传输延时时间
	case 0x0105://心跳周期 
	case 0x0132://被动激活模式连续无通讯自动断线时间
		*pInt = 300; 
		break;
	case 0x0222://日数据冻结点数
	case 0x0127://永久在线模式重拨间隔
	case nID_MaxVWindow://滑差时间
		*pInt = 60; 
		break;
	case 0x0151://行政区划码
		*pInt = 0x2081;
		break;
	case 0x01A0://"RS232波特率"
	case 0x01B0://"红外波特率"
		*pInt = 9600;
		break;
	case 0x0116://APN
		pBuf = "CMNET";
		break; 
	case 0x01D1://User
	case 0x01D2://Password
		pBuf = "CARD";
		break; 
	case 0x01C1://DNS
		pBuf = "gtpower.vicp.net";
		break;
	case 0x01E1://终端名称
		pBuf = "PDK6000配变监测终端";
		break;
		
	case 0x0221://曲线冻结点数
		*pInt = 5760;
		break;
	case 0x0223://月数据冻结点数
		*pInt = 6;
		break;
	case 0x0410:
	case 0x0411:
		pBuf = (uint8_t *)arrFF;
		break;
	case 0x0861: {//电压谐波限值
			uint16_t *pThd = (uint16_t *)pBuf;
			for (i = 0; i < 19; ++i) {
				pThd[i] = 0x0050;
			}
		}
		break;
	case 0x0862: {//电流谐波限值
			uint16_t *pThd = (uint16_t *)pBuf;
			for (i = 0; i < 19; ++i) {
				pThd[i] = 0x0500;
			}
		}
		break;
	case nID_MaxVCycle://最大需量周期
		*pInt = 900;
		break;
	case 0x0A10:
		pBuf = "JNF";
		break;
	case 0x0A11:
		pBuf = "00000001";
		break;
	case 0x0A12:
		*pInt = VER_SOFT;
		break;
	case 0x0A17:
		*pInt = VER_HARD;
		break;

	case 0x1212:
		pBuf = (uint8_t *)arrFF;
		break;

	case 0x2763://"额定电压"
		*pInt = FLOAT2FIX(220);
		break;
	case 0x2764://"额定电流"
		*pInt = FLOAT2FIX(5);
		break;
	case 0x2767://接线方式
		*pInt = 2;	//3相4线
		break;
	case 0x2771://"电压合格上限", 			"V",
		*pInt = FLOAT2FIX(220 * 1.07);
		break;
	case 0x2772://"电压合格下限", 			"V",
		*pInt = FLOAT2FIX(220 * 0.9);
		break;
	case 0x2773://"电压断相门限", 			"V",
		*pInt = FLOAT2FIX(220 * 0.7);
		break;
	case 0x2774://"过压门限", 				"V",
		*pInt = FLOAT2FIX(220 * 1.3);
		break;
	case 0x2775://"欠压门限", 				"V",
		*pInt = FLOAT2FIX(220 * 0.85);
		break;
	case 0x2776://"过流门限", 				"A",
		*pInt = FLOAT2FIX(5 * 1.3);
		break;
	case 0x2777://"额定电流门限", 			"A",
		*pInt = FLOAT2FIX(5);
		break;
	case 0x2781://"零序电流上限", 			"A",
		*pInt = FLOAT2FIX(5 * 0.25);
		break;
	case 0x2782://"视在功率上上限",			"KVA",
		*pInt = FLOAT2FIX(3 * 1.2);
		break;
	case 0x2783://"视在功率上限", 			"KVA",
		*pInt = FLOAT2FIX(3);
		break;
	case 0x2784://"三相电压不平衡上限",		"",
	case 0x2785://"三相电流不平衡上限", 	"",
		*pInt = FLOAT2FIX(0.5);
		break;
	case 0x2788://"功率因数分段限值1",		"",
		*pInt = FLOAT2FIX(0.95);
		break;
	case 0x2789://"功率因数分段限值2",		"",
		*pInt = FLOAT2FIX(0.8);
		break;
	case 0x2791://"连续失压时间限值", 		"Min",
		*pInt = 5;			
		break;
	case 0x8541://最小电压
	case 0x8542:
	case 0x8543:
	case 0x8841:
	case 0x8842:
	case 0x8843:
		*pInt = 0x7FFFFFFF;
		break;
#endif
	default:
		pBuf = (uint8_t *)arrZero;
		break; 
	}
	return pBuf;
}
Exemplo n.º 3
0
static A_Err MDLIO_InflateOptions( AEIO_BasicData * basic_dataP
	, AEIO_InSpecH specH
	, AEIO_Handle flat_optionsH )
{
	/*	During this function,

	+	Create a non-flat options structure, containing the info from the
	flat_optionsH you're passed.

	+	Set the options for the InSpecH using AEGP_SetInSpecOptionsHandle().
	*/

	AEGP_SuiteHandler	suites( basic_dataP->pica_basicP );
	Menge::Logger logger( basic_dataP->msg_func );

	if( flat_optionsH == nullptr )
	{
		return A_Err_NONE;
	}

	std::wstring ptcPath;
	s_AEGP_GetInSpecFilePath( basic_dataP, specH, ptcPath );

	if( ptcPath.empty() == true )
	{
		return A_Err_NONE;
	}

	unsigned char * flat_headerP = NULL;
	suites.MemorySuite1()->AEGP_LockMemHandle( flat_optionsH, (void**)&flat_headerP );

	if( flat_headerP == nullptr )
	{
		return A_Err_GENERIC;
	}

	AEIO_Handle optionsH = NULL;
	suites.MemorySuite1()->AEGP_NewMemHandle( basic_dataP->aegp_plug_id,
		"MDLOptions",
		sizeof( Menge::MDLOptions ),
		AEGP_MemFlag_CLEAR,
		&optionsH );

	if( optionsH == nullptr )
	{
		return A_Err_GENERIC;
	}

	Menge::MDLOptions * new_headerP = NULL;
	suites.MemorySuite1()->AEGP_LockMemHandle( optionsH, reinterpret_cast<void **>(&new_headerP) );

	if( new_headerP == nullptr )
	{
		return A_Err_GENERIC;
	}

	new_headerP->readFlatten( flat_headerP );

	Menge::MDLRender * render = (Menge::MDLRender *)basic_dataP->aegp_refconPV;

	bool successful = s_InitInSpecFromFile( logger, new_headerP, render, ptcPath );

	if( successful == true )
	{
		AEIO_Handle old_optionsH = NULL;
		suites.IOInSuite4()->AEGP_SetInSpecOptionsHandle( specH,
			optionsH,
			reinterpret_cast<void **>(&old_optionsH) );

		suites.IOInSuite4()->AEGP_SetInSpecDepth( specH, 32 ); // always 32 bits
		suites.IOInSuite4()->AEGP_SetInSpecDuration( specH, &new_headerP->duration );
		suites.IOInSuite4()->AEGP_SetInSpecDimensions( specH, new_headerP->width, new_headerP->height );

		A_Fixed	native_fps = FLOAT2FIX( 29.97 );
		suites.IOInSuite4()->AEGP_SetInSpecNativeFPS( specH, native_fps );
	}

	suites.MemorySuite1()->AEGP_UnlockMemHandle( optionsH );
	suites.MemorySuite1()->AEGP_UnlockMemHandle( flat_optionsH );

	if( successful == false )
	{
		return A_Err_GENERIC;
	}

	return A_Err_NONE;
};
Exemplo n.º 4
0
noise_stats_t *
fe_init_noisestats(int num_filters)
{
    int i;
    noise_stats_t *noise_stats;

    noise_stats = (noise_stats_t *) ckd_calloc(1, sizeof(noise_stats_t));

    noise_stats->power =
        (powspec_t *) ckd_calloc(num_filters, sizeof(powspec_t));
    noise_stats->noise =
        (powspec_t *) ckd_calloc(num_filters, sizeof(powspec_t));
    noise_stats->floor =
        (powspec_t *) ckd_calloc(num_filters, sizeof(powspec_t));
    noise_stats->peak =
        (powspec_t *) ckd_calloc(num_filters, sizeof(powspec_t));

    noise_stats->undefined = TRUE;
    noise_stats->num_filters = num_filters;

#ifndef FIXED_POINT
    noise_stats->lambda_power = LAMBDA_POWER;
    noise_stats->comp_lambda_power = 1 - LAMBDA_POWER;
    noise_stats->lambda_a = LAMBDA_A;
    noise_stats->comp_lambda_a = 1 - LAMBDA_A;
    noise_stats->lambda_b = LAMBDA_B;
    noise_stats->comp_lambda_b = 1 - LAMBDA_B;
    noise_stats->lambda_t = LAMBDA_T;
    noise_stats->mu_t = MU_T;
    noise_stats->max_gain = MAX_GAIN;
    noise_stats->inv_max_gain = 1.0 / MAX_GAIN;
    
    for (i = 0; i < 2 * SMOOTH_WINDOW + 1; i++) {
        noise_stats->smooth_scaling[i] = 1.0 / i;
    }
#else
    noise_stats->lambda_power = FLOAT2FIX(log(LAMBDA_POWER));
    noise_stats->comp_lambda_power = FLOAT2FIX(log(1 - LAMBDA_POWER));
    noise_stats->lambda_a = FLOAT2FIX(log(LAMBDA_A));
    noise_stats->comp_lambda_a = FLOAT2FIX(log(1 - LAMBDA_A));
    noise_stats->lambda_b = FLOAT2FIX(log(LAMBDA_B));
    noise_stats->comp_lambda_b = FLOAT2FIX(log(1 - LAMBDA_B));
    noise_stats->lambda_t = FLOAT2FIX(log(LAMBDA_T));
    noise_stats->mu_t = FLOAT2FIX(log(MU_T));
    noise_stats->max_gain = FLOAT2FIX(log(MAX_GAIN));
    noise_stats->inv_max_gain = FLOAT2FIX(log(1.0 / MAX_GAIN));

    for (i = 1; i < 2 * SMOOTH_WINDOW + 3; i++) {
        noise_stats->smooth_scaling[i] = FLOAT2FIX(log(i));
    }
#endif

    return noise_stats;
}