Browse Source

update

master
zhaohe 2 years ago
parent
commit
c6e600538c
  1. 13
      README.md
  2. 97
      src/main_control_service.cpp
  3. 2
      src/main_control_service.hpp
  4. 10
      src/service/disinfection_ctl_service.cpp
  5. 22
      src/service/disinfection_ctl_service.hpp

13
README.md

@ -55,4 +55,17 @@ https://www.sqlite.org/docs.html
```
```
```
测试指令
```
```
1. 开始消毒后
```

97
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> webSocket, json& cmd, json& receipt) {
#if 0
//login
@ -281,6 +300,49 @@ void MainControlService::processFrontEndMessage(weak_ptr<WebSocket> 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> 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;
}

2
src/main_control_service.hpp

@ -82,5 +82,7 @@ class MainControlService : public enable_shared_from_this<MainControlService> {
void createReactionConfigCardInfoReportAndSend();
void processFrontEndMessage(weak_ptr<WebSocket> webSocket, json& cmd, json& receipt);
json createSensorDataJson();
};
} // namespace iflytop

10
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<recursive_mutex> lock(lock_);
@ -80,4 +80,10 @@ int32_t DisinfectionCtrlService::getEstimatedRemainingTimeS() {
string DisinfectionCtrlService::getDisinfectionID() {
lock_guard<recursive_mutex> lock(lock_);
return m_disinfectionID;
}
}
void DisinfectionCtrlService::startReplenishingFluids() {}
void DisinfectionCtrlService::stopReplenishingFluids() {}
void DisinfectionCtrlService::startDraining() {}
void DisinfectionCtrlService::stopDraining() {}

22
src/service/disinfection_ctl_service.hpp

@ -14,7 +14,9 @@
#include <string>
#include <vector>
#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<DisinfectionCtrlS
bool m_isDisinfectionRunning = false;
recursive_mutex lock_;
shared_ptr<ZCanHost> m_zcanHost;
public:
DisinfectionCtrlService();
@ -51,8 +55,22 @@ class DisinfectionCtrlService : public enable_shared_from_this<DisinfectionCtrlS
*
* @param loglevel
*/
void startDisinfection(int loglevel,float roomVol);
void stopDisinfection();
void startDisinfection(int loglevel, float roomVol);
void stopDisinfection();
/**
* @brief
*
* @return true
* @return false
*/
void startReplenishingFluids();
void stopReplenishingFluids();
void startDraining();
void stopDraining();
bool isDisinfectionRunning();
int32_t getEstimatedRemainingTimeS();
string getDisinfectionID();

Loading…
Cancel
Save