Browse Source

update

storage-in-realtime
zhaohe 11 months ago
parent
commit
3ea31833f0
  1. 8
      appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp
  2. 50
      appsrc/service/hardware/device_io_ctrl_service.cpp

8
appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp

@ -165,6 +165,8 @@ shared_ptr<Receipt> ZSCanProtocolCom::base_callcmd(int32_t to, int32_t cmdid, ui
} }
sendframe(1, to, (uint8_t *)frame, paramLen + sizeof(zcanbus_packet_t)); sendframe(1, to, (uint8_t *)frame, paramLen + sizeof(zcanbus_packet_t));
if (to == 0xff) return nullptr; // 广播包没有回执
bool rxreceipt = false; bool rxreceipt = false;
for (int32_t i = 0; i < overtime; i++) { for (int32_t i = 0; i < overtime; i++) {
@ -206,7 +208,7 @@ shared_ptr<Receipt> ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t
for (size_t i = 0; i <= 3; i++) { for (size_t i = 0; i <= 3; i++) {
try { try {
receipt = base_callcmd(to, cmdid, param, paramLen, overtime);
return base_callcmd(to, cmdid, param, paramLen, overtime);
} catch (const appexception &e) { } catch (const appexception &e) {
if (e.ecode == kerr_overtime) { if (e.ecode == kerr_overtime) {
if (i != 0) logger->warn("callcmd cmdid[{}] to [{}] overtime, retry {}", cmdid, to, i); if (i != 0) logger->warn("callcmd cmdid[{}] to [{}] overtime, retry {}", cmdid, to, i);
@ -222,8 +224,8 @@ shared_ptr<Receipt> ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t
break; break;
} }
if (receipt == nullptr) THROW_APP_EXCEPTION(kerr_overtime, "overtime");
return receipt;
THROW_APP_EXCEPTION(kerr_overtime, "overtime");
return nullptr;
} }
shared_ptr<Receipt> ZSCanProtocolCom::callcmd0(int32_t to, int32_t cmdid, int32_t overtime) { return callcmd(to, cmdid, nullptr, 0, overtime); } shared_ptr<Receipt> ZSCanProtocolCom::callcmd0(int32_t to, int32_t cmdid, int32_t overtime) { return callcmd(to, cmdid, nullptr, 0, overtime); }
shared_ptr<Receipt> ZSCanProtocolCom::callcmd1(int32_t device_id, int32_t cmdid, int32_t param0, int32_t overtime) { shared_ptr<Receipt> ZSCanProtocolCom::callcmd1(int32_t device_id, int32_t cmdid, int32_t param0, int32_t overtime) {

50
appsrc/service/hardware/device_io_ctrl_service.cpp

@ -114,9 +114,12 @@ void DeviceIoControlService::initialize() {
heartThread.reset(new Thread("heartThread", [this]() { heartThread.reset(new Thread("heartThread", [this]() {
while (true) { 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(); 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) { 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); 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; return 0;
} }
@ -203,7 +207,15 @@ int DeviceIoControlService::processReportMsg(uint8_t from, uint8_t *hex, uint32_
} }
else if (packet->function_id == kreport_device_reset) { 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 { } else {
logger->info(" REPORT [Unknow][FROM:{}] function_id:{:x}", from, packet->function_id); logger->info(" REPORT [Unknow][FROM:{}] function_id:{:x}", from, packet->function_id);
} }

Loading…
Cancel
Save