From f7d49270537a4b62f69e2905ab0e4cf37c3302ab Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 10 Sep 2023 20:24:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B6=88=E6=AF=92=E5=89=A9?= =?UTF-8?q?=E4=BD=99=E6=97=B6=E9=97=B4=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/disinfection_ctl_service.cpp | 55 ++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/src/service/disinfection_ctl_service.cpp b/src/service/disinfection_ctl_service.cpp index 6c4fa2f..67516cc 100644 --- a/src/service/disinfection_ctl_service.cpp +++ b/src/service/disinfection_ctl_service.cpp @@ -226,8 +226,14 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, "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) { +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("--:--:--"); + } +} +void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& context) { auto* sensors = &m_context.h2o2data.h2o2sensor_data[0]; auto ds = m_deviceIoControlService; float dvalue = 0; @@ -236,25 +242,28 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionCon } else { dvalue = m_context.dvalue; } + + int remaintime = getEstimatedRemainingTimeS(); + context.csvlogger->write( fmt::format("{}," // - "{},{},{},{}," // - // "{},{},{},{}," // - // "{},{},{},{}," // - "{:.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, // - 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))); + "{},{},{},{}," // + // "{},{},{},{}," // + // "{},{},{},{}," // + "{:.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, // + 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(remaintime))); } void DisinfectionCtrlService::finishDisinfection(DisinfectionContext& context) { @@ -322,7 +331,7 @@ void DisinfectionCtrlService::dumpDisinfectionLogs(DisinfectionContext& context) 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); + getEstimatedRemainingTimeS()); } /** @@ -530,7 +539,11 @@ int32_t DisinfectionCtrlService::getEstimatedRemainingTimeS() { if (m_context.m_state == kpreheat) { return getPreHeatRaminTimeS(); } else if (m_context.m_state == kdisinfection || m_context.m_state == kdisinfection_take_a_break) { - return m_context.m_remaintime; + if (m_context.dvalue > 0) { + return m_context.m_remaintime; + } else { + return -1; + } } else { return 0; }