|
|
|
@ -3219,6 +3219,7 @@ void ProvBuban104SendAllData(int commid, RTUMSG * rtumsg)
|
|
|
|
|
//====================================================================
|
|
|
|
|
//if(pPortParam->m_bProvAiType == 13)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104Send103DI(commid,rtumsg,0);
|
|
|
|
|
ProvBuban104SendAIwithFloat(commid, rtumsg, 0);
|
|
|
|
|
}
|
|
|
|
|
/*else
|
|
|
|
@ -4686,7 +4687,7 @@ void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
if (iaddr1 == iaddr0)
|
|
|
|
|
{
|
|
|
|
|
; //commandbuf[9] = (u_char)iaddr0; //
|
|
|
|
|
//commandbuf[10] = (u_char)(iaddr0 >> 8); // 应用服务数据单元公共地址
|
|
|
|
|
//commandbuf[10] = (u_char)(iaddr0 >> 8); // 应用服务数据单元公共地址
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -4744,6 +4745,157 @@ void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
//printf("get total %d item!\n", i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
int j // 对应数据库数据点号
|
|
|
|
|
int *igno // 组号
|
|
|
|
|
int* iItemNo 条目号
|
|
|
|
|
DAY_TIME* sCurTime 时间
|
|
|
|
|
u_char* uValue 数据值
|
|
|
|
|
u_char *iBitNo 数据位号
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
WORD Year;
|
|
|
|
|
u_char Month;
|
|
|
|
|
u_char Day;
|
|
|
|
|
u_char WeekDay;
|
|
|
|
|
u_char MonthDay;
|
|
|
|
|
u_char Hour;
|
|
|
|
|
u_char Min;
|
|
|
|
|
u_char Sec;
|
|
|
|
|
u_char reserved;
|
|
|
|
|
WORD mSec;
|
|
|
|
|
} DAY_TIME;
|
|
|
|
|
返回值1:成功取值 -1:取值失败
|
|
|
|
|
*/
|
|
|
|
|
int GetDIPntMsg(int j, int *igno, int* iItemNo, DAY_TIME* sCurTime, u_char* uValue, int *iaddr, u_char *iBitNo)
|
|
|
|
|
{
|
|
|
|
|
*igno = 1;
|
|
|
|
|
*iItemNo = 1;
|
|
|
|
|
*iaddr = 1;
|
|
|
|
|
*iBitNo = 1;
|
|
|
|
|
sCurTime->Hour = 12;
|
|
|
|
|
sCurTime->Min = 30;
|
|
|
|
|
sCurTime->Month = 11;
|
|
|
|
|
sCurTime->MonthDay = 1;
|
|
|
|
|
sCurTime->mSec = 600;
|
|
|
|
|
sCurTime->Sec = 26;
|
|
|
|
|
sCurTime->Year = 2023;
|
|
|
|
|
*uValue = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define MAX_DI_NUM 10000
|
|
|
|
|
void ProvBuban104Send103DI(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN], iNumb[MAX_DI_NUM];
|
|
|
|
|
DWORD dDiData=0;
|
|
|
|
|
int iLenth, iSendCount = 1, iaddr0 = 1, iaddr1 = 1, ibyid = 11827;
|
|
|
|
|
int i, j, iAllDataCount, iSendNum, flag, iErgodic;
|
|
|
|
|
int iNo, iCmdType, igno, iItemNo, igno0, iItemNo0;
|
|
|
|
|
u_char uValue, iBitNo=1;
|
|
|
|
|
DAY_TIME sCurTime;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
PROV_AI_PNT *aiprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
|
|
|
|
|
if (iGroupNo == 0)//总召唤
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->AiNum;
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
if (iAllDataCount >= MAX_DI_NUM)
|
|
|
|
|
iAllDataCount = MAX_DI_NUM;
|
|
|
|
|
|
|
|
|
|
memset(iNumb, 0, sizeof(iNumb));
|
|
|
|
|
for(;;)
|
|
|
|
|
{
|
|
|
|
|
for (iErgodic = 0; iErgodic < iAllDataCount; iErgodic++)
|
|
|
|
|
{ // 寻查最近一个未获取数据的数据点号
|
|
|
|
|
if (0 == iNumb[iErgodic])
|
|
|
|
|
{
|
|
|
|
|
flag = GetDIPntMsg(iErgodic, (unsigned int*)&igno0, (unsigned int*)&iItemNo0, &sCurTime, &uValue, (unsigned int*)&iaddr0, &iBitNo);
|
|
|
|
|
if (0 == flag)
|
|
|
|
|
return;
|
|
|
|
|
iNumb[iErgodic] = 1;
|
|
|
|
|
if (-1 == flag)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ((iBitNo < 1) || (iBitNo > 32))
|
|
|
|
|
continue;
|
|
|
|
|
dDiData = (((DWORD)uValue << (iBitNo - 1)) | dDiData);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (iErgodic >= iAllDataCount)
|
|
|
|
|
return;
|
|
|
|
|
memset(commandbuf, 0, sizeof(commandbuf));
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 10; // 类型标识TYP
|
|
|
|
|
commandbuf[7] = 0x81; // 可变结构限定词VSQ
|
|
|
|
|
commandbuf[8] = 0x2A; // 传送原因COT
|
|
|
|
|
commandbuf[9] = (u_char)iaddr0; //
|
|
|
|
|
commandbuf[10] = (u_char)(iaddr0 >> 8); // 应用服务数据单元公共地址
|
|
|
|
|
commandbuf[11] = 254; // 功能类型FUN
|
|
|
|
|
commandbuf[12] = 241; // 信息序号INF
|
|
|
|
|
commandbuf[13] = 0; // 返回信息标识码RII
|
|
|
|
|
commandbuf[14] = 0x81; // 通用分类数据集数目NGD
|
|
|
|
|
iLenth = 15;
|
|
|
|
|
commandbuf[iLenth++] = igno0;
|
|
|
|
|
commandbuf[iLenth++] = iItemNo0;
|
|
|
|
|
commandbuf[iLenth++] = 1; // 描述类别KOD(实际值)
|
|
|
|
|
commandbuf[iLenth++] = 7; // 数据类型
|
|
|
|
|
commandbuf[iLenth++] = 4; // 数据宽度
|
|
|
|
|
commandbuf[iLenth++] = 4; // 数据数目
|
|
|
|
|
commandbuf[iLenth++] = sCurTime.mSec % 256;
|
|
|
|
|
commandbuf[iLenth++] = sCurTime.mSec / 256;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Min;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Hour;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Day;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Month;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)(sCurTime.Year % 100);
|
|
|
|
|
for (i = iErgodic + 1; i < iAllDataCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (1 == iNumb[i]) // 已经寻查过,不再查询
|
|
|
|
|
continue;
|
|
|
|
|
flag = GetDIPntMsg(i, (unsigned int*)&igno, (unsigned int*)&iItemNo, &sCurTime, &uValue, (unsigned int*)&iaddr1, &iBitNo);
|
|
|
|
|
if (0 == flag)
|
|
|
|
|
break;
|
|
|
|
|
if (-1 == flag)
|
|
|
|
|
{ // 查询数据失败的,标注已经查询
|
|
|
|
|
iNumb[i] = 1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ((iaddr0 == iaddr1) && (igno0 == igno) && (iItemNo0 == iItemNo))
|
|
|
|
|
{
|
|
|
|
|
iNumb[i] = 1;
|
|
|
|
|
if ((iBitNo < 1) || (iBitNo > 32))
|
|
|
|
|
continue;
|
|
|
|
|
dDiData = (((DWORD)uValue << (iBitNo - 1)) | dDiData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLenth++] = (u_char)dDiData;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)(dDiData >> 8);
|
|
|
|
|
commandbuf[iLenth++] = (u_char)(dDiData >> 16);
|
|
|
|
|
commandbuf[iLenth++] = (u_char)(dDiData >> 24);
|
|
|
|
|
iLenth += 4;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)ibyid;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)(ibyid >> 8); // 变电站ID
|
|
|
|
|
commandbuf[1] = (char)(iLenth - 2);
|
|
|
|
|
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|