|
|
@ -48,6 +48,18 @@ void DisinfectionCtrlService::initialize() { |
|
|
|
m_deviceIoControlService->airCompressor_setState(false); |
|
|
|
} |
|
|
|
|
|
|
|
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() { |
|
|
|
struct tm tm = {0}; |
|
|
|
|
|
|
@ -126,6 +138,7 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context, int logl |
|
|
|
context.m_loglevel = loglevel; |
|
|
|
context.m_roomvol = roomVol; |
|
|
|
m_context.m_preheatFlag = true; |
|
|
|
m_context.dvalue = 0; |
|
|
|
|
|
|
|
context.stoped_gs = m_dbService->getSettingVal("stoped_gs"); |
|
|
|
context.continued_gs = m_dbService->getSettingVal("continued_gs"); |
|
|
@ -241,7 +254,7 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& con |
|
|
|
"{}," //
|
|
|
|
"{}\n" //
|
|
|
|
, |
|
|
|
zsteady_clock().elapsedTimeS(m_context.m_starttp), //
|
|
|
|
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, //
|
|
|
@ -311,7 +324,7 @@ void DisinfectionCtrlService::processDisinfectionState(DisinfectionContext& cont |
|
|
|
* @brief 周期性计算剩余时间 |
|
|
|
*/ |
|
|
|
computeRemainTime(m_context); |
|
|
|
dumpDisinfectionLogsToCSV(m_context); |
|
|
|
// dumpDisinfectionLogsToCSV(m_context);
|
|
|
|
} |
|
|
|
|
|
|
|
dumpDisinfectionLogs(m_context); |
|
|
@ -372,6 +385,7 @@ void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
|
while (!thisThread.getExitFlag()) { |
|
|
|
thisThread.sleepForMs(1000); |
|
|
|
// logger->info("disinfection running {} {}s preheatFlag:{}", m_context.m_disinfectionID, m_context.m_remaintime, m_context.m_preheatFlag);
|
|
|
|
m_deviceIoControlService->getAllSensorData(m_context.h2o2data); |
|
|
|
|
|
|
|
if (m_context.m_preheatFlag) { |
|
|
|
processPreheatState(m_context); |
|
|
@ -379,6 +393,11 @@ void DisinfectionCtrlService::startDisinfection(int loglevel, float roomVol) { |
|
|
|
processDisinfectionState(m_context); |
|
|
|
} |
|
|
|
|
|
|
|
if (zsteady_clock().elapsedTimeS(m_context.m_lastlogTp) > DVALUE_COMPUTEPERIOD_TIME_S) { |
|
|
|
m_context.m_lastlogTp = zsteady_clock().now(); |
|
|
|
dumpDisinfectionLogsToCSV(m_context); |
|
|
|
} |
|
|
|
|
|
|
|
m_context.m_remaintime--; |
|
|
|
if (m_context.m_remaintime == 0) { |
|
|
|
logger->info("disinfection finished {}", m_context.m_disinfectionID); |
|
|
|