|
@ -1,41 +1,56 @@ |
|
|
#include "test_page_mgr_service.hpp"
|
|
|
#include "test_page_mgr_service.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include "appdep/components/ziconv.hpp"
|
|
|
using namespace iflytop; |
|
|
using namespace iflytop; |
|
|
|
|
|
|
|
|
void TestPageMgrService::getTestPageCfgInfo(shared_ptr<MsgProcessContext> cxt) { cxt->rely["items"] = m_testPageItemMgr.getPageCfgInfo(); } |
|
|
void TestPageMgrService::getTestPageCfgInfo(shared_ptr<MsgProcessContext> cxt) { cxt->rely["items"] = m_testPageItemMgr.getPageCfgInfo(); } |
|
|
void TestPageMgrService::onButton(shared_ptr<MsgProcessContext> cxt) { m_testPageItemMgr.processOnButton(cxt->params); } |
|
|
|
|
|
|
|
|
void TestPageMgrService::onButton(shared_ptr<MsgProcessContext> cxt, string groupName, string buttonName, json params) { m_testPageItemMgr.processOnButton(groupName, buttonName, params); } |
|
|
void TestPageMgrService::readState(shared_ptr<MsgProcessContext> cxt) { cxt->rely = m_testPageItemMgr.readState(); } |
|
|
void TestPageMgrService::readState(shared_ptr<MsgProcessContext> cxt) { cxt->rely = m_testPageItemMgr.readState(); } |
|
|
void TestPageMgrService::triggerOnePrompt(shared_ptr<MsgProcessContext> cxt) { GET_SERVICE(IflytopFrontEndService)->sendPrompt("测试Prompt"); } |
|
|
void TestPageMgrService::triggerOnePrompt(shared_ptr<MsgProcessContext> cxt) { GET_SERVICE(IflytopFrontEndService)->sendPrompt("测试Prompt"); } |
|
|
void TestPageMgrService::startReportState(shared_ptr<MsgProcessContext> cxt) { m_testPageItemMgr.startReportState(1000); } |
|
|
void TestPageMgrService::startReportState(shared_ptr<MsgProcessContext> cxt) { m_testPageItemMgr.startReportState(1000); } |
|
|
void TestPageMgrService::stopReportState(shared_ptr<MsgProcessContext> cxt) { m_testPageItemMgr.stopReportState(); } |
|
|
void TestPageMgrService::stopReportState(shared_ptr<MsgProcessContext> 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() { |
|
|
void TestPageMgrService::initialize() { |
|
|
GET_TO_SERVICE(m_db); |
|
|
GET_TO_SERVICE(m_db); |
|
|
GET_TO_SERVICE(m_ds); |
|
|
GET_TO_SERVICE(m_ds); |
|
|
GET_TO_SERVICE(dcs); |
|
|
GET_TO_SERVICE(dcs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
REG_EXTFN_VOID(getTestPageCfgInfo, void()); |
|
|
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(readState, void()); |
|
|
REG_EXTFN_VOID(triggerOnePrompt, void()); |
|
|
REG_EXTFN_VOID(triggerOnePrompt, void()); |
|
|
REG_EXTFN_VOID(startReportState, void()); |
|
|
REG_EXTFN_VOID(startReportState, void()); |
|
|
REG_EXTFN_VOID(stopReportState, void()); |
|
|
REG_EXTFN_VOID(stopReportState, void()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
REG_FN_VOID(PrinterTest_test, void()); |
|
|
|
|
|
|
|
|
m_dict = make_shared<ZDictionary>(); |
|
|
m_dict = make_shared<ZDictionary>(); |
|
|
m_testPageItemMgr.installDict(m_dict); |
|
|
m_testPageItemMgr.installDict(m_dict); |
|
|
|
|
|
|
|
|
// 喷液泵1
|
|
|
// 喷液泵1
|
|
|
m_dict->insert("pumpVel", "速度"); |
|
|
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<string> 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<string> param) { //
|
|
|
|
|
|
logger->info("SprayPumpCtrl on button.{} ({})", buttonName, param[0]); |
|
|
if (buttonName == "forward") { |
|
|
if (buttonName == "forward") { |
|
|
dcs->SprayPump_startInRPM(atoi(param[0].c_str())); |
|
|
dcs->SprayPump_startInRPM(atoi(param[0].c_str())); |
|
|
} else if (buttonName == "backward") { |
|
|
} else if (buttonName == "backward") { |
|
@ -43,15 +58,14 @@ void TestPageMgrService::initialize() { |
|
|
} else if (buttonName == "stop") { |
|
|
} else if (buttonName == "stop") { |
|
|
dcs->SprayPump_stop(); |
|
|
dcs->SprayPump_stop(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 加液泵2
|
|
|
// 加液泵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<string> 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<string> param) { //
|
|
|
|
|
|
logger->info("on AddDischargePumpCtrl.{}", buttonName); |
|
|
if (buttonName == "addingLiquid") { |
|
|
if (buttonName == "addingLiquid") { |
|
|
dcs->AddLiquidPump_addLiquid(); |
|
|
dcs->AddLiquidPump_addLiquid(); |
|
|
} else if (buttonName == "drainLiquid") { |
|
|
} else if (buttonName == "drainLiquid") { |
|
@ -60,10 +74,11 @@ void TestPageMgrService::initialize() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 空压机3
|
|
|
// 空压机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<string> 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<string> param) { //
|
|
|
|
|
|
logger->info("on AirCompressorCtrl.{}", buttonName); |
|
|
if (buttonName == "on") { |
|
|
if (buttonName == "on") { |
|
|
dcs->AC_ctrl(1); |
|
|
dcs->AC_ctrl(1); |
|
|
} else if (buttonName == "off") { |
|
|
} else if (buttonName == "off") { |
|
@ -72,14 +87,19 @@ void TestPageMgrService::initialize() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 空压机电流4
|
|
|
// 空压机电流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()); |
|
|
return fmt::format("{:.2f}A", dcs->AC_readEI()); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 风机5
|
|
|
// 风机5
|
|
|
m_dict->insert("blowerCtrl", "风机控制"); |
|
|
|
|
|
m_testPageItemMgr.insertButtons("blowerCtrl", {}, {"on", "off"}, [this](string buttonName, vector<string> 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<string> param) { //
|
|
|
|
|
|
logger->info("on BlowerCtrl.{}", buttonName); |
|
|
if (buttonName == "on") { |
|
|
if (buttonName == "on") { |
|
|
dcs->Blower_ctrl(90); |
|
|
dcs->Blower_ctrl(90); |
|
|
} else if (buttonName == "off") { |
|
|
} else if (buttonName == "off") { |
|
@ -89,16 +109,18 @@ void TestPageMgrService::initialize() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 风机电流6
|
|
|
// 风机电流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
|
|
|
// 加热片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<string> 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<string> param) { //
|
|
|
|
|
|
logger->info("on HeatingCtrl.{}", buttonName); |
|
|
if (buttonName == "on") { |
|
|
if (buttonName == "on") { |
|
|
dcs->Heater_ctrl(1); |
|
|
dcs->Heater_ctrl(1); |
|
|
} else if (buttonName == "off") { |
|
|
} else if (buttonName == "off") { |
|
@ -107,10 +129,10 @@ void TestPageMgrService::initialize() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 加热片状态8
|
|
|
// 加热片状态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") { |
|
|
if (stateName == "temperature") { |
|
|
return fmt::format("{:.2f}℃", dcs->Heater_readTemperature()); |
|
|
return fmt::format("{:.2f}℃", dcs->Heater_readTemperature()); |
|
|
} else if (stateName == "current") { |
|
|
} else if (stateName == "current") { |
|
@ -120,16 +142,9 @@ void TestPageMgrService::initialize() { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 9
|
|
|
// 9
|
|
|
m_dict->insert("printerTest", "打印机测试"); |
|
|
|
|
|
m_dict->insert("printerTest.test", "测试"); |
|
|
|
|
|
m_testPageItemMgr.insertButtons("printerTest", {}, {"test"}, [this](string buttonName, vector<string> 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<string> param) { PrinterTest_test(); }); |
|
|
|
|
|
|
|
|
// 10
|
|
|
// 10
|
|
|
m_testPageItemMgr.insertPlaceHolder(); |
|
|
m_testPageItemMgr.insertPlaceHolder(); |
|
@ -143,6 +158,7 @@ void TestPageMgrService::initialize() { |
|
|
m_dict->insert("AirLeakDetectTestModeCtrl.normal", "正常模式"); |
|
|
m_dict->insert("AirLeakDetectTestModeCtrl.normal", "正常模式"); |
|
|
m_dict->insert("AirLeakDetectTestModeCtrl.airTight", "密封模式"); |
|
|
m_dict->insert("AirLeakDetectTestModeCtrl.airTight", "密封模式"); |
|
|
m_testPageItemMgr.insertButtons("AirLeakDetectTestModeCtrl", {}, {"normal", "airTight"}, [this](string buttonName, vector<string> param) { //
|
|
|
m_testPageItemMgr.insertButtons("AirLeakDetectTestModeCtrl", {}, {"normal", "airTight"}, [this](string buttonName, vector<string> param) { //
|
|
|
|
|
|
logger->info("AirLeakDetectTestModeCtrl buttonName:{} param:{}", buttonName, param); |
|
|
if (buttonName == "normal") { |
|
|
if (buttonName == "normal") { |
|
|
dcs->AirLeakDetectTestModeCtrl_setMode(0); |
|
|
dcs->AirLeakDetectTestModeCtrl_setMode(0); |
|
|
} else if (buttonName == "airTight") { |
|
|
} 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.installParamType("proportionalOpenPercent", "%", {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"}); |
|
|
|
|
|
|
|
|
m_testPageItemMgr.insertButtons("PosiPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
|
|
|
m_testPageItemMgr.insertButtons("PosiPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
|
|
|
|
|
|
logger->info("PosiPressurePropCtrl buttonName:{} params:{}", buttonName, param); |
|
|
if (buttonName == "set") { |
|
|
if (buttonName == "set") { |
|
|
dcs->PosiPressureProp_setValve(atoi(param[0].c_str())); |
|
|
dcs->PosiPressureProp_setValve(atoi(param[0].c_str())); |
|
|
} else if (buttonName == "close") { |
|
|
} else if (buttonName == "close") { |
|
@ -171,6 +188,7 @@ void TestPageMgrService::initialize() { |
|
|
|
|
|
|
|
|
// 比例阀控制 13
|
|
|
// 比例阀控制 13
|
|
|
m_testPageItemMgr.insertButtons("NegaPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
|
|
|
m_testPageItemMgr.insertButtons("NegaPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
|
|
|
|
|
|
logger->info("NegaPressurePropCtrl buttonName:{},params:{}", buttonName, param); |
|
|
if (buttonName == "set") { |
|
|
if (buttonName == "set") { |
|
|
dcs->NegaPressureProp_setValve(atoi(param[0].c_str())); |
|
|
dcs->NegaPressureProp_setValve(atoi(param[0].c_str())); |
|
|
} else if (buttonName == "close") { |
|
|
} else if (buttonName == "close") { |
|
|