add deviceId state
This commit is contained in:
parent
5ca3eb7c6f
commit
5261921899
@ -247,6 +247,7 @@ int main(int argc, char** argv)
|
||||
i++; uid++;
|
||||
#endif
|
||||
snprintf(config.processes[i].name, sizeof(config.processes[i].name), "%s", "本地调试");
|
||||
config.processes[i].irn = 0;
|
||||
config.processes[i].state = TRUE;
|
||||
config.processes[i].time_accept = FALSE;
|
||||
config.processes[i].proto = PROTOCOL_LOCAL_DEBUG;
|
||||
|
@ -2249,6 +2249,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
|
||||
}
|
||||
}
|
||||
|
||||
config_config.units[uid].irn = strtoll(id.c_str(), NULL, 10);
|
||||
config_config.units[uid].value = SPI_ON;
|
||||
config_config.units[uid].softdog = UNIT_WATCHDOG_TIME;
|
||||
config_config.units[uid].state = TRUE;
|
||||
@ -2756,11 +2757,13 @@ void CRYDevice::heart_beat(int status)
|
||||
payload["status"] = status;
|
||||
|
||||
if (status == 1) {
|
||||
Json::Value jsonItem;
|
||||
Json::Value jsonLink;
|
||||
Json::Value jsonDevice;
|
||||
Json::Value jsonValue;
|
||||
for (int i = 0; i < PROCESSES_NUM - 1; i++) {
|
||||
for (int i = 0; i < PROCESSES_NUM; i++) {
|
||||
if (config.processes[i].state == TRUE) {
|
||||
char linkId[32];
|
||||
if (config.processes[i].irn == 0) continue;
|
||||
#ifdef NOPOLL_64BIT_PLATFORM
|
||||
snprintf(linkId, sizeof(linkId), "%ld", config.processes[i].irn);
|
||||
#else
|
||||
@ -2768,11 +2771,30 @@ void CRYDevice::heart_beat(int status)
|
||||
#endif
|
||||
jsonValue["linkId"] = linkId;
|
||||
jsonValue["online"] = (config.processes[i].softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
||||
jsonItem.append(jsonValue);
|
||||
jsonLink.append(jsonValue);
|
||||
}
|
||||
}
|
||||
if (jsonItem.size() > 0) {
|
||||
payload["links"] = jsonItem;
|
||||
if (jsonLink.size() > 0) {
|
||||
vLog(LOG_DEBUG, "link is: %d\n", jsonLink.size());
|
||||
payload["links"] = jsonLink;
|
||||
}
|
||||
for (int i = 0; i < UNIT_NUM; i++) {
|
||||
if (config.units[i].state == TRUE) {
|
||||
char deviceId[32];
|
||||
if (config.units[i].irn == 0) continue;
|
||||
#ifdef NOPOLL_64BIT_PLATFORM
|
||||
snprintf(deviceId, sizeof(deviceId), "%ld", config.units[i].irn);
|
||||
#else
|
||||
snprintf(deviceId, sizeof(deviceId), "%lld", config.units[i].irn);
|
||||
#endif
|
||||
jsonValue["deviceId"] = deviceId;
|
||||
jsonValue["online"] = (config.units[i].softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
|
||||
jsonDevice.append(jsonValue);
|
||||
}
|
||||
}
|
||||
if (jsonLink.size() > 0) {
|
||||
vLog(LOG_DEBUG, "device is: %d\n", jsonDevice.size());
|
||||
payload["devices"] = jsonDevice;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,7 +701,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
|
||||
ymcount = GetUnitYMCount(uid);
|
||||
yxcount = GetUnitYXCount(uid);
|
||||
|
||||
vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
|
||||
//vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
|
||||
|
||||
BYTE params[MAX_UNIT_POINT_PARAM_SIZE];
|
||||
BYTE* pData = params;
|
||||
@ -720,7 +720,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
|
||||
if (m_adsDatas[0].adsDataBlocks.find(registerAddr) == m_adsDatas[0].adsDataBlocks.end()) {
|
||||
m_adsDatas[0].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YC));
|
||||
} else {
|
||||
vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
|
||||
//vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -730,7 +730,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
|
||||
if (m_adsDatas[1].adsDataBlocks.find(registerAddr) == m_adsDatas[1].adsDataBlocks.end()) {
|
||||
m_adsDatas[1].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YC));
|
||||
} else {
|
||||
vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
|
||||
//vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -747,7 +747,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
|
||||
if (m_adsDatas[0].adsDataBlocks.find(registerAddr) == m_adsDatas[0].adsDataBlocks.end()) {
|
||||
m_adsDatas[0].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YM));
|
||||
} else {
|
||||
vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
|
||||
//vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -757,7 +757,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
|
||||
if (m_adsDatas[1].adsDataBlocks.find(registerAddr) == m_adsDatas[1].adsDataBlocks.end()) {
|
||||
m_adsDatas[1].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YM));
|
||||
} else {
|
||||
vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
|
||||
//vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -827,8 +827,8 @@ BOOLEAN CHostADSBFProcess::OnPreCreate(int id)
|
||||
try {
|
||||
SetLocalAddress(AmsNetId(m_localNetId));
|
||||
m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort};
|
||||
//readDeviceState(*m_turbine);
|
||||
} catch (const AdsException& ex) {
|
||||
vLog(LOG_ERROR, "Error: %d\n", ex.errorCode);
|
||||
vLog(LOG_ERROR, "AdsException message: %s\n", ex.what());
|
||||
vLog(LOG_DEBUG, "try to add a route to remote device.\n");
|
||||
AddRemoteRoute(m_remoteIp, m_localNetId, m_localIp, std::string("isoftstone"), std::string("guest"), std::string("1"));
|
||||
@ -917,8 +917,8 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
|
||||
}
|
||||
readRealData();
|
||||
} catch (const AdsException& ex) {
|
||||
vLog(LOG_ERROR, "Error: %d\n", ex.errorCode);
|
||||
vLog(LOG_ERROR, "AdsException message: %s\n", ex.what());
|
||||
//vLog(LOG_ERROR, "Error: %d\n", ex.errorCode);
|
||||
vLog(LOG_ERROR, "%s AdsException message: %s\n", GetCurProcessName(), ex.what());
|
||||
} catch (const std::runtime_error& ex) {
|
||||
vLog(LOG_ERROR, "%s\n", ex.what());
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ void CHostModbusTcpBFProcess::calc2(void)
|
||||
ymcount = GetUnitYMCount(uid);
|
||||
yxcount = GetUnitYXCount(uid);
|
||||
|
||||
vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
|
||||
//vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
|
||||
|
||||
STRUCT_PARAM *ycparam = NULL, *ymparam = NULL, *yxparam = NULL;
|
||||
if (yccount) ycparam = new STRUCT_PARAM[yccount];
|
||||
|
Loading…
Reference in New Issue
Block a user