|
|
@ -1,6 +1,28 @@ |
|
|
|
#include "disinfection_ctl_service.hpp"
|
|
|
|
using namespace iflytop; |
|
|
|
using namespace std; |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* 流程 |
|
|
|
* 预热: |
|
|
|
* |
|
|
|
* 风机开 |
|
|
|
* 1s |
|
|
|
* 空压机 |
|
|
|
* 1s |
|
|
|
* 蠕动泵 |
|
|
|
* 1s |
|
|
|
* |
|
|
|
* |
|
|
|
* 关蠕动泵 |
|
|
|
* 1s |
|
|
|
* 关空压机 |
|
|
|
* 1s |
|
|
|
* 关风机 |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
#define PRE_HEAT_TIME 60
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::drainingPump_open() { m_zcanHost->pumpctrl_c1004(1, 300, -300, 1, 20); } |
|
|
|
void DisinfectionCtrlService::drainingPump_close() { m_zcanHost->pumpctrl_c1004(1, 300, 0, 1, 20); } |
|
|
@ -8,7 +30,7 @@ void DisinfectionCtrlService::drainingPump_close() { m_zcanHost->pumpctrl_c1004( |
|
|
|
void DisinfectionCtrlService::replenishingFluidsPump_open() { m_zcanHost->pumpctrl_c1004(1, 300, 300, 1, 20); } |
|
|
|
void DisinfectionCtrlService::replenishingFluidsPump_close() { m_zcanHost->pumpctrl_c1004(1, 300, 0, 1, 20); } |
|
|
|
|
|
|
|
void DisinfectionCtrlService::sprayLiquidPump_open() { m_zcanHost->pumpctrl_c1004(1, 300, 300, 1, 10); } |
|
|
|
void DisinfectionCtrlService::sprayLiquidPump_open() { m_zcanHost->pumpctrl_c1004(1, 300, 200, 1, 10); } |
|
|
|
void DisinfectionCtrlService::sprayLiquidPump_close() { m_zcanHost->pumpctrl_c1004(1, 300, 0, 1, 10); } |
|
|
|
|
|
|
|
void DisinfectionCtrlService::airCompressor(bool val) { |
|
|
@ -64,7 +86,10 @@ string DisinfectionCtrlService::createDisinfectionID() { |
|
|
|
tm.tm_min, tm.tm_sec); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::initialize() { GET_TO_SERVICE(m_zcanHost); } |
|
|
|
void DisinfectionCtrlService::initialize() { |
|
|
|
GET_TO_SERVICE(m_zcanHost); |
|
|
|
GET_TO_SERVICE(m_sensorDataScan); |
|
|
|
} |
|
|
|
void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
|
|
|
@ -73,27 +98,17 @@ void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
|
} |
|
|
|
|
|
|
|
m_disinfectionID = createDisinfectionID(); |
|
|
|
m_remaintime = loglevel * 20 * 60; |
|
|
|
m_remaintime = loglevel * 20 * 60; // 计算总的加热时间
|
|
|
|
|
|
|
|
m_disinfectionThread.reset(new Thread("m_disinfectionThread", [this, roomVol, loglevel]() { |
|
|
|
// do something
|
|
|
|
// m_disinfectionThread->detach();
|
|
|
|
ThisThread thisThread; |
|
|
|
bool preHeartFinishedFlag = false; |
|
|
|
|
|
|
|
// 发送开始拍照消息
|
|
|
|
logger->info("start disinfection {}", m_disinfectionID); |
|
|
|
|
|
|
|
m_isDisinfectionRunning = true; |
|
|
|
m_disinfectionWorkState = 1; |
|
|
|
logger->info("startDisinfection {} {} {}", loglevel, roomVol, m_disinfectionID); |
|
|
|
|
|
|
|
airCompressor(true); |
|
|
|
usleep(100 * 1000); |
|
|
|
blower_setPower(true); |
|
|
|
usleep(100 * 1000); |
|
|
|
auto starttime = zsteady_clock().now(); |
|
|
|
m_disinfectionWorkState = 1; |
|
|
|
heartingPlate_setPower(true); |
|
|
|
usleep(100 * 1000); |
|
|
|
sprayLiquidPump_open(); |
|
|
|
|
|
|
|
while (!thisThread.getExitFlag()) { |
|
|
|
thisThread.sleepForMs(1000); |
|
|
@ -101,25 +116,36 @@ void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
|
logger->info("disinfection paused {} {}", m_disinfectionID, m_remaintime); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
m_remaintime--; |
|
|
|
if (m_remaintime == 0) { |
|
|
|
logger->info("disinfection finished {}", m_disinfectionID); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
logger->info("disinfection running {} {}s", m_disinfectionID, m_remaintime); |
|
|
|
logger->info("disinfection running {} {}s preheatFlag:{}", m_disinfectionID, m_remaintime, preHeartFinishedFlag); |
|
|
|
|
|
|
|
if (!preHeartFinishedFlag && zsteady_clock().elapsedTimeS(starttime) > PRE_HEAT_TIME) { |
|
|
|
logger->info("preheat finished {}", m_disinfectionID); |
|
|
|
blower_setPower(true); |
|
|
|
usleep(1000 * 1000); |
|
|
|
airCompressor(true); |
|
|
|
usleep(1000 * 1000); |
|
|
|
sprayLiquidPump_open(); |
|
|
|
preHeartFinishedFlag = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_remaintime = 0; |
|
|
|
logger->info("stop disinfection {}", m_disinfectionID); |
|
|
|
|
|
|
|
sprayLiquidPump_close(); |
|
|
|
usleep(1000 * 1000); |
|
|
|
airCompressor(false); |
|
|
|
usleep(10 * 1000); |
|
|
|
usleep(1000 * 1000); |
|
|
|
blower_setPower(false); |
|
|
|
usleep(10 * 1000); |
|
|
|
usleep(1000 * 1000); |
|
|
|
heartingPlate_setPower(false); |
|
|
|
usleep(10 * 1000); |
|
|
|
sprayLiquidPump_close(); |
|
|
|
m_disinfectionWorkState = 3; |
|
|
|
})); |
|
|
|
} |
|
|
@ -135,10 +161,6 @@ void DisinfectionCtrlService::stopDisinfection() { |
|
|
|
m_disinfectionThread = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
bool DisinfectionCtrlService::isDisinfectionRunning() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
return m_isDisinfectionRunning; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t DisinfectionCtrlService::getEstimatedRemainingTimeS() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
@ -150,16 +172,37 @@ string DisinfectionCtrlService::getDisinfectionID() { |
|
|
|
} |
|
|
|
|
|
|
|
// 加液
|
|
|
|
void DisinfectionCtrlService::startReplenishingFluids() { |
|
|
|
void DisinfectionCtrlService::startReplenishingFluids(int stopatg) { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
if (m_disinfectionThread) { |
|
|
|
m_disinfectionThread->join(); |
|
|
|
m_disinfectionThread = nullptr; |
|
|
|
} |
|
|
|
int32_t nowvolume = m_sensorDataScan->getDisinfectantVolume_g(); |
|
|
|
if (nowvolume > stopatg) { |
|
|
|
logger->warn("start Replenishing fail, nowvolume {} > stopatg {}", nowvolume, stopatg); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
m_disinfectionThread.reset(new Thread("disinfectionThread", [this, stopatg]() { |
|
|
|
ThisThread thisThread; |
|
|
|
replenishingFluidsPump_open(); |
|
|
|
m_replenishingFluidsWorkState = 1; |
|
|
|
while (thisThread.getExitFlag()) { |
|
|
|
int32_t nowvolume = m_sensorDataScan->getDisinfectantVolume_g(); |
|
|
|
logger->info("replenishingFluids {}g", nowvolume); |
|
|
|
if (nowvolume > stopatg) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
logger->info("stopReplenishingFluids"); |
|
|
|
replenishingFluidsPump_close(); |
|
|
|
m_replenishingFluidsWorkState = 0; |
|
|
|
})); |
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
logger->info("startReplenishingFluids"); |
|
|
|
replenishingFluidsPump_open(); |
|
|
|
m_replenishingFluidsWorkState = 1; |
|
|
|
logger->info("startReplenishingFluids "); |
|
|
|
} |
|
|
|
// 停止加液
|
|
|
|
void DisinfectionCtrlService::stopReplenishingFluids() { |
|
|
|