diff --git a/src/configs/project_setting.hpp b/src/configs/project_setting.hpp index 7b3c0ad..4b9b97a 100644 --- a/src/configs/project_setting.hpp +++ b/src/configs/project_setting.hpp @@ -11,8 +11,8 @@ // #define PROJECT_TYPE_LARGE_SPACE_DISINFECTION 1 // 大空间 // #define PROJECT_TYPE_SMALL_SPACE_DISINFECTION 1 // 小空间 -#define PROJECT_TYPE_PIPE_DISINFECTION 1 // 管道消毒机 -// #define PROJECT_TYPE_DRAW_BAR_BOX 1 // 拉感箱 +// #define PROJECT_TYPE_PIPE_DISINFECTION 1 // 管道消毒机 +#define PROJECT_TYPE_DRAW_BAR_BOX 1 // 拉感箱 // #if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION) diff --git a/src/service/device_io_control_service_test.cpp b/src/service/device_io_control_service_test.cpp index 9741a9e..933959e 100644 --- a/src/service/device_io_control_service_test.cpp +++ b/src/service/device_io_control_service_test.cpp @@ -291,6 +291,6 @@ int32_t DeviceIoControlServiceTest::DBDB__extValveCtrl(int index) { } int32_t DeviceIoControlServiceTest::DBDB__extValBoardIsOnline() { logger->info("DBDB__extValBoardIsOnline"); - return 0; + return 1; } #endif \ No newline at end of file diff --git a/src/service/disfection_ctl/disinfection_service.cpp b/src/service/disfection_ctl/disinfection_service.cpp index 74bc58e..84e0614 100644 --- a/src/service/disfection_ctl/disinfection_service.cpp +++ b/src/service/disfection_ctl/disinfection_service.cpp @@ -596,12 +596,70 @@ void DisinfectionService::updateSprayLiquidPumpSpeed() { void DisinfectionService::beforeStateProcess() { updateH2O2SensorData(); } 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 (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 + } + + // + 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); + 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); + return; + } else { + logger->info("dehumidification {} > {} ", context.max_humid, cfg.bf_dinft_dehumidification_target_val); + } +#else + sm.changeState(next_state); +#endif + tryLogSatate(false); + + } + + else if (event->event == kdisinfection_event_stop) { + sm.changeState(kstate_finished); + } +} + void DisinfectionService::processStatePreheat(disinfection_event_t* event) { /** * @brief 状态逻辑 * 1. 记录日志 * 2. 检查是否预热完成 */ + disinfection_state_t next_state = kstate_disinfection; /******************************************************************************* * 进入状态 * @@ -639,7 +697,7 @@ void DisinfectionService::processStatePreheat(disinfection_event_t* event) { /** * @brief 退出预热状态,进入消毒状态 */ - sm.changeState(kstate_disinfection); + sm.changeState(next_state); } tryLogSatate(false); } @@ -653,6 +711,8 @@ void DisinfectionService::processStatePreheat(disinfection_event_t* event) { } void DisinfectionService::processStateDisinfection(disinfection_event_t* event) { + disinfection_state_t next_state = kstate_dehumidification_after_disinfection; + /** * @brief 状态逻辑 * 1. 记录日志 @@ -767,7 +827,7 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) /** * @brief 消毒结束 */ - sm.changeState(kstate_degradation); + sm.changeState(next_state); } tryLogSatate(false); @@ -785,6 +845,114 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) } } +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 + } + + // + 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); + 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); + return; + } else { + logger->info("dehumidification {} > {} ", context.max_humid, cfg.af_dinft_dehumidification_target_val); + } +#else + sm.changeState(next_state); +#endif + tryLogSatate(false); + + } + + else if (event->event == kdisinfection_event_stop) { + sm.changeState(kstate_finished); + } +} + +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) { + 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); + } + tryLogSatate(false); + } + + else if (event->event == kdisinfection_event_stop) { + sm.changeState(kstate_finished); + } +} + void DisinfectionService::processStateFinished(disinfection_event_t* event) { if (event->event == kdisinfection_event_enter_state) { if (event->enterState.last != kstate_idle && event->enterState.last != kstate_finished) { @@ -838,36 +1006,3 @@ void DisinfectionService::processStateFinished(disinfection_event_t* event) { } } } - -void DisinfectionService::processStateDegradation(disinfection_event_t* event) { - // - if (event->event == kdisinfection_event_enter_state) { -#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) -#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) -#endif - } - - // - 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(kstate_finished); - } - } - - else if (event->event == kdisinfection_event_stop) { - sm.changeState(kstate_finished); - } -} -void DisinfectionService::processStateDehumidification_before_disinfection(disinfection_event_t* event) {} -void DisinfectionService::processStateDehumidification_after_disinfection(disinfection_event_t* event) {}