From 942656f257940ba6608d181924f17efa459a3627 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 27 May 2024 12:32:30 +0800 Subject: [PATCH] v8.0 --- README.md | 2 + iflytoplinuxsdk | 2 +- .../disfection_ctl/disinfection_service.cpp | 523 +++++++-------------- .../disfection_ctl/disinfection_service.hpp | 36 +- .../disfection_ctl/disinfection_service_config.hpp | 53 +++ .../disfection_ctl/disinfection_service_port.cpp | 245 ++++++++++ .../disfection_ctl/disinfection_service_port.hpp | 85 ++++ src/service/light_ctrl_service.hpp | 1 - src/version.hpp | 2 +- 9 files changed, 566 insertions(+), 383 deletions(-) create mode 100644 src/service/disfection_ctl/disinfection_service_config.hpp create mode 100644 src/service/disfection_ctl/disinfection_service_port.cpp create mode 100644 src/service/disfection_ctl/disinfection_service_port.hpp diff --git a/README.md b/README.md index 6a59655..fddc520 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ 调整默认风压 V6.5 修改H2O2浓度错误的BUG + V8.0 + 重构部分代码,改善打印出来的日志效果。 ``` diff --git a/iflytoplinuxsdk b/iflytoplinuxsdk index efa46c4..bdfc324 160000 --- a/iflytoplinuxsdk +++ b/iflytoplinuxsdk @@ -1 +1 @@ -Subproject commit efa46c4c7dc2c30b0951ddff97de9473e2db00e5 +Subproject commit bdfc3246092f426a9b86f2a3fbf04dca4854ea3f diff --git a/src/service/disfection_ctl/disinfection_service.cpp b/src/service/disfection_ctl/disinfection_service.cpp index e85d854..f2231b2 100644 --- a/src/service/disfection_ctl/disinfection_service.cpp +++ b/src/service/disfection_ctl/disinfection_service.cpp @@ -26,6 +26,11 @@ void DisinfectionService::initialize() { GET_TO_SERVICE(m_dbService); GET_TO_SERVICE(m_disinfectionLogsManager); GET_TO_SERVICE(m_disinfectionPrinterService); + GET_TO_SERVICE(m_lightCtrlService); + + m_disinfectionServicePort.reset(new DisinfectionServicePort()); + m_disinfectionServicePort->initialize(&cfg); + m_dvalueComputer.initialize(); m_deviceIoControlService->sprayLiquidPump_close(); @@ -80,7 +85,7 @@ 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("--:--:--"); + return fmt::format("N/A"); } } @@ -156,6 +161,30 @@ void DisinfectionService::__dumpDisinfectionLogsToCSV(bool header) { content += fmt::format("{},", getTime()); } + if (header) { + content += fmt::format("{},", ZIconv::noChange("设备状态")); + } else { + if (sm.getState() == kstate_idle) { + content += fmt::format("{},", ZIconv::noChange("空闲")); + } else if (sm.getState() == kstate_preheat) { + content += fmt::format("{},", ZIconv::noChange("预热")); + } else if (sm.getState() == kstate_disinfection) { + content += fmt::format("{},", ZIconv::noChange("消毒中")); + } else if (sm.getState() == kstate_degradation) { + content += fmt::format("{},", ZIconv::noChange("降解中")); + } else if (sm.getState() == kstate_finished) { + content += fmt::format("{},", ZIconv::noChange("结束")); + } else if (sm.getState() == kstate_dehumidification_before_disinfection) { + content += fmt::format("{},", ZIconv::noChange("消毒前除湿")); + } else if (sm.getState() == kstate_dehumidification_after_disinfection) { + content += fmt::format("{},", ZIconv::noChange("消毒后除湿")); + } else if (sm.getState() == kstate_empty_liquid_from_the_line) { + content += fmt::format("{},", ZIconv::noChange("排空管路")); + } else { + content += fmt::format("{},", ZIconv::noChange("未知")); + } + } + #if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) if (header) { content += fmt::format(" {} , {} , {} , {} ,", ZIconv::noChange("仓内-过氧化氢"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度")); @@ -300,15 +329,15 @@ int DisinfectionService::getDisinfectionWorkState() { return sm.getState(); bool DisinfectionService::isDisinfectionRunning() { return sm.getState() != kstate_finished; } int32_t DisinfectionService::getEstimatedRemainingTimeS() { if (sm.getState() == kstate_disinfection) { - return context.remaintime; + int ret = context.remaintime; + if (ret < 0) ret = 0; + return ret; } else if (sm.getState() == kstate_preheat) { return getPreHeatRaminTimeS(); } else if (sm.getState() == kstate_empty_liquid_from_the_line) { int32_t remaintime = EMTPTY_LINE_WHEN_DISINFECTION - sm.getStateHasPassedTimeMs(); if (remaintime < 0) remaintime = 0; return remaintime; - } else if (sm.getState() == kstate_finished) { - return 0; } else { return -1; } @@ -405,7 +434,7 @@ void DisinfectionService::initState() { cfg.pre_heat_time_s = 5; } - context.remaintime = cfg.pre_heat_time_s + cfg.targetLoglevel * 90 * 60; // 计算总的加热时间 + context.remaintime = cfg.targetLoglevel * 60 * 60; // 计算总的加热时间 context.now_loglevel = 0; context.dvalue = 0; @@ -422,23 +451,9 @@ void DisinfectionService::initState() { context.max_humid = 0; context.max_saturation = 0; context.stateSnapshotList.clear(); - context.afterDisinfectantVolume_g = 0; - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - context.beforeDisinfectantVolume_g = m_deviceIoControlService->getDisinfectantVolume_g(); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - context.beforeDisinfectantVolume_g = 0; -#else -#endif - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->heartingPlate_setPower(true); - m_deviceIoControlService->airBlower_setState(true); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) -#else -#endif - - context.csvlogger = createCSVLogger(context.id); + context.afterDisinfectantVolume_g = 0; + context.beforeDisinfectantVolume_g = m_disinfectionServicePort->getDisinfectantVolume(); + context.csvlogger = createCSVLogger(context.id); __dumpDisinfectionLogsToCSV(true); m_disinfectionWorkState = 1; } @@ -538,9 +553,6 @@ bool DisinfectionService::isTimeToPauseDisinfection() { float nowSatur = context.max_saturation; float nowh2o2 = context.max_h2o2; float humid = context.max_humid; - // if (nowSatur > cfg.stoped_satur || nowh2o2 > cfg.stoped_gs || humid > cfg.stoped_humi) { - // return true; - // } if (nowSatur > cfg.stoped_satur) { logger->info("nowSatur {} > cfg.stoped_satur {}", nowSatur, cfg.stoped_satur); @@ -577,88 +589,109 @@ bool DisinfectionService::isTimeToResumeDisinfection() { return false; } -void DisinfectionService::pauseDisinfection() { - logger->info("pauseDisinfection"); - - m_deviceIoControlService->sprayLiquidPump_close(); - usleep(1000 * 1000); - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->airCompressor_setState(false); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(0); -#endif - - context.is_disinfection_take_break = true; -} -void DisinfectionService::resumeDisinfection() { - logger->info("resumeDisinfection"); - m_deviceIoControlService->sprayLiquidPump_open(cfg.injection_pump_speed); - usleep(1000 * 1000); - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->airCompressor_setState(true); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(1); -#endif - context.is_disinfection_take_break = false; -} - void DisinfectionService::updateSprayLiquidPumpSpeed() { m_deviceIoControlService->sprayLiquidPump_open(cfg.injection_pump_speed); } - void DisinfectionService::beforeStateProcess() { updateH2O2SensorData(); } +void DisinfectionService::changeToNextState() { + /** + * @brief + * + * + * kstate_idle + * | + * kstate_finished ------------------------ + * | | + * kstate_dehumidification_before_disinfection | + * | | + * kstate_preheat <----------------------| + * | + * kstate_disinfection + * | + * kstate_empty_liquid_from_the_line -----| + * | | + * kstate_dehumidification_after_disinfection | + * | | + * kstate_degradation <----| + * | + * kstate_finished + * + */ -void DisinfectionService::processStateIdle(disinfection_event_t* event) { sm.changeState(kstate_finished); } - -void DisinfectionService::processStateDehumidification_before_disinfection(disinfection_event_t* event) { - disinfection_state_t next_state = kstate_preheat; - - auto dsio = m_deviceIoControlService; - if (!cfg.enable_bf_dinft_dehumidification) { - if (event->event == kdisinfection_event_enter_state) { - sm.changeState(next_state); - return; + if (sm.getState() == kstate_idle) { + sm.changeState(kstate_finished); + } + // + else if (sm.getState() == kstate_finished) { + if (cfg.enable_bf_dinft_dehumidification && // + m_disinfectionServicePort->equipmentCapacity_isSupportDehumidification() && // + m_disinfectionServicePort->equipmentCapacity_isDehumidificationComponentOnline()) { + sm.changeState(kstate_dehumidification_before_disinfection); + } else { + sm.changeState(kstate_preheat); } } // + else if (sm.getState() == kstate_dehumidification_before_disinfection) { + sm.changeState(kstate_preheat); + } + // + else if (sm.getState() == kstate_preheat) { + sm.changeState(kstate_disinfection); + } + // + else if (sm.getState() == kstate_disinfection) { + sm.changeState(kstate_empty_liquid_from_the_line); + } + // + else if (sm.getState() == kstate_empty_liquid_from_the_line) { + if (cfg.enable_af_dinft_dehumidification && // + m_disinfectionServicePort->equipmentCapacity_isSupportDehumidification() && // + m_disinfectionServicePort->equipmentCapacity_isDehumidificationComponentOnline()) { + sm.changeState(kstate_dehumidification_after_disinfection); + } else { + sm.changeState(kstate_degradation); + } + } + // + else if (sm.getState() == kstate_dehumidification_after_disinfection) { + sm.changeState(kstate_degradation); + } + // + else if (sm.getState() == kstate_degradation) { + sm.changeState(kstate_finished); + } +} + +void DisinfectionService::processStateIdle(disinfection_event_t* event) { sm.changeState(kstate_finished); } +void DisinfectionService::processStateDehumidification_before_disinfection(disinfection_event_t* event) { + auto dsio = m_deviceIoControlService; if (event->event == kdisinfection_event_enter_state) { tryLogSatate(true); -#if (defined PROJECT_TYPE_DRAW_BAR_BOX) - dsio->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 - usleep(100 * 1000); - dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_dehumidificationChannel); -#endif - + m_disinfectionServicePort->doStateDehumidification_before_disinfection_enterEvent(); } // else if (event->event == kdisinfection_event_exit_state) { -#if (defined PROJECT_TYPE_DRAW_BAR_BOX) - dsio->DBDB__miniPwmBlowerCtrl(0); - usleep(100 * 1000); - dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); -#endif + m_disinfectionServicePort->doStateDehumidification_before_disinfection_exitEvent(); + tryLogSatate(true); } - // else if (event->event == kdisinfection_event_tmr_1s) { #if (defined PROJECT_TYPE_DRAW_BAR_BOX) if (!dsio->DBDB__extValBoardIsOnline()) { logger->error("exit dehumidification state, because extValBoard is offline"); - sm.changeState(next_state); + changeToNextState(); return; } if (context.max_humid <= cfg.bf_dinft_dehumidification_target_val) { logger->info("exit dehumidification state, because humidity is lower than target value"); - sm.changeState(next_state); + changeToNextState(); return; } else { logger->info("dehumidification {} > {} ", context.max_humid, cfg.bf_dinft_dehumidification_target_val); } #else - sm.changeState(next_state); + changeToNextState(); #endif tryLogSatate(false); - } else if (event->event == kdisinfection_event_stop) { @@ -667,161 +700,36 @@ void DisinfectionService::processStateDehumidification_before_disinfection(disin } void DisinfectionService::processStatePreheat(disinfection_event_t* event) { - /** - * @brief 状态逻辑 - * 1. 记录日志 - * 2. 检查是否预热完成 - */ - disinfection_state_t next_state = kstate_disinfection; - - /******************************************************************************* - * 进入状态 * - *******************************************************************************/ if (event->event == kdisinfection_event_enter_state) { logger->info("preheat state enter"); tryLogSatate(true); - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->heartingPlate_setPower(true); - m_deviceIoControlService->airBlower_setState(true); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 - - usleep(1000 * 1000); - - m_deviceIoControlService->DBDB__heaterCtrl(true); - usleep(100 * 1000); - m_deviceIoControlService->DBDB__heaterCtrlSafeValve(true); -#else -#endif - } - - /******************************************************************************* - * 离开状态 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_exit_state) { -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->heartingPlate_setPower(false); - m_deviceIoControlService->airBlower_setState(false); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - - m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(0); // 风量 - usleep(1000 * 1000); - m_deviceIoControlService->DBDB__heaterCtrl(false); - usleep(100 * 1000); - m_deviceIoControlService->DBDB__heaterCtrlSafeValve(false); -#else -#endif - } - - /******************************************************************************* - * 状态周期调度事件 * - *******************************************************************************/ - - else if (event->event == kdisinfection_event_tmr_1s) { + m_disinfectionServicePort->doStatePreheat_enterEvent(); + } else if (event->event == kdisinfection_event_exit_state) { + logger->info("preheat state exit"); + m_disinfectionServicePort->doStatePreheat_exitEvent(); + tryLogSatate(true); + } else if (event->event == kdisinfection_event_tmr_1s) { if (sm.getStateHasPassedTimeMs() > cfg.pre_heat_time_s * 1000) { - /** - * @brief 退出预热状态,进入消毒状态 - */ - sm.changeState(next_state); + // 退出预热状态,进入消毒状态 + changeToNextState(); } tryLogSatate(false); - } - - /******************************************************************************* - * 结束消毒 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_stop) { + } else if (event->event == kdisinfection_event_stop) { sm.changeState(kstate_finished); } } void DisinfectionService::processStateDisinfection(disinfection_event_t* event) { - // disinfection_state_t next_state = kstate_dehumidification_after_disinfection; - disinfection_state_t next_state = kstate_empty_liquid_from_the_line; - - /** - * @brief 状态逻辑 - * 1. 记录日志 - * 2. 检查是否消毒完成 - */ - - /******************************************************************************* - * 进入状态 * - *******************************************************************************/ if (event->event == kdisinfection_event_enter_state) { tryLogSatate(true); context.is_disinfection_take_break = false; + m_disinfectionServicePort->doStateDisinfection_enterEvent(); -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - -#if (defined PROJECT_TYPE_PIPE_DISINFECTION) - - m_deviceIoControlService->airCompressor_channelSelect(1); - m_deviceIoControlService->airCompressor_setValve1(1); - m_deviceIoControlService->airCompressor_setValve2(1); -#endif - m_deviceIoControlService->airBlower_setState(true); - usleep(1000 * 1000); - m_deviceIoControlService->airCompressor_setState(true); - usleep(1000 * 1000); - m_deviceIoControlService->heartingPlate_setPower(true); -#endif - -#if (defined PROJECT_TYPE_DRAW_BAR_BOX) - m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(1); - usleep(1000 * 1000); - m_deviceIoControlService->DBDB__heaterCtrl(1); - usleep(100 * 1000); - m_deviceIoControlService->DBDB__heaterCtrlSafeValve(1); - usleep(1000 * 1000); - m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 - usleep(1000 * 1000); - m_deviceIoControlService->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); -#endif - - m_deviceIoControlService->sprayLiquidPump_open(cfg.injection_pump_speed); - - } - - /******************************************************************************* - * 离开状态 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_exit_state) { + } else if (event->event == kdisinfection_event_exit_state) { context.dvalue = 0; - m_deviceIoControlService->sprayLiquidPump_close(); - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - -#if (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->airCompressor_channelSelect(1); - m_deviceIoControlService->airCompressor_setValve1(1); - m_deviceIoControlService->airCompressor_setValve2(1); -#endif - m_deviceIoControlService->airBlower_setState(false); - usleep(1000 * 1000); - m_deviceIoControlService->airCompressor_setState(false); - usleep(1000 * 1000); - m_deviceIoControlService->heartingPlate_setPower(false); -#endif - -#if (defined PROJECT_TYPE_DRAW_BAR_BOX) - m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(0); - usleep(100 * 1000); - m_deviceIoControlService->DBDB__heaterCtrl(0); - usleep(100 * 1000); - m_deviceIoControlService->DBDB__heaterCtrlSafeValve(0); - usleep(100 * 1000); - m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(0); - usleep(100 * 1000); -#endif - - } - - /******************************************************************************* - * 周期 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_tmr_1s) { + m_disinfectionServicePort->doStateDisinfection_exitEvent(); + tryLogSatate(true); + } else if (event->event == kdisinfection_event_tmr_1s) { /** * @brief * 计算D值 @@ -842,13 +750,17 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) if (!context.is_disinfection_take_break) { if (isTimeToPauseDisinfection()) { + logger->info("pauseDisinfection"); logstate(); - pauseDisinfection(); + m_disinfectionServicePort->doStateDisinfection_whenPause(); + context.is_disinfection_take_break = true; } } else { if (isTimeToResumeDisinfection()) { + logger->info("resumeDisinfection"); logstate(); - resumeDisinfection(); + m_disinfectionServicePort->doStateDisinfection_whenContinue(); + context.is_disinfection_take_break = false; } } @@ -856,7 +768,7 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) /** * @brief 消毒结束 */ - sm.changeState(next_state); + changeToNextState(); } tryLogSatate(false); @@ -865,107 +777,59 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) if (!context.is_disinfection_take_break) { updateSprayLiquidPumpSpeed(); } - } - /******************************************************************************* - * 结束消毒 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_stop) { + } else if (event->event == kdisinfection_event_stop) { sm.changeState(kstate_finished); } } void DisinfectionService::processStateEmpytLiquidFromTheLine(disinfection_event_t* event) { // - disinfection_state_t next_state = kstate_dehumidification_after_disinfection; - - /** - * @brief 状态逻辑 - * 1. 记录日志 - * 2. 检查是否消毒完成 - */ - - /******************************************************************************* - * 进入状态 * - *******************************************************************************/ if (event->event == kdisinfection_event_enter_state) { tryLogSatate(true); - m_deviceIoControlService->sprayLiquidPump_open(-SPRAYLIQUID_PUMP_MAX_GPM); - } - - /******************************************************************************* - * 离开状态 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_exit_state) { - m_deviceIoControlService->sprayLiquidPump_close(); - } - - /******************************************************************************* - * 周期 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_tmr_1s) { + m_disinfectionServicePort->doStateEmpytLiquidFromTheLine_enterEvent(); + } else if (event->event == kdisinfection_event_exit_state) { + m_disinfectionServicePort->doStateEmpytLiquidFromTheLine_exitEvent(); + tryLogSatate(true); + } else if (event->event == kdisinfection_event_tmr_1s) { if (sm.getStateHasPassedTimeMs() > EMTPTY_LINE_WHEN_DISINFECTION * 1000) { - sm.changeState(next_state); + changeToNextState(); } - } - /******************************************************************************* - * 结束消毒 * - *******************************************************************************/ - else if (event->event == kdisinfection_event_stop) { + } else if (event->event == kdisinfection_event_stop) { sm.changeState(kstate_finished); } } void DisinfectionService::processStateDehumidification_after_disinfection(disinfection_event_t* event) { - disinfection_state_t next_state = kstate_degradation; - auto dsio = m_deviceIoControlService; - if (!cfg.enable_af_dinft_dehumidification) { - if (event->event == kdisinfection_event_enter_state) { - sm.changeState(next_state); - return; - } - } - // + if (event->event == kdisinfection_event_enter_state) { tryLogSatate(true); -#if (defined PROJECT_TYPE_DRAW_BAR_BOX) - dsio->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 - usleep(100 * 1000); - dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_dehumidificationChannel); -#endif - - } - // - else if (event->event == kdisinfection_event_exit_state) { -#if (defined PROJECT_TYPE_DRAW_BAR_BOX) - dsio->DBDB__miniPwmBlowerCtrl(0); - usleep(100 * 1000); - dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); -#endif - } + m_disinfectionServicePort->doStateDehumidification_after_disinfection_enterEvent(); + } else if (event->event == kdisinfection_event_exit_state) { + m_disinfectionServicePort->doStateDehumidification_after_disinfection_exitEvent(); + tryLogSatate(true); - // - else if (event->event == kdisinfection_event_tmr_1s) { + } else if (event->event == kdisinfection_event_tmr_1s) { #if (defined PROJECT_TYPE_DRAW_BAR_BOX) if (!dsio->DBDB__extValBoardIsOnline()) { logger->error("exit dehumidification state, because extValBoard is offline"); - sm.changeState(next_state); + changeToNextState(); + return; } if (context.max_humid <= cfg.af_dinft_dehumidification_target_val) { logger->info("exit dehumidification state, because humidity is lower than target value"); - sm.changeState(next_state); + changeToNextState(); + return; } else { logger->info("dehumidification {} > {} ", context.max_humid, cfg.af_dinft_dehumidification_target_val); } #else - sm.changeState(next_state); + changeToNextState(); #endif tryLogSatate(false); - } - - else if (event->event == kdisinfection_event_stop) { + } else if (event->event == kdisinfection_event_stop) { sm.changeState(kstate_finished); } } @@ -974,50 +838,20 @@ void DisinfectionService::processStateDegradation(disinfection_event_t* event) { disinfection_state_t next_state = kstate_finished; auto dsio = m_deviceIoControlService; - if (!cfg.enable_degradation) { - if (event->event == kdisinfection_event_enter_state) { - sm.changeState(next_state); - return; - } - } - - // if (event->event == kdisinfection_event_enter_state) { tryLogSatate(true); - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->airBlower_setState(true); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - - if (dsio->DBDB__extValBoardIsOnline()) dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_degradationChannel); - usleep(100 * 1000); - dsio->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 -#endif - - } - // - else if (event->event == kdisinfection_event_exit_state) { -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->airBlower_setState(false); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - if (dsio->DBDB__extValBoardIsOnline()) dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); - usleep(100 * 1000); - dsio->DBDB__miniPwmBlowerCtrl(0); - -#endif - } - - // - else if (event->event == kdisinfection_event_tmr_1s) { + m_disinfectionServicePort->doStateDegradation_enterEvent(); + } else if (event->event == kdisinfection_event_exit_state) { + m_disinfectionServicePort->doStateDegradation_exitEvent(); + tryLogSatate(true); + } else if (event->event == kdisinfection_event_tmr_1s) { logger->info("waitting for h2o2 concentration to safe value {}=>{}", context.max_h2o2, 1); if (context.max_h2o2 < 1) { logger->info("h2o2 concentration to safe value"); - sm.changeState(next_state); + changeToNextState(); } tryLogSatate(false); - } - - else if (event->event == kdisinfection_event_stop) { + } else if (event->event == kdisinfection_event_stop) { sm.changeState(kstate_finished); } } @@ -1028,29 +862,19 @@ void DisinfectionService::processStateFinished(disinfection_event_t* event) { /** * @brief 消毒结束 */ - context.complete_tp = zsystem_clock().now(); -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - context.afterDisinfectantVolume_g = m_deviceIoControlService->getDisinfectantVolume_g(); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) - context.afterDisinfectantVolume_g = 0; -#endif - context.remaintime = 0; + m_disinfectionServicePort->doStateFinished_enterEvent(); + + context.complete_tp = zsystem_clock().now(); + context.afterDisinfectantVolume_g = m_disinfectionServicePort->getDisinfectantVolume(); + context.remaintime = 0; + + m_lightCtrlService->setworkFlag(false); tryLogSatate(true); pushDisinfectionPrinterTask(); context.csvlogger = nullptr; - logger->info("finished disinfection {}", context.id); m_disinfectionWorkState = 3; - -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->sprayLiquidPump_close(); - m_deviceIoControlService->airCompressor_setState(false); - m_deviceIoControlService->airBlower_setState(false); - m_deviceIoControlService->heartingPlate_setPower(false); - m_deviceIoControlService->warningLightCtrl(0, 1, 0, 0); -#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) -#endif return; } @@ -1062,16 +886,7 @@ void DisinfectionService::processStateFinished(disinfection_event_t* event) { * @brief 开始消毒 */ initState(); -#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) - m_deviceIoControlService->warningLightCtrl(0, 0, 1, 0); -#elif (defined PROJECT_TYPE_PIPE_DISINFECTION) - m_deviceIoControlService->warningLightCtrl(1, 1, 0, 0); -#endif - - if (cfg.enable_bf_dinft_dehumidification) { - sm.changeState(kstate_dehumidification_before_disinfection); - } else { - sm.changeState(kstate_preheat); - } + m_lightCtrlService->setworkFlag(true); + changeToNextState(); } } diff --git a/src/service/disfection_ctl/disinfection_service.hpp b/src/service/disfection_ctl/disinfection_service.hpp index 5528909..6743864 100644 --- a/src/service/disfection_ctl/disinfection_service.hpp +++ b/src/service/disfection_ctl/disinfection_service.hpp @@ -14,7 +14,10 @@ #include #include +#include "../light_ctrl_service.hpp" #include "db/db_service.hpp" +#include "disinfection_service_config.hpp" +#include "disinfection_service_port.hpp" #include "disinfection_state.hpp" #include "disinfection_state_machine.hpp" #include "iflytop/components/zcanreceiver/zcanhost.hpp" @@ -44,27 +47,6 @@ class DisinfectionService : public enable_shared_from_this public: typedef struct { - int pre_heat_time_s = 5; // 预热时间 - int stoped_gs = 0; // 停止H2O2浓度 - int continued_gs = 0; // 继续H2O2浓度 - int stoped_satur = 0; // 停止饱和度 - int continued_satur = 0; // 继续饱和度 - int stoped_humi = 0; // 停止湿度 - int continued_humi = 0; // 继续湿度 - int injection_pump_speed; // 注液泵速度 - float targetLoglevel = 0; // 目标浓度 - - bool enable_bf_dinft_dehumidification = false; // 是否在消毒前开启除湿 - bool enable_af_dinft_dehumidification = false; // 是否在消毒后开启除湿 - bool enable_degradation = true; // 是否开启降解 - - int bf_dinft_dehumidification_target_val = 20; // 消毒前除湿目标湿度 - int af_dinft_dehumidification_target_val = 20; // 消毒后除湿目标湿度 - int degradation_target_val = 0; // - - } config_t; - - typedef struct { string id; zsteady_tp start_steady_tp; zsystem_tp start_tp; @@ -107,6 +89,8 @@ class DisinfectionService : public enable_shared_from_this shared_ptr m_dbService; shared_ptr m_disinfectionLogsManager; shared_ptr m_disinfectionPrinterService; + shared_ptr m_disinfectionServicePort; + shared_ptr m_lightCtrlService; recursive_mutex lock_; DValueComputer m_dvalueComputer; @@ -116,8 +100,8 @@ class DisinfectionService : public enable_shared_from_this int m_disinfectionWorkState = 0; public: - config_t cfg; - state_t context; + DisinfectionServiceConfig_t cfg; + state_t context; public: DisinfectionService(); @@ -164,7 +148,6 @@ class DisinfectionService : public enable_shared_from_this void stopDisinfection(); void updateDisinfectionCfg(); - int getDisinfectionWorkState(); bool isDisinfectionRunning(); int32_t getEstimatedRemainingTimeS(); @@ -182,6 +165,9 @@ class DisinfectionService : public enable_shared_from_this void processStateDehumidification_before_disinfection(disinfection_event_t* event); void processStateDehumidification_after_disinfection(disinfection_event_t* event); void processStateEmpytLiquidFromTheLine(disinfection_event_t* event); + + void changeToNextState(); + private: void initState(); @@ -208,8 +194,6 @@ class DisinfectionService : public enable_shared_from_this bool isTimeToPauseDisinfection(); bool isTimeToResumeDisinfection(); - void pauseDisinfection(); - void resumeDisinfection(); void updateSprayLiquidPumpSpeed(); void pushDisinfectionPrinterTask(); diff --git a/src/service/disfection_ctl/disinfection_service_config.hpp b/src/service/disfection_ctl/disinfection_service_config.hpp new file mode 100644 index 0000000..08004a8 --- /dev/null +++ b/src/service/disfection_ctl/disinfection_service_config.hpp @@ -0,0 +1,53 @@ +// +// Created by zwsd +// + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @brief + * + * service: DisinfectionService + * + * 监听事件: + * 依赖状态: + * 依赖服务: + * 作用: + * + */ + +namespace iflytop { +using namespace std; +typedef struct { + public: + int pre_heat_time_s = 5; // 预热时间 + int stoped_gs = 0; // 停止H2O2浓度 + int continued_gs = 0; // 继续H2O2浓度 + int stoped_satur = 0; // 停止饱和度 + int continued_satur = 0; // 继续饱和度 + int stoped_humi = 0; // 停止湿度 + int continued_humi = 0; // 继续湿度 + int injection_pump_speed; // 注液泵速度 + float targetLoglevel = 0; // 目标浓度 + + bool enable_bf_dinft_dehumidification = false; // 是否在消毒前开启除湿 + bool enable_af_dinft_dehumidification = false; // 是否在消毒后开启除湿 + bool enable_degradation = true; // 是否开启降解 + + int bf_dinft_dehumidification_target_val = 20; // 消毒前除湿目标湿度 + int af_dinft_dehumidification_target_val = 20; // 消毒后除湿目标湿度 + int degradation_target_val = 0; // + +} DisinfectionServiceConfig_t; + +} // namespace iflytop \ No newline at end of file diff --git a/src/service/disfection_ctl/disinfection_service_port.cpp b/src/service/disfection_ctl/disinfection_service_port.cpp new file mode 100644 index 0000000..76b4ab0 --- /dev/null +++ b/src/service/disfection_ctl/disinfection_service_port.cpp @@ -0,0 +1,245 @@ +#include "disinfection_service_port.hpp" + +#include +#include + +#include "configs/gconfig.hpp" +#include "configs/project_setting.hpp" +#include "iflytop/components/uart_printer/uart_printer.hpp" +#include "iflytoplinuxsdk/src/iflytop/components/ziconv.hpp" +#include "service/device_state_service.hpp" +using namespace iflytop; +using namespace std; + +namespace iflytop { +extern bool g_in_test; + +} + +void DisinfectionServicePort::initialize(DisinfectionServiceConfig_t* cfg) { + GET_TO_SERVICE(m_deviceIoControlService); + GET_TO_SERVICE(m_dbService); + GET_TO_SERVICE(m_disinfectionLogsManager); + GET_TO_SERVICE(m_disinfectionPrinterService); + this->cfg = cfg; +} +void DisinfectionServicePort::doStateDehumidification_before_disinfection_enterEvent() { + auto dsio = m_deviceIoControlService; + +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + dsio->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 + usleep(100 * 1000); + dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_dehumidificationChannel); +#endif +} +void DisinfectionServicePort::doStateDehumidification_before_disinfection_exitEvent() { + auto dsio = m_deviceIoControlService; + +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + dsio->DBDB__miniPwmBlowerCtrl(0); + usleep(100 * 1000); + dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); +#endif +} +void DisinfectionServicePort::doStateIdle_enterEvent() {} +void DisinfectionServicePort::doStateIdle_exitEvent() {} +void DisinfectionServicePort::doStatePreheat_enterEvent() { +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->heartingPlate_setPower(true); + m_deviceIoControlService->airBlower_setState(true); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) + m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 + + usleep(1000 * 1000); + + m_deviceIoControlService->DBDB__heaterCtrl(true); + usleep(100 * 1000); + m_deviceIoControlService->DBDB__heaterCtrlSafeValve(true); +#else +#endif +} +void DisinfectionServicePort::doStatePreheat_exitEvent() { +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->heartingPlate_setPower(false); + m_deviceIoControlService->airBlower_setState(false); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) + + m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(0); // 风量 + usleep(1000 * 1000); + m_deviceIoControlService->DBDB__heaterCtrl(false); + usleep(100 * 1000); + m_deviceIoControlService->DBDB__heaterCtrlSafeValve(false); +#else +#endif +} +void DisinfectionServicePort::doStateDisinfection_enterEvent() { +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + +#if (defined PROJECT_TYPE_PIPE_DISINFECTION) + + m_deviceIoControlService->airCompressor_channelSelect(1); + m_deviceIoControlService->airCompressor_setValve1(1); + m_deviceIoControlService->airCompressor_setValve2(1); +#endif + m_deviceIoControlService->airBlower_setState(true); + usleep(1000 * 1000); + m_deviceIoControlService->airCompressor_setState(true); + usleep(1000 * 1000); + m_deviceIoControlService->heartingPlate_setPower(true); +#endif + +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(1); + usleep(1000 * 1000); + m_deviceIoControlService->DBDB__heaterCtrl(1); + usleep(100 * 1000); + m_deviceIoControlService->DBDB__heaterCtrlSafeValve(1); + usleep(1000 * 1000); + m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 + usleep(1000 * 1000); + m_deviceIoControlService->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); +#endif + + m_deviceIoControlService->sprayLiquidPump_open(cfg->injection_pump_speed); +} +void DisinfectionServicePort::doStateDisinfection_exitEvent() { + m_deviceIoControlService->sprayLiquidPump_close(); + +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + +#if (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->airCompressor_channelSelect(1); + m_deviceIoControlService->airCompressor_setValve1(1); + m_deviceIoControlService->airCompressor_setValve2(1); +#endif + m_deviceIoControlService->airBlower_setState(false); + usleep(1000 * 1000); + m_deviceIoControlService->airCompressor_setState(false); + usleep(1000 * 1000); + m_deviceIoControlService->heartingPlate_setPower(false); +#endif + +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(0); + usleep(100 * 1000); + m_deviceIoControlService->DBDB__heaterCtrl(0); + usleep(100 * 1000); + m_deviceIoControlService->DBDB__heaterCtrlSafeValve(0); + usleep(100 * 1000); + m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(0); + usleep(100 * 1000); +#endif +} + +void DisinfectionServicePort::doStateDisinfection_whenPause() { + m_deviceIoControlService->sprayLiquidPump_close(); + usleep(1000 * 1000); + +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->airCompressor_setState(false); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) + m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(0); +#endif +} +void DisinfectionServicePort::doStateDisinfection_whenContinue() { + m_deviceIoControlService->sprayLiquidPump_open(cfg->injection_pump_speed); + usleep(1000 * 1000); + +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->airCompressor_setState(true); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) + m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(1); +#endif +} + +void DisinfectionServicePort::doStateEmpytLiquidFromTheLine_enterEvent() { m_deviceIoControlService->sprayLiquidPump_open(-SPRAYLIQUID_PUMP_MAX_GPM); } +void DisinfectionServicePort::doStateEmpytLiquidFromTheLine_exitEvent() { m_deviceIoControlService->sprayLiquidPump_close(); } + +void DisinfectionServicePort::doStateDehumidification_after_disinfection_enterEvent() { + auto dsio = m_deviceIoControlService; +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + dsio->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 + usleep(100 * 1000); + dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_dehumidificationChannel); +#endif +} +void DisinfectionServicePort::doStateDehumidification_after_disinfection_exitEvent() { + auto dsio = m_deviceIoControlService; + + +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + dsio->DBDB__miniPwmBlowerCtrl(0); + usleep(100 * 1000); + dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); +#endif +} +void DisinfectionServicePort::doStateDegradation_enterEvent() { + auto dsio = m_deviceIoControlService; + + +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->airBlower_setState(true); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) + + if (dsio->DBDB__extValBoardIsOnline()) dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_degradationChannel); + usleep(100 * 1000); + dsio->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量 +#endif +} +void DisinfectionServicePort::doStateDegradation_exitEvent() { + auto dsio = m_deviceIoControlService; + +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->airBlower_setState(false); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) + if (dsio->DBDB__extValBoardIsOnline()) dsio->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); + usleep(100 * 1000); + dsio->DBDB__miniPwmBlowerCtrl(0); + +#endif +} + +void DisinfectionServicePort::doStateFinished_enterEvent() { +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + m_deviceIoControlService->sprayLiquidPump_close(); + m_deviceIoControlService->airCompressor_setState(false); + m_deviceIoControlService->airBlower_setState(false); + m_deviceIoControlService->heartingPlate_setPower(false); + m_deviceIoControlService->warningLightCtrl(0, 1, 0, 0); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) +#endif +} + +int DisinfectionServicePort::getDisinfectantVolume() { +#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) + return m_deviceIoControlService->getDisinfectantVolume_g(); +#elif (defined PROJECT_TYPE_DRAW_BAR_BOX) + return 0; +#endif +} +/** + * @brief 除湿功能是否支持 + * + * @return true + * @return false + */ +bool DisinfectionServicePort::equipmentCapacity_isSupportDehumidification() { +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + return true; +#endif + return false; +} +/** + * @brief 除湿组件是否在线 + * + * @return true + * @return false + */ +bool DisinfectionServicePort::equipmentCapacity_isDehumidificationComponentOnline() { + auto dsio = m_deviceIoControlService; + +#if (defined PROJECT_TYPE_DRAW_BAR_BOX) + return dsio->DBDB__extValBoardIsOnline(); +#endif + return false; +} \ No newline at end of file diff --git a/src/service/disfection_ctl/disinfection_service_port.hpp b/src/service/disfection_ctl/disinfection_service_port.hpp new file mode 100644 index 0000000..00a28dc --- /dev/null +++ b/src/service/disfection_ctl/disinfection_service_port.hpp @@ -0,0 +1,85 @@ +// +// Created by zwsd +// + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "db/db_service.hpp" +#include "disinfection_service_config.hpp" +#include "disinfection_state.hpp" +#include "disinfection_state_machine.hpp" +#include "iflytop/components/zcanreceiver/zcanhost.hpp" +#include "iflytop/core/core.hpp" +#include "service/device_io_control_service.hpp" +#include "service/disinfection_logs_manager.hpp" +#include "service/disinfection_printer_service.hpp" +#include "utils/dvalue_computer.hpp" +#include "zservice_container/zservice_container.hpp" +/** + * @brief + * + * service: DisinfectionServicePort + * + * 监听事件: + * 依赖状态: + * 依赖服务: + * 作用: + * + */ + +namespace iflytop { +using namespace std; +using namespace core; +class DisinfectionServicePort : public enable_shared_from_this { + ENABLE_LOGGER(DisinfectionServicePort); + + private: + shared_ptr m_deviceIoControlService; + shared_ptr m_dbService; + shared_ptr m_disinfectionLogsManager; + shared_ptr m_disinfectionPrinterService; + DisinfectionServiceConfig_t* cfg; + + public: + void initialize(DisinfectionServiceConfig_t* cfg); + + void doStateIdle_enterEvent(); + void doStateIdle_exitEvent(); + void doStatePreheat_enterEvent(); + void doStatePreheat_exitEvent(); + void doStateDehumidification_before_disinfection_enterEvent(); + void doStateDehumidification_before_disinfection_exitEvent(); + + void doStateDisinfection_enterEvent(); + void doStateDisinfection_exitEvent(); + void doStateDisinfection_whenPause(); + void doStateDisinfection_whenContinue(); + + void doStateDegradation_enterEvent(); + void doStateDegradation_exitEvent(); + void doStateDehumidification_after_disinfection_enterEvent(); + void doStateDehumidification_after_disinfection_exitEvent(); + void doStateEmpytLiquidFromTheLine_enterEvent(); + void doStateEmpytLiquidFromTheLine_exitEvent(); + + /** + * @brief Finished + */ + void doStateFinished_enterEvent(); + + int getDisinfectantVolume(); + + bool equipmentCapacity_isSupportDehumidification(); + bool equipmentCapacity_isDehumidificationComponentOnline(); +}; +} // namespace iflytop \ No newline at end of file diff --git a/src/service/light_ctrl_service.hpp b/src/service/light_ctrl_service.hpp index abc5fc8..c8f1b1d 100644 --- a/src/service/light_ctrl_service.hpp +++ b/src/service/light_ctrl_service.hpp @@ -18,7 +18,6 @@ // #include "configs/gconfig.hpp" -#include "service/disinfection_ctl_service.hpp" #include "service/if_devoce_io_contrl_service.hpp" // diff --git a/src/version.hpp b/src/version.hpp index 9077550..e745f03 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -1,2 +1,2 @@ #pragma once -#define VERSION "7.0" \ No newline at end of file +#define VERSION "8.0" \ No newline at end of file