67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
![]() |
#include "rtustatus.h"
|
||
|
|
||
|
CRTUStatusProcess::CRTUStatusProcess()
|
||
|
{
|
||
|
watch_dog_count = 0;
|
||
|
}
|
||
|
|
||
|
CRTUStatusProcess::~CRTUStatusProcess()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
BOOLEAN CRTUStatusProcess::OnPreCreate(int id)
|
||
|
{
|
||
|
if (!CProcess::OnPreCreate(id)) return FALSE;
|
||
|
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
BOOLEAN CRTUStatusProcess::Run(void)
|
||
|
{
|
||
|
if (!CProcess::Run()) return FALSE;
|
||
|
|
||
|
usleep(20000);
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
BOOLEAN CRTUStatusProcess::OnTimer(void)
|
||
|
{
|
||
|
if (!CProcess::OnTimer()) return FALSE;
|
||
|
|
||
|
int i;
|
||
|
int uid = GetCurUnitID();
|
||
|
if (last_sec != (time_t)system32.timers)
|
||
|
{
|
||
|
last_sec = system32.timers;
|
||
|
|
||
|
//更新协议运行状态
|
||
|
for (i = 1; i < PROCESSES_NUM; i++)
|
||
|
{
|
||
|
config.processes[i].softdog++;
|
||
|
if (config.processes[i].softdog > PROCESS_WATCHDOG_TIME)
|
||
|
{
|
||
|
config.processes[i].softdog = PROCESS_WATCHDOG_TIME;
|
||
|
SetUnitYX(uid, i, SPI_ON); // 协议中断
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SetUnitYX(uid, i, SPI_OFF); //协议运行
|
||
|
}
|
||
|
}
|
||
|
//更新单元通讯状态
|
||
|
for (i = 0; i < UNIT_NUM; i++)
|
||
|
{
|
||
|
//单元状态在idle_process中计算,此处刷新单元状态
|
||
|
if (GetUnitYX(uid, i + PROCESSES_NUM) != config.units[i].value)
|
||
|
{
|
||
|
SetUnitSOE(uid, i + PROCESSES_NUM, config.units[i].value, system32.now);
|
||
|
}
|
||
|
SetUnitYX(uid, i + PROCESSES_NUM, config.units[i].value); //单元通讯中断,设置单元数据无效
|
||
|
}
|
||
|
}
|
||
|
UnitFeedDog(uid);
|
||
|
FeedDog();
|
||
|
return TRUE;
|
||
|
}
|
||
|
|