|
|
@ -104,101 +104,114 @@ static bool zfeq(float a, float b, float eps = 0.01) { |
|
|
|
shared_ptr<DisinfectionLogger> DisinfectionService::createCSVLogger(string log_file_name) { |
|
|
|
shared_ptr<DisinfectionLogger> _logger = m_disinfectionLogsManager->createNewLogger(log_file_name); |
|
|
|
|
|
|
|
_logger->write( |
|
|
|
fmt::format("{}," |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
return _logger; |
|
|
|
} |
|
|
|
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#else
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#endif
|
|
|
|
" {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {}" |
|
|
|
"\n", |
|
|
|
ZIconv::noChange("时间"), |
|
|
|
void DisinfectionService::__dumpDisinfectionLogsToCSV(bool header) { |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度"), //
|
|
|
|
ZIconv::noChange("环境1-气化过氧化氢浓度"), ZIconv::noChange("环境1-温度"), ZIconv::noChange("环境1-相对湿度"), ZIconv::noChange("环境1-相对饱和度"), //
|
|
|
|
ZIconv::noChange("环境2-气化过氧化氢浓度"), ZIconv::noChange("环境2-温度"), ZIconv::noChange("环境2-相对湿度"), ZIconv::noChange("环境2-相对饱和度"), //
|
|
|
|
#else
|
|
|
|
ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度"), //
|
|
|
|
|
|
|
|
static_assert(MAX_H2O2_SENSOR_NUM == 3, "MAX_H2O2_SENSOR_NUM must be 3"); |
|
|
|
#endif
|
|
|
|
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; |
|
|
|
} |
|
|
|
if (!context.csvlogger) return; |
|
|
|
|
|
|
|
void DisinfectionService::logstate() { |
|
|
|
auto& cx = context; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
if (context.dvalue <= 0) { |
|
|
|
dvalue = 0; |
|
|
|
} else { |
|
|
|
dvalue = context.dvalue; |
|
|
|
} |
|
|
|
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]; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
int remaintime = 0; |
|
|
|
|
|
|
|
if (!header) { |
|
|
|
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]); |
|
|
|
} |
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
|
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"; |
|
|
|
} |
|
|
|
|
|
|
|
logger->info( |
|
|
|
fmt::format("{}," |
|
|
|
if (context.dvalue <= 0) { |
|
|
|
dvalue = 0; |
|
|
|
} else { |
|
|
|
dvalue = context.dvalue; |
|
|
|
} |
|
|
|
|
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
"s0({},{},{},{})," |
|
|
|
"s1({},{},{},{})," |
|
|
|
"s2({},{},{},{})," |
|
|
|
#else
|
|
|
|
"s2({},{},{},{})," |
|
|
|
remaintime = getEstimatedRemainingTimeS(); |
|
|
|
} |
|
|
|
|
|
|
|
string content; |
|
|
|
|
|
|
|
if (header) { |
|
|
|
content += fmt::format("{},", ZIconv::noChange("时间")); |
|
|
|
} else { |
|
|
|
content += fmt::format("{}", getTime()); |
|
|
|
} |
|
|
|
|
|
|
|
#endif
|
|
|
|
"min_h2o2:{},max_h2o2:{},max_hum:{},max_sa:{}," |
|
|
|
"dv:{},log:{},tlog:{}," |
|
|
|
"h:{},airB:{},airC:{},pump:{}," |
|
|
|
"g:{},remainS:{}", |
|
|
|
getTime(), //
|
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
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], //
|
|
|
|
if (header) { |
|
|
|
content += fmt::format(" {} , {} , {} , {} ,", ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度")); |
|
|
|
content += fmt::format(" {} , {} , {} , {} ,", ZIconv::noChange("环境1-气化过氧化氢浓度"), ZIconv::noChange("环境1-温度"), ZIconv::noChange("环境1-相对湿度"), ZIconv::noChange("环境1-相对饱和度")); |
|
|
|
content += fmt::format(" {} , {} , {} , {} ,", ZIconv::noChange("环境2-气化过氧化氢浓度"), ZIconv::noChange("环境2-温度"), ZIconv::noChange("环境2-相对湿度"), ZIconv::noChange("环境2-相对饱和度")); |
|
|
|
} else { |
|
|
|
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) { |
|
|
|
content += fmt::format(" {} , {} , {} , {} ,", h2o2str[i], tempstr[i], humidstr[i], satstr[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
#else
|
|
|
|
cx.h2o2[0], cx.temp[0], cx.humid[0], cx.saturation[0], //
|
|
|
|
if (header) { |
|
|
|
content += fmt::format(" {} , {} , {} ,", ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度")); |
|
|
|
} else { |
|
|
|
content += fmt::format(" {} , {} , {} ,", h2o2str[0], tempstr[0], humidstr[0]); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
context.min_h2o2, context.max_h2o2, context.max_humid, context.max_saturation, //
|
|
|
|
(int32_t)dvalue, context.now_loglevel, (int32_t)cfg.targetLoglevel, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::dumpDisinfectionLogsToCSV() { |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
static_assert(MAX_H2O2_SENSOR_NUM == 3, "MAX_H2O2_SENSOR_NUM must be 3"); |
|
|
|
#endif
|
|
|
|
if (header) { |
|
|
|
content += fmt::format(" {} , {} , {} ,", ZIconv::noChange("D值"), ZIconv::noChange("当前LOG"), ZIconv::noChange("目标LOG")); |
|
|
|
} else { |
|
|
|
content += fmt::format(" {} , {} , {} ,", (int32_t)dvalue, (int32_t)context.now_loglevel, (int32_t)cfg.targetLoglevel); |
|
|
|
} |
|
|
|
|
|
|
|
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]; |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
|
|
|
|
if (header) { |
|
|
|
content += fmt::format(" {} ,", ZIconv::noChange("喷液泵(g/min)")); |
|
|
|
} else { |
|
|
|
content += fmt::format(" {} ,", ds->sprayLiquidPump_getGPM()); |
|
|
|
} |
|
|
|
|
|
|
|
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 (header) { |
|
|
|
content += fmt::format(" {} ,", ZIconv::noChange("消毒剂剩余量(g)")); |
|
|
|
} else { |
|
|
|
content += fmt::format(" {} ,", m_deviceIoControlService->getDisinfectantVolume_g()); |
|
|
|
} |
|
|
|
|
|
|
|
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"; |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
if (header) { |
|
|
|
content += fmt::format(" {} ,", ZIconv::noChange("喷液泵(g/min)")); |
|
|
|
} else { |
|
|
|
content += fmt::format(" {} ,", ds->DBDB__sprayLiquidPump_readSpeed()); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
if (header) { |
|
|
|
content += fmt::format(" {}\n", ZIconv::noChange("预计剩余时间")); |
|
|
|
} else { |
|
|
|
content += fmt::format(" {}\n", formattimeS(remaintime)); |
|
|
|
} |
|
|
|
|
|
|
|
context.csvlogger->write(content); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::dumpDisinfectionLogsToCSV() { __dumpDisinfectionLogsToCSV(false); } |
|
|
|
|
|
|
|
void DisinfectionService::logstate() { |
|
|
|
auto& cx = context; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
if (context.dvalue <= 0) { |
|
|
@ -208,33 +221,25 @@ void DisinfectionService::dumpDisinfectionLogsToCSV() { |
|
|
|
} |
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
|
if (context.csvlogger) |
|
|
|
context.csvlogger->write( |
|
|
|
fmt::format(" {} ," |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#else
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#endif
|
|
|
|
" {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} " |
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
|
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
h2o2str[0], tempstr[0], humidstr[0], satstr[0], //
|
|
|
|
h2o2str[1], tempstr[1], humidstr[1], satstr[1], //
|
|
|
|
h2o2str[2], tempstr[2], humidstr[2], satstr[2], //
|
|
|
|
#else
|
|
|
|
h2o2str[0], tempstr[0], humidstr[0], satstr[0], //
|
|
|
|
string logval; |
|
|
|
logval += fmt::format("{},", getTime()); |
|
|
|
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) { |
|
|
|
logval += fmt::format("s{}({},{},{},{}) ,", i, cx.h2o2[i], cx.temp[i], cx.humid[i], cx.saturation[i]); |
|
|
|
} |
|
|
|
logval += fmt::format("min_h2o2:{},max_h2o2:{},max_hum:{},max_sa:{},", context.min_h2o2, context.max_h2o2, context.max_humid, context.max_saturation); |
|
|
|
logval += fmt::format("dv:{},log:{},tlog:{},", (int32_t)dvalue, context.now_loglevel, (int32_t)cfg.targetLoglevel); |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
|
|
|
|
logval += fmt::format("h:{},airB:{},airC:{},pump:{},", ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM()); |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
logval += fmt::format("pump:{},", ds->DBDB__sprayLiquidPump_readSpeed()); |
|
|
|
#endif
|
|
|
|
|
|
|
|
(int32_t)dvalue, (int32_t)context.now_loglevel, (int32_t)cfg.targetLoglevel, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime))); |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
|
|
|
|
logval += fmt::format("g:{},remainS:{}", m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime)); |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
logval += fmt::format("remainS:{}", formattimeS(remaintime)); |
|
|
|
#endif
|
|
|
|
logger->info(logval); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::pushDisinfectionPrinterTask() { //
|
|
|
@ -420,7 +425,8 @@ void DisinfectionService::initState() { |
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
context.csvlogger = createCSVLogger(context.id); |
|
|
|
context.csvlogger = createCSVLogger(context.id); |
|
|
|
__dumpDisinfectionLogsToCSV(true); |
|
|
|
m_disinfectionWorkState = 1; |
|
|
|
} |
|
|
|
|
|
|
|