|
|
@ -143,7 +143,7 @@ void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
|
//
|
|
|
|
} |
|
|
|
|
|
|
|
logger->info("computeRemainTime minh2o2 {} dvalue {}", context.sensor_stat.min_h2o2, dvalue); |
|
|
|
logger->info("computeRemainTime minh2o2 {} dvalue {}", context.min_h2o2, dvalue); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::initContext(DisinfectionContext& context, //
|
|
|
@ -238,53 +238,27 @@ shared_ptr<DisinfectionLogger> DisinfectionCtrlService::createCSVLogger(string l |
|
|
|
void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& context) { |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
|
|
|
|
int h2o2_0 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(0); |
|
|
|
int h2o2_1 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(1); |
|
|
|
int h2o2_2 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(2); |
|
|
|
static_assert(MAX_H2O2_SENSOR_NUM == 3, "MAX_H2O2_SENSOR_NUM must be 3"); |
|
|
|
|
|
|
|
int humid0 = m_deviceIoControlService->H2O2Sensor_readHumid(0); |
|
|
|
int humid1 = m_deviceIoControlService->H2O2Sensor_readHumid(1); |
|
|
|
int humid2 = m_deviceIoControlService->H2O2Sensor_readHumid(2); |
|
|
|
auto& cx = context; |
|
|
|
string h2o2str[MAX_H2O2_SENSOR_NUM]; |
|
|
|
string tempstr[MAX_H2O2_SENSOR_NUM]; |
|
|
|
string humidstr[MAX_H2O2_SENSOR_NUM]; |
|
|
|
string satstr[MAX_H2O2_SENSOR_NUM]; |
|
|
|
|
|
|
|
int temp0 = m_deviceIoControlService->H2O2Sensor_readTemperature(0); |
|
|
|
int temp1 = m_deviceIoControlService->H2O2Sensor_readTemperature(1); |
|
|
|
int temp2 = m_deviceIoControlService->H2O2Sensor_readTemperature(2); |
|
|
|
|
|
|
|
int sat0 = m_deviceIoControlService->H2O2Sensor_readSaturation(0); |
|
|
|
int sat1 = m_deviceIoControlService->H2O2Sensor_readSaturation(1); |
|
|
|
int sat2 = m_deviceIoControlService->H2O2Sensor_readSaturation(2); |
|
|
|
|
|
|
|
string h2o2_0_str = fmt::format("{}", h2o2_0); |
|
|
|
string h2o2_1_str = fmt::format("{}", h2o2_1); |
|
|
|
string h2o2_2_str = fmt::format("{}", h2o2_2); |
|
|
|
|
|
|
|
string humid0_str = fmt::format("{}", humid0); |
|
|
|
string humid1_str = fmt::format("{}", humid1); |
|
|
|
string humid2_str = fmt::format("{}", humid2); |
|
|
|
|
|
|
|
string temp0_str = fmt::format("{}", temp0); |
|
|
|
string temp1_str = fmt::format("{}", temp1); |
|
|
|
string temp2_str = fmt::format("{}", temp2); |
|
|
|
|
|
|
|
string sat0_str = fmt::format("{}", sat0); |
|
|
|
string sat1_str = fmt::format("{}", sat1); |
|
|
|
string sat2_str = fmt::format("{}", sat2); |
|
|
|
|
|
|
|
if (h2o2_0 < 0) h2o2_0_str = "N/A"; |
|
|
|
if (h2o2_1 < 0) h2o2_1_str = "N/A"; |
|
|
|
if (h2o2_2 < 0) h2o2_2_str = "N/A"; |
|
|
|
|
|
|
|
if (humid0 < 0) humid0_str = "N/A"; |
|
|
|
if (humid1 < 0) humid1_str = "N/A"; |
|
|
|
if (humid2 < 0) humid2_str = "N/A"; |
|
|
|
|
|
|
|
if (temp0 < 0) temp0_str = "N/A"; |
|
|
|
if (temp1 < 0) temp1_str = "N/A"; |
|
|
|
if (temp2 < 0) temp2_str = "N/A"; |
|
|
|
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) { |
|
|
|
h2o2str[i] = fmt::format("{}", cx.h2o2[i]); |
|
|
|
tempstr[i] = fmt::format("{}", cx.temp[i]); |
|
|
|
humidstr[i] = fmt::format("{}", cx.humid[i]); |
|
|
|
satstr[i] = fmt::format("{}", cx.saturation[i]); |
|
|
|
} |
|
|
|
|
|
|
|
if (sat0 < 0) sat0_str = "N/A"; |
|
|
|
if (sat1 < 0) sat1_str = "N/A"; |
|
|
|
if (sat2 < 0) sat2_str = "N/A"; |
|
|
|
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) { |
|
|
|
if (cx.h2o2[i] < 0) h2o2str[i] = "N/A"; |
|
|
|
if (cx.temp[i] < 0) tempstr[i] = "N/A"; |
|
|
|
if (cx.humid[i] < 0) humidstr[i] = "N/A"; |
|
|
|
if (cx.saturation[i] < 0) satstr[i] = "N/A"; |
|
|
|
} |
|
|
|
|
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
@ -306,9 +280,9 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& con |
|
|
|
"{},{}", |
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
h2o2_0_str, temp0_str, humid0_str, sat0_str, //
|
|
|
|
h2o2_1_str, temp1_str, humid1_str, sat1_str, //
|
|
|
|
h2o2_2_str, temp2_str, humid2_str, sat2_str, //
|
|
|
|
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, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
@ -318,22 +292,23 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& con |
|
|
|
void DisinfectionCtrlService::log(DisinfectionContext& context) { |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
|
|
|
|
int h2o2_0 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(0); |
|
|
|
int h2o2_1 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(1); |
|
|
|
int h2o2_2 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(2); |
|
|
|
// int h2o2_0 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(0);
|
|
|
|
// int h2o2_1 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(1);
|
|
|
|
// int h2o2_2 = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(2);
|
|
|
|
|
|
|
|
int humid0 = m_deviceIoControlService->H2O2Sensor_readHumid(0); |
|
|
|
int humid1 = m_deviceIoControlService->H2O2Sensor_readHumid(1); |
|
|
|
int humid2 = m_deviceIoControlService->H2O2Sensor_readHumid(2); |
|
|
|
// int humid0 = m_deviceIoControlService->H2O2Sensor_readHumid(0);
|
|
|
|
// int humid1 = m_deviceIoControlService->H2O2Sensor_readHumid(1);
|
|
|
|
// int humid2 = m_deviceIoControlService->H2O2Sensor_readHumid(2);
|
|
|
|
|
|
|
|
int temp0 = m_deviceIoControlService->H2O2Sensor_readTemperature(0); |
|
|
|
int temp1 = m_deviceIoControlService->H2O2Sensor_readTemperature(1); |
|
|
|
int temp2 = m_deviceIoControlService->H2O2Sensor_readTemperature(2); |
|
|
|
// int temp0 = m_deviceIoControlService->H2O2Sensor_readTemperature(0);
|
|
|
|
// int temp1 = m_deviceIoControlService->H2O2Sensor_readTemperature(1);
|
|
|
|
// int temp2 = m_deviceIoControlService->H2O2Sensor_readTemperature(2);
|
|
|
|
|
|
|
|
int sat0 = m_deviceIoControlService->H2O2Sensor_readSaturation(0); |
|
|
|
int sat1 = m_deviceIoControlService->H2O2Sensor_readSaturation(1); |
|
|
|
int sat2 = m_deviceIoControlService->H2O2Sensor_readSaturation(2); |
|
|
|
// int sat0 = m_deviceIoControlService->H2O2Sensor_readSaturation(0);
|
|
|
|
// int sat1 = m_deviceIoControlService->H2O2Sensor_readSaturation(1);
|
|
|
|
// int sat2 = m_deviceIoControlService->H2O2Sensor_readSaturation(2);
|
|
|
|
|
|
|
|
auto& cx = context; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
if (m_context.dvalue <= 0) { |
|
|
@ -354,15 +329,14 @@ void DisinfectionCtrlService::log(DisinfectionContext& context) { |
|
|
|
"dv:{},log:{},tlog:{}," |
|
|
|
"h:{},airB:{},airC:{},pump:{}," |
|
|
|
"g:{},remainS:{}", |
|
|
|
|
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
h2o2_0, temp0, humid0, sat0, //
|
|
|
|
h2o2_1, temp1, humid1, sat1, //
|
|
|
|
h2o2_2, temp2, humid2, sat2, //
|
|
|
|
m_context.sensor_stat.max_h2o2, m_context.sensor_stat.min_h2o2, m_context.sensor_stat.max_humid, m_context.sensor_stat.max_saturation, //
|
|
|
|
(int32_t)dvalue, (int32_t)m_context.m_nowLoglevel, (int32_t)m_context.m_targetLoglevel, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
getTime(), //
|
|
|
|
cx.h2o2[0], cx.temp[0], cx.humid[0], cx.saturation[0], //
|
|
|
|
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, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
|
#endif
|
|
|
|
} |
|
|
@ -422,9 +396,9 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
|
/**
|
|
|
|
* @brief 检查当前 |
|
|
|
*/ |
|
|
|
float nowSatur = m_context.sensor_stat.max_saturation; |
|
|
|
float nowh2o2 = m_context.sensor_stat.max_h2o2; |
|
|
|
float humid = m_context.sensor_stat.max_humid; |
|
|
|
float nowSatur = m_context.max_saturation; |
|
|
|
float nowh2o2 = m_context.max_h2o2; |
|
|
|
float humid = m_context.max_humid; |
|
|
|
|
|
|
|
if (m_context.injection_pump_speed_changed) { |
|
|
|
m_deviceIoControlService->sprayLiquidPump_open(context.injection_pump_speed); |
|
|
@ -443,9 +417,9 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
|
m_context.m_state = kdisinfection_take_a_break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
float nowSatur = m_context.sensor_stat.max_saturation; |
|
|
|
float nowh2o2 = m_context.sensor_stat.max_h2o2; |
|
|
|
float humid = m_context.sensor_stat.max_humid; |
|
|
|
float nowSatur = m_context.max_saturation; |
|
|
|
float nowh2o2 = m_context.max_h2o2; |
|
|
|
float humid = m_context.max_humid; |
|
|
|
|
|
|
|
// && humid < m_context.continued_satur
|
|
|
|
if (nowSatur < m_context.continued_satur && nowh2o2 < m_context.continued_gs && humid < context.continued_humi) { |
|
|
@ -470,11 +444,11 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
/**
|
|
|
|
* @brief 更新传感器信息 |
|
|
|
*/ |
|
|
|
m_context.sensor_stat = m_deviceIoControlService->H2O2Sensor_getStatisticsResult(); |
|
|
|
updateH2O2SensorData(m_context); |
|
|
|
/**
|
|
|
|
* @brief 计算D值 |
|
|
|
*/ |
|
|
|
m_context.dvalue = getDisinfectionDValue(m_context.sensor_stat.min_h2o2); |
|
|
|
m_context.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(); |
|
|
@ -513,8 +487,8 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
/**
|
|
|
|
* @brief 等待h2o2浓度下降 |
|
|
|
*/ |
|
|
|
logger->info("waitting for h2o2 concentration to safe value {}=>{}", m_context.sensor_stat.min_h2o2, 1); |
|
|
|
if (m_context.sensor_stat.min_h2o2 < 1) { |
|
|
|
logger->info("waitting for h2o2 concentration to safe value {}=>{}", m_context.min_h2o2, 1); |
|
|
|
if (m_context.min_h2o2 < 1) { |
|
|
|
logger->info("h2o2 concentration to safe value"); |
|
|
|
breakflag = true; |
|
|
|
forcelog = true; |
|
|
@ -817,4 +791,51 @@ void DisinfectionCtrlService::stopDraining() { |
|
|
|
m_drainingWorkState = 0; |
|
|
|
// drainingPump_close();
|
|
|
|
m_deviceIoControlService->drainingPump_close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::updateH2O2SensorData(DisinfectionContext& context) { |
|
|
|
auto& cx = context; |
|
|
|
for (size_t i = 0; i < MAX_EXT_H2O2_SENSOR_NUM; i++) { |
|
|
|
cx.h2o2[i] = m_deviceIoControlService->H2O2Sensor_readH2O2PPM(i); |
|
|
|
} |
|
|
|
|
|
|
|
for (size_t i = 0; i < MAX_EXT_H2O2_SENSOR_NUM; i++) { |
|
|
|
cx.humid[i] = m_deviceIoControlService->H2O2Sensor_readHumid(i); |
|
|
|
} |
|
|
|
|
|
|
|
for (size_t i = 0; i < MAX_EXT_H2O2_SENSOR_NUM; i++) { |
|
|
|
cx.temp[i] = m_deviceIoControlService->H2O2Sensor_readTemperature(i); |
|
|
|
} |
|
|
|
|
|
|
|
for (size_t i = 0; i < MAX_EXT_H2O2_SENSOR_NUM; i++) { |
|
|
|
cx.saturation[i] = m_deviceIoControlService->H2O2Sensor_readSaturation(i); |
|
|
|
} |
|
|
|
|
|
|
|
cx.min_h2o2 = cx.h2o2[0]; |
|
|
|
cx.max_h2o2 = cx.h2o2[0]; |
|
|
|
cx.max_humid = cx.humid[0]; |
|
|
|
cx.max_saturation = cx.saturation[0]; |
|
|
|
|
|
|
|
for (size_t i = 0; i < MAX_EXT_H2O2_SENSOR_NUM; i++) { |
|
|
|
if (cx.h2o2[i] < cx.min_h2o2) { |
|
|
|
cx.min_h2o2 = cx.h2o2[i]; |
|
|
|
} |
|
|
|
|
|
|
|
if (cx.h2o2[i] > cx.max_h2o2) { |
|
|
|
cx.max_h2o2 = cx.h2o2[i]; |
|
|
|
} |
|
|
|
|
|
|
|
if (cx.humid[i] > cx.max_humid) { |
|
|
|
cx.max_humid = cx.humid[i]; |
|
|
|
} |
|
|
|
|
|
|
|
if (cx.saturation[i] > cx.max_saturation) { |
|
|
|
cx.max_saturation = cx.saturation[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (cx.max_h2o2 < 0) cx.max_h2o2 = 0; |
|
|
|
if (cx.min_h2o2 < 0) cx.min_h2o2 = 0; |
|
|
|
if (cx.max_humid < 0) cx.max_humid = 0; |
|
|
|
if (cx.max_saturation < 0) cx.max_saturation = 0; |
|
|
|
} |