diff --git a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp index 409601c..6e66ca5 100644 --- a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp +++ b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp @@ -195,6 +195,7 @@ shared_ptr ZSCanProtocolCom::base_callcmd(int32_t to, int32_t cmdid, ui shared_ptr ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t *param, int32_t paramLen, int32_t overtime) { shared_ptr receipt; + lock_guard lock(m_lock); usleep(10 * 1000); for (size_t i = 0; i <= 3; i++) { diff --git a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp index 72bac29..fa9c41d 100644 --- a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp +++ b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.hpp @@ -72,6 +72,9 @@ class ZSCanProtocolCom { RxReceiptContext m_rxReceiptContext; mutex m_rxReceiptContext_lock; + mutex m_lock; + + /******************************************************************************* * TX CONTEXT * *******************************************************************************/ diff --git a/appsrc/service/app/add_liquid_service.cpp b/appsrc/service/app/add_liquid_service.cpp index 97e8e00..dc3a31f 100644 --- a/appsrc/service/app/add_liquid_service.cpp +++ b/appsrc/service/app/add_liquid_service.cpp @@ -124,6 +124,7 @@ void AddLiquidService::addLiquidWork(int stopatg, bool& errorflag) { for (size_t i = 0; i < EMTPTY_LINE_WHEN_ADDING_DISINFECTANT_TIMES; i++) { if (thisThread.getExitFlag()) break; thisThread.sleepForMs(100); + logger->info("empty line liquid {}:{}", i * 100, EMTPTY_LINE_WHEN_ADDING_DISINFECTANT_TIMES * 100); } m_dics->AddLiquidPump_stop(); m_dics->SprayPump_stop(); diff --git a/appsrc/service/app/drain_liquid_service.cpp b/appsrc/service/app/drain_liquid_service.cpp index db7cd26..1031d5a 100644 --- a/appsrc/service/app/drain_liquid_service.cpp +++ b/appsrc/service/app/drain_liquid_service.cpp @@ -63,7 +63,17 @@ void DrainLiquidService::start() { } DrainLiquidService::state_t DrainLiquidService::getWorkstate() { return m_workstate; } -void DrainLiquidService::stop() { m_workstate = kidle; } +void DrainLiquidService::stop() { + lock_guard lock(lock_); + if (m_thread) { + m_thread->join(); + m_thread = nullptr; + } + m_workstate = kidle; + m_dics->AddLiquidPump_stop(); + m_dics->SprayPump_stop(); + logger->info("stopDraining "); +} void DrainLiquidService::start(shared_ptr cxt) { // start(); diff --git a/appsrc/service/app_core.cpp b/appsrc/service/app_core.cpp index 896efef..b87c9e9 100644 --- a/appsrc/service/app_core.cpp +++ b/appsrc/service/app_core.cpp @@ -201,8 +201,7 @@ void AppCore::initialize() { } }); - // REG_EXTFN_VOID(getState, void(void)); - + REG_EXTFN_VOID(getState, void(void)); REG_EXTFN(promptConfirm, void(string), promptId); REG_EXTFN_VOID(promptGetAll, void(void)); REG_EXTFN_VOID(promptGetNext, void(void)); diff --git a/appsrc/service/hardware/disinfectant_weight_update_service.cpp b/appsrc/service/hardware/disinfectant_weight_update_service.cpp index 9a516d1..d885e95 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); } - sleep(1); + usleep(500); } } \ 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 098800e..cfb8934 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 = {20}; + MovingAverageFilter filter = {10}; float weightCache = 0; public: