diff --git a/appdep/iflytop/core/thread/thread.cpp b/appdep/iflytop/core/thread/thread.cpp index a21a16f..dc7f14a 100644 --- a/appdep/iflytop/core/thread/thread.cpp +++ b/appdep/iflytop/core/thread/thread.cpp @@ -19,12 +19,12 @@ using namespace iflytop; using namespace core; using namespace moodycamel; -static std::mutex m_threadinfolock; +static std::mutex m_threadinfolock; static map m_thread_map; Thread::Thread(std::function run) { Thread("notSet", run); } Thread::Thread(string name, function run) { - this->run = run; + this->run = run; this->name = name; if (this->run == nullptr) { throw zexception("Create Thread run == nullptr"); @@ -69,6 +69,15 @@ void Thread::join() { } } }; + +void Thread::stopNoBlock() { + std::lock_guard lock(lock_); + if (!hasJointd) { + exitFlag = true; + signal.notify(); + } +} + Thread::~Thread() { if (!hasJointd) { logger->error(fmt::format("fatal error,thread {} unjoin ", name)); diff --git a/appdep/iflytop/core/thread/thread.hpp b/appdep/iflytop/core/thread/thread.hpp index 01a73e2..504e5f3 100644 --- a/appdep/iflytop/core/thread/thread.hpp +++ b/appdep/iflytop/core/thread/thread.hpp @@ -46,6 +46,7 @@ class Thread { Thread(string name, function run); void wake(); void join(); + void stopNoBlock(); bool isWaitingForJoin() { return waitingForJoin; } bool getExitFlag() { return exitFlag; } pthread_t getId() const; diff --git a/appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp b/appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp index fe83444..1e4927f 100644 --- a/appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp +++ b/appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp @@ -28,8 +28,16 @@ class AppCheckPointCheckFailEvent : public IAppEvent { AppCheckPointCheckFailEvent(vector checkpoint) : IAppEvent(AppEventType::AppCheckPointCheckFailEvent) { errCheckPoints = checkpoint; } virtual ~AppCheckPointCheckFailEvent() {} - NLOHMANN_DEFINE_TYPE_INTRUSIVE(AppCheckPointCheckFailEvent, uuid, type); - virtual json toJson() { return json(*this); } + // NLOHMANN_DEFINE_TYPE_INTRUSIVE(AppCheckPointCheckFailEvent, errCheckPoints, uuid, type); + virtual json toJson() { + // return json(*this); + json j; + j["uuid"] = uuid; + j["type"] = type; + j["errCheckPoints"] = errCheckPoints; + return j; + + } }; } // namespace iflytop \ No newline at end of file diff --git a/appsrc/appconfig/basic/zappversion.hpp b/appsrc/appconfig/basic/zappversion.hpp index 5e45177..75ef06e 100644 --- a/appsrc/appconfig/basic/zappversion.hpp +++ b/appsrc/appconfig/basic/zappversion.hpp @@ -1,3 +1,3 @@ #pragma once -#define VERSION "2.0.6" +#define VERSION "2.0.8" #define PROJECT_NAME "TRANSMIT_DM" \ No newline at end of file diff --git a/appsrc/service/app/add_liquid_service.cpp b/appsrc/service/app/add_liquid_service.cpp index 225a8e4..33b9790 100644 --- a/appsrc/service/app/add_liquid_service.cpp +++ b/appsrc/service/app/add_liquid_service.cpp @@ -123,21 +123,20 @@ void AddLiquidService::addLiquidWork(int stopatg, bool& errorflag) { /** * @brief 停止加液 */ + logger->info("stop add liquid"); m_dics->AddLiquidPump_stop(); - thisThread.sleepForMs(2500); - /** * @brief 选择排空管路通道 */ logger->info("start drain the liquid from the line"); m_workstate = kemptyLineLiquid; + usleep(1500 * 1000); m_dics->setAddFluidChannelSelectorValve(false); m_dics->AddLiquidPump_run(-GET_SETTING(int, SettingId::drainage_pump_speed)); // 等待 30s 排空管路 for (size_t i = 0; i < EMTPTY_LINE_WHEN_ADDING_DISINFECTANT_TIMES; i++) { - if (thisThread.getExitFlag()) break; - thisThread.sleepForMs(100); + usleep(1000 * 100); if (i % 10 == 0) logger->info("empty line liquid {}:{} s", i * 100 / 1000, EMTPTY_LINE_WHEN_ADDING_DISINFECTANT_TIMES * 100 / 1000.0); } m_dics->AddLiquidPump_stop(); @@ -145,14 +144,12 @@ void AddLiquidService::addLiquidWork(int stopatg, bool& errorflag) { void AddLiquidService::stop() { lock_guard lock(lock_); - if (m_workstate == kidle) { + if (m_workstate == kidle || m_workstate == kemptyLineLiquid) { return; } - m_workstate = kidle; - if (m_thread) { - m_thread->join(); - m_thread = nullptr; + if (m_thread && !m_thread->getExitFlag()) { + m_thread->stopNoBlock(); } logger->info("stoped add liquid"); } diff --git a/appsrc/service/app/drain_liquid_service.cpp b/appsrc/service/app/drain_liquid_service.cpp index 04564d9..a3fdb0d 100644 --- a/appsrc/service/app/drain_liquid_service.cpp +++ b/appsrc/service/app/drain_liquid_service.cpp @@ -170,7 +170,8 @@ void DrainLiquidService::workThread() { logger->info("stopDraining"); m_dics->AddLiquidPump_stop(); - thisThread.sleepForMs(1000); + // thisThread.sleepForMs(1000); + usleep(1500 * 1000); m_dics->setAddFluidChannelSelectorValve(false); } @@ -194,9 +195,8 @@ void DrainLiquidService::startStateReport(shared_ptr cxt) { })); } void DrainLiquidService::stopStateReport(shared_ptr cxt) { - if (stateUpdateThread) { - stateUpdateThread->join(); - stateUpdateThread = nullptr; + if (stateUpdateThread && !stateUpdateThread->getExitFlag()) { + stateUpdateThread->stopNoBlock(); } } json DrainLiquidService::getState() { diff --git a/appsrc/service/debug_page_test_service.cpp b/appsrc/service/debug_page_test_service.cpp index 4087c01..932eed8 100644 --- a/appsrc/service/debug_page_test_service.cpp +++ b/appsrc/service/debug_page_test_service.cpp @@ -128,9 +128,15 @@ void DebugPageTestService::triggerPromptEvent(shared_ptr cxt, } void DebugPageTestService::triggerAppCheckPointFailEvent(shared_ptr cxt) { // vector checkPoints; - CheckPoint checkPoint(kCheckPointCode_evaporationBinWSTrigger, "消毒蒸发仓位传感器触发", false); - checkPoint.ecode = err::kappe_the_evaporation_bin_has_water; - checkPoints.push_back(checkPoint); + + auto cp1 = CheckPoint(kCheckPointCode_evaporationBinWSTrigger, "蒸发仓内液位检查", true); + auto cp2 = CheckPoint(kCheckPointCode_deviceBottomWSTrigger, "硬件仓液位检测", true); + + cp1.ecode = err::kappe_the_evaporation_bin_has_water; + cp1.ecodeInfo = ecode2str(cp1.ecode); + cp2.ecode = err::kappe_the_bottom_of_the_device_has_water; + cp2.ecodeInfo = ecode2str(cp2.ecode); + checkPoints.push_back(cp1); AppEventBus::ins()->push(make_shared(checkPoints)); }