修复bug 定期总召优化

main
BlueMatthew 2 years ago
parent de07be4ef2
commit c4b0d15c50

@ -214,10 +214,14 @@ static bool iGetIEC104Conf()
memset(szTmp, 0x00, sizeof(szTmp));
if ((iRet = iGetString("IEC_DEVCOUNT", "iec_break_count", szTmp, sizeof(szTmp))) < 0) {
vPrtLogMsg(LOG_ERROR, iRet, "get iec_break_count parameter failed!");
fclose(fpIec);
return false;
// fclose(fpIec);
// return false;
g_iec_conf.iec_break_count = 0;
}
else
{
g_iec_conf.iec_break_count = (unsigned int)atoi(szTmp);
}
g_iec_conf.iec_break_count = (unsigned int)atoi(szTmp);
// 申请断路器设备编码缓冲区
g_iec_conf.pstBrkCode = (ST_BREAK_EQM_CODE*)calloc(g_iec_conf.iec_break_count, sizeof(ST_BREAK_EQM_CODE));
if (!g_iec_conf.pstBrkCode) {
@ -2197,7 +2201,7 @@ void * thread_origin_proc_new(void * arg)
g_IecCtrl.last_origin_time = now;
memset(szSql, 0x00, sizeof(szSql));
vTranHostTimeFmt((now - g_iec_conf.orgin_data_save_internal), szWaringTime);
snprintf(szSql, sizeof(szSql), "DELETE FROM niec_origin_data_new WHERE d_time<'%s' ", szWaringTime);
snprintf(szSql, sizeof(szSql), "DELETE FROM niec_origin_data WHERE d_time<'%s' ", szWaringTime);
pdbHandle->AddInsertRecord(pMySql, szSql);
}
@ -3682,11 +3686,26 @@ unsigned char getDevFaultState(ST_IECPOINT_TABLE &stIec)
void *thread_Timer_proc(void *arg)
{
vPrtLogMsg(LOG_DEBUG, 0, "thread_Timer_proc = %d startup...", GETTID());
while (g_Running && g_IecCtrl.isConnect)
while (g_Running)
{
// Sleep(1000);
if (!g_IecCtrl.isConnect)
{
_SLEEP(1000);
continue;
}
// 间隔1s
time_t timeOrigin = time(NULL);
time_t timeOrigin = time(NULL);
// 定期总召
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); // 发送总召激活
}
_SLEEP(1000);
continue;
while ((time(NULL) - timeOrigin) < 1000) _SLEEP(1000);
if (!g_IecCtrl.isConnect) // t0时间内连接未建立则重新连接并发送U启动帧激活数据传输
@ -3744,13 +3763,6 @@ 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;

Loading…
Cancel
Save