|
|
@ -2,6 +2,44 @@ |
|
|
|
using namespace iflytop; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
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); } |
|
|
|
|
|
|
|
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_close() { m_zcanHost->pumpctrl_c1004(1, 300, 0, 1, 10); } |
|
|
|
|
|
|
|
void DisinfectionCtrlService::airCompressor(bool val) { |
|
|
|
if (val) { |
|
|
|
m_zcanHost->writeio(0, 1); |
|
|
|
m_zcanHost->writeio(1, 1); |
|
|
|
} else { |
|
|
|
m_zcanHost->writeio(0, 0); |
|
|
|
m_zcanHost->writeio(1, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::blower_setPower(bool val) { |
|
|
|
if (val) { |
|
|
|
m_zcanHost->writeio(2, 1); |
|
|
|
m_zcanHost->writeio(3, 1); |
|
|
|
} else { |
|
|
|
m_zcanHost->writeio(2, 0); |
|
|
|
m_zcanHost->writeio(3, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
void DisinfectionCtrlService::heartingPlate_setPower(bool val) { |
|
|
|
if (val) { |
|
|
|
m_zcanHost->writeio(4, 1); |
|
|
|
m_zcanHost->writeio(5, 1); |
|
|
|
} else { |
|
|
|
m_zcanHost->writeio(4, 0); |
|
|
|
m_zcanHost->writeio(5, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DisinfectionCtrlService::DisinfectionCtrlService() {} |
|
|
|
|
|
|
|
string DisinfectionCtrlService::createDisinfectionID() { |
|
|
@ -34,24 +72,10 @@ void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
|
stopDisinfection(); |
|
|
|
} |
|
|
|
|
|
|
|
m_disinfectionID = createDisinfectionID(); |
|
|
|
m_remaintime = 20 * 60; |
|
|
|
m_isDisinfectionRunning = true; |
|
|
|
logger->info("startDisinfection {} {} {}", loglevel, roomVol, m_disinfectionID); |
|
|
|
m_drainingWorkState = 1; |
|
|
|
m_disinfectionID = createDisinfectionID(); |
|
|
|
m_remaintime = loglevel * 20 * 60; |
|
|
|
|
|
|
|
m_zcanHost->writeio(0, 1); |
|
|
|
m_zcanHost->writeio(1, 1); |
|
|
|
sleep(1); |
|
|
|
m_zcanHost->writeio(2, 1); |
|
|
|
m_zcanHost->writeio(3, 1); |
|
|
|
sleep(1); |
|
|
|
m_zcanHost->writeio(4, 1); |
|
|
|
m_zcanHost->writeio(5, 1); |
|
|
|
sleep(1); |
|
|
|
m_zcanHost->pumpctrl_c1004(2, 300, 1000); |
|
|
|
|
|
|
|
m_disinfectionThread.reset(new Thread("m_disinfectionThread", [this, loglevel]() { |
|
|
|
m_disinfectionThread.reset(new Thread("m_disinfectionThread", [this, roomVol, loglevel]() { |
|
|
|
// do something
|
|
|
|
// m_disinfectionThread->detach();
|
|
|
|
ThisThread thisThread; |
|
|
@ -59,30 +83,44 @@ void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
|
// 发送开始拍照消息
|
|
|
|
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); |
|
|
|
heartingPlate_setPower(true); |
|
|
|
usleep(100 * 1000); |
|
|
|
sprayLiquidPump_open(); |
|
|
|
|
|
|
|
while (!thisThread.getExitFlag()) { |
|
|
|
thisThread.sleepForMs(1000); |
|
|
|
if (m_disinfectionWorkState == 2) { |
|
|
|
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); |
|
|
|
thisThread.sleepForMs(1000); |
|
|
|
} |
|
|
|
|
|
|
|
m_remaintime = 0; |
|
|
|
logger->info("stop disinfection {}", m_disinfectionID); |
|
|
|
|
|
|
|
m_zcanHost->writeio(0, 0); |
|
|
|
m_zcanHost->writeio(1, 0); |
|
|
|
sleep(1); |
|
|
|
m_zcanHost->writeio(2, 0); |
|
|
|
m_zcanHost->writeio(3, 0); |
|
|
|
sleep(1); |
|
|
|
m_zcanHost->writeio(4, 0); |
|
|
|
m_zcanHost->writeio(5, 0); |
|
|
|
sleep(1); |
|
|
|
m_zcanHost->pumpctrl_c1004(2, 300, 0); |
|
|
|
m_disinfectionWorkState = 0; |
|
|
|
airCompressor(false); |
|
|
|
usleep(10 * 1000); |
|
|
|
blower_setPower(false); |
|
|
|
usleep(10 * 1000); |
|
|
|
heartingPlate_setPower(false); |
|
|
|
usleep(10 * 1000); |
|
|
|
sprayLiquidPump_close(); |
|
|
|
m_disinfectionWorkState = 3; |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
@ -114,54 +152,49 @@ string DisinfectionCtrlService::getDisinfectionID() { |
|
|
|
// 加液
|
|
|
|
void DisinfectionCtrlService::startReplenishingFluids() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
|
|
|
|
if (m_disinfectionThread) { |
|
|
|
m_disinfectionThread->join(); |
|
|
|
m_disinfectionThread = nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
logger->info("startReplenishingFluids"); |
|
|
|
m_zcanHost->pumpctrl_c1004(1, 300, 300, 1, 20); |
|
|
|
replenishingFluidsPump_open(); |
|
|
|
m_replenishingFluidsWorkState = 1; |
|
|
|
} |
|
|
|
// 停止加液
|
|
|
|
void DisinfectionCtrlService::stopReplenishingFluids() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
|
|
|
|
logger->info("stopReplenishingFluids"); |
|
|
|
m_zcanHost->pumpctrl_c1004(1, 300, 0, 1, 20); |
|
|
|
m_replenishingFluidsWorkState = 0; |
|
|
|
|
|
|
|
if (m_disinfectionThread) { |
|
|
|
m_disinfectionThread->join(); |
|
|
|
m_disinfectionThread = nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
logger->info("stopReplenishingFluids"); |
|
|
|
replenishingFluidsPump_close(); |
|
|
|
m_replenishingFluidsWorkState = 0; |
|
|
|
} |
|
|
|
// 开始排液
|
|
|
|
void DisinfectionCtrlService::startDraining() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
|
|
|
|
logger->info("startDraining"); |
|
|
|
m_zcanHost->pumpctrl_c1004(1, 300, -300, 1, 20); |
|
|
|
m_drainingWorkState = 1; |
|
|
|
|
|
|
|
if (m_disinfectionThread) { |
|
|
|
m_disinfectionThread->join(); |
|
|
|
m_disinfectionThread = nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
logger->info("startDraining"); |
|
|
|
drainingPump_open(); |
|
|
|
m_drainingWorkState = 1; |
|
|
|
} |
|
|
|
// 停止排液体
|
|
|
|
void DisinfectionCtrlService::stopDraining() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
|
|
|
|
logger->info("stopDraining"); |
|
|
|
m_zcanHost->pumpctrl_c1004(1, 300, 0, 1, 20); |
|
|
|
m_drainingWorkState = 0; |
|
|
|
|
|
|
|
if (m_disinfectionThread) { |
|
|
|
m_disinfectionThread->join(); |
|
|
|
m_disinfectionThread = nullptr; |
|
|
|
} |
|
|
|
logger->info("stopDraining"); |
|
|
|
m_drainingWorkState = 0; |
|
|
|
drainingPump_close(); |
|
|
|
} |
|
|
|
int DisinfectionCtrlService::getReplenishingFluidsWorkState() { return m_replenishingFluidsWorkState; } |
|
|
|
int DisinfectionCtrlService::getDrainingWorkState() { return m_drainingWorkState; } |