From a155df5090ef4c7429c39ebcbda64e99e01b7902 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 17 Aug 2024 17:54:26 +0800 Subject: [PATCH] update some code --- app_protocols/transmit_disfection_protocol | 2 +- appsrc/appbase/appbean/hardware_component.hpp | 2 +- .../transmit_disinfection_can_master.cpp | 2 +- .../transmit_disinfection_can_master.hpp | 9 +- appsrc/appsetting/project_port/project_port.cpp | 6 +- .../disinfection_ctrl_service.cpp | 3 +- appsrc/service/hardware/device_ctrl_service.cpp | 14 ++- appsrc/service/hardware/device_ctrl_service.hpp | 4 +- appsrc/service/test_page_mgr_service.cpp | 123 +++++++++++++++------ appsrc/service/test_page_mgr_service.hpp | 2 + appsrc/service/testpage/test_page_processer.cpp | 8 +- 11 files changed, 117 insertions(+), 58 deletions(-) diff --git a/app_protocols/transmit_disfection_protocol b/app_protocols/transmit_disfection_protocol index 9836b9c..bd6d6b0 160000 --- a/app_protocols/transmit_disfection_protocol +++ b/app_protocols/transmit_disfection_protocol @@ -1 +1 @@ -Subproject commit 9836b9c4356e8cf635be9ab8394d75c8fb301dfe +Subproject commit bd6d6b04af6fbcb7d9dced79f8ecacb636492a17 diff --git a/appsrc/appbase/appbean/hardware_component.hpp b/appsrc/appbase/appbean/hardware_component.hpp index 91603a9..66963fd 100644 --- a/appsrc/appbase/appbean/hardware_component.hpp +++ b/appsrc/appbase/appbean/hardware_component.hpp @@ -13,7 +13,7 @@ marco(type, PositivePressureProportional) /**/ \ marco(type, NegativePressureProportional) /**/ \ marco(type, AirLeakDetectTestAC) /**/ \ - marco(type, AirLeakDetectTestChannelCtrl) /**/ \ + marco(type, AirLeakDetectTestModeCtrl) /**/ \ marco(type, ExtChSelector) /**/ \ marco(type, EvaporationBinWS) /**/ \ marco(type, DeviceBottomWS) /**/ \ diff --git a/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.cpp b/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.cpp index 89c6665..8c73c04 100644 --- a/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.cpp +++ b/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.cpp @@ -86,7 +86,7 @@ int TransmitDisinfectionCanMaster::airCompressorReadEIAdcRaw(int boardid) { // } int TransmitDisinfectionCanMaster::airLeakDetectTestACCtrl(int boardid, int32_t val) { - auto rec = m_com->callcmd1(boardid, kfn_air_tightness_test_ac_ctrl, val); + auto rec = m_com->callcmd1(boardid, kfn_air_leak_detect_ac_ctrl, val); return rec->getContent(0); } diff --git a/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.hpp b/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.hpp index 44c9739..8a362d0 100644 --- a/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.hpp +++ b/appsrc/appcomponents/canchannel/transmit_disinfection_can_master.hpp @@ -91,7 +91,7 @@ class TransmitDisinfectionCanMaster { int airCompressorIsOpen(int boardid) { return m_com->callcmd0(boardid, kfn_air_compressor_is_open, DEFUALT_OVERTIME)->getContent(0); } int airLeakDetectTestACCtrl(int boardid, int32_t val); - int airLeakDetectTestACIsOpen(int boardid) { return m_com->callcmd0(boardid, kfn_air_tightness_test_ac_is_open, DEFUALT_OVERTIME)->getContent(0); } + int airLeakDetectTestACIsOpen(int boardid) { return m_com->callcmd0(boardid, kfn_air_leak_detect_ac_is_open, DEFUALT_OVERTIME)->getContent(0); } /*********************************************************************************************************************** * heater * @@ -125,10 +125,9 @@ class TransmitDisinfectionCanMaster { int proportionalReadPos(int boardid, int valveId) { return m_com->callcmd1(boardid, kfn_proportional_read_pos, valveId, DEFUALT_OVERTIME)->getContent(0); } int proportionalIsBusy(int boardid, int valveId) { return m_com->callcmd1(boardid, kfn_proportional_is_busy, valveId, DEFUALT_OVERTIME)->getContent(0); } - // kfn_air_tightness_test_is_cutoff - void airLeakDetectTestCloseOffCh(int boardid) { m_com->callcmd0(boardid, kfn_air_tightness_test_cutoff_ch, DEFUALT_OVERTIME); } - void airLeakDetectTestReleaseCh(int boardid) { m_com->callcmd0(boardid, kfn_air_tightness_test_release_ch, DEFUALT_OVERTIME); } - int airLeakDetectTestIsCutoff(int boardid) { return m_com->callcmd0(boardid, kfn_air_tightness_test_is_cutoff, DEFUALT_OVERTIME)->getContent(0); } + + void airLeakDetectTestSetMode(int boardid, int mode) { m_com->callcmd1(boardid, kfn_air_leak_detect_test_set_mode, mode, DEFUALT_OVERTIME); } + int airLeakDetectTestGetMode(int boardid) { return m_com->callcmd0(boardid, kfn_air_tightness_test_get_mode, DEFUALT_OVERTIME)->getContent(0); } void extChSelectorSetCh(int boardid, int ch) { m_com->callcmd1(boardid, kfn_ext_ch_selector_set_ch, ch, DEFUALT_OVERTIME); } int extChSelectorGetCh(int boardid) { return m_com->callcmd0(boardid, kfn_ext_ch_selector_get_ch, DEFUALT_OVERTIME)->getContent(0); } diff --git a/appsrc/appsetting/project_port/project_port.cpp b/appsrc/appsetting/project_port/project_port.cpp index 94b8168..2f06f96 100644 --- a/appsrc/appsetting/project_port/project_port.cpp +++ b/appsrc/appsetting/project_port/project_port.cpp @@ -44,7 +44,7 @@ void ProjectPort::initProjectSetting(int projectTypeInt) { // 设备ID初始化 if (isLageSpaceDM() || isSmallSpaceDM() || isPipeDM()) { - // 加液泵 + // 加液泵 INSERT(HardwareComponent::kAddLiquidPump, kFixBoardId_LiquidCtrl, kpumpid_add_liquid); // 喷雾泵 INSERT(HardwareComponent::kSprayPump, kFixBoardId_LiquidCtrl, kpumpid_spray); @@ -62,7 +62,7 @@ void ProjectPort::initProjectSetting(int projectTypeInt) { INSERT(HardwareComponent::kDeviceBottomWS, kFixBoardId_LiquidCtrl, 0); // 主H2O2传感器 INSERT(HardwareComponent::kMainH2O2Sensor, kFixBoardId_PowerControl, 0); - // 液体重量传感器 + // 液体重量传感器 INSERT(HardwareComponent::kLiquidWeightPS, kFixBoardId_LiquidCtrl, 1); // 空压机后压力传感器 INSERT(HardwareComponent::kACPostPS, kFixBoardId_LiquidCtrl, 2); @@ -77,7 +77,7 @@ void ProjectPort::initProjectSetting(int projectTypeInt) { // 负压比例阀 INSERT(HardwareComponent::kNegativePressureProportional, kFixBoardId_LiquidCtrl, NEGATIVE_PRESSURE_PROPORTIONAL_ID); // 空气密度测试通道控制 - INSERT(HardwareComponent::kAirLeakDetectTestChannelCtrl, kFixBoardId_LiquidCtrl, 0); + INSERT(HardwareComponent::kAirLeakDetectTestModeCtrl, kFixBoardId_LiquidCtrl, 0); } } if (isDrawBarDM()) { diff --git a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp index 6892f1f..ed831e8 100644 --- a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp +++ b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp @@ -107,7 +107,6 @@ void DisinfectionCtrlService::initialize() { GET_TO_SERVICE(dcs); GET_TO_SERVICE(dwus); - sm.regStateProcesser(DisinfectionState::idle, bind(&DisinfectionCtrlService::processStateIdle, this, placeholders::_1)); sm.regStateProcesser(DisinfectionState::preheat, bind(&DisinfectionCtrlService::processStatePreheat, this, placeholders::_1)); sm.regStateProcesser(DisinfectionState::disinfection, bind(&DisinfectionCtrlService::processStateDisinfection, this, placeholders::_1)); @@ -324,7 +323,7 @@ void DisinfectionCtrlService::processStateDisinfection(DisinfectionEvent* event) tryLogState(true); s_isDisinfectionTakeBreak = false; if (PORT.isPipeDM()) { - dcs->AirLeakDetectTestChannelCtrl_releaseCh(); + dcs->AirLeakDetectTestModeCtrl_setMode(0); } dcs->ExtChSelector_trySelectCh(kext_ch_disinfection); dcs->AC_ctrl(1); diff --git a/appsrc/service/hardware/device_ctrl_service.cpp b/appsrc/service/hardware/device_ctrl_service.cpp index 5950fcf..b280f65 100644 --- a/appsrc/service/hardware/device_ctrl_service.cpp +++ b/appsrc/service/hardware/device_ctrl_service.cpp @@ -226,15 +226,17 @@ bool DeviceIoControlService::NegaPressureProp_isBusy() { } #undef COMPONENT -#define COMPONENT HardwareComponent::AirLeakDetectTestChannelCtrl -void DeviceIoControlService::AirLeakDetectTestChannelCtrl_cutoffCh() { +#define COMPONENT HardwareComponent::AirLeakDetectTestModeCtrl + +void DeviceIoControlService::AirLeakDetectTestModeCtrl_setMode(int mode) { if (isInPc()) return; - CAN_MASTER->airLeakDetectTestCloseOffCh(GET_BOARDID()); + CAN_MASTER->airLeakDetectTestSetMode(GET_BOARDID(), mode); } -void DeviceIoControlService::AirLeakDetectTestChannelCtrl_releaseCh() { - if (isInPc()) return; - CAN_MASTER->airLeakDetectTestReleaseCh(GET_BOARDID()); +int DeviceIoControlService::AirLeakDetectTestModeCtrl_getMode() { + if (isInPc()) return 0; + return CAN_MASTER->airLeakDetectTestGetMode(GET_BOARDID()); } + #undef COMPONENT // ExtChSelector diff --git a/appsrc/service/hardware/device_ctrl_service.hpp b/appsrc/service/hardware/device_ctrl_service.hpp index 3c6c537..5ab3b30 100644 --- a/appsrc/service/hardware/device_ctrl_service.hpp +++ b/appsrc/service/hardware/device_ctrl_service.hpp @@ -87,8 +87,8 @@ class DeviceIoControlService : public enable_shared_from_this cxt) { m_ void TestPageMgrService::initialize() { GET_TO_SERVICE(m_db); GET_TO_SERVICE(m_ds); + GET_TO_SERVICE(dcs); REGFN(TestPageMgrService, getTestPageCfgInfo); REGFN(TestPageMgrService, onButton); @@ -20,83 +21,139 @@ void TestPageMgrService::initialize() { REGFN(TestPageMgrService, stopReportState); m_dict = make_shared(); - m_dict->insert("pumpVel", "速度"); - m_dict->insert("pumpDir", "方向"); - m_dict->insert("sprayPumpCtrl", "喷液泵控制"); - m_dict->insert("addDischargePumpCtrl", "加液泵控制"); - m_dict->insert("airCompressorCtrl", "空压机控制"); - m_dict->insert("blowerCtrl", "风机控制"); - m_dict->insert("heatingCtrl", "加热片控制"); - m_dict->insert("addingLiquid", "加液"); - m_dict->insert("drainLiquid", "排液"); - m_dict->insert("on", "打开"); - m_dict->insert("off", "关闭"); - m_dict->insert("AcCurrent", "空压机电流"); - m_dict->insert("temperature", "温度"); - m_dict->insert("current", "电流"); - m_dict->insert("voltage", "电压"); - m_dict->insert("heatingState", "加热片状态"); - m_dict->insert("heatingTemperature", "加热片温度"); - m_dict->insert("heatingCurrent", "加热片电流"); - m_dict->insert("forward", "正转"); - m_dict->insert("backward", "反转"); - m_dict->insert("stop", "停止"); - m_testPageItemMgr.installDict(m_dict); // 喷液泵 - m_testPageItemMgr.installParamType("pumpVel", "g/min", {"5", "10", "15"}); - m_testPageItemMgr.insertButtons("sprayPumpCtrl", {"pumpVel"}, {"forward", "backward", "stop"}, [this](string buttonName, vector param) { // + m_dict->insert("pumpVel", "速度"); + m_dict->insert("sprayPumpCtrl", "喷液泵控制"); + m_dict->insert("sprayPumpCtrl.forward", "正转"); + m_dict->insert("sprayPumpCtrl.backward", "反转"); + m_dict->insert("sprayPumpCtrl.stop", "停止"); + m_testPageItemMgr.installParamType("sprayPumpCtrl.pumpVel", "g/min", {"5", "10", "15"}); + m_testPageItemMgr.insertButtons("sprayPumpCtrl", {"sprayPumpCtrl.pumpVel"}, {"forward", "backward", "stop"}, [this](string buttonName, vector param) { // logger->info("sprayPumpCtrl on button.{} ({})", buttonName, param[0]); + + if (buttonName == "forward") { + dcs->SprayPump_startInRPM(atoi(param[0].c_str())); + } else if (buttonName == "backward") { + dcs->SprayPump_startInRPM(-atoi(param[0].c_str())); + } else if (buttonName == "stop") { + dcs->SprayPump_stop(); + } + }); // 加液泵 + m_dict->insert("addDischargePumpCtrl", "加液泵控制"); + m_dict->insert("addDischargePumpCtrl.addingLiquid", "加液"); + m_dict->insert("addDischargePumpCtrl.drainLiquid", "排液"); m_testPageItemMgr.insertButtons("addDischargePumpCtrl", {}, {"addingLiquid", "drainLiquid"}, [this](string buttonName, vector param) { // logger->info("on addDischargePumpCtrl.{}", buttonName); if (buttonName == "addingLiquid") { + dcs->AddLiquidPump_addLiquid(); } else if (buttonName == "drainLiquid") { + dcs->AddLiquidPump_drainLiquid(); } }); // 空压机 + m_dict->insert("airCompressorCtrl", "空压机控制"); + m_dict->insert("airCompressorCtrl.on", "打开"); + m_dict->insert("airCompressorCtrl.off", "关闭"); m_testPageItemMgr.insertButtons("airCompressorCtrl", {}, {"on", "off"}, [this](string buttonName, vector param) { // if (buttonName == "on") { + dcs->AC_ctrl(1); } else if (buttonName == "off") { + dcs->AC_close(); } }); // 空压机电流 - m_testPageItemMgr.insertState("AcCurrent", [this](string stateName) { // - return "1.2"; + m_dict->insert("acCurrent", "空压机电流"); + m_testPageItemMgr.insertState("acCurrent", [this](string stateName) { // + return fmt::format("{:.2f}A", dcs->AC_readEI()); }); // 风机 + m_dict->insert("blowerCtrl", "风机控制"); m_testPageItemMgr.insertButtons("blowerCtrl", {}, {"on", "off"}, [this](string buttonName, vector param) { // if (buttonName == "on") { + dcs->Blower_ctrl(90); } else if (buttonName == "off") { + dcs->Blower_close(); } + return "error"; }); + m_dict->insert("blowerCurrent", "风机电流"); m_testPageItemMgr.insertState("blowerCurrent", [this](string stateName) { // - return "1.2"; + return fmt::format("{:.2f}A", dcs->Blower_readEI()); }); // 加热片 + m_dict->insert("heatingCtrl", "加热片控制"); + m_dict->insert("heatingCtrl.on", "打开"); + m_dict->insert("heatingCtrl.off", "关闭"); m_testPageItemMgr.insertButtons("heatingCtrl", {}, {"on", "off"}, [this](string buttonName, vector param) { // if (buttonName == "on") { + dcs->Heater_ctrl(1); } else if (buttonName == "off") { + dcs->Heater_close(); } }); - m_testPageItemMgr.insertStates("heatingState", {"heatingTemperature", "heatingCurrent"}, [this](string stateName) { // - if (stateName == "heatingTemperature") { - return "25"; - } else if (stateName == "heatingCurrent") { - return "1.2"; + m_dict->insert("heatingState", "加热片状态"); + m_dict->insert("heatingState.temperature", "温度"); + m_dict->insert("heatingState.current", "电流"); + m_testPageItemMgr.insertStates("heatingState", {"temperature", "current"}, [this](string stateName) { // + if (stateName == "temperature") { + return fmt::format("{:.2f}℃", dcs->Heater_readTemperature()); + } else if (stateName == "current") { + return fmt::format("{:.2f}A", dcs->Heater_readEI()); } - return "error"; + return string("error"); }); + if (PORT.isPipeDM()) { + m_dict->insert("AirLeakDetectTestModeCtrl", ""); + m_dict->insert("AirLeakDetectTestModeCtrl.normal", "正常模式"); + m_dict->insert("AirLeakDetectTestModeCtrl.airTight", "密封模式"); + m_testPageItemMgr.insertButtons("AirLeakDetectTestModeCtrl", {}, {"normal", "airTight"}, [this](string buttonName, vector param) { // + if (buttonName == "normal") { + dcs->AirLeakDetectTestModeCtrl_setMode(0); + } else if (buttonName == "airTight") { + dcs->AirLeakDetectTestModeCtrl_setMode(1); + } + }); + + // 比例阀控制 + m_dict->insert("PosiPressurePropCtrl", "正压比例阀控制"); + m_dict->insert("PosiPressurePropCtrl.set", "设置"); + m_dict->insert("PosiPressurePropCtrl.close", "关闭"); + m_dict->insert("NegaPressurePropCtrl", "负压比例阀控制"); + m_dict->insert("NegaPressurePropCtrl.set", "设置"); + m_dict->insert("NegaPressurePropCtrl.close", "关闭"); + m_dict->insert("proportionalOpenPercent", "数值"); + + m_testPageItemMgr.installParamType("proportionalOpenPercent", "%", {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"}); + + m_testPageItemMgr.insertButtons("PosiPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector param) { // + if (buttonName == "set") { + dcs->PosiPressureProp_setValve(atoi(param[0].c_str())); + } else if (buttonName == "close") { + dcs->PosiPressureProp_setValve(0); + } + }); + + m_testPageItemMgr.insertButtons("NegaPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector param) { // + if (buttonName == "set") { + dcs->NegaPressureProp_setValve(atoi(param[0].c_str())); + } else if (buttonName == "close") { + dcs->NegaPressureProp_setValve(0); + } + }); + } + m_testPageItemMgr.onState.connect([this](json state) { // GET_SERVICE(IflytopFrontEndService)->sendClassReport(thisClass.className, "onState", state); }); diff --git a/appsrc/service/test_page_mgr_service.hpp b/appsrc/service/test_page_mgr_service.hpp index 9d54ec0..f398e0a 100644 --- a/appsrc/service/test_page_mgr_service.hpp +++ b/appsrc/service/test_page_mgr_service.hpp @@ -12,6 +12,7 @@ #include "appbase/appbean/test_page_iterm.hpp" #include "baseservice/baseservice.hpp" #include "testpage/test_page_processer.hpp" +#include "service/hardware/device_ctrl_service.hpp" namespace iflytop { using namespace testpage; @@ -20,6 +21,7 @@ class TestPageMgrService : public enable_shared_from_this { shared_ptr m_db; shared_ptr m_ds; + shared_ptr dcs; unique_ptr m_thread; diff --git a/appsrc/service/testpage/test_page_processer.cpp b/appsrc/service/testpage/test_page_processer.cpp index 672aa3b..7ccced0 100644 --- a/appsrc/service/testpage/test_page_processer.cpp +++ b/appsrc/service/testpage/test_page_processer.cpp @@ -12,10 +12,10 @@ void TestPageItemMgr::installParamType(string name, string uint, vector param.displayName = getDisplayVal(name); param.uint = uint; - for (int i = 0; i < enumItems.size(); i++) { + for (uint32_t i = 0; i < enumItems.size(); i++) { param.enums.push_back(enumItems[i]); if (displayNames.size() == 0) { - param.enumDisplayNames.push_back(getDisplayVal(enumItems[i])); + param.enumDisplayNames.push_back(getDisplayVal(name + "." + enumItems[i])); } else { param.enumDisplayNames.push_back(displayNames[i]); } @@ -33,7 +33,7 @@ void TestPageItemMgr::insertButtons(string name, vector params, vectorparams.push_back(para); } for (auto& b : buttons) { - item->buttonDisplayNames.push_back(getDisplayVal(b)); + item->buttonDisplayNames.push_back(name + "." + getDisplayVal(b)); } item->onButton = onButton; insert(item); @@ -64,7 +64,7 @@ void TestPageItemMgr::insertStates(string name, vector states, readState item->readState = readStates; // stateDisplayNames for (auto& s : states) { - item->stateDisplayNames.push_back(getDisplayVal(s)); + item->stateDisplayNames.push_back(name+ "." +getDisplayVal(s)); } insert(item); }