|
@ -6,8 +6,12 @@ |
|
|
#include "configs/gconfig.hpp"
|
|
|
#include "configs/gconfig.hpp"
|
|
|
#include "configs/project_setting.hpp"
|
|
|
#include "configs/project_setting.hpp"
|
|
|
#include "iflytop/components/uart_printer/uart_printer.hpp"
|
|
|
#include "iflytop/components/uart_printer/uart_printer.hpp"
|
|
|
|
|
|
#include "iflytoplinuxsdk/src/iflytop/components/ziconv.hpp"
|
|
|
#include "service/device_state_service.hpp"
|
|
|
#include "service/device_state_service.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
// #define PROJECT_TYPE_LARGE_SPACE_DISINFECTION 1 // 大空间
|
|
|
|
|
|
// #define PROJECT_TYPE_SMALL_SPACE_DISINFECTION 1 // 小空间
|
|
|
|
|
|
|
|
|
using namespace iflytop; |
|
|
using namespace iflytop; |
|
|
using namespace std; |
|
|
using namespace std; |
|
|
/**
|
|
|
/**
|
|
@ -42,6 +46,26 @@ extern bool g_in_test; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static string formattimeS(int sec) { |
|
|
|
|
|
if (sec >= 0) { |
|
|
|
|
|
return fmt::format("{:0>2}:{:0>2}:{:0>2}", sec / 3600, sec % 3600 / 60, sec % 60); |
|
|
|
|
|
} else { |
|
|
|
|
|
return fmt::format("--:--:--"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static string getTime() { |
|
|
|
|
|
struct tm tm = {0}; |
|
|
|
|
|
|
|
|
|
|
|
time_t t = time(nullptr); |
|
|
|
|
|
struct tm* tmp = localtime_r(&t, &tm); |
|
|
|
|
|
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
|
|
|
|
|
|
tm.tm_mon + 1, //
|
|
|
|
|
|
tm.tm_mday, //
|
|
|
|
|
|
tm.tm_hour, //
|
|
|
|
|
|
tm.tm_min, tm.tm_sec); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
DisinfectionCtrlService::DisinfectionCtrlService() {} |
|
|
DisinfectionCtrlService::DisinfectionCtrlService() {} |
|
|
void DisinfectionCtrlService::initialize() { |
|
|
void DisinfectionCtrlService::initialize() { |
|
|
GET_TO_SERVICE(m_zcanHost); |
|
|
GET_TO_SERVICE(m_zcanHost); |
|
@ -59,18 +83,6 @@ void DisinfectionCtrlService::initialize() { |
|
|
m_dvalueComputer.initialize(); |
|
|
m_dvalueComputer.initialize(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static string getTime() { |
|
|
|
|
|
struct tm tm = {0}; |
|
|
|
|
|
|
|
|
|
|
|
time_t t = time(nullptr); |
|
|
|
|
|
struct tm* tmp = localtime_r(&t, &tm); |
|
|
|
|
|
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
|
|
|
|
|
|
tm.tm_mon + 1, //
|
|
|
|
|
|
tm.tm_mday, //
|
|
|
|
|
|
tm.tm_hour, //
|
|
|
|
|
|
tm.tm_min, tm.tm_sec); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string DisinfectionCtrlService::createDisinfectionID() { |
|
|
string DisinfectionCtrlService::createDisinfectionID() { |
|
|
struct tm tm = {0}; |
|
|
struct tm tm = {0}; |
|
|
|
|
|
|
|
@ -131,7 +143,7 @@ void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
//
|
|
|
//
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
logger->info("computeRemainTime minh2o2 {} dvalue {}", context.h2o2data.min_h2o2, dvalue); |
|
|
|
|
|
|
|
|
logger->info("computeRemainTime minh2o2 {} dvalue {}", context.sensor_stat.min_h2o2, dvalue); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::initContext(DisinfectionContext& context, //
|
|
|
void DisinfectionCtrlService::initContext(DisinfectionContext& context, //
|
|
@ -186,40 +198,96 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, |
|
|
|
|
|
|
|
|
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); |
|
|
context.csvlogger = m_disinfectionLogsManager->createNewLogger(context.m_disinfectionID); |
|
|
|
|
|
|
|
|
|
|
|
// zsteady_clock().elapsedTimeS(m_context.m_starttp), //
|
|
|
|
|
|
// sensors[0].h2o2, sensors[0].temp, sensors[0].humid, sensors[0].saturation, //
|
|
|
|
|
|
// sensors[1].h2o2, sensors[1].temp, sensors[1].humid, sensors[1].saturation, //
|
|
|
|
|
|
// sensors[2].h2o2, sensors[2].temp, sensors[2].humid, sensors[2].saturation, //
|
|
|
|
|
|
// m_context.dvalue, m_context.m_nowLoglevel, (int)m_context.m_targetLoglevel, //
|
|
|
|
|
|
// ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getRPM(), //
|
|
|
|
|
|
// ds->getPressureSensorData(1), ds->getPressureSensorData(2), ds->getPressureSensorData(3), ds->getPressureSensorData(4), //
|
|
|
|
|
|
// m_deviceIoControlService->getDisinfectantVolume_g(), //
|
|
|
|
|
|
// m_context.m_remaintime
|
|
|
|
|
|
|
|
|
|
|
|
context.csvlogger->write( |
|
|
|
|
|
"Date," //
|
|
|
|
|
|
"Hydrogen peroxide volume(ppm),Temperature(C),Relative humidity(%RH),H2O H2O2 RS(%RS)," //
|
|
|
|
|
|
// "h2o22,temp2,humi2,saturation2," //
|
|
|
|
|
|
// "h2o23,temp3,humi3,saturation3," //
|
|
|
|
|
|
"Dvalue,Loglevel,Targetloglevel," //
|
|
|
|
|
|
"Heating,Blower,Compressor,Pump(g/min)," //
|
|
|
|
|
|
"Disinfectant Volume(g)," //
|
|
|
|
|
|
"Remaining time (s)\n" //
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
context.csvlogger = createCSVLogger(context.m_disinfectionID); |
|
|
} |
|
|
} |
|
|
static string formattimeS(int sec) { |
|
|
|
|
|
if (sec >= 0) { |
|
|
|
|
|
return fmt::format("{:0>2}:{:0>2}:{:0>2}", sec / 3600, sec % 3600 / 60, sec % 60); |
|
|
|
|
|
} else { |
|
|
|
|
|
return fmt::format("--:--:--"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shared_ptr<DisinfectionLogger> DisinfectionCtrlService::createCSVLogger(string log_file_name) { |
|
|
|
|
|
shared_ptr<DisinfectionLogger> logger = m_disinfectionLogsManager->createNewLogger(log_file_name); |
|
|
|
|
|
// ZIconv::utf8_to_gb2312(str)
|
|
|
|
|
|
|
|
|
|
|
|
// context.csvlogger->write(
|
|
|
|
|
|
// "Date," // 1
|
|
|
|
|
|
// "H2O20(ppm),Temp0(C),RH0(%RH),RS0(%RS)," // 2,3,4,5
|
|
|
|
|
|
// "H2O21(ppm),Temp1(C),RH1(%RH),RS1(%RS)," // 6,7,8,9
|
|
|
|
|
|
// "H2O22(ppm),Temp2(C),RH2(%RH),RS2(%RS)," // 10,11,12,13
|
|
|
|
|
|
// "Dvalue,Loglevel,Targetloglevel," // 14,15,16
|
|
|
|
|
|
// "Heating,Blower,Compressor,Pump(g/min)," // 17,18,19,20
|
|
|
|
|
|
// "Disinfectant Volume(g)," // 21,
|
|
|
|
|
|
// "Remaining time (s)\n" // 22
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
logger->write( |
|
|
|
|
|
fmt::format("{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{},{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{}", |
|
|
|
|
|
"\n", |
|
|
|
|
|
ZIconv::noChange("日期"), //
|
|
|
|
|
|
ZIconv::noChange("过氧化氢浓度(PPM)"), ZIconv::noChange("温度(C)"), ZIconv::noChange("相对湿度"), ZIconv::noChange("相对饱和度"), //
|
|
|
|
|
|
ZIconv::noChange("远端-过氧化氢浓度1(PPM)"), ZIconv::noChange("远端-温度1(C)"), ZIconv::noChange("远端-相对湿度1"), ZIconv::noChange("远端-相对饱和度1"), //
|
|
|
|
|
|
ZIconv::noChange("远端-过氧化氢浓度2(PPM)"), ZIconv::noChange("远端-温度2(C)"), ZIconv::noChange("远端-相对湿度2"), ZIconv::noChange("远端-相对饱和度2"), //
|
|
|
|
|
|
ZIconv::noChange("D值"), ZIconv::noChange("当前LOG"), ZIconv::noChange("目标LOG"), //
|
|
|
|
|
|
ZIconv::noChange("加热器电源"), ZIconv::noChange("风机电源"), ZIconv::noChange("空压机电源"), ZIconv::noChange("喷液泵(g/min)"), //
|
|
|
|
|
|
ZIconv::noChange("消毒剩余剂量(g)"), ZIconv::noChange("剩余时间(s)"))); |
|
|
|
|
|
return logger; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& context) { |
|
|
void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& context) { |
|
|
auto* sensors = &m_context.h2o2data.h2o2sensor_data[0]; |
|
|
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
|
|
float dvalue = 0; |
|
|
|
|
|
|
|
|
#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 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 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"; |
|
|
|
|
|
|
|
|
|
|
|
if (sat0 < 0) sat0_str = "N/A"; |
|
|
|
|
|
if (sat1 < 0) sat1_str = "N/A"; |
|
|
|
|
|
if (sat2 < 0) sat2_str = "N/A"; |
|
|
|
|
|
|
|
|
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
|
|
float dvalue = 0; |
|
|
if (m_context.dvalue <= 0) { |
|
|
if (m_context.dvalue <= 0) { |
|
|
dvalue = 0; |
|
|
dvalue = 0; |
|
|
} else { |
|
|
} else { |
|
@ -229,24 +297,74 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& con |
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
|
|
|
|
|
|
context.csvlogger->write( |
|
|
context.csvlogger->write( |
|
|
fmt::format("{}," //
|
|
|
|
|
|
"{},{},{},{}," //
|
|
|
|
|
|
// "{},{},{},{}," //
|
|
|
|
|
|
// "{},{},{},{}," //
|
|
|
|
|
|
"{},{},{}," //
|
|
|
|
|
|
"{},{},{},{}," //
|
|
|
|
|
|
// "{},{},{},{}," //
|
|
|
|
|
|
"{}," //
|
|
|
|
|
|
"{}\n" //
|
|
|
|
|
|
, |
|
|
|
|
|
getTime(), //
|
|
|
|
|
|
sensors[0].h2o2, sensors[0].temp, sensors[0].humid, sensors[0].saturation, //
|
|
|
|
|
|
// sensors[1].h2o2, sensors[1].temp, sensors[1].humid, sensors[1].saturation, //
|
|
|
|
|
|
// sensors[2].h2o2, sensors[2].temp, sensors[2].humid, sensors[2].saturation, //
|
|
|
|
|
|
|
|
|
fmt::format("{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{},{}," |
|
|
|
|
|
"{},{},{},{}," |
|
|
|
|
|
"{},{}", |
|
|
|
|
|
"\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, //
|
|
|
(int32_t)dvalue, (int32_t)m_context.m_nowLoglevel, (int32_t)m_context.m_targetLoglevel, //
|
|
|
(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(), //
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), //
|
|
|
|
|
|
formattimeS(remaintime))); |
|
|
|
|
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
|
|
|
#endif
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 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 sat0 = m_deviceIoControlService->H2O2Sensor_readSaturation(0); |
|
|
|
|
|
int sat1 = m_deviceIoControlService->H2O2Sensor_readSaturation(1); |
|
|
|
|
|
int sat2 = m_deviceIoControlService->H2O2Sensor_readSaturation(2); |
|
|
|
|
|
|
|
|
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
|
|
float dvalue = 0; |
|
|
|
|
|
if (m_context.dvalue <= 0) { |
|
|
|
|
|
dvalue = 0; |
|
|
|
|
|
} else { |
|
|
|
|
|
dvalue = m_context.dvalue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
|
|
|
|
|
|
|
|
|
context.csvlogger->write( |
|
|
|
|
|
fmt::format("{}," |
|
|
|
|
|
"s0({},{},{},{})," |
|
|
|
|
|
"s1({},{},{},{})," |
|
|
|
|
|
"s2({},{},{},{})," |
|
|
|
|
|
"s2({},{},{},{})," |
|
|
|
|
|
"min_h2o2:{},max_h2o2:{},max_hum:{},max_sa:{}," |
|
|
|
|
|
"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(), //
|
|
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
|
|
|
#endif
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::finishDisinfection(DisinfectionContext& context) { |
|
|
void DisinfectionCtrlService::finishDisinfection(DisinfectionContext& context) { |
|
@ -275,48 +393,17 @@ void DisinfectionCtrlService::processPreheatState(DisinfectionContext& context) |
|
|
// logger->info("preheat {}", context.m_disinfectionID);
|
|
|
// logger->info("preheat {}", context.m_disinfectionID);
|
|
|
if ((context.m_state == kpreheat && hasstarttime > m_context.pre_heat_time_s)) { |
|
|
if ((context.m_state == kpreheat && hasstarttime > m_context.pre_heat_time_s)) { |
|
|
logger->info("preheat finished {}", context.m_disinfectionID); |
|
|
logger->info("preheat finished {}", context.m_disinfectionID); |
|
|
// blower_setPower(true);
|
|
|
|
|
|
m_deviceIoControlService->airBlower_setState(true); |
|
|
m_deviceIoControlService->airBlower_setState(true); |
|
|
usleep(1000 * 1000); |
|
|
usleep(1000 * 1000); |
|
|
// airCompressor(true);
|
|
|
|
|
|
m_deviceIoControlService->airCompressor_setState(true); |
|
|
m_deviceIoControlService->airCompressor_setState(true); |
|
|
usleep(1000 * 1000); |
|
|
usleep(1000 * 1000); |
|
|
// sprayLiquidPump_open();
|
|
|
|
|
|
m_deviceIoControlService->sprayLiquidPump_open(context.injection_pump_speed); |
|
|
m_deviceIoControlService->sprayLiquidPump_open(context.injection_pump_speed); |
|
|
context.m_state = kdisinfection; |
|
|
context.m_state = kdisinfection; |
|
|
// context.m_preheatFlag = false;
|
|
|
|
|
|
// context.sprayLiquidFlag = true;
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
logger->info("{}: preheat {}", context.m_disinfectionID, m_context.pre_heat_time_s - hasstarttime); |
|
|
logger->info("{}: preheat {}", context.m_disinfectionID, m_context.pre_heat_time_s - hasstarttime); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::dumpDisinfectionLogs(DisinfectionContext& context) { |
|
|
|
|
|
// float h2o2_g = m_deviceIoControlService->getDisinfectantVolume_g();
|
|
|
|
|
|
auto* sensors = &m_context.h2o2data.h2o2sensor_data[0]; |
|
|
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
|
|
logger->info( |
|
|
|
|
|
"T:{}," //
|
|
|
|
|
|
"s1:({},{},{},{})," //
|
|
|
|
|
|
"s2:({},{},{},{})," //
|
|
|
|
|
|
"s3:({},{},{},{})," //
|
|
|
|
|
|
"D:{},log:({}:{})," //
|
|
|
|
|
|
"io:({},{},{},{})," //
|
|
|
|
|
|
"p:({},{},{},{})," //
|
|
|
|
|
|
"h2o2g:{}," //
|
|
|
|
|
|
"rt:{}" //
|
|
|
|
|
|
, |
|
|
|
|
|
zsteady_clock().elapsedTimeS(m_context.m_starttp), //
|
|
|
|
|
|
sensors[0].h2o2, sensors[0].temp, sensors[0].humid, sensors[0].saturation, //
|
|
|
|
|
|
sensors[1].h2o2, sensors[1].temp, sensors[1].humid, sensors[1].saturation, //
|
|
|
|
|
|
sensors[2].h2o2, sensors[2].temp, sensors[2].humid, sensors[2].saturation, //
|
|
|
|
|
|
m_context.dvalue, m_context.m_nowLoglevel, (int)m_context.m_targetLoglevel, //
|
|
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getRPM(), //
|
|
|
|
|
|
ds->getPressureSensorData(1), ds->getPressureSensorData(2), ds->getPressureSensorData(3), ds->getPressureSensorData(4), //
|
|
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), //
|
|
|
|
|
|
getEstimatedRemainingTimeS()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* @brief |
|
|
* @brief |
|
|
* 消毒中状态处理 |
|
|
* 消毒中状态处理 |
|
@ -335,9 +422,9 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
/**
|
|
|
/**
|
|
|
* @brief 检查当前 |
|
|
* @brief 检查当前 |
|
|
*/ |
|
|
*/ |
|
|
float nowSatur = m_context.h2o2data.max_saturation; |
|
|
|
|
|
float nowh2o2 = m_context.h2o2data.max_h2o2; |
|
|
|
|
|
float humid = m_context.h2o2data.max_humid; |
|
|
|
|
|
|
|
|
float nowSatur = m_context.sensor_stat.max_saturation; |
|
|
|
|
|
float nowh2o2 = m_context.sensor_stat.max_h2o2; |
|
|
|
|
|
float humid = m_context.sensor_stat.max_humid; |
|
|
|
|
|
|
|
|
if (m_context.injection_pump_speed_changed) { |
|
|
if (m_context.injection_pump_speed_changed) { |
|
|
m_deviceIoControlService->sprayLiquidPump_open(context.injection_pump_speed); |
|
|
m_deviceIoControlService->sprayLiquidPump_open(context.injection_pump_speed); |
|
@ -356,9 +443,9 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
m_context.m_state = kdisinfection_take_a_break; |
|
|
m_context.m_state = kdisinfection_take_a_break; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
float nowSatur = m_context.h2o2data.max_saturation; |
|
|
|
|
|
float nowh2o2 = m_context.h2o2data.max_h2o2; |
|
|
|
|
|
float humid = m_context.h2o2data.max_humid; |
|
|
|
|
|
|
|
|
float nowSatur = m_context.sensor_stat.max_saturation; |
|
|
|
|
|
float nowh2o2 = m_context.sensor_stat.max_h2o2; |
|
|
|
|
|
float humid = m_context.sensor_stat.max_humid; |
|
|
|
|
|
|
|
|
// && humid < m_context.continued_satur
|
|
|
// && humid < m_context.continued_satur
|
|
|
if (nowSatur < m_context.continued_satur && nowh2o2 < m_context.continued_gs && humid < context.continued_humi) { |
|
|
if (nowSatur < m_context.continued_satur && nowh2o2 < m_context.continued_gs && humid < context.continued_humi) { |
|
@ -383,11 +470,11 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
/**
|
|
|
/**
|
|
|
* @brief 更新传感器信息 |
|
|
* @brief 更新传感器信息 |
|
|
*/ |
|
|
*/ |
|
|
m_deviceIoControlService->getAllSensorData(m_context.h2o2data); |
|
|
|
|
|
|
|
|
m_context.sensor_stat = m_deviceIoControlService->H2O2Sensor_getStatisticsResult(); |
|
|
/**
|
|
|
/**
|
|
|
* @brief 计算D值 |
|
|
* @brief 计算D值 |
|
|
*/ |
|
|
*/ |
|
|
m_context.dvalue = getDisinfectionDValue(m_context.h2o2data.min_h2o2); |
|
|
|
|
|
|
|
|
m_context.dvalue = getDisinfectionDValue(m_context.sensor_stat.min_h2o2); |
|
|
|
|
|
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastComputeDvalueTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastComputeDvalueTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
m_context.m_lastComputeDvalueTp = zsteady_clock().now(); |
|
|
m_context.m_lastComputeDvalueTp = zsteady_clock().now(); |
|
@ -426,8 +513,8 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
/**
|
|
|
/**
|
|
|
* @brief 等待h2o2浓度下降 |
|
|
* @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("waitting for h2o2 concentration to safe value {}=>{}", m_context.sensor_stat.min_h2o2, 1); |
|
|
|
|
|
if (m_context.sensor_stat.min_h2o2 < 1) { |
|
|
logger->info("h2o2 concentration to safe value"); |
|
|
logger->info("h2o2 concentration to safe value"); |
|
|
breakflag = true; |
|
|
breakflag = true; |
|
|
forcelog = true; |
|
|
forcelog = true; |
|
@ -439,8 +526,8 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
|
|
|
|
|
if (forcelog || zsteady_clock().elapsedTimeS(m_context.m_lastlogTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
if (forcelog || zsteady_clock().elapsedTimeS(m_context.m_lastlogTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
m_context.m_lastlogTp = zsteady_clock().now(); |
|
|
m_context.m_lastlogTp = zsteady_clock().now(); |
|
|
dumpDisinfectionLogs(m_context); |
|
|
|
|
|
dumpDisinfectionLogsToCSV(m_context); |
|
|
dumpDisinfectionLogsToCSV(m_context); |
|
|
|
|
|
log(m_context); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -463,8 +550,7 @@ void DisinfectionCtrlService::changeDisinfectionParameter(int injection_pump_spe |
|
|
m_context.continued_humi = continued_humi; |
|
|
m_context.continued_humi = continued_humi; |
|
|
m_context.injection_pump_speed_changed = true; |
|
|
m_context.injection_pump_speed_changed = true; |
|
|
|
|
|
|
|
|
logger->info("changeDisinfectionParameter {} {} {} {} {} {} {}", injection_pump_speed, stoped_gs, continued_gs, stoped_satur, continued_satur, stoped_humi, |
|
|
|
|
|
continued_humi); |
|
|
|
|
|
|
|
|
logger->info("changeDisinfectionParameter {} {} {} {} {} {} {}", injection_pump_speed, stoped_gs, continued_gs, stoped_satur, continued_satur, stoped_humi, continued_humi); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DisinfectionCtrlService::startDisinfection(int loglevel, //
|
|
|
void DisinfectionCtrlService::startDisinfection(int loglevel, //
|
|
|