diff --git a/README.md b/README.md index de41812..893192b 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,17 @@ https://www.sqlite.org/docs.html ``` +``` + +``` +测试指令 + + +``` + + +``` +1. 开始消毒后 + + ``` \ No newline at end of file diff --git a/src/main_control_service.cpp b/src/main_control_service.cpp index 685764a..f4e6db0 100644 --- a/src/main_control_service.cpp +++ b/src/main_control_service.cpp @@ -133,29 +133,48 @@ void MainControlService::initialize() { ThisThread thisThread; while (!thisThread.getExitFlag()) { json report; - report["command"] = "RealtimeSensorDataReport"; - report["sensor_data"]["heating_strip"] = 1; - report["sensor_data"]["air_compressor"] = 0; - report["sensor_data"]["sprinkler_pump"] = 1; - report["sensor_data"]["disinfectant_volume"] = 99; - report["sensor_data"]["h2o2_1"] = 10; - report["sensor_data"]["temp_1"] = 11; - report["sensor_data"]["humid_1"] = 12; - report["sensor_data"]["saturation_1"] = 13; - report["sensor_data"]["h2o2_2"] = 14; - report["sensor_data"]["temp_2"] = 15; - report["sensor_data"]["humid_2"] = 16; - report["sensor_data"]["saturation_2"] = 17; - report["sensor_data"]["h2o2_3"] = 18; - report["sensor_data"]["temp_3"] = 19; - report["sensor_data"]["humid_3"] = 20; - report["sensor_data"]["saturation_3"] = 21; + report["command"] = "RealtimeSensorDataReport"; + report["sensor_data"] = createSensorDataJson(); m_iflytopwsService->sendReport(report); thisThread.sleepForMs(1000); } })); }; +json MainControlService::createSensorDataJson() { + json report; + + report["airCompressor"]["io1"] = 1; + report["airCompressor"]["io2"] = 0; + report["airCompressor"]["currentVal"] = 2.2; + + report["airBlower"]["io1"] = 1; + report["airBlower"]["io2"] = 0; + report["airBlower"]["currentVal"] = 2.2; + + report["heatingStrip"]["io1"] = 1; + report["heatingStrip"]["io2"] = 0; + report["heatingStrip"]["currentVal"] = 2.2; + + report["sprinklerPump"] = 1000; + report["chargingPump"] = 999; + + report["disinfectant_volume"] = 99; + report["h2o2_1"] = 10; + report["temp_1"] = 11; + report["humid_1"] = 12; + report["saturation_1"] = 13; + report["h2o2_2"] = 14; + report["temp_2"] = 15; + report["humid_2"] = 16; + report["saturation_2"] = 17; + report["h2o2_3"] = 18; + report["temp_3"] = 19; + report["humid_3"] = 20; + report["saturation_3"] = 21; + return report; +} + void MainControlService::processFrontEndMessage(weak_ptr webSocket, json& cmd, json& receipt) { #if 0 //login @@ -281,6 +300,49 @@ void MainControlService::processFrontEndMessage(weak_ptr webSocket, j return; } +#if 0 +//开始加液 +{ + "command":"startReplenishingFluids", +} +//停止加液 +{ + "command":"stopReplenishingFluids", +} +//开始排液 +{ + "command":"startDraining", +} +//停止排液 +{ + "command":"stopDraining", +} +#endif + + if (cmdstr == "startReplenishingFluids") { + logger->info("startReplenishingFluids"); + m_disinfectionCtrlService->startReplenishingFluids(); + return; + } + + if (cmdstr == "stopReplenishingFluids") { + logger->info("stopReplenishingFluids"); + m_disinfectionCtrlService->stopReplenishingFluids(); + return; + } + + if (cmdstr == "startDraining") { + logger->info("startDraining"); + m_disinfectionCtrlService->startDraining(); + return; + } + + if (cmdstr == "stopDraining") { + logger->info("stopDraining"); + m_disinfectionCtrlService->stopDraining(); + return; + } + /******************************************************************************* * getState * *******************************************************************************/ @@ -291,6 +353,7 @@ void MainControlService::processFrontEndMessage(weak_ptr webSocket, j receipt["state"]["workState"] = m_disinfectionCtrlService->isDisinfectionRunning(); receipt["state"]["estimatedRemainingTimeS"] = m_disinfectionCtrlService->getEstimatedRemainingTimeS(); receipt["state"]["disinfection_id"] = m_disinfectionCtrlService->getDisinfectionID(); + receipt["state"]["sensor_data"] = createSensorDataJson(); return; } diff --git a/src/main_control_service.hpp b/src/main_control_service.hpp index 86a8d31..adfd7a8 100644 --- a/src/main_control_service.hpp +++ b/src/main_control_service.hpp @@ -82,5 +82,7 @@ class MainControlService : public enable_shared_from_this { void createReactionConfigCardInfoReportAndSend(); void processFrontEndMessage(weak_ptr webSocket, json& cmd, json& receipt); + + json createSensorDataJson(); }; } // namespace iflytop \ No newline at end of file diff --git a/src/service/disinfection_ctl_service.cpp b/src/service/disinfection_ctl_service.cpp index 1be41ac..73bbeb1 100644 --- a/src/service/disinfection_ctl_service.cpp +++ b/src/service/disinfection_ctl_service.cpp @@ -26,7 +26,7 @@ string DisinfectionCtrlService::createDisinfectionID() { tm.tm_min, tm.tm_sec); } -void DisinfectionCtrlService::initialize() {} +void DisinfectionCtrlService::initialize() { GET_TO_SERVICE(m_zcanHost); } void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { lock_guard lock(lock_); @@ -80,4 +80,10 @@ int32_t DisinfectionCtrlService::getEstimatedRemainingTimeS() { string DisinfectionCtrlService::getDisinfectionID() { lock_guard lock(lock_); return m_disinfectionID; -} \ No newline at end of file +} + +void DisinfectionCtrlService::startReplenishingFluids() {} +void DisinfectionCtrlService::stopReplenishingFluids() {} + +void DisinfectionCtrlService::startDraining() {} +void DisinfectionCtrlService::stopDraining() {} diff --git a/src/service/disinfection_ctl_service.hpp b/src/service/disinfection_ctl_service.hpp index bf71ca2..921052b 100644 --- a/src/service/disinfection_ctl_service.hpp +++ b/src/service/disinfection_ctl_service.hpp @@ -14,7 +14,9 @@ #include #include +#include "iflytop/components/zcanreceiver/zcanhost.hpp" #include "iflytop/core/core.hpp" +#include "zservice_container/zservice_container.hpp" /** * @brief @@ -41,6 +43,8 @@ class DisinfectionCtrlService : public enable_shared_from_this m_zcanHost; + public: DisinfectionCtrlService(); @@ -51,8 +55,22 @@ class DisinfectionCtrlService : public enable_shared_from_this