增加遥信和总召

main
BlueMatthew 2 years ago
parent b950ea6aaf
commit de07be4ef2

@ -9,6 +9,10 @@ iec_byq_count = 1
iec_break_count = 1
iec_site_id = 1
[IEC_INTERVAL]
# activation timer
action_interval = 30
[COMM_SAVE_INTERNAL]
DATA_SAVE_INTERNAL = 30
ORIGIN_DATA_SAVE_INTERNAL = 3600

@ -138,6 +138,7 @@ typedef struct _IEC104_CONF
{
unsigned int save_internal; // 104时间保存间隔时间(s)
unsigned int orgin_data_save_internal; // 104原始数据保存时间(s)
unsigned int action_interval; // 总召间隔时间(s)
unsigned int iec_byq_count; // 变压器数量
unsigned int iec_break_count; // 断路器数量
unsigned char site_id[DEF_EQM_CODE_SIZE]; // 站点ID

@ -246,6 +246,15 @@ static bool iGetIEC104Conf()
}
g_iec_conf.save_internal = (unsigned int)atoi(szTmp);
// 总召间隔时间(s)
memset(szTmp, 0x00, sizeof(szTmp));
if ((iRet = iGetString("IEC_INTERVAL", "action_interval", szTmp, sizeof(szTmp))) < 0) {
vPrtLogMsg(LOG_ERROR, iRet, "get action_interval parameter failed!");
fclose(fpIec);
return false;
}
g_iec_conf.action_interval = (unsigned int)atoi(szTmp);
// 104原始数据保存时间(s)
memset(szTmp, 0x00, sizeof(szTmp));
if ((iRet = iGetString("COMM_SAVE_INTERNAL", "ORIGIN_DATA_SAVE_INTERNAL", szTmp, sizeof(szTmp))) < 0) {
@ -1459,6 +1468,11 @@ bool bSetPointTableValueYC(const std::vector<IEC_OBJVAL_NEW>& values)
mutex_lock(g_map_iec_mutex_new);
for (std::vector<IEC_OBJVAL_NEW>::const_iterator it = values.begin(); it != values.end(); ++it)
{
if (it->stype == 1)
{
continue;
}
itPoint = g_map_iec_new.find(it->sadr);
if (itPoint == g_map_iec_new.end() || strlen((const char*)itPoint->second.fieldName) == 0)
{
@ -1600,6 +1614,15 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
adr = ps->addr2 << 16 | ps->addr1 << 8 | ps->addr0;
vPrtLogMsg(LOG_DEBUG, RET_OK, "type=%d SP_%d: val:%d Valid: %d Blocked: %d", header->type, adr, ps->siq.spi, ps->siq.iv, ps->siq.bl);
bSetPointTableValueYX(ps->siq.spi, adr);
/*
ycItem.stype = 1;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.ival = ps->siq.spi;
ycItems.push_back(ycItem);
*/
pos = sizeof(ST_ASDU_HEADER)+sizeof(SP104);
while (pos < len)
{
@ -1607,6 +1630,15 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
pi = (SIQ104*)&msgbuf[pos];
//
bSetPointTableValueYX(pi->spi, adr);
/*
ycItem.stype = 1;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.ival = pi->spi;
ycItems.push_back(ycItem);
*/
if (pi->spi)
vPrtLogMsg(LOG_DEBUG, RET_OK, "type=%d SP_%d: val:%d Valid: %d Blocked: %d", header->type, adr, pi->spi, pi->iv, pi->bl);
pos++;
@ -1620,6 +1652,14 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
SP104 *ps = (SP104*)&msgbuf[pos];
adr = ps->addr2 << 16 | ps->addr1 << 8 | ps->addr0;
bSetPointTableValueYX(ps->siq.spi, adr);
/*
ycItem.stype = 1;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.ival = ps->siq.spi;
ycItems.push_back(ycItem);
*/
vPrtLogMsg(LOG_DEBUG, RET_OK, "type=%d SP_%d: val:%d Valid: %d Blocked: %d", header->type, adr, ps->siq.spi, ps->siq.iv, ps->siq.bl);
pos += sizeof(SP104);
}
@ -1634,6 +1674,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
short *val = (short*)&pf->val[0];
bSetPointTableValueYC(*val, adr);
ycItem.stype = 2;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.fval = *val;
@ -1648,6 +1689,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
short *val = (short*)&pfv->val[0];
bSetPointTableValueYC(*val, adr);
ycItem.stype = 2;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.fval = *val;
@ -1667,6 +1709,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
short *val = (short*)&pf->val[0];
bSetPointTableValueYC(*val, adr);
ycItem.stype = 2;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.fval = *val;
@ -1686,6 +1729,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
float *val = (float*)&pf->val[0];
bSetPointTableValueYC(*val, adr);
ycItem.stype = 2;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.fval = *val;
@ -1700,6 +1744,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
float *val = (float*)&pfv->val[0];
bSetPointTableValueYC(*val, adr);
ycItem.stype = 2;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.fval = *val;
@ -1718,6 +1763,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
float *val = (float*)&pf->val[0];
bSetPointTableValueYC(*val, adr);
ycItem.stype = 2;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.fval = *val;
@ -1738,6 +1784,15 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
char buf[32];
t56.GetTimeString(buf, sizeof(buf));
bSetPointTableValueYX(ps->siq.spi, adr);
/*
ycItem.stype = 1;
ycItem.dtime = ts;
ycItem.sadr = adr;
ycItem.ival = ps->siq.spi;
ycItems.push_back(ycItem);
*/
vPrtLogMsg(LOG_DEBUG, RET_OK, "type=%d SP_%d: val:%d Valid: %d Blocked: %d time:%s", header->type, adr, ps->siq.spi, ps->siq.iv, ps->siq.bl, buf);
pos += sizeof(SP104_T);
}
@ -1754,6 +1809,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
CP56Time t56(pf->time);
ycItem.stype = 2;
ycItem.dtime = t56.GetTime();
ycItem.sadr = adr;
ycItem.fval = *val;
@ -1803,6 +1859,7 @@ int DecodeMsgFormatI(unsigned char *msgbuf, unsigned int len, unsigned short sen
}
else if (cause == 10) // 激活结束
{
g_IecCtrl.time_action = ts; // time(NULL);
// SendMsgFormatS(sendno); // 总召唤结束发送S帧确认
if (g_TConfig.shouldParseBusiData() != 0)
{
@ -1855,7 +1912,8 @@ int SendMsgFormatIAction(unsigned char cmd)
g_Tcp.tcpCloseSocket(g_IecCtrl.sockid);
g_IecCtrl.isConnect = false;
}
g_IecCtrl.time_action = time(NULL); // 总召间隔时间更新
g_IecCtrl.time_action = -1; // 总召间隔时间更新
vPrtLogHex(LOG_PACK, g_IecCtrl.sockid, PRT_PACK_SEND, (unsigned char*)&stPack, iRet);
}
return iRet;
@ -3686,6 +3744,13 @@ void *thread_Timer_proc(void *arg)
SendMsgFormatU(CMD_TESTFR);
g_IecCtrl.timer_U_Testflag = true;
}
// 定期总召
if ((g_IecCtrl.time_action != -1) && ((timeOrigin - g_IecCtrl.time_action) > g_iec_conf.action_interval))
{
vPrtLogMsg(LOG_DEBUG, RET_OK, "Send Activation");
SendMsgFormatIAction(CMD_CTL_64H); // 发送总召激活
}
}
}
return NULL;

@ -451,10 +451,14 @@ static void vLoadIECPointTableNew()
stSensor.one_dtime = (unsigned char)strtoul(row[idx], NULL, 10);
}
stSensor.sensor_id = stPoint.sensor_id;
if (stPoint.stype == 1) // YX
{
continue;
}
// vPrtLogMsg(LOG_WARNG, RET_OK, "----TABLE %s oneTime=%u", (const char*)stSensor.tableName, (unsigned int)stSensor.one_dtime);
mutex_lock(g_map_iec_mutex_new);
itDev = g_map_devices.find(stSensor.sensor_id);
if (itDev == g_map_devices.end())
{

Loading…
Cancel
Save