diff --git a/appsrc/appbase/appbean/setting_id.hpp b/appsrc/appbase/appbean/setting_id.hpp index 1d7693b..87e4648 100644 --- a/appsrc/appbase/appbean/setting_id.hpp +++ b/appsrc/appbase/appbean/setting_id.hpp @@ -7,12 +7,12 @@ marco(type, continued_gs) /**/ \ marco(type, stoped_satur) /**/ \ marco(type, continued_satur) /**/ \ + marco(type, stoped_humi) /**/ \ + marco(type, continued_humi) /**/ \ marco(type, max_humidity) /**/ \ marco(type, drainage_pump_speed) /**/ \ marco(type, injection_pump_speed) /**/ \ marco(type, pre_heat_time_s) /**/ \ - marco(type, stoped_humi) /**/ \ - marco(type, continued_humi) /**/ \ marco(type, record_period_min) /**/ \ marco(type, record_printer_period_min) /**/ \ marco(type, loglevel) /*消毒等级*/ \ diff --git a/appsrc/appconfig/basic/zappversion.hpp b/appsrc/appconfig/basic/zappversion.hpp index 72c9a3e..c2093f3 100644 --- a/appsrc/appconfig/basic/zappversion.hpp +++ b/appsrc/appconfig/basic/zappversion.hpp @@ -1,3 +1,3 @@ #pragma once -#define VERSION "3.0.4" +#define VERSION "3.0.7" #define PROJECT_NAME "TRANSMIT_DM" \ No newline at end of file diff --git a/appsrc/baseservice/db/calibrate_info_dao.hpp b/appsrc/baseservice/db/calibrate_info_dao.hpp index 6a8e160..75ae6ea 100644 --- a/appsrc/baseservice/db/calibrate_info_dao.hpp +++ b/appsrc/baseservice/db/calibrate_info_dao.hpp @@ -35,7 +35,7 @@ using namespace nlohmann; namespace db { typedef struct { - int id; + int id; float h2O2LiquidWeightSensorZeroBias; // H2O2液体重量传感器零点偏差 } CalibrationInfo; } // namespace db @@ -62,8 +62,12 @@ class CalibrationInfoDao : public KeyValDBV2Dao { CalibrationInfo getCalibrationInfo(); json getCalibrationInfoJson(); - void setH2O2LiquidWeightSensorZeroBias(float bias); - float getH2O2LiquidWeightSensorZeroBias(); + void setH2O2LiquidWeightSensorZeroBias(float bias); + float getH2O2LiquidWeightSensorZeroBias(); + + + + private: void initialize(); diff --git a/appsrc/baseservice/db/setting_db_dao.cpp b/appsrc/baseservice/db/setting_db_dao.cpp index 364fa00..0c27b33 100644 --- a/appsrc/baseservice/db/setting_db_dao.cpp +++ b/appsrc/baseservice/db/setting_db_dao.cpp @@ -55,25 +55,25 @@ using namespace iflytop; using namespace db; static Setting settingInitTable[] = { - {.setting_id = SettingId::kstoped_gs}, - {.setting_id = SettingId::kcontinued_gs}, - {.setting_id = SettingId::kstoped_satur}, - {.setting_id = SettingId::kcontinued_satur}, - {.setting_id = SettingId::kmax_humidity}, - {.setting_id = SettingId::kdrainage_pump_speed}, - {.setting_id = SettingId::kinjection_pump_speed}, - {.setting_id = SettingId::kpre_heat_time_s}, - {.setting_id = SettingId::kstoped_humi}, - {.setting_id = SettingId::kcontinued_humi}, - {.setting_id = SettingId::krecord_period_min}, - {.setting_id = SettingId::krecord_printer_period_min}, - {.setting_id = SettingId::kloglevel}, - {.setting_id = SettingId::kenable_bd_dehumidify}, - {.setting_id = SettingId::kbd_dehumidify_threshold}, - {.setting_id = SettingId::kenable_ad_dehumidify}, - {.setting_id = SettingId::kad_dehumidify_threshold}, - {.setting_id = SettingId::kenable_ad_degrade}, - {.setting_id = SettingId::kad_degrade_threshold}, + {.setting_id = SettingId::stoped_gs}, + {.setting_id = SettingId::continued_gs}, + {.setting_id = SettingId::stoped_satur}, + {.setting_id = SettingId::continued_satur}, + {.setting_id = SettingId::stoped_humi}, + {.setting_id = SettingId::continued_humi}, + {.setting_id = SettingId::max_humidity}, + {.setting_id = SettingId::drainage_pump_speed}, + {.setting_id = SettingId::injection_pump_speed}, + {.setting_id = SettingId::pre_heat_time_s}, + {.setting_id = SettingId::loglevel}, + {.setting_id = SettingId::record_period_min}, + {.setting_id = SettingId::record_printer_period_min}, + {.setting_id = SettingId::enable_bd_dehumidify}, + {.setting_id = SettingId::bd_dehumidify_threshold}, + {.setting_id = SettingId::enable_ad_dehumidify}, + {.setting_id = SettingId::ad_dehumidify_threshold}, + {.setting_id = SettingId::enable_ad_degrade}, + {.setting_id = SettingId::ad_degrade_threshold}, {.setting_id = SettingId::dvalue_correct_coefficient}, }; diff --git a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp index 29c5cbd..6ee3a00 100644 --- a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp +++ b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp @@ -214,7 +214,7 @@ void DisinfectionCtrlService::checkBeforeStart() { void DisinfectionCtrlService::startWorkThread() { resetState(); - + handlePumpStopFlag = false; m_thread.reset(new Thread("DisinfectionStateMachineThread", [this]() { DS->setDeviceState(DeviceState::Disinfection); logger->info("DisinfectionStateMachineThread start"); @@ -550,8 +550,10 @@ void DisinfectionCtrlService::processStateDisinfection(DisinfectionEvent* event) } else { if (isTimeToResumeDisinfection()) { logger->info("resumeDisinfection"); - dics->AC_ctrl(1); - dics->SprayPump_start(getSettingAsInt(SettingId::injection_pump_speed)); + if (!handlePumpStopFlag) { + dics->AC_ctrl(1); + dics->SprayPump_start(getSettingAsInt(SettingId::injection_pump_speed)); + } s_isDisinfectionTakeBreak = false; tryLogState(true); } @@ -596,11 +598,35 @@ void DisinfectionCtrlService::processStateDisinfection(DisinfectionEvent* event) // 检查是否消毒完成 } else if (event->event == kevent_update_cfg) { - if (!s_isDisinfectionTakeBreak) { + if (!s_isDisinfectionTakeBreak && !handlePumpStopFlag) { + dics->AC_ctrl(1); dics->SprayPump_start(getSettingAsInt(SettingId::injection_pump_speed)); } + if (handlePumpStopFlag) { + dics->SprayPump_stop(); + dics->AC_close(); + } } } + +// void DisinfectionCtrlService::setHandleStopPumpInjectionFlag() { +// handlePumpStopFlag = true; +// updateCfg(); +// } +// void DisinfectionCtrlService::clearHandleStopPumpInjectionFlag() { +// handlePumpStopFlag = false; +// updateCfg(); +// } + +void DisinfectionCtrlService::handleStopPumpInjection() { + handlePumpStopFlag = true; + updateCfg(); +} +void DisinfectionCtrlService::handleStartPumpInjection() { + handlePumpStopFlag = false; + updateCfg(); +} + void DisinfectionCtrlService::processStateEmpytLiquidFromTheLine(DisinfectionEvent* event) { if (event->event == kevent_enter_state) { tryLogState(true); diff --git a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp index e5f0adf..70a794b 100644 --- a/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp +++ b/appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp @@ -61,6 +61,8 @@ class DisinfectionCtrlService : public enable_shared_from_this syncState) { sm.getStateSafeBlock(syncState); } + // void clearHandleStopPumpInjectionFlag(); + // void setHandleStopPumpInjectionFlag(); + void handleStopPumpInjection(); + void handleStartPumpInjection(); + + + bool getHandlePumpStopFlag() { return handlePumpStopFlag; } + map& getRealtimeCfg() { return m_realtimeCfg; } DisinfectionState getState() { return sm.getState(); } int getCurStateRemainTimeS() { return s_remaintime; } diff --git a/appsrc/service/app/disinfection_ctrl_service_ext.cpp b/appsrc/service/app/disinfection_ctrl_service_ext.cpp index 06343e8..62a150b 100644 --- a/appsrc/service/app/disinfection_ctrl_service_ext.cpp +++ b/appsrc/service/app/disinfection_ctrl_service_ext.cpp @@ -52,6 +52,11 @@ void DisinfectionCtrlServiceExt::initialize() { REG_EXTFN_VOID(getServiceConfig, void()); REG_EXTFN_VOID(startStateReport, void()); REG_EXTFN_VOID(stopStateReport, void()); + REG_EXTFN_VOID(handleStopPumpInjection, void()); + REG_EXTFN_VOID(handleStartPumpInjection, void()); + REG_EXTFN_VOID(setHandleStopPumpInjectionFlag, void()); + REG_EXTFN_VOID(clearHandleStopPumpInjectionFlag, void()); + stateUpdateThread.reset(new Thread("DisinfectionCtrlServiceExt-stateUpdateThread", [this]() { ThisThread thisThread; @@ -109,7 +114,23 @@ void DisinfectionCtrlServiceExt::setRealtimeConfig(shared_ptr dcs->getRealtimeCfg()[key] = val; dcs->updateCfg(); } +void DisinfectionCtrlServiceExt::handleStopPumpInjection(shared_ptr cxt) { + dcs->handleStopPumpInjection(); + if (stateUpdateThread) stateUpdateThread->wake(); +} +void DisinfectionCtrlServiceExt::handleStartPumpInjection(shared_ptr cxt) { + dcs->handleStartPumpInjection(); + if (stateUpdateThread) stateUpdateThread->wake(); +} +void DisinfectionCtrlServiceExt::clearHandleStopPumpInjectionFlag(shared_ptr cxt) { + dcs->handleStopPumpInjection(); + if (stateUpdateThread) stateUpdateThread->wake(); +} +void DisinfectionCtrlServiceExt::setHandleStopPumpInjectionFlag(shared_ptr cxt) { + dcs->handleStartPumpInjection(); + if (stateUpdateThread) stateUpdateThread->wake(); +} void DisinfectionCtrlServiceExt::getState(shared_ptr cxt) { cxt->rely = getState(); } json DisinfectionCtrlServiceExt::getState() { json rely; @@ -123,6 +144,7 @@ json DisinfectionCtrlServiceExt::getState() { rely["injectedVelocity"] = dcs->getInjectedVelocity(); rely["startTimestamp"] = dcs->getStartTP(); rely["completeTimestamp"] = dcs->getCompleteTP(); + rely["handlePumpStopFlag"] = dcs->getHandlePumpStopFlag(); }); return rely; } diff --git a/appsrc/service/app/disinfection_ctrl_service_ext.hpp b/appsrc/service/app/disinfection_ctrl_service_ext.hpp index 4186d9d..68e5777 100644 --- a/appsrc/service/app/disinfection_ctrl_service_ext.hpp +++ b/appsrc/service/app/disinfection_ctrl_service_ext.hpp @@ -44,6 +44,12 @@ class DisinfectionCtrlServiceExt : public enable_shared_from_this cxt, string key, string val); void updateTargetLogLevel(shared_ptr cxt, float loglevel); + void clearHandleStopPumpInjectionFlag(shared_ptr cxt); + void setHandleStopPumpInjectionFlag(shared_ptr cxt); + + void handleStopPumpInjection(shared_ptr cxt); + void handleStartPumpInjection(shared_ptr cxt); + /******************************************************************************* * 状态 * *******************************************************************************/ @@ -55,7 +61,7 @@ class DisinfectionCtrlServiceExt : public enable_shared_from_thisgetState(); } - int64_t getDisinfectionStartTP() { return dcs->getStartTP(); } + int64_t getDisinfectionStartTP() { return dcs->getStartTP(); } }; } // namespace iflytop \ No newline at end of file diff --git a/appsrc/service/os_mgr_service.cpp b/appsrc/service/os_mgr_service.cpp index 579e8af..3367fa4 100644 --- a/appsrc/service/os_mgr_service.cpp +++ b/appsrc/service/os_mgr_service.cpp @@ -35,4 +35,15 @@ void OsMgrService::updateTime(shared_ptr cxt, int hour, int m dosystem(fmt::format("hwclock -w").c_str()); } -void OsMgrService::getTime(shared_ptr cxt) { cxt->rely["time"] = duration_cast(system_clock::now().time_since_epoch()).count(); } +void OsMgrService::getTime(shared_ptr cxt) { + // cxt->rely["time"] = duration_cast(system_clock::now().time_since_epoch()).count(); + + struct timeval tv; + gettimeofday(&tv, NULL); + + // 计算毫秒级 Unix 时间戳 + // TODO: 修改成时区来自系统 + long long timestamp_ms = (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000; + timestamp_ms += 8 * 3600 * 1000; // 转换为北京时间(UTC+8) + cxt->rely["time"] = timestamp_ms; +}