|
|
@ -102,30 +102,30 @@ float DisinfectionCtrlService::getDisinfectionDValue(float ppm) { // |
|
|
|
return m_dvalueComputer.computeDValue(ppm); |
|
|
|
} |
|
|
|
float DisinfectionCtrlService::computeNowLogLevel(DisinfectionContext& context) { |
|
|
|
float dvalue = context.dvalue; |
|
|
|
float dvalue = context.state_dvalue; |
|
|
|
if (dvalue > 0) { |
|
|
|
/**
|
|
|
|
* @brief 计算 m_nowLoglevel |
|
|
|
* @brief 计算 state_now_loglevel |
|
|
|
*/ |
|
|
|
return context.m_nowLoglevel + DVALUE_COMPUTEPERIOD_TIME_S / (dvalue * 60); |
|
|
|
return context.state_now_loglevel + DVALUE_COMPUTEPERIOD_TIME_S / (dvalue * 60); |
|
|
|
} |
|
|
|
return context.m_nowLoglevel; |
|
|
|
return context.state_now_loglevel; |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
|
/**
|
|
|
|
* @brief 计算Dvalue |
|
|
|
*/ |
|
|
|
float dvalue = context.dvalue; |
|
|
|
float dvalue = context.state_dvalue; |
|
|
|
|
|
|
|
if (dvalue > 0) { |
|
|
|
/**
|
|
|
|
* @brief 计算 m_nowLoglevel |
|
|
|
* @brief 计算 state_now_loglevel |
|
|
|
*/ |
|
|
|
if (context.m_targetLoglevel >= context.m_nowLoglevel) { |
|
|
|
context.m_remaintime = (context.m_targetLoglevel - context.m_nowLoglevel) * (dvalue * 60); |
|
|
|
if (context.cfg_targetLoglevel >= context.state_now_loglevel) { |
|
|
|
context.state_remaintime = (context.cfg_targetLoglevel - context.state_now_loglevel) * (dvalue * 60); |
|
|
|
} else { |
|
|
|
context.m_remaintime = 0; |
|
|
|
context.state_remaintime = 0; |
|
|
|
} |
|
|
|
} else { |
|
|
|
//
|
|
|
@ -182,10 +182,10 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& con |
|
|
|
|
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
if (m_context.dvalue <= 0) { |
|
|
|
if (m_context.state_dvalue <= 0) { |
|
|
|
dvalue = 0; |
|
|
|
} else { |
|
|
|
dvalue = m_context.dvalue; |
|
|
|
dvalue = m_context.state_dvalue; |
|
|
|
} |
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
@ -203,7 +203,7 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& con |
|
|
|
h2o2str[0], tempstr[0], humidstr[0], satstr[0], //
|
|
|
|
h2o2str[1], tempstr[1], humidstr[1], satstr[1], //
|
|
|
|
h2o2str[2], tempstr[2], humidstr[2], satstr[2], //
|
|
|
|
(int32_t)dvalue, (int32_t)m_context.m_nowLoglevel, (int32_t)m_context.m_targetLoglevel, //
|
|
|
|
(int32_t)dvalue, (int32_t)m_context.state_now_loglevel, (int32_t)m_context.cfg_targetLoglevel, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
|
#endif
|
|
|
@ -215,10 +215,10 @@ void DisinfectionCtrlService::log(DisinfectionContext& context) { |
|
|
|
auto& cx = context; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
if (m_context.dvalue <= 0) { |
|
|
|
if (m_context.state_dvalue <= 0) { |
|
|
|
dvalue = 0; |
|
|
|
} else { |
|
|
|
dvalue = m_context.dvalue; |
|
|
|
dvalue = m_context.state_dvalue; |
|
|
|
} |
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
@ -238,7 +238,7 @@ void DisinfectionCtrlService::log(DisinfectionContext& context) { |
|
|
|
cx.h2o2[1], cx.temp[1], cx.humid[1], cx.saturation[1], //
|
|
|
|
cx.h2o2[2], cx.temp[2], cx.humid[2], cx.saturation[2], //
|
|
|
|
m_context.max_h2o2, m_context.min_h2o2, m_context.max_humid, m_context.max_saturation, //
|
|
|
|
(int32_t)dvalue, (int32_t)m_context.m_nowLoglevel, (int32_t)m_context.m_targetLoglevel, //
|
|
|
|
(int32_t)dvalue, (int32_t)m_context.state_now_loglevel, (int32_t)m_context.cfg_targetLoglevel, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
|
#endif
|
|
|
@ -274,7 +274,7 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, |
|
|
|
context.pre_heat_time_s = 5; |
|
|
|
} |
|
|
|
|
|
|
|
logger->info("startDisinfection {} {}", m_context.m_targetLoglevel, m_context.m_disinfectionID); |
|
|
|
logger->info("startDisinfection {} {}", m_context.cfg_targetLoglevel, 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); |
|
|
@ -284,13 +284,13 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, |
|
|
|
logger->info(" pre_heat_time_s {}", context.pre_heat_time_s); |
|
|
|
logger->info(""); |
|
|
|
|
|
|
|
// m_remaintime = loglevel * 20 * 60; // 计算总的加热时间
|
|
|
|
context.m_remaintime = context.pre_heat_time_s + loglevel * 90 * 60; // 计算总的加热时间
|
|
|
|
m_disinfectionWorkState = 1; |
|
|
|
context.m_targetLoglevel = loglevel; |
|
|
|
context.m_nowLoglevel = 0; |
|
|
|
// state_remaintime = loglevel * 20 * 60; // 计算总的加热时间
|
|
|
|
context.state_remaintime = context.pre_heat_time_s + loglevel * 90 * 60; // 计算总的加热时间
|
|
|
|
m_disinfectionWorkState = 1; |
|
|
|
context.cfg_targetLoglevel = loglevel; |
|
|
|
context.state_now_loglevel = 0; |
|
|
|
// m_context.m_preheatFlag = true;
|
|
|
|
m_context.dvalue = 0; |
|
|
|
m_context.state_dvalue = 0; |
|
|
|
// m_context.stopedflag = false;
|
|
|
|
|
|
|
|
m_context.m_state = kstate_preheat; |
|
|
@ -320,7 +320,7 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::finishDisinfection(DisinfectionContext& context) { |
|
|
|
context.m_remaintime = 0; |
|
|
|
context.state_remaintime = 0; |
|
|
|
logger->info("stop disinfection {}", context.m_disinfectionID); |
|
|
|
|
|
|
|
// sprayLiquidPump_close();
|
|
|
@ -369,7 +369,7 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
|
/**
|
|
|
|
* @brief 根据湿度启停喷雾 |
|
|
|
*/ |
|
|
|
if (!m_context.isDisinfectionTakeBreak) { |
|
|
|
if (!m_context.state_is_disinfection_take_break) { |
|
|
|
/**
|
|
|
|
* @brief 检查当前 |
|
|
|
*/ |
|
|
@ -391,7 +391,7 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
|
m_deviceIoControlService->airCompressor_setState(false); |
|
|
|
|
|
|
|
// m_context.sprayLiquidFlag = false;
|
|
|
|
m_context.isDisinfectionTakeBreak = true; |
|
|
|
m_context.state_is_disinfection_take_break = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
float nowSatur = m_context.max_saturation; |
|
|
@ -405,18 +405,18 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
|
m_deviceIoControlService->sprayLiquidPump_open(context.injection_pump_speed); |
|
|
|
usleep(1000 * 1000); |
|
|
|
m_deviceIoControlService->airCompressor_setState(true); |
|
|
|
m_context.isDisinfectionTakeBreak = false; |
|
|
|
m_context.state_is_disinfection_take_break = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
// logger->info("disinfection running {} {}s preheatFlag:{}", m_context.m_disinfectionID, m_context.m_remaintime, m_context.m_preheatFlag);
|
|
|
|
// logger->info("disinfection running {} {}s preheatFlag:{}", m_context.m_disinfectionID, m_context.state_remaintime, m_context.m_preheatFlag);
|
|
|
|
ThisThread thisThread; |
|
|
|
m_context.m_remaintime--; |
|
|
|
m_context.state_remaintime--; |
|
|
|
bool forcelog = false; |
|
|
|
if (m_context.m_remaintime < 0) { |
|
|
|
m_context.m_remaintime = 0; |
|
|
|
if (m_context.state_remaintime < 0) { |
|
|
|
m_context.state_remaintime = 0; |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
@ -426,13 +426,13 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
/**
|
|
|
|
* @brief 计算D值 |
|
|
|
*/ |
|
|
|
m_context.dvalue = getDisinfectionDValue(m_context.min_h2o2); |
|
|
|
m_context.state_dvalue = getDisinfectionDValue(m_context.min_h2o2); |
|
|
|
|
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastComputeDvalueTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.m_lastComputeDvalueTp = zsteady_clock().now(); |
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.state_last_compute_dvalue_tp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.state_last_compute_dvalue_tp = zsteady_clock().now(); |
|
|
|
//
|
|
|
|
if (m_context.m_state == kstate_disinfection) { |
|
|
|
m_context.m_nowLoglevel = computeNowLogLevel(m_context); |
|
|
|
m_context.state_now_loglevel = computeNowLogLevel(m_context); |
|
|
|
computeRemainTime(m_context); |
|
|
|
} |
|
|
|
} |
|
|
@ -448,9 +448,9 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
*/ |
|
|
|
processDisinfectionState(m_context); |
|
|
|
//
|
|
|
|
if (m_context.m_remaintime <= 0 && m_context.m_nowLoglevel > (m_context.m_targetLoglevel + 0.01)) { |
|
|
|
m_context.m_remaintime = 0; |
|
|
|
m_context.m_nowLoglevel = m_context.m_targetLoglevel + 0.01; |
|
|
|
if (m_context.state_remaintime <= 0 && m_context.state_now_loglevel > (m_context.cfg_targetLoglevel + 0.01)) { |
|
|
|
m_context.state_remaintime = 0; |
|
|
|
m_context.state_now_loglevel = m_context.cfg_targetLoglevel + 0.01; |
|
|
|
logger->info("disinfection finished {},but waitting for h2o2 to safe", m_context.m_disinfectionID); |
|
|
|
m_deviceIoControlService->sprayLiquidPump_close(); |
|
|
|
usleep(1000 * 1000); |
|
|
@ -492,8 +492,8 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
log(m_context); |
|
|
|
printfDisinfectionContextResult(); |
|
|
|
} else { |
|
|
|
if (forcelog || zsteady_clock().elapsedTimeS(m_context.m_lastlogTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.m_lastlogTp = zsteady_clock().now(); |
|
|
|
if (forcelog || zsteady_clock().elapsedTimeS(m_context.state_lastlog_tp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.state_lastlog_tp = zsteady_clock().now(); |
|
|
|
takeStateSnapshot(m_context); |
|
|
|
dumpDisinfectionLogsToCSV(m_context); |
|
|
|
log(m_context); |
|
|
@ -567,8 +567,8 @@ int32_t DisinfectionCtrlService::getEstimatedRemainingTimeS() { |
|
|
|
if (m_context.m_state == kstate_preheat) { |
|
|
|
return getPreHeatRaminTimeS(); |
|
|
|
} else if (m_context.m_state == kstate_disinfection) { |
|
|
|
if (m_context.dvalue > 0) { |
|
|
|
return m_context.m_remaintime; |
|
|
|
if (m_context.state_dvalue > 0) { |
|
|
|
return m_context.state_remaintime; |
|
|
|
} else { |
|
|
|
return -1; |
|
|
|
} |
|
|
@ -599,17 +599,10 @@ bool DisinfectionCtrlService::isPreheatState() { |
|
|
|
return m_context.m_state == kstate_preheat; |
|
|
|
} |
|
|
|
|
|
|
|
int DisinfectionCtrlService::getReplenishingFluidsWorkState() { return m_replenishingFluidsWorkState; } |
|
|
|
int DisinfectionCtrlService::getDrainingWorkState() { return m_drainingWorkState; } |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* // 加液 *
|
|
|
|
*******************************************************************************/ |
|
|
|
/**
|
|
|
|
* @brief 开始加液 |
|
|
|
* |
|
|
|
* @param stopatg |
|
|
|
*/ |
|
|
|
int DisinfectionCtrlService::getReplenishingFluidsWorkState() { return m_replenishingFluidsWorkState; } |
|
|
|
void DisinfectionCtrlService::startReplenishingFluids(int stopatg) { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
if (m_disinfectionThread) { |
|
|
@ -658,10 +651,7 @@ void DisinfectionCtrlService::startReplenishingFluids(int stopatg) { |
|
|
|
m_replenishingFluidsWorkState = 1; |
|
|
|
logger->info("startReplenishingFluids "); |
|
|
|
} |
|
|
|
/**
|
|
|
|
* @brief 停止加液 |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
void DisinfectionCtrlService::stopReplenishingFluids() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
if (m_disinfectionThread) { |
|
|
@ -677,10 +667,6 @@ void DisinfectionCtrlService::stopReplenishingFluids() { |
|
|
|
/*******************************************************************************
|
|
|
|
* 排液 * |
|
|
|
*******************************************************************************/ |
|
|
|
/**
|
|
|
|
* @brief 开始排液 |
|
|
|
* |
|
|
|
*/ |
|
|
|
void DisinfectionCtrlService::startDraining() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
if (m_disinfectionThread) { |
|
|
@ -726,9 +712,6 @@ void DisinfectionCtrlService::startDraining() { |
|
|
|
// drainingPump_open();
|
|
|
|
m_drainingWorkState = 1; |
|
|
|
} |
|
|
|
/**
|
|
|
|
* @brief 停止排液体 |
|
|
|
*/ |
|
|
|
void DisinfectionCtrlService::stopDraining() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
if (m_disinfectionThread) { |
|
|
@ -740,6 +723,7 @@ void DisinfectionCtrlService::stopDraining() { |
|
|
|
// drainingPump_close();
|
|
|
|
m_deviceIoControlService->drainingPump_close(); |
|
|
|
} |
|
|
|
int DisinfectionCtrlService::getDrainingWorkState() { return m_drainingWorkState; } |
|
|
|
|
|
|
|
void DisinfectionCtrlService::updateH2O2SensorData(DisinfectionContext& context) { |
|
|
|
auto& cx = context; |
|
|
|