diff --git a/.gitmodules b/.gitmodules index 78a530a..dd2868f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "app_protocols/transmit_disfection_protocol"] path = app_protocols/transmit_disfection_protocol - url = zwsd@192.168.1.3:p_transmit_disinfection_v3/transmit_disfection_protocol.git + url = http://47.92.195.73:8081/p_transmit_disinfection_v3/transmit_disfection_protocol.git [submodule "app_protocols/zscanprotocol"] path = app_protocols/zscanprotocol - url = zwsd@192.168.1.3:zprotocols/zscanprotocol.git + url = http://47.92.195.73:8081/zprotocols/zscanprotocol.git diff --git a/README.md b/README.md index cae8ddb..16cbaf0 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,9 @@ VERSION 1.1.7 VERSION 1.1.8 1. 增加运行时修改loggerlevel的功能 +VERSION 1.1.9 + 1. 添加底层复位检测 + TODO: 添加用户增加用户查重检查 diff --git a/app_protocols/apperrorcode/apperrorcode.hpp b/app_protocols/apperrorcode/apperrorcode.hpp index cdfa420..f778beb 100644 --- a/app_protocols/apperrorcode/apperrorcode.hpp +++ b/app_protocols/apperrorcode/apperrorcode.hpp @@ -50,6 +50,9 @@ typedef enum { kappe_disinfection_state_is_wrong = 10218, // 消毒状态错误 kappe_component_cfg_not_find = 10219, // 组件配置未找到 + kappe_liquid_ctrl_reboot = 10300, + kappe_power_control_reboot = 10301, + } apperror_t; } diff --git a/app_protocols/appexception/appexception.hpp b/app_protocols/appexception/appexception.hpp index 1dbd99e..88ffb04 100644 --- a/app_protocols/appexception/appexception.hpp +++ b/app_protocols/appexception/appexception.hpp @@ -20,6 +20,7 @@ #include "app_protocols/apperrorcode/app_errorcode_mgr.hpp" #include "app_protocols/apperrorcode/apperrorcode.hpp" +#include "app_protocols/transmit_disfection_protocol/transmit_disfection_protocol.hpp" #include "iflytop/core/thisclass/thisclass.hpp" namespace iflytop { using namespace std; @@ -53,10 +54,10 @@ class appexception : public std::exception { appexception() { this->traceinfo = printStackTrace(); - whatstr = this->traceinfo; + whatstr = this->traceinfo; } - appexception( int32_t ecode, const string &description) { + appexception(int32_t ecode, const string &description) { this->description = description; this->ecode = ecode; this->traceinfo = printStackTrace(); diff --git a/app_protocols/transmit_disfection_protocol b/app_protocols/transmit_disfection_protocol index e4de0c8..0edd82d 160000 --- a/app_protocols/transmit_disfection_protocol +++ b/app_protocols/transmit_disfection_protocol @@ -1 +1 @@ -Subproject commit e4de0c8b6fac07853f99ce3b9562e490c8f27923 +Subproject commit 0edd82d824736ca1d4d2f113a382204e702709bc diff --git a/app_protocols/zscanprotocol b/app_protocols/zscanprotocol index 8a3aeaf..81529a1 160000 --- a/app_protocols/zscanprotocol +++ b/app_protocols/zscanprotocol @@ -1 +1 @@ -Subproject commit 8a3aeaf8883a3c7d01594e0399fbe96bf8b9cf72 +Subproject commit 81529a15c57000f73cc5bd4b7276f567099b9988 diff --git a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp index eaae7da..152f073 100644 --- a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp +++ b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp @@ -6,6 +6,7 @@ using namespace iflytop; using namespace zscanprotocol; +using namespace transmit_disfection_protocol; #define TAG "ZScanProtocolCom" @@ -72,7 +73,7 @@ void ZSCanProtocolCom::sendframe(int32_t from, int32_t to, uint8_t *frame, size_ int npacket = len / 8 + (len % 8 == 0 ? 0 : 1); if (npacket > 255) { - THROW_APP_EXCEPTION(err::kerr_invalid_param, "param error: packet too long"); + THROW_APP_EXCEPTION(kerr_invalid_param, "param error: packet too long"); } int finalpacketlen = len % 8 == 0 ? 8 : len % 8; @@ -179,7 +180,7 @@ shared_ptr ZSCanProtocolCom::base_callcmd(int32_t to, int32_t cmdid, ui } if (!rxreceipt) { - THROW_APP_EXCEPTION(err::kerr_overtime, "overtime"); + THROW_APP_EXCEPTION(kerr_overtime, "overtime"); } if (m_receipt_frame->ptype == kerror_receipt) { @@ -202,11 +203,11 @@ shared_ptr ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t try { receipt = base_callcmd(to, cmdid, param, paramLen, overtime); } catch (const appexception &e) { - if (e.ecode == err::kerr_overtime) { + if (e.ecode == kerr_overtime) { if (i != 0) logger->warn("callcmd cmdid[{}] to [{}] overtime, retry {}", cmdid, to, i); usleep(100 * 1000); continue; - } else if (e.ecode == err::kerr_subdevice_overtime) { + } else if (e.ecode == kerr_subdevice_overtime) { if (i != 0) logger->warn("callcmd cmdid[{}] to [{}] subdevice_overtime, retry {}", cmdid, to, i); usleep(100 * 1000); continue; @@ -216,7 +217,7 @@ shared_ptr ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t break; } - if (receipt == nullptr) THROW_APP_EXCEPTION(err::kerr_overtime, "overtime"); + if (receipt == nullptr) THROW_APP_EXCEPTION(kerr_overtime, "overtime"); return receipt; } shared_ptr ZSCanProtocolCom::callcmd0(int32_t to, int32_t cmdid, int32_t overtime) { return callcmd(to, cmdid, nullptr, 0, overtime); } diff --git a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp index fa9c41d..c405d83 100644 --- a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp +++ b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp @@ -13,7 +13,7 @@ #include // -#include "app_protocols/zscanprotocol/zscanprotocol.hpp" +#include "app_protocols/zscanprotocol/zscanprotocol.h" #include "iflytop/core/core.hpp" #include "socket_can.hpp" diff --git a/appsrc/appsetting/project_port/basic/zappversion.hpp b/appsrc/appsetting/project_port/basic/zappversion.hpp index 15f627d..3dc5a68 100644 --- a/appsrc/appsetting/project_port/basic/zappversion.hpp +++ b/appsrc/appsetting/project_port/basic/zappversion.hpp @@ -1,3 +1,3 @@ #pragma once -#define VERSION "1.1.8" +#define VERSION "1.1.9" #define PROJECT_NAME "TRANSMIT_DM" \ No newline at end of file diff --git a/appsrc/service/app_core.cpp b/appsrc/service/app_core.cpp index e7e23a0..126e05d 100644 --- a/appsrc/service/app_core.cpp +++ b/appsrc/service/app_core.cpp @@ -107,6 +107,8 @@ static void installEcodeInfo() { AppEcodeInfoMgr::ins().regEcodeInfo(kappe_setting_id_outof_range, "设置ID超出范围"); AppEcodeInfoMgr::ins().regEcodeInfo(kappe_exception_flag_is_setted, "设备硬件异常"); AppEcodeInfoMgr::ins().regEcodeInfo(kappe_disinfection_state_is_wrong, "消毒状态错误"); + AppEcodeInfoMgr::ins().regEcodeInfo(kappe_liquid_ctrl_reboot, "液路板复位"); + AppEcodeInfoMgr::ins().regEcodeInfo(kappe_power_control_reboot, "功率板复位"); // AppEcodeInfoMgr::ins().regEcodeInfo(kerr_motor_reset_error, "电机复位错误"); // AppEcodeInfoMgr::ins().regEcodeInfo(kerr_motor_subdevice_offline, "电机子设备离线"); diff --git a/appsrc/service/hardware/device_io_ctrl_service.cpp b/appsrc/service/hardware/device_io_ctrl_service.cpp index 177bbcb..a06026a 100644 --- a/appsrc/service/hardware/device_io_ctrl_service.cpp +++ b/appsrc/service/hardware/device_io_ctrl_service.cpp @@ -80,6 +80,8 @@ void DeviceIoControlService::initialize() { } else { } + // fn_clear_reset_flag + TransmitDisinfectionCanMaster::ins()->initialize(m_config->get_canIF().c_str(), m_config->get_canBitrate(), false); TransmitDisinfectionCanMaster::ins()->getCanProtocolCom()->regOnRawData( // [this](packet_type_t type, uint8_t from, uint8_t to, uint8_t *hex, uint32_t hexlen) { @@ -94,6 +96,9 @@ void DeviceIoControlService::initialize() { */ try { if (PORT.isLageSpaceDM() || PORT.isSmallSpaceDM() || PORT.isPipeDM()) { + // CAN_MASTER->clearResetFlag(kFixBoardId_LiquidCtrl); + // CAN_MASTER->clearResetFlag(kFixBoardId_PowerControl); + AddLiquidPump_stop(); SprayPump_stop(); Blower_close(); @@ -110,6 +115,16 @@ void DeviceIoControlService::initialize() { logger->error("initialize hardware error:{}", e.what()); AppEventBus::ins()->pushWarningPromptEvent(e); } + + heartThread.reset(new Thread("heartThread", [this]() { + while (true) { + std::this_thread::sleep_for(std::chrono::seconds(10)); + if (isInTestMode()) continue; + CAN_MASTER->pingAllBoard(); + } + })); + + // heartThread-> } #define TRY_DO(func) \ @@ -134,6 +149,27 @@ int DeviceIoControlService::forceStopDeviceWithoutExc() { return 0; } +int DeviceIoControlService::processHeartReportMsg(uint8_t from, report_heatpacket_data_t *report) { + logger->info(" REPORT [Heat ][FROM:{}] HeatIndex:{:x} ToardType:{} flag:{:x}", 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(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; +} + int DeviceIoControlService::processReportMsg(uint8_t from, uint8_t *hex, uint32_t hexlen) { // if (DS->isTestMode()) return 0; zcanbus_packet_t *packet = (zcanbus_packet_t *)hex; @@ -149,7 +185,7 @@ int DeviceIoControlService::processReportMsg(uint8_t from, uint8_t *hex, uint32_ m_h2o2SensorDataMgr->updateH2o2SensorData(sensorId, h2o2data); } else if (packet->function_id == kreport_heatpacket_pong) { report_heatpacket_data_t *ack = (report_heatpacket_data_t *)packet->params; - logger->info(" REPORT [Heat ][FROM:{}] HeatIndex:{:x} ToardType:{} flag:{:x}", from, ack->heartIndex, BoardTypeId2Str(ack->boardType), ack->flag); + processHeartReportMsg(from, ack); } else if (packet->function_id == kreport_exception_error) { report_exeception_data_t *ack = (report_exeception_data_t *)packet->params; logger->error(" REPORT [Exception][FROM:{}] subid:{:x} ecode:{}", from, ack->subid, ecode2str(ack->ecode)); diff --git a/appsrc/service/hardware/device_io_ctrl_service.hpp b/appsrc/service/hardware/device_io_ctrl_service.hpp index 047beb7..4d562cc 100644 --- a/appsrc/service/hardware/device_io_ctrl_service.hpp +++ b/appsrc/service/hardware/device_io_ctrl_service.hpp @@ -43,9 +43,11 @@ class DeviceIoControlService : public enable_shared_from_this