|
|
@ -81,6 +81,12 @@ string DisinfectionCtrlService::createDisinfectionID() { |
|
|
|
tm.tm_hour, //
|
|
|
|
tm.tm_min, tm.tm_sec); |
|
|
|
} |
|
|
|
static bool zfeq(float a, float b, float eps = 0.01) { |
|
|
|
if (fabs(a - b) < eps) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
float DisinfectionCtrlService::getDisinfectionDValue(float ppm) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
@ -91,6 +97,10 @@ float DisinfectionCtrlService::getDisinfectionDValue(float ppm) { |
|
|
|
* 浓度大于150时,y=-0.1405X+40.369 |
|
|
|
*/ |
|
|
|
|
|
|
|
if (zfeq(ppm, 0)) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
float dvalue = 0; |
|
|
|
|
|
|
|
if (ppm < 150) { |
|
|
@ -115,6 +125,7 @@ void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
|
*/ |
|
|
|
float dvalue = context.dvalue; |
|
|
|
|
|
|
|
if (dvalue > 0) { |
|
|
|
/**
|
|
|
|
* @brief 计算 m_nowLoglevel |
|
|
|
*/ |
|
|
@ -124,6 +135,10 @@ void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
|
} else { |
|
|
|
context.m_remaintime = 0; |
|
|
|
} |
|
|
|
} else { |
|
|
|
//
|
|
|
|
} |
|
|
|
|
|
|
|
logger->info("computeRemainTime minh2o2 {} dvalue {}", context.h2o2data.min_h2o2, dvalue); |
|
|
|
} |
|
|
|
|
|
|
@ -187,16 +202,16 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, |
|
|
|
|
|
|
|
context.csvlogger->write( |
|
|
|
"date," //
|
|
|
|
"hydrogen_peroxide_volume[1],temperature[1],relative_humidity[1],h2o_h2o2_rs[1]," //
|
|
|
|
"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," //
|
|
|
|
// "disinfectantVolume," //
|
|
|
|
"remaintime\n" //
|
|
|
|
"heating,blower,compressor,pump(g/min)," //
|
|
|
|
"disinfectantVolume(g)," //
|
|
|
|
"remaintime(s)\n" //
|
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
static string formattimeS(int sec) { return fmt::format("{:0>2}:{:0>2}:{:0>2}", sec / 3600, sec % 3600 / 60, sec % 60); } |
|
|
|
void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& context) { |
|
|
|
auto* sensors = &m_context.h2o2data.h2o2sensor_data[0]; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
@ -205,20 +220,20 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& con |
|
|
|
"{},{},{},{}," //
|
|
|
|
// "{},{},{},{}," //
|
|
|
|
// "{},{},{},{}," //
|
|
|
|
"{},{},{}," //
|
|
|
|
"{:.2f},{:.2f},{:.2f}," //
|
|
|
|
"{},{},{},{}," //
|
|
|
|
// "{},{},{},{}," //
|
|
|
|
// "{}," //
|
|
|
|
"{}," //
|
|
|
|
"{}\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, //
|
|
|
|
m_context.dvalue, m_context.m_nowLoglevel, (int)m_context.m_targetLoglevel, //
|
|
|
|
m_context.dvalue, m_context.m_nowLoglevel, m_context.m_targetLoglevel, //
|
|
|
|
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
|
|
|
|
// m_deviceIoControlService->getDisinfectantVolume_g(), //
|
|
|
|
m_context.m_remaintime)); |
|
|
|
m_deviceIoControlService->getDisinfectantVolume_g(), //
|
|
|
|
formattimeS(m_context.m_remaintime))); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::finishDisinfection(DisinfectionContext& context) { |
|
|
@ -299,10 +314,7 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
|
/**
|
|
|
|
* @brief 周期性计算剩余时间 |
|
|
|
*/ |
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastComputeDvalueTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.m_lastComputeDvalueTp = zsteady_clock().now(); |
|
|
|
computeRemainTime(m_context); |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 根据湿度启停喷雾 |
|
|
|
*/ |
|
|
@ -364,6 +376,11 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
*/ |
|
|
|
m_context.dvalue = getDisinfectionDValue(m_context.h2o2data.min_h2o2); |
|
|
|
|
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastComputeDvalueTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.m_lastComputeDvalueTp = zsteady_clock().now(); |
|
|
|
computeRemainTime(m_context); |
|
|
|
} |
|
|
|
|
|
|
|
if (m_context.m_state == kpreheat) { |
|
|
|
/**
|
|
|
|
* @brief 预热中 |
|
|
|