From b6a00f1d0d4fe7e86106b79df3f8961b3af4bc0c Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 18 Aug 2024 21:36:04 +0800 Subject: [PATCH] update --- README.md | 2 ++ .../disinfection_ctrl_service.cpp | 26 +++++++++++++++++++--- .../disinfection_ctrl_service.hpp | 1 - appsrc/service/disinfection_logs_service.hpp | 6 ++--- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 24b1a8c..fc0e059 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ TODO: 8. 添加一个程序根据全局异常标志位,对设备进行相应的检查,如果检查通过则清空标志位。同时如果发生异常,则发送板子复位指令,对板子进行复位。 整理错误码,为所有错误吗添加中文示意 +消毒过程中检测水禁传感器, + ... 5. 单片机支持自动过滤掉重发的指令。 diff --git a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp index 18a7a7b..8576a95 100644 --- a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp +++ b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp @@ -254,7 +254,19 @@ void DisinfectionCtrlService::tryLogState(bool forceLog) { } } -void DisinfectionCtrlService::logState() {} +void DisinfectionCtrlService::logState() { + shared_ptr snapshot = make_shared(); + snapshot->state = sm.getState(); + snapshot->time = zsystem_clock().now(); + snapshot->dval = s_dvalue; + snapshot->nlog = s_nlog; + snapshot->tlog = m_tlog; + snapshot->remainTime = s_remaintime; + snapshot->remainDisinfectant = dwus->getWeight(); + snapshot->h2o2Snapshot = s_h2o2Snapshot; + + AppEventBus::ins()->push(make_shared(snapshot)); +} void DisinfectionCtrlService::traceState() { string tracecontent; @@ -270,7 +282,6 @@ void DisinfectionCtrlService::traceState() { /******************************************************************************* * StateMachine * *******************************************************************************/ -void DisinfectionCtrlService::initState() {} void DisinfectionCtrlService::beforeStateProcess() { s_h2o2Snapshot = dics->getH2O2SensorMgr()->takeSnapshot(); } @@ -373,7 +384,7 @@ void DisinfectionCtrlService::processStateInit(DisinfectionEvent* event) { */ s_sessionId = createDisinfectionID(); - s_remaintime = m_tlog * 60 * 60; // 计算总的加热时间 + s_remaintime = -1; s_nlog = 0; s_dvalue = 0; s_start_tp = zsystem_clock().now(); @@ -397,6 +408,7 @@ void DisinfectionCtrlService::processStateDehumidificationBeforeDisinfection(Dis dics->Blower_ctrl(DEFAULT_BLOWSER_LEVEL); usleep(100 * 1000); dics->ExtChSelector_trySelectCh(kext_ch_dehumidification); + s_remaintime = -1; } // else if (event->event == kevent_exit_state) { @@ -429,6 +441,7 @@ void DisinfectionCtrlService::processStatePreheat(DisinfectionEvent* event) { dics->Blower_ctrl(90); usleep(1000 * 1000); dics->Heater_ctrl(100); + s_remaintime = getSettingAsInt(SettingId::pre_heat_time_s); } else if (event->event == kevent_exit_state) { logger->info("preheat state exit"); @@ -440,6 +453,10 @@ void DisinfectionCtrlService::processStatePreheat(DisinfectionEvent* event) { tryLogState(true); } else if (event->event == kevent_tmr_1s) { int preHeatTimeS = getSettingAsInt(SettingId::pre_heat_time_s); + s_remaintime--; + if (s_remaintime <= 0) { + s_remaintime = 0; + } if (sm.getStateHasPassedTimeMs() > preHeatTimeS * 1000) { // 退出预热状态,进入消毒状态 @@ -535,6 +552,7 @@ void DisinfectionCtrlService::processStateEmpytLiquidFromTheLine(DisinfectionEve if (event->event == kevent_enter_state) { tryLogState(true); dics->SprayPump_startInRPM(-PORT.getSprayLiquidPumpMaxRPM()); + s_remaintime = -1; } else if (event->event == kevent_exit_state) { tryLogState(true); @@ -550,6 +568,7 @@ void DisinfectionCtrlService::processStateDehumidificationAfterDisinfection(Disi tryLogState(true); dics->Blower_ctrl(DEFAULT_BLOWSER_LEVEL); dics->ExtChSelector_trySelectCh(kext_ch_dehumidification); + s_remaintime = -1; } else if (event->event == kevent_exit_state) { dics->Blower_close(); dics->ExtChSelector_trySelectCh(kext_ch_disinfection); @@ -580,6 +599,7 @@ void DisinfectionCtrlService::processStateDegradation(DisinfectionEvent* event) tryLogState(true); dics->ExtChSelector_trySelectCh(kext_ch_degradation); dics->Blower_ctrl(DEFAULT_BLOWSER_LEVEL); + s_remaintime = -1; } else if (event->event == kevent_exit_state) { dics->Blower_close(); dics->ExtChSelector_trySelectCh(kext_ch_disinfection); diff --git a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp index c49d5b7..87bba55 100644 --- a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp +++ b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp @@ -110,7 +110,6 @@ class DisinfectionCtrlService : public enable_shared_from_this { THISCLASS(DisinfectionLogsService); @@ -27,7 +24,7 @@ class DisinfectionLogsService : public enable_shared_from_this m_gConfig; shared_ptr m_udiskMgrService; - string m_sessionId; + string m_sessionId; list> m_snapshots; ZDictionary m_csvHeaderDict; @@ -37,6 +34,7 @@ class DisinfectionLogsService : public enable_shared_from_this snapshot); void finishDisinfectionSession();