{
INT16U afn; /*功能码 */
INT16U point; /*测量点 */
INT16U id_len; /*源数据长度 */
const INT16U *id_buff; /*源数据缓冲区,主要是传递ID号用,其他数据传递请勿用 */
const INT8U *pSource; /*主要是参数查询,需要传递的一些数据*/
INT16U dlen; /*目的数据长度 */
INT8U *dbuff; /*目的数据缓冲区 */
}InterfaceStruct;
ID = F25;
parestuct.afn = METER_READ;
parestuct.point = 1;
parestuct.id_buff = &ID;
parestuct.id_len = 1;
parestuct.dlen = 0;
parestuct.dbuff =TC_Para;
parestuct.dlen = sizeof(TC_Para);
GWContral_function(&parestuct);
INT16U GWContral_function(InterfaceStruct *pdata)
{
INT32S postion ;
INT16U tmpID;
INT16U result;
。。。。。。
tmpID = * (pdata->id_buff);
postion = BinarySearchAgreememtID(tmpID,V2_CONTRAL_PARA_TABLE,(sizeof(V2_CONTRAL_PARA_TABLE)/sizeof(_PARA_TABLE_)));
result = 0 ;
if(postion>=0)
{
pInformTble =& V2_CONTRAL_PARA_TABLE[postion];
。。。。。。
}
INT32S BinarySearchAgreememtID( INT16U ID,const _PARA_TABLE_ arraryTable[ ] ,INT32U dataTpyeLen )
{ //读取所在位置
INT32U sizeArray;
sizeArray = dataTpyeLen;
if(sizeArray>0)
{
INT32S left = 0 ;
INT32S right = sizeArray-1;
while(left<right)
{
INT32U middle = (left+right+1)/2;
if(ID<arraryTable[middle].DataID)
right = middle-1;
else
left = middle;
}
if(ID ==arraryTable[left].DataID)
return left;
}
return -1;
}
const _PARA_TABLE_ V2_CONTRAL_PARA_TABLE[]=
// INT16UDataID INT8U PointNums INT16U DataLen INT32U AddrOffset
{
{ 0, 1, 0 , 0 }
#ifdef GUOWANG_FU
,{ F1, RETOTECONTRAOL_SUM, sizeof(_CONTRAL_F1) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF1) }
,{ F2, RETOTECONTRAOL_SUM, sizeof(_CONTRAL_F1) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF1) }
#else
,{ F1, NULLPOINT, 0 , 0 }
,{ F2, NULLPOINT, 0 , 0 }
#endif
,{ F3, NULLPOINT, 0 , 0 }
,{ F4, NULLPOINT, 0 , 0 }
,{ F5, NULLPOINT, 0 , 0 }
,{ F6, NULLPOINT, 0 , 0 }
,{ F7, NULLPOINT, 0 , 0 }
,{ F8, NULLPOINT, 0 , 0 }
#ifdef GUOWANG_FU
,{ F9, ZJZ_SUM, sizeof(_CONTRAL_F9) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF9) }
,{ F10, ZJZ_SUM, sizeof(_CONTRAL_F10) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF10) }
,{ F11, ZJZ_SUM, sizeof(_CONTRAL_F11) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF11) }
,{ F12, ZJZ_SUM, sizeof(_CONTRAL_F12) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF12) }
#else
,{ F9, NULLPOINT, 0 , 0 }
,{ F10, NULLPOINT, 0 , 0 }
,{ F11, NULLPOINT, 0 , 0 }
,{ F12, NULLPOINT, 0 , 0 }
#endif
,{ F13, NULLPOINT, 0 , 0 }
,{ F14, NULLPOINT, 0 , 0 }
#ifdef GUOWANG_FU
,{ F15, ZJZ_SUM, sizeof(_CONTRAL_F15) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF15) }
,{ F16, ZJZ_SUM, sizeof(_CONTRAL_F16) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF16) }
,{ F17, ZJZ_SUM, sizeof(_CONTRAL_F9) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF9 ) }
,{ F18, ZJZ_SUM, sizeof(_CONTRAL_F10) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF10) }
,{ F19, ZJZ_SUM, sizeof(_CONTRAL_F11) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF11) }
,{ F20, ZJZ_SUM, sizeof(_CONTRAL_F12) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF12) }
#else
,{ F15, NULLPOINT, 0 , 0 }
,{ F16, NULLPOINT, 0 , 0 }
,{ F17, NULLPOINT, 0 , 0 }
,{ F18, NULLPOINT, 0 , 0 }
,{ F19, NULLPOINT, 0 , 0 }
,{ F20, NULLPOINT, 0 , 0 }
#endif
,{ F21, NULLPOINT, 0 , 0 }
,{ F22, NULLPOINT, 0 , 0 }
#ifdef GUOWANG_FU
,{ F23, ZJZ_SUM, sizeof(_CONTRAL_F15) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF15) }
,{ F24, ZJZ_SUM, sizeof(_CONTRAL_F16) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF16) }
,{ F25, 1, sizeof(_CONTRAL_F25) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF25) }
,{ F26, 1, sizeof(_CONTRAL_F26) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF26) }
#else
,{ F23, NULLPOINT, 0 , 0 }
,{ F24, NULLPOINT, 0 , 0 }
,{ F25, NULLPOINT, 0 , 0 }
,{ F26, NULLPOINT, 0 , 0 }
#endif
,{ F27, 1, sizeof(_CONTRAL_F27) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF27) }
#ifdef GUOWANG_FU
,{ F28, 1, sizeof(_CONTRAL_F28) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF28) }
#else
,{ F28, NULLPOINT, 0 , 0 }
#endif
,{ F29, 1, sizeof(_CONTRAL_F29) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF29) }
,{ F30, NULLPOINT, 0 , 0 }
,{ F31, 1, sizeof(_CONTRAL_F31) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF31) }
,{ F32, 1, sizeof(_CONTRAL_F32) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF32) }
#ifdef GUOWANG_FU
,{ F33, 1, sizeof(_CONTRAL_F25) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF25) }
,{ F34, 1, sizeof(_CONTRAL_F26) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF26) }
#else
,{ F33, NULLPOINT, 0 , 0 }
,{ F34, NULLPOINT, 0 , 0 }
#endif
,{ F35, 1, sizeof(_CONTRAL_F27) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF27) }
#ifdef GUOWANG_FU
,{ F36, 1, sizeof(_CONTRAL_F28) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF28) }
#else
,{ F36, NULLPOINT, 0 , 0 }
#endif
,{ F37, 1, sizeof(_CONTRAL_F29) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF29) }
,{ F38, 1, sizeof(_CONTRAL_F38) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF38) }
,{ F39, 1, sizeof(_CONTRAL_F38) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF38) }
,{ F40, NULLPOINT, 0 , 0 }
,{ F41, MaxMeter, sizeof(_CONTRAL_F41) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF41) }
,{ F42, MaxMeter, sizeof(_CONTRAL_F41) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF41) }
// ,{ F43, NULLPOINT, 0 , 0 }
// ,{ F44, NULLPOINT, 0 , 0 }
// ,{ F45, NULLPOINT, 0 , 0 }
// ,{ F46, NULLPOINT, 0 , 0 }
// ,{ F47, NULLPOINT, 0 , 0 }
// ,{ F48, NULLPOINT, 0 , 0 }
,{ F49, 1, sizeof(_CONTRAL_F49) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF49) }
,{ F50, 1, sizeof(_CONTRAL_F49) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF49) }
,{ F51, 1, sizeof(_CONTRAL_F49) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF49) }
,{ F52, 1, sizeof(_CONTRAL_F51) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF51) }
,{ F53, 1, sizeof(_CONTRAL_F51) , OFFSETOF(_ALL_CONTRAL_PARA_TABLE,CF51) }
// ,{ F54, NULLPOINT, 0 , 0 }
// ,{ F55, NULLPOINT, 0 , 0 }
// ,{ F56, NULLPOINT, 0 , 0 }
// ,{ F57, NULLPOINT, 0 , 0 }
// ,{ F58, NULLPOINT, 0 , 0 }
// ,{ F59, NULLPOINT, 0 , 0 }
};
以上对应国网控制函数主体