From 7daa234377bf222be84b321c9a94180ac89630fb Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 21 Aug 2024 17:06:17 +0800 Subject: [PATCH] update --- appsrc/service/app/add_liquid_service.cpp | 10 +++++----- appsrc/service/app/air_leak_detect_test.cpp | 11 +++++++++-- appsrc/service/app/drain_liquid_service.cpp | 2 ++ appsrc/service/hardware/device_io_ctrl_service.cpp | 6 +++--- .../service/hardware/disinfectant_weight_update_service.cpp | 2 +- .../service/hardware/disinfectant_weight_update_service.hpp | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/appsrc/service/app/add_liquid_service.cpp b/appsrc/service/app/add_liquid_service.cpp index 884a757..3faed61 100644 --- a/appsrc/service/app/add_liquid_service.cpp +++ b/appsrc/service/app/add_liquid_service.cpp @@ -22,7 +22,9 @@ void AddLiquidService::initialize() { void AddLiquidService::start(int stopatg) { lock_guard lock(lock_); - auto nowstate = m_ds->getDeviceState(); + + auto nowstate = m_ds->getDeviceState(); + if (nowstate != DeviceState::Idle) { logger->warn("start add liquid fail, device state is not idle"); THROW_APP_EXCEPTION(getDeviceBusyReason(nowstate), ""); @@ -32,10 +34,6 @@ void AddLiquidService::start(int stopatg) { THROW_APP_EXCEPTION(err::kappe_exception_flag_is_setted, ""); } - if (DS->getDeviceState() != DeviceState::Idle) { - THROW_APP_EXCEPTION(err::kappe_state_is_busy, ""); - } - if (zsteady_clock().gets() < SENSOR_PREHEART_TIME_S) { THROW_APP_EXCEPTION(err::kappe_sensor_is_pre_hearting, ""); } @@ -67,6 +65,7 @@ void AddLiquidService::start(int stopatg) { } m_workstate = kaddingLiquid; + DS->setDeviceState(DeviceState::AddingLiquid); m_thread.reset(new Thread("addLiquid", [this, stopatg]() { ThisThread thisThread; bool errorflag = false; @@ -83,6 +82,7 @@ void AddLiquidService::start(int stopatg) { GET_SERVICE(IflytopFrontEndService)->sendPrompt("加液完成"); } m_workstate = kidle; + DS->setDeviceState(DeviceState::Idle); })); // logger->info("start add liquid success"); diff --git a/appsrc/service/app/air_leak_detect_test.cpp b/appsrc/service/app/air_leak_detect_test.cpp index 877f14a..8b35370 100644 --- a/appsrc/service/app/air_leak_detect_test.cpp +++ b/appsrc/service/app/air_leak_detect_test.cpp @@ -14,12 +14,18 @@ void AirLeakDetectTest::initialize() { REG_EXTFN_VOID(stop, void()); REG_EXTFN_VOID(getState, void()); REG_EXTFN_VOID(getServiceConfig, void()); - } void AirLeakDetectTest::start() { logger->info("AirLeakDetectTest start"); + auto nowstate = m_ds->getDeviceState(); + if (nowstate != DeviceState::Idle) { + logger->warn("start add liquid fail, device state is not idle"); + THROW_APP_EXCEPTION(getDeviceBusyReason(nowstate), ""); + } + m_workstate = kinitDevice; + DS->setDeviceState(DeviceState::AirLeakDetectTesting); m_thread.reset(new Thread("AirLeakDetectTestThread", [this]() { try { airLeakDetectTestThread(); @@ -35,6 +41,7 @@ void AirLeakDetectTest::start() { } m_workstate = kidle; + DS->setDeviceState(DeviceState::Idle); })); } void AirLeakDetectTest::stop() { @@ -105,6 +112,6 @@ void AirLeakDetectTest::getServiceConfig(shared_ptr cxt) { cfg["pressureMax"] = 8.0; cfg["show"] = true; cfg["updatePeriod"] = 300; - cxt->rely = cfg; + cxt->rely = cfg; } } \ No newline at end of file diff --git a/appsrc/service/app/drain_liquid_service.cpp b/appsrc/service/app/drain_liquid_service.cpp index 1031d5a..deadc94 100644 --- a/appsrc/service/app/drain_liquid_service.cpp +++ b/appsrc/service/app/drain_liquid_service.cpp @@ -51,6 +51,7 @@ void DrainLiquidService::start() { } m_workstate = kwork; + DS->setDeviceState(DeviceState::DrainingLiquid); m_thread.reset(new Thread("drainLiquid", [this]() { try { workThread(); @@ -59,6 +60,7 @@ void DrainLiquidService::start() { DS->setAppExceptionFlag(e); } m_workstate = kidle; + DS->setDeviceState(DeviceState::Idle); })); } DrainLiquidService::state_t DrainLiquidService::getWorkstate() { return m_workstate; } diff --git a/appsrc/service/hardware/device_io_ctrl_service.cpp b/appsrc/service/hardware/device_io_ctrl_service.cpp index 8f5adf7..f648a2e 100644 --- a/appsrc/service/hardware/device_io_ctrl_service.cpp +++ b/appsrc/service/hardware/device_io_ctrl_service.cpp @@ -256,7 +256,7 @@ int DeviceIoControlService::AC_close() { return 0; } float DeviceIoControlService::AC_readEI() { - logger->info(" AC_readEI"); + // logger->info(" AC_readEI"); if (!isInTestMode()) return CAN_MASTER->airCompressorReadEI(GET_BOARDID()) / 1000.0; return 0; } @@ -276,12 +276,12 @@ int DeviceIoControlService::Heater_close() { return 0; } float DeviceIoControlService::Heater_readEI() { - logger->info(" Heater_readEI"); + // logger->info(" Heater_readEI"); if (!isInTestMode()) return CAN_MASTER->heaterReadEI(GET_BOARDID()) / 1000.0; return 0; } float DeviceIoControlService::Heater_readTemperature() { - logger->info(" Heater_readTemperature"); + // logger->info(" Heater_readTemperature"); if (!isInTestMode()) return CAN_MASTER->heaterReadTemperature(GET_BOARDID()) / 10.0; return 0; } diff --git a/appsrc/service/hardware/disinfectant_weight_update_service.cpp b/appsrc/service/hardware/disinfectant_weight_update_service.cpp index fc28817..fd8192c 100644 --- a/appsrc/service/hardware/disinfectant_weight_update_service.cpp +++ b/appsrc/service/hardware/disinfectant_weight_update_service.cpp @@ -47,6 +47,6 @@ void DisinfectantWeightUpdateService::updateWeightThread() { logger->error("updateWeightThread error: {}", e.what()); DS->setAppExceptionFlag(e); } - usleep(500); + usleep(1000*1000); } } \ No newline at end of file diff --git a/appsrc/service/hardware/disinfectant_weight_update_service.hpp b/appsrc/service/hardware/disinfectant_weight_update_service.hpp index cfb8934..3b529b6 100644 --- a/appsrc/service/hardware/disinfectant_weight_update_service.hpp +++ b/appsrc/service/hardware/disinfectant_weight_update_service.hpp @@ -38,7 +38,7 @@ class DisinfectantWeightUpdateService : public enable_shared_from_this updateThread; shared_ptr deviceIoControlService; - MovingAverageFilter filter = {10}; + MovingAverageFilter filter = {5}; float weightCache = 0; public: