|
@ -23,7 +23,7 @@ using namespace std; |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
// #define PRE_HEAT_TIME (2)
|
|
|
// #define PRE_HEAT_TIME (2)
|
|
|
#define PRE_HEAT_TIME (5 * 60)
|
|
|
|
|
|
|
|
|
// #define PRE_HEAT_TIME (5 * 60)
|
|
|
|
|
|
|
|
|
#define DVALUE_COMPUTEPERIOD_TIME_S (10.0)
|
|
|
#define DVALUE_COMPUTEPERIOD_TIME_S (10.0)
|
|
|
#define MAX_VOLUME (5000)
|
|
|
#define MAX_VOLUME (5000)
|
|
@ -130,28 +130,38 @@ void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::initContext(DisinfectionContext& context, int loglevel, float roomVol) { |
|
|
void DisinfectionCtrlService::initContext(DisinfectionContext& context, int loglevel, float roomVol) { |
|
|
context.m_disinfectionID = createDisinfectionID(); |
|
|
context.m_disinfectionID = createDisinfectionID(); |
|
|
|
|
|
context.pre_heat_time_s = m_dbService->getSettingVal("pre_heat_time_s"); |
|
|
|
|
|
context.stoped_gs = m_dbService->getSettingVal("stoped_gs"); |
|
|
|
|
|
context.continued_gs = m_dbService->getSettingVal("continued_gs"); |
|
|
|
|
|
context.stoped_satur = m_dbService->getSettingVal("stoped_satur"); |
|
|
|
|
|
context.continued_satur = m_dbService->getSettingVal("continued_satur"); |
|
|
|
|
|
context.stoped_humi = m_dbService->getSettingVal("stoped_humi"); |
|
|
|
|
|
context.continued_humi = m_dbService->getSettingVal("continued_humi"); |
|
|
|
|
|
|
|
|
|
|
|
logger->info("startDisinfection {} {} {}", m_context.m_loglevel, m_context.m_roomvol, m_context.m_disinfectionID); |
|
|
|
|
|
logger->info(" stoped_gs {}", context.stoped_gs); |
|
|
|
|
|
logger->info(" continued_gs {}", context.continued_gs); |
|
|
|
|
|
logger->info(" stoped_satur {}", context.stoped_satur); |
|
|
|
|
|
logger->info(" continued_satur {}", context.continued_satur); |
|
|
|
|
|
logger->info(" stoped_humi {}", context.stoped_humi); |
|
|
|
|
|
logger->info(" continued_humi {}", context.continued_humi); |
|
|
|
|
|
logger->info(" pre_heat_time_s {}", context.pre_heat_time_s); |
|
|
|
|
|
logger->info(""); |
|
|
|
|
|
|
|
|
// m_remaintime = loglevel * 20 * 60; // 计算总的加热时间
|
|
|
// m_remaintime = loglevel * 20 * 60; // 计算总的加热时间
|
|
|
context.m_remaintime = PRE_HEAT_TIME + loglevel * 90 * 60; // 计算总的加热时间
|
|
|
|
|
|
|
|
|
context.m_remaintime = context.pre_heat_time_s + loglevel * 90 * 60; // 计算总的加热时间
|
|
|
m_disinfectionWorkState = 1; |
|
|
m_disinfectionWorkState = 1; |
|
|
context.m_targetLoglevel = loglevel; |
|
|
context.m_targetLoglevel = loglevel; |
|
|
context.m_nowLoglevel = 0; |
|
|
context.m_nowLoglevel = 0; |
|
|
context.m_loglevel = loglevel; |
|
|
context.m_loglevel = loglevel; |
|
|
context.m_roomvol = roomVol; |
|
|
context.m_roomvol = roomVol; |
|
|
m_context.m_preheatFlag = true; |
|
|
|
|
|
m_context.dvalue = 0; |
|
|
|
|
|
|
|
|
// m_context.m_preheatFlag = true;
|
|
|
|
|
|
m_context.dvalue = 0; |
|
|
|
|
|
// m_context.stopedflag = false;
|
|
|
|
|
|
|
|
|
context.stoped_gs = m_dbService->getSettingVal("stoped_gs"); |
|
|
|
|
|
context.continued_gs = m_dbService->getSettingVal("continued_gs"); |
|
|
|
|
|
context.stoped_satur = m_dbService->getSettingVal("stoped_satur"); |
|
|
|
|
|
context.continued_satur = m_dbService->getSettingVal("continued_satur"); |
|
|
|
|
|
|
|
|
m_context.m_state = kpreheat; |
|
|
|
|
|
|
|
|
m_context.m_starttp = zsteady_clock().now(); |
|
|
m_context.m_starttp = zsteady_clock().now(); |
|
|
logger->info("startDisinfection {} {} {}", m_context.m_loglevel, m_context.m_roomvol, m_context.m_disinfectionID); |
|
|
|
|
|
logger->info(" stoped_gs {}", context.stoped_gs); |
|
|
|
|
|
logger->info(" continued_gs {}", context.continued_gs); |
|
|
|
|
|
logger->info(" stoped_satur {}", context.stoped_satur); |
|
|
|
|
|
logger->info(" continued_satur {}", context.continued_satur); |
|
|
|
|
|
logger->info(""); |
|
|
|
|
|
|
|
|
|
|
|
m_zcanHost->warning_light_ctrl_c1002(1, 0, 0, 1, 0); |
|
|
m_zcanHost->warning_light_ctrl_c1002(1, 0, 0, 1, 0); |
|
|
m_deviceIoControlService->heartingPlate_setPower(true); |
|
|
m_deviceIoControlService->heartingPlate_setPower(true); |
|
@ -202,7 +212,7 @@ void DisinfectionCtrlService::processPreheatState(DisinfectionContext& context) |
|
|
int hasstarttime = zsteady_clock().elapsedTimeS(context.m_starttp); |
|
|
int hasstarttime = zsteady_clock().elapsedTimeS(context.m_starttp); |
|
|
|
|
|
|
|
|
// logger->info("preheat {}", context.m_disinfectionID);
|
|
|
// logger->info("preheat {}", context.m_disinfectionID);
|
|
|
if ((context.m_preheatFlag && hasstarttime > PRE_HEAT_TIME) || !g_preheat) { |
|
|
|
|
|
|
|
|
if ((context.m_state == kpreheat && hasstarttime > m_context.pre_heat_time_s) || !g_preheat) { |
|
|
logger->info("preheat finished {}", context.m_disinfectionID); |
|
|
logger->info("preheat finished {}", context.m_disinfectionID); |
|
|
// blower_setPower(true);
|
|
|
// blower_setPower(true);
|
|
|
m_deviceIoControlService->airBlower_setState(true); |
|
|
m_deviceIoControlService->airBlower_setState(true); |
|
@ -212,10 +222,11 @@ void DisinfectionCtrlService::processPreheatState(DisinfectionContext& context) |
|
|
usleep(1000 * 1000); |
|
|
usleep(1000 * 1000); |
|
|
// sprayLiquidPump_open();
|
|
|
// sprayLiquidPump_open();
|
|
|
m_deviceIoControlService->sprayLiquidPump_open(); |
|
|
m_deviceIoControlService->sprayLiquidPump_open(); |
|
|
context.m_preheatFlag = false; |
|
|
|
|
|
context.sprayLiquidFlag = true; |
|
|
|
|
|
|
|
|
context.m_state = kdisinfection; |
|
|
|
|
|
// context.m_preheatFlag = false;
|
|
|
|
|
|
// context.sprayLiquidFlag = true;
|
|
|
} else { |
|
|
} else { |
|
|
logger->info("{}: preheat {}", context.m_disinfectionID, PRE_HEAT_TIME - hasstarttime); |
|
|
|
|
|
|
|
|
logger->info("{}: preheat {}", context.m_disinfectionID, m_context.pre_heat_time_s - hasstarttime); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -313,6 +324,7 @@ void DisinfectionCtrlService::dumpDisinfectionLogs(DisinfectionContext& context) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& context) { |
|
|
void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& context) { |
|
|
|
|
|
ZCHECK(context.m_state == kdisinfection || context.m_state == kdisinfection_take_a_break, "state error"); |
|
|
/**
|
|
|
/**
|
|
|
* @brief 读取传感器数值 |
|
|
* @brief 读取传感器数值 |
|
|
*/ |
|
|
*/ |
|
@ -331,7 +343,7 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
/**
|
|
|
/**
|
|
|
* @brief 根据湿度启停喷雾 |
|
|
* @brief 根据湿度启停喷雾 |
|
|
*/ |
|
|
*/ |
|
|
if (m_context.sprayLiquidFlag) { |
|
|
|
|
|
|
|
|
if (m_context.m_state == kdisinfection) { |
|
|
/**
|
|
|
/**
|
|
|
* @brief 检查当前 |
|
|
* @brief 检查当前 |
|
|
*/ |
|
|
*/ |
|
@ -340,14 +352,15 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
float humid = m_context.h2o2data.max_humid; |
|
|
float humid = m_context.h2o2data.max_humid; |
|
|
|
|
|
|
|
|
// humid > m_context.stoped_satur
|
|
|
// humid > m_context.stoped_satur
|
|
|
if (nowSatur > m_context.stoped_satur || nowh2o2 > m_context.stoped_gs) { |
|
|
|
|
|
|
|
|
if (nowSatur > m_context.stoped_satur || nowh2o2 > m_context.stoped_gs || humid > m_context.stoped_humi) { |
|
|
logger->info("stop sprayLiquid"); |
|
|
logger->info("stop sprayLiquid"); |
|
|
|
|
|
|
|
|
m_deviceIoControlService->sprayLiquidPump_close(); |
|
|
m_deviceIoControlService->sprayLiquidPump_close(); |
|
|
usleep(1000 * 1000); |
|
|
usleep(1000 * 1000); |
|
|
m_deviceIoControlService->airCompressor_setState(false); |
|
|
m_deviceIoControlService->airCompressor_setState(false); |
|
|
|
|
|
|
|
|
m_context.sprayLiquidFlag = false; |
|
|
|
|
|
|
|
|
// m_context.sprayLiquidFlag = false;
|
|
|
|
|
|
m_context.m_state = kdisinfection_take_a_break; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
float nowSatur = m_context.h2o2data.max_saturation; |
|
|
float nowSatur = m_context.h2o2data.max_saturation; |
|
@ -355,15 +368,60 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
float humid = m_context.h2o2data.max_humid; |
|
|
float humid = m_context.h2o2data.max_humid; |
|
|
|
|
|
|
|
|
// && humid < m_context.continued_satur
|
|
|
// && humid < m_context.continued_satur
|
|
|
if (nowSatur < m_context.continued_satur && nowh2o2 < m_context.continued_gs) { |
|
|
|
|
|
|
|
|
if (nowSatur < m_context.continued_satur && nowh2o2 < m_context.continued_gs && humid < context.continued_humi) { |
|
|
logger->info("start sprayLiquid"); |
|
|
logger->info("start sprayLiquid"); |
|
|
|
|
|
|
|
|
m_deviceIoControlService->sprayLiquidPump_open(); |
|
|
m_deviceIoControlService->sprayLiquidPump_open(); |
|
|
usleep(1000 * 1000); |
|
|
usleep(1000 * 1000); |
|
|
m_deviceIoControlService->airCompressor_setState(true); |
|
|
m_deviceIoControlService->airCompressor_setState(true); |
|
|
|
|
|
m_context.m_state = kdisinfection; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
|
|
// logger->info("disinfection running {} {}s preheatFlag:{}", m_context.m_disinfectionID, m_context.m_remaintime, m_context.m_preheatFlag);
|
|
|
|
|
|
m_context.m_remaintime--; |
|
|
|
|
|
|
|
|
m_context.sprayLiquidFlag = true; |
|
|
|
|
|
|
|
|
m_deviceIoControlService->getAllSensorData(m_context.h2o2data); |
|
|
|
|
|
if (m_context.m_state == kpreheat) { |
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 预热中 |
|
|
|
|
|
*/ |
|
|
|
|
|
processPreheatState(m_context); |
|
|
|
|
|
} else if (m_context.m_state == kdisinfection || m_context.m_state == kdisinfection_take_a_break) { |
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 消毒中 |
|
|
|
|
|
*/ |
|
|
|
|
|
processDisinfectionState(m_context); |
|
|
|
|
|
//
|
|
|
|
|
|
if (m_context.m_remaintime <= 0) { |
|
|
|
|
|
m_context.m_remaintime = 0; |
|
|
|
|
|
logger->info("disinfection finished {},but waitting for h2o2 to safe", m_context.m_disinfectionID); |
|
|
|
|
|
m_deviceIoControlService->sprayLiquidPump_close(); |
|
|
|
|
|
usleep(1000 * 1000); |
|
|
|
|
|
m_deviceIoControlService->airCompressor_setState(false); |
|
|
|
|
|
usleep(1000 * 1000); |
|
|
|
|
|
m_deviceIoControlService->heartingPlate_setPower(false); |
|
|
|
|
|
m_context.m_state = kwait_for_h2o2_down; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (m_context.m_state == kwait_for_h2o2_down) { |
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 等待h2o2浓度下降 |
|
|
|
|
|
*/ |
|
|
|
|
|
logger->info("waitting for h2o2 concentration to safe value {}=>{}", m_context.h2o2data.min_h2o2, 1); |
|
|
|
|
|
if (m_context.h2o2data.min_h2o2 <= 1) { |
|
|
|
|
|
logger->info("h2o2 concentration to safe value"); |
|
|
|
|
|
breakflag = true; |
|
|
|
|
|
m_context.m_state = kfinished; |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
ZCHECK(false, "state error"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastlogTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
|
|
m_context.m_lastlogTp = zsteady_clock().now(); |
|
|
|
|
|
dumpDisinfectionLogsToCSV(m_context); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -384,26 +442,14 @@ void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
ThisThread thisThread; |
|
|
ThisThread thisThread; |
|
|
while (!thisThread.getExitFlag()) { |
|
|
while (!thisThread.getExitFlag()) { |
|
|
thisThread.sleepForMs(1000); |
|
|
thisThread.sleepForMs(1000); |
|
|
// logger->info("disinfection running {} {}s preheatFlag:{}", m_context.m_disinfectionID, m_context.m_remaintime, m_context.m_preheatFlag);
|
|
|
|
|
|
m_deviceIoControlService->getAllSensorData(m_context.h2o2data); |
|
|
|
|
|
|
|
|
|
|
|
if (m_context.m_preheatFlag) { |
|
|
|
|
|
processPreheatState(m_context); |
|
|
|
|
|
} else { |
|
|
|
|
|
processDisinfectionState(m_context); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastlogTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
|
|
m_context.m_lastlogTp = zsteady_clock().now(); |
|
|
|
|
|
dumpDisinfectionLogsToCSV(m_context); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_context.m_remaintime--; |
|
|
|
|
|
if (m_context.m_remaintime == 0) { |
|
|
|
|
|
logger->info("disinfection finished {}", m_context.m_disinfectionID); |
|
|
|
|
|
|
|
|
bool breakflag = false; |
|
|
|
|
|
disinfectionLoop(breakflag); |
|
|
|
|
|
if (breakflag) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
finishDisinfection(m_context); |
|
|
finishDisinfection(m_context); |
|
|
})); |
|
|
})); |
|
|
//
|
|
|
//
|
|
@ -427,8 +473,8 @@ int32_t DisinfectionCtrlService::getEstimatedRemainingTimeS() { |
|
|
int32_t DisinfectionCtrlService::getPreHeatRaminTimeS() { |
|
|
int32_t DisinfectionCtrlService::getPreHeatRaminTimeS() { |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
int32_t remaintime = 0; |
|
|
int32_t remaintime = 0; |
|
|
if (m_context.m_preheatFlag) { |
|
|
|
|
|
remaintime = PRE_HEAT_TIME - zsteady_clock().elapsedTimeS(m_context.m_starttp); |
|
|
|
|
|
|
|
|
if (m_context.m_state == kpreheat) { |
|
|
|
|
|
remaintime = m_context.pre_heat_time_s - zsteady_clock().elapsedTimeS(m_context.m_starttp); |
|
|
if (remaintime < 0) { |
|
|
if (remaintime < 0) { |
|
|
remaintime = 0; |
|
|
remaintime = 0; |
|
|
} |
|
|
} |
|
@ -444,7 +490,7 @@ string DisinfectionCtrlService::getDisinfectionID() { |
|
|
} |
|
|
} |
|
|
bool DisinfectionCtrlService::isPreheatState() { |
|
|
bool DisinfectionCtrlService::isPreheatState() { |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
return m_context.m_preheatFlag; |
|
|
|
|
|
|
|
|
return m_context.m_state == kpreheat; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int DisinfectionCtrlService::getReplenishingFluidsWorkState() { return m_replenishingFluidsWorkState; } |
|
|
int DisinfectionCtrlService::getReplenishingFluidsWorkState() { return m_replenishingFluidsWorkState; } |
|
|