|
|
@ -114,9 +114,12 @@ void DeviceIoControlService::initialize() { |
|
|
|
|
|
|
|
heartThread.reset(new Thread("heartThread", [this]() { |
|
|
|
while (true) { |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(10)); |
|
|
|
if (isInTestMode()) continue; |
|
|
|
if (isInTestMode()) { |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(60)); |
|
|
|
continue; |
|
|
|
} |
|
|
|
CAN_MASTER->pingAllBoard(); |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(60)); |
|
|
|
} |
|
|
|
})); |
|
|
|
|
|
|
@ -146,23 +149,24 @@ int DeviceIoControlService::forceStopDeviceWithoutExc() { |
|
|
|
} |
|
|
|
|
|
|
|
int DeviceIoControlService::processHeartReportMsg(uint8_t from, report_heatpacket_data_t *report) { |
|
|
|
// if (from < 100) {
|
|
|
|
logger->info(" REPORT [Heat ][FROM:{}] HeatIndex:{:x} ToardType:{} flag:{}", from, report->heartIndex, BoardTypeId2Str(report->boardType), report->flag); |
|
|
|
|
|
|
|
#define CHECK_BOARD_IS_REBOOT(boardid, ecode) \
|
|
|
|
{ \ |
|
|
|
static bool firstReport = true; \ |
|
|
|
if (report->flag != 0 && from == boardid) { \ |
|
|
|
if (firstReport) { \ |
|
|
|
CAN_MASTER->clearResetFlag(boardid); \ |
|
|
|
firstReport = false; \ |
|
|
|
} else { \ |
|
|
|
AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(ecode)); \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
} |
|
|
|
|
|
|
|
CHECK_BOARD_IS_REBOOT(kFixBoardId_LiquidCtrl, err::kappe_liquid_ctrl_reboot); |
|
|
|
CHECK_BOARD_IS_REBOOT(kFixBoardId_PowerControl, err::kappe_power_control_reboot); |
|
|
|
// }
|
|
|
|
// #define CHECK_BOARD_IS_REBOOT(boardid, ecode) \ |
|
|
|
// { \ |
|
|
|
// static bool firstReport = true; \ |
|
|
|
// if (report->flag != 0 && from == boardid) { \ |
|
|
|
// if (firstReport) { \ |
|
|
|
// CAN_MASTER->clearResetFlag(boardid); \ |
|
|
|
// firstReport = false; \ |
|
|
|
// } else { \ |
|
|
|
// logger->error("Detected board:{} is rebooting, push warning prompt.", boardid); \ |
|
|
|
// AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(ecode)); \ |
|
|
|
// } \ |
|
|
|
// } \ |
|
|
|
// }
|
|
|
|
// CHECK_BOARD_IS_REBOOT(kFixBoardId_LiquidCtrl, err::kappe_liquid_ctrl_reboot);
|
|
|
|
// CHECK_BOARD_IS_REBOOT(kFixBoardId_PowerControl, err::kappe_power_control_reboot);
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
@ -203,7 +207,15 @@ int DeviceIoControlService::processReportMsg(uint8_t from, uint8_t *hex, uint32_ |
|
|
|
} |
|
|
|
|
|
|
|
else if (packet->function_id == kreport_device_reset) { |
|
|
|
logger->info(" REPORT [DeviceReset][FROM:{}]", from); |
|
|
|
logger->warn(" REPORT [DeviceReset][FROM:{}] reason:{}", from, packet->params[0]); |
|
|
|
if (kFixBoardId_LiquidCtrl == from) { |
|
|
|
logger->error("Detected board:{} is rebooting, push warning prompt.", from); |
|
|
|
AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(err::kappe_liquid_ctrl_reboot)); |
|
|
|
} else if (kFixBoardId_PowerControl == from) { |
|
|
|
logger->error("Detected board:{} is rebooting, push warning prompt.", from); |
|
|
|
AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(err::kappe_power_control_reboot)); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
logger->info(" REPORT [Unknow][FROM:{}] function_id:{:x}", from, packet->function_id); |
|
|
|
} |
|
|
|