|
|
@ -118,6 +118,16 @@ float DisinfectionCtrlService::getDisinfectionDValue(float ppm) { |
|
|
|
} |
|
|
|
return dvalue; |
|
|
|
} |
|
|
|
float DisinfectionCtrlService::computeNowLogLevel(DisinfectionContext& context) { |
|
|
|
float dvalue = context.dvalue; |
|
|
|
if (dvalue > 0) { |
|
|
|
/**
|
|
|
|
* @brief 计算 m_nowLoglevel |
|
|
|
*/ |
|
|
|
return context.m_nowLoglevel + DVALUE_COMPUTEPERIOD_TIME_S / (dvalue * 60); |
|
|
|
} |
|
|
|
return context.m_nowLoglevel; |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
|
/**
|
|
|
@ -129,7 +139,6 @@ void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) { |
|
|
|
/**
|
|
|
|
* @brief 计算 m_nowLoglevel |
|
|
|
*/ |
|
|
|
context.m_nowLoglevel += DVALUE_COMPUTEPERIOD_TIME_S / (dvalue * 60); |
|
|
|
if (context.m_targetLoglevel >= context.m_nowLoglevel) { |
|
|
|
context.m_remaintime = (context.m_targetLoglevel - context.m_nowLoglevel) * (dvalue * 60); |
|
|
|
} else { |
|
|
@ -201,20 +210,26 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, |
|
|
|
// m_context.m_remaintime
|
|
|
|
|
|
|
|
context.csvlogger->write( |
|
|
|
"date," //
|
|
|
|
"hydrogen_peroxide_volume(ppm),temperature(C),relative_humidity(%RH),h2o_h2o2_rs(%RS)," //
|
|
|
|
"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)," //
|
|
|
|
"disinfectantVolume(g)," //
|
|
|
|
"remaintime(s)\n" //
|
|
|
|
"Dvalue,Loglevel,Targetloglevel," //
|
|
|
|
"Heating,Blower,Compressor,Pump(g/min)," //
|
|
|
|
"Disinfectant Volume(g)," //
|
|
|
|
"Remaining time (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; |
|
|
|
float dvalue = 0; |
|
|
|
if (m_context.dvalue <= 0) { |
|
|
|
dvalue = 0; |
|
|
|
} else { |
|
|
|
dvalue = m_context.dvalue; |
|
|
|
} |
|
|
|
context.csvlogger->write( |
|
|
|
fmt::format("{}," //
|
|
|
|
"{},{},{},{}," //
|
|
|
@ -230,7 +245,7 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionCon |
|
|
|
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, m_context.m_targetLoglevel, //
|
|
|
|
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(), //
|
|
|
|
formattimeS(m_context.m_remaintime))); |
|
|
@ -378,8 +393,12 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { |
|
|
|
|
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastComputeDvalueTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.m_lastComputeDvalueTp = zsteady_clock().now(); |
|
|
|
//
|
|
|
|
if (m_context.m_state == kdisinfection || m_context.m_state == kdisinfection_take_a_break) { |
|
|
|
m_context.m_nowLoglevel = computeNowLogLevel(m_context); |
|
|
|
computeRemainTime(m_context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (m_context.m_state == kpreheat) { |
|
|
|
/**
|
|
|
|