diff --git a/.vscode/settings.json b/.vscode/settings.json index 8eb4eff..81d0527 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -67,6 +67,7 @@ "variant": "cpp", "codecvt": "cpp", "bak": "c", - "any": "cpp" + "any": "cpp", + "unordered_set": "cpp" } } \ No newline at end of file diff --git a/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp b/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp index d42387a..c00d397 100644 --- a/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp +++ b/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp @@ -17,16 +17,15 @@ using namespace iflytop; #define _REG_ENUM_TYPE(type, ...) regEnumType(#type, {__VA_ARGS__}) void FrontMsgProcesser::initialize() { _REG_TYPE(string); - _REG_TYPE(void(void)); _REG_TYPE(int); - _REG_TYPE(int32_t); - _REG_TYPE(float); + regType("int"); + regType("float"); _REG_TYPE(double); _REG_TYPE(void); _REG_TYPE(json); _REG_TYPE(vector); _REG_TYPE(vector); - _REG_TYPE(vector); + regType>("vector"); _REG_TYPE(vector); _REG_TYPE(vector); _REG_TYPE(vector); diff --git a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp index 0c5b608..1e96851 100644 --- a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp +++ b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp @@ -282,6 +282,7 @@ void DisinfectionCtrlService::traceState() { tracecontent += fmt::format("log:{}->{} ", s_nlog, m_tlog); tracecontent += fmt::format("takebreak:{} ", s_isDisinfectionTakeBreak); tracecontent += fmt::format("remaintime:{} ", s_remaintime); + tracecontent += fmt::format("heartTemperature:{} ", dics->Heater_readTemperature() / 10.0); logger->info(tracecontent); } diff --git a/appsrc/service/disinfection_logs_service.cpp b/appsrc/service/disinfection_logs_service.cpp index 831e59a..ef67d2b 100644 --- a/appsrc/service/disinfection_logs_service.cpp +++ b/appsrc/service/disinfection_logs_service.cpp @@ -353,7 +353,7 @@ void DisinfectionLogsService::dumpDisinfectionToPrinterLog(string sessionId, lis content += fmt::format("总耗时: {}:{}:{}\n", total_hours, total_mins, total_secs); content += fmt::format("目标LOG: {}\n", m_statistics->tLog); content += fmt::format("实际LOG: {}\n", m_statistics->finalLog); - content += fmt::format("消毒液使用: {}g\n", m_statistics->disinfectantVolume_g); + content += fmt::format("消毒液使用: {}g\n", abs(m_statistics->disinfectantVolume_g)); content += fmt::format("日志打印间隔: {}min\n", logdtime / 60); content += fmt::format("= = = = = = = = = = = = = = = \n"); diff --git a/appsrc/service/test_page_mgr_service.cpp b/appsrc/service/test_page_mgr_service.cpp index 3453d93..5024bfc 100644 --- a/appsrc/service/test_page_mgr_service.cpp +++ b/appsrc/service/test_page_mgr_service.cpp @@ -1,41 +1,56 @@ #include "test_page_mgr_service.hpp" + +#include "appdep/components/ziconv.hpp" using namespace iflytop; void TestPageMgrService::getTestPageCfgInfo(shared_ptr cxt) { cxt->rely["items"] = m_testPageItemMgr.getPageCfgInfo(); } -void TestPageMgrService::onButton(shared_ptr cxt) { m_testPageItemMgr.processOnButton(cxt->params); } +void TestPageMgrService::onButton(shared_ptr cxt, string groupName, string buttonName, json params) { m_testPageItemMgr.processOnButton(groupName, buttonName, params); } void TestPageMgrService::readState(shared_ptr cxt) { cxt->rely = m_testPageItemMgr.readState(); } void TestPageMgrService::triggerOnePrompt(shared_ptr cxt) { GET_SERVICE(IflytopFrontEndService)->sendPrompt("测试Prompt"); } void TestPageMgrService::startReportState(shared_ptr cxt) { m_testPageItemMgr.startReportState(1000); } void TestPageMgrService::stopReportState(shared_ptr cxt) { m_testPageItemMgr.stopReportState(); } +int TestPageMgrService::PrinterTest_test() { + GET_SERVICE(UartPrinter)->print("abcdefghijklmn\n"); + usleep(100 * 1000); + GET_SERVICE(UartPrinter)->print("opqrstuvwxyz\n"); + usleep(100 * 1000); + GET_SERVICE(UartPrinter)->print("1234567890\n"); + usleep(100 * 1000); + GET_SERVICE(UartPrinter)->print(ZIconv::utf8_to_gb2312("打印机中文测试\n")); + usleep(100 * 1000); + GET_SERVICE(UartPrinter)->print("\n"); + GET_SERVICE(UartPrinter)->print("\n"); + GET_SERVICE(UartPrinter)->print("\n"); + GET_SERVICE(UartPrinter)->print("\n"); + return 0; +} void TestPageMgrService::initialize() { GET_TO_SERVICE(m_db); GET_TO_SERVICE(m_ds); GET_TO_SERVICE(dcs); - REG_EXTFN_VOID(getTestPageCfgInfo, void()); - REG_EXTFN_VOID(onButton, void()); + REG_EXTFN(onButton, void(string, string, json), goupName, buttonName, params); REG_EXTFN_VOID(readState, void()); REG_EXTFN_VOID(triggerOnePrompt, void()); REG_EXTFN_VOID(startReportState, void()); REG_EXTFN_VOID(stopReportState, void()); - + REG_FN_VOID(PrinterTest_test, void()); m_dict = make_shared(); m_testPageItemMgr.installDict(m_dict); // 喷液泵1 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]); - + 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", {"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") { @@ -43,15 +58,14 @@ void TestPageMgrService::initialize() { } else if (buttonName == "stop") { dcs->SprayPump_stop(); } - }); // 加液泵2 - 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); + 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") { @@ -60,10 +74,11 @@ void TestPageMgrService::initialize() { }); // 空压机3 - 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) { // + 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) { // + logger->info("on AirCompressorCtrl.{}", buttonName); if (buttonName == "on") { dcs->AC_ctrl(1); } else if (buttonName == "off") { @@ -72,14 +87,19 @@ void TestPageMgrService::initialize() { }); // 空压机电流4 - m_dict->insert("acCurrent", "空压机电流"); - m_testPageItemMgr.insertState("acCurrent", [this](string stateName) { // + m_dict->insert("ACState", "空压机状态"); + m_dict->insert("ACState.current", "电流"); + m_testPageItemMgr.insertStates("ACState", {"current"}, [this](string stateName) { // return fmt::format("{:.2f}A", dcs->AC_readEI()); }); // 风机5 - m_dict->insert("blowerCtrl", "风机控制"); - m_testPageItemMgr.insertButtons("blowerCtrl", {}, {"on", "off"}, [this](string buttonName, vector param) { // + m_dict->insert("BlowerCtrl", "风机控制"); + m_dict->insert("BlowerCtrl.on", "打开"); + m_dict->insert("BlowerCtrl.off", "关闭"); + + m_testPageItemMgr.insertButtons("BlowerCtrl", {}, {"on", "off"}, [this](string buttonName, vector param) { // + logger->info("on BlowerCtrl.{}", buttonName); if (buttonName == "on") { dcs->Blower_ctrl(90); } else if (buttonName == "off") { @@ -89,16 +109,18 @@ void TestPageMgrService::initialize() { }); // 风机电流6 - m_dict->insert("blowerCurrent", "风机电流"); - m_testPageItemMgr.insertState("blowerCurrent", [this](string stateName) { // - return fmt::format("{:.2f}A", dcs->Blower_readEI()); + m_dict->insert("Blower", "风机状态"); + m_dict->insert("Blower.current", "电流"); + m_testPageItemMgr.insertStates("Blower", {"current"}, [this](string stateName) { // + return fmt::format("{:.2f}A", dcs->AC_readEI()); }); // 加热片7 - 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) { // + 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) { // + logger->info("on HeatingCtrl.{}", buttonName); if (buttonName == "on") { dcs->Heater_ctrl(1); } else if (buttonName == "off") { @@ -107,10 +129,10 @@ void TestPageMgrService::initialize() { }); // 加热片状态8 - m_dict->insert("heatingState", "加热片状态"); - m_dict->insert("heatingState.temperature", "温度"); - m_dict->insert("heatingState.current", "电流"); - m_testPageItemMgr.insertStates("heatingState", {"temperature", "current"}, [this](string stateName) { // + 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") { @@ -120,16 +142,9 @@ void TestPageMgrService::initialize() { }); // 9 - m_dict->insert("printerTest", "打印机测试"); - m_dict->insert("printerTest.test", "测试"); - m_testPageItemMgr.insertButtons("printerTest", {}, {"test"}, [this](string buttonName, vector param) { // - GET_SERVICE(UartPrinter)->print("abcdefghijklmn\nopqrstuvwxyz\n1234567890"); - GET_SERVICE(UartPrinter)->print("一二三四五六七八九十\n十九八七六五四三二一"); - GET_SERVICE(UartPrinter)->print("\n"); - GET_SERVICE(UartPrinter)->print("\n"); - GET_SERVICE(UartPrinter)->print("\n"); - GET_SERVICE(UartPrinter)->print("\n"); - }); + m_dict->insert("PrinterTest", "打印机测试"); + m_dict->insert("PrinterTest.test", "测试"); + m_testPageItemMgr.insertButtons("PrinterTest", {}, {"test"}, [this](string buttonName, vector param) { PrinterTest_test(); }); // 10 m_testPageItemMgr.insertPlaceHolder(); @@ -143,6 +158,7 @@ void TestPageMgrService::initialize() { m_dict->insert("AirLeakDetectTestModeCtrl.normal", "正常模式"); m_dict->insert("AirLeakDetectTestModeCtrl.airTight", "密封模式"); m_testPageItemMgr.insertButtons("AirLeakDetectTestModeCtrl", {}, {"normal", "airTight"}, [this](string buttonName, vector param) { // + logger->info("AirLeakDetectTestModeCtrl buttonName:{} param:{}", buttonName, param); if (buttonName == "normal") { dcs->AirLeakDetectTestModeCtrl_setMode(0); } else if (buttonName == "airTight") { @@ -162,6 +178,7 @@ void TestPageMgrService::initialize() { 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) { // + logger->info("PosiPressurePropCtrl buttonName:{} params:{}", buttonName, param); if (buttonName == "set") { dcs->PosiPressureProp_setValve(atoi(param[0].c_str())); } else if (buttonName == "close") { @@ -171,6 +188,7 @@ void TestPageMgrService::initialize() { // 比例阀控制 13 m_testPageItemMgr.insertButtons("NegaPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector param) { // + logger->info("NegaPressurePropCtrl buttonName:{},params:{}", buttonName, param); if (buttonName == "set") { dcs->NegaPressureProp_setValve(atoi(param[0].c_str())); } else if (buttonName == "close") { diff --git a/appsrc/service/test_page_mgr_service.hpp b/appsrc/service/test_page_mgr_service.hpp index 6d744ac..4ef7a07 100644 --- a/appsrc/service/test_page_mgr_service.hpp +++ b/appsrc/service/test_page_mgr_service.hpp @@ -11,16 +11,16 @@ // #include "appbase/appbean/test_page_iterm.hpp" #include "baseservice/baseservice.hpp" -#include "testpage/test_page_processer.hpp" #include "service/hardware/device_io_ctrl_service.hpp" +#include "testpage/test_page_processer.hpp" namespace iflytop { using namespace testpage; class TestPageMgrService : public enable_shared_from_this { THISCLASS(TestPageMgrService); - shared_ptr m_db; - shared_ptr m_ds; + shared_ptr m_db; + shared_ptr m_ds; shared_ptr dcs; unique_ptr m_thread; @@ -33,7 +33,7 @@ class TestPageMgrService : public enable_shared_from_this { private: void getTestPageCfgInfo(shared_ptr cxt); - void onButton(shared_ptr cxt); + void onButton(shared_ptr cxt, string groupName, string buttonName, json params); void readState(shared_ptr cxt); void startReportState(shared_ptr cxt); void stopReportState(shared_ptr cxt); @@ -41,6 +41,7 @@ class TestPageMgrService : public enable_shared_from_this { void triggerOnePrompt(shared_ptr cxt); private: + int PrinterTest_test(); }; } // namespace iflytop diff --git a/appsrc/service/testpage/test_page_processer.cpp b/appsrc/service/testpage/test_page_processer.cpp index edfe69e..58b6396 100644 --- a/appsrc/service/testpage/test_page_processer.cpp +++ b/appsrc/service/testpage/test_page_processer.cpp @@ -6,55 +6,45 @@ using namespace testpage; void TestPageItemMgr::initialize() {} void TestPageItemMgr::installDict(shared_ptr dict) { this->dict = dict; } -void TestPageItemMgr::installParamType(string name, string uint, vector enumItems, vector displayNames) { +void TestPageItemMgr::installParamType(string paramType, string uint, vector enumItems) { Parameter param; - param.name = name; - param.displayName = getDisplayVal(name); + param.name = paramType; + param.displayName = getDisplayVal(paramType, paramType); param.uint = uint; for (uint32_t i = 0; i < enumItems.size(); i++) { param.enums.push_back(enumItems[i]); - if (displayNames.size() == 0) { - param.enumDisplayNames.push_back(getDisplayVal(name + "." + enumItems[i])); - } else { - param.enumDisplayNames.push_back(displayNames[i]); - } + param.enumDisplayNames.push_back(getDisplayVal(paramType + "xx." + enumItems[i], enumItems[i])); } - m_paramTypes[name] = param; + m_paramTypes[paramType] = param; } -void TestPageItemMgr::insertButtons(string name, vector params, vector buttons, onButton_t onButton) { +void TestPageItemMgr::insertButtons(string groupName, vector params, vector buttons, onButton_t onButton) { shared_ptr item = make_shared(); - item->name = name; - item->displayName = getDisplayVal(name); + item->name = groupName; + item->displayName = getDisplayVal(groupName, groupName); item->buttons = buttons; for (auto& p : params) { - Parameter para = getParamType(p); + Parameter para = getParamType(groupName + "." + p); item->params.push_back(para); } - for (auto& b : buttons) { - item->buttonDisplayNames.push_back(name + "." + getDisplayVal(b)); + for (auto& bname : buttons) { + item->buttonDisplayNames.push_back(getDisplayVal(groupName + "." + bname, bname)); } item->onButton = onButton; insert(item); } -void TestPageItemMgr::insertState(string name, readState_t readState) { - shared_ptr item = make_shared(); - item->name = name; - item->displayName = getDisplayVal(name); - item->readState = readState; - insert(item); -} -void TestPageItemMgr::insertStates(string name, vector states, readState_t readStates) { + +void TestPageItemMgr::insertStates(string groupname, vector states, readState_t readStates) { shared_ptr item = make_shared(); - item->name = name; - item->displayName = getDisplayVal(name); + item->name = groupname; + item->displayName = getDisplayVal(groupname, groupname); item->states = states; item->readState = readStates; // stateDisplayNames for (auto& s : states) { - item->stateDisplayNames.push_back(name + "." + getDisplayVal(s)); + item->stateDisplayNames.push_back(getDisplayVal(groupname + "." + s, s)); } insert(item); } @@ -64,10 +54,9 @@ void TestPageItemMgr::insertPlaceHolder() { insert(item); } -string TestPageItemMgr::getDisplayVal(string name) { - if (!dict) return name; - string it = dict->getChName(name); - return it.empty() ? name : it; +string TestPageItemMgr::getDisplayVal(string name, string defaultVal) { + if (!dict) return defaultVal; + return dict->getChName(name, defaultVal); } Parameter TestPageItemMgr::getParamType(string name) { auto it = m_paramTypes.find(name); @@ -79,13 +68,11 @@ Parameter TestPageItemMgr::getParamType(string name) { void TestPageItemMgr::insert(shared_ptr item) { m_itemList.push_back(item); } -void TestPageItemMgr::processOnButton(json cmd) { - string itermName = cmd["itermName"]; - string buttonName = cmd["buttonName"]; +void TestPageItemMgr::processOnButton(string groupName, string buttonName, json params) { for (auto& it : m_itemList) { shared_ptr item = it; - if (item->name != itermName) continue; + if (item->name != groupName) continue; // // if (item->type == TestPageItermType::button) { @@ -104,13 +91,13 @@ void TestPageItemMgr::processOnButton(json cmd) { ZASSERT(buttons); ZASSERT(buttons->onButton); - vector params; + vector paramstable; for (auto& p : buttons->params) { - auto it = cmd["params"].find(p.name); - if (it == cmd["params"].end()) { + auto it = params.find(p.name); + if (it == params.end()) { THROW_APP_EXCEPTION(err::kappe_missing_param, "missing parameter %s", p.name.c_str()); } - params.push_back(it->get()); + paramstable.push_back(it->get()); } for (uint32_t i = 0; i < buttons->buttons.size(); i++) { diff --git a/appsrc/service/testpage/test_page_processer.hpp b/appsrc/service/testpage/test_page_processer.hpp index f3c76c8..fe23641 100644 --- a/appsrc/service/testpage/test_page_processer.hpp +++ b/appsrc/service/testpage/test_page_processer.hpp @@ -32,18 +32,15 @@ class TestPageItemMgr { public: void initialize(); void installDict(shared_ptr dict); - void installParamType(string name, string uint, vector enumItems, vector displayNames); - void installParamType(string name, string uint, vector enumItems) { installParamType(name, uint, enumItems, {}); } + void installParamType(string name, string uint, vector enumItems); void insertButtons(string name, vector buttons, vector params, onButton_t onButton); - // void insertButton(string name, vector params, onButton_t onButton); - void insertState(string name, readState_t readState); void insertStates(string name, vector states, readState_t readStates); void insertPlaceHolder(); // ZDictionaryIterm public: - void processOnButton(json cmd); + void processOnButton(string groupName, string buttonName, json params); void startReportState(int interval); void stopReportState(); json getPageCfgInfo(); @@ -51,7 +48,7 @@ class TestPageItemMgr { private: void insert(shared_ptr item); - string getDisplayVal(string name); + string getDisplayVal(string name,string defaultVal); Parameter getParamType(string name); };