Browse Source

fix some bug

master
zhaohe 8 months ago
parent
commit
993cd0779c
  1. 13
      appdep/iflytop/core/thread/thread.cpp
  2. 1
      appdep/iflytop/core/thread/thread.hpp
  3. 12
      appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp
  4. 2
      appsrc/appconfig/basic/zappversion.hpp
  5. 15
      appsrc/service/app/add_liquid_service.cpp
  6. 8
      appsrc/service/app/drain_liquid_service.cpp
  7. 12
      appsrc/service/debug_page_test_service.cpp

13
appdep/iflytop/core/thread/thread.cpp

@ -19,12 +19,12 @@ using namespace iflytop;
using namespace core; using namespace core;
using namespace moodycamel; using namespace moodycamel;
static std::mutex m_threadinfolock;
static std::mutex m_threadinfolock;
static map<pthread_t, Thread *> m_thread_map; static map<pthread_t, Thread *> m_thread_map;
Thread::Thread(std::function<void()> run) { Thread("notSet", run); } Thread::Thread(std::function<void()> run) { Thread("notSet", run); }
Thread::Thread(string name, function<void()> run) { Thread::Thread(string name, function<void()> run) {
this->run = run;
this->run = run;
this->name = name; this->name = name;
if (this->run == nullptr) { if (this->run == nullptr) {
throw zexception("Create Thread run == nullptr"); throw zexception("Create Thread run == nullptr");
@ -69,6 +69,15 @@ void Thread::join() {
} }
} }
}; };
void Thread::stopNoBlock() {
std::lock_guard<std::mutex> lock(lock_);
if (!hasJointd) {
exitFlag = true;
signal.notify();
}
}
Thread::~Thread() { Thread::~Thread() {
if (!hasJointd) { if (!hasJointd) {
logger->error(fmt::format("fatal error,thread {} unjoin ", name)); logger->error(fmt::format("fatal error,thread {} unjoin ", name));

1
appdep/iflytop/core/thread/thread.hpp

@ -46,6 +46,7 @@ class Thread {
Thread(string name, function<void()> run); Thread(string name, function<void()> run);
void wake(); void wake();
void join(); void join();
void stopNoBlock();
bool isWaitingForJoin() { return waitingForJoin; } bool isWaitingForJoin() { return waitingForJoin; }
bool getExitFlag() { return exitFlag; } bool getExitFlag() { return exitFlag; }
pthread_t getId() const; pthread_t getId() const;

12
appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp

@ -28,8 +28,16 @@ class AppCheckPointCheckFailEvent : public IAppEvent {
AppCheckPointCheckFailEvent(vector<CheckPoint> checkpoint) : IAppEvent(AppEventType::AppCheckPointCheckFailEvent) { errCheckPoints = checkpoint; } AppCheckPointCheckFailEvent(vector<CheckPoint> checkpoint) : IAppEvent(AppEventType::AppCheckPointCheckFailEvent) { errCheckPoints = checkpoint; }
virtual ~AppCheckPointCheckFailEvent() {} 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 } // namespace iflytop

2
appsrc/appconfig/basic/zappversion.hpp

@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION "2.0.6"
#define VERSION "2.0.8"
#define PROJECT_NAME "TRANSMIT_DM" #define PROJECT_NAME "TRANSMIT_DM"

15
appsrc/service/app/add_liquid_service.cpp

@ -123,21 +123,20 @@ void AddLiquidService::addLiquidWork(int stopatg, bool& errorflag) {
/** /**
* @brief * @brief
*/ */
logger->info("stop add liquid");
m_dics->AddLiquidPump_stop(); m_dics->AddLiquidPump_stop();
thisThread.sleepForMs(2500);
/** /**
* @brief * @brief
*/ */
logger->info("start drain the liquid from the line"); logger->info("start drain the liquid from the line");
m_workstate = kemptyLineLiquid; m_workstate = kemptyLineLiquid;
usleep(1500 * 1000);
m_dics->setAddFluidChannelSelectorValve(false); m_dics->setAddFluidChannelSelectorValve(false);
m_dics->AddLiquidPump_run(-GET_SETTING(int, SettingId::drainage_pump_speed)); m_dics->AddLiquidPump_run(-GET_SETTING(int, SettingId::drainage_pump_speed));
// 等待 30s 排空管路 // 等待 30s 排空管路
for (size_t i = 0; i < EMTPTY_LINE_WHEN_ADDING_DISINFECTANT_TIMES; i++) { 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); 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(); m_dics->AddLiquidPump_stop();
@ -145,14 +144,12 @@ void AddLiquidService::addLiquidWork(int stopatg, bool& errorflag) {
void AddLiquidService::stop() { void AddLiquidService::stop() {
lock_guard<recursive_mutex> lock(lock_); lock_guard<recursive_mutex> lock(lock_);
if (m_workstate == kidle) {
if (m_workstate == kidle || m_workstate == kemptyLineLiquid) {
return; 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"); logger->info("stoped add liquid");
} }

8
appsrc/service/app/drain_liquid_service.cpp

@ -170,7 +170,8 @@ void DrainLiquidService::workThread() {
logger->info("stopDraining"); logger->info("stopDraining");
m_dics->AddLiquidPump_stop(); m_dics->AddLiquidPump_stop();
thisThread.sleepForMs(1000);
// thisThread.sleepForMs(1000);
usleep(1500 * 1000);
m_dics->setAddFluidChannelSelectorValve(false); m_dics->setAddFluidChannelSelectorValve(false);
} }
@ -194,9 +195,8 @@ void DrainLiquidService::startStateReport(shared_ptr<MsgProcessContext> cxt) {
})); }));
} }
void DrainLiquidService::stopStateReport(shared_ptr<MsgProcessContext> cxt) { void DrainLiquidService::stopStateReport(shared_ptr<MsgProcessContext> cxt) {
if (stateUpdateThread) {
stateUpdateThread->join();
stateUpdateThread = nullptr;
if (stateUpdateThread && !stateUpdateThread->getExitFlag()) {
stateUpdateThread->stopNoBlock();
} }
} }
json DrainLiquidService::getState() { json DrainLiquidService::getState() {

12
appsrc/service/debug_page_test_service.cpp

@ -128,9 +128,15 @@ void DebugPageTestService::triggerPromptEvent(shared_ptr<MsgProcessContext> cxt,
} }
void DebugPageTestService::triggerAppCheckPointFailEvent(shared_ptr<MsgProcessContext> cxt) { // void DebugPageTestService::triggerAppCheckPointFailEvent(shared_ptr<MsgProcessContext> cxt) { //
vector<CheckPoint> checkPoints; vector<CheckPoint> 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<AppCheckPointCheckFailEvent>(checkPoints)); AppEventBus::ins()->push(make_shared<AppCheckPointCheckFailEvent>(checkPoints));
} }
Loading…
Cancel
Save