Browse Source

v2.4.3 | 去掉设备自检服务

master
zhaohe 1 month ago
parent
commit
9c541e56ec
  1. 9
      appsrc/service/app_core.cpp
  2. 108
      appsrc/service/device_check_point_check_service.cpp
  3. 95
      appsrc/service/device_monitor_service.cpp
  4. 17
      appsrc/service/device_monitor_service.hpp

9
appsrc/service/app_core.cpp

@ -12,7 +12,7 @@
#include "service/test_page_ctrl_service.hpp"
#include "service/user_mgr_service.hpp"
//
#include "device_check_point_check_service.hpp"
#include "device_monitor_service.hpp"
#include "service/app/add_liquid_service.hpp"
#include "service/app/air_leak_detect_test.hpp"
#include "service/app/disinfection_ctrl_service_ext.hpp"
@ -26,9 +26,9 @@
#include "baseservice/db/device_ext_setting_dao.hpp"
#include "calibration/h2o2_liquid_weight_sensor_calibration_service.hpp"
#include "equipment_usage_info_mgr_service.hpp"
#include "service/hardware/h2o2_sensor_state_sync.hpp"
#include "service/hardware/sensor_state_sync_service.hpp"
#include "setting/ext_setting_mgr_service.hpp"
#include "service/hardware/h2o2_sensor_state_sync.hpp"
// DeviceExtSettingDAO
@ -144,7 +144,7 @@ void AppCore::initialize() {
BUILD_AND_REG_SERRVICE(WarningLightControler);
BUILD_AND_REG_SERRVICE(SensorStateSyncService);
BUILD_AND_REG_SERRVICE(H2O2SensorStateSyncService);
//
BUILD_AND_REG_SERRVICE(PipelinePressureControl);
BUILD_AND_REG_SERRVICE(UDiskMgrService);
@ -169,11 +169,12 @@ void AppCore::initialize() {
BUILD_AND_REG_SERRVICE(DisinfectionCtrlServiceExt);
BUILD_AND_REG_SERRVICE(DrainLiquidService);
BUILD_AND_REG_SERRVICE(DebugPageTestService);
BUILD_AND_REG_SERRVICE(DeviceCheckPointCheckService);
BUILD_AND_REG_SERRVICE(H2O2LiquidWeightSensorCalibrationService); // H2O2液体重量传感器校准
BUILD_AND_REG_SERRVICE(ExtSettingMgrService);
BUILD_AND_REG_SERRVICE(EquipmentUsageInfoMgrService);
BUILD_AND_REG_SERRVICE(DeviceMonitorService);
// int cnt = 0;
// while (true) {
// uint64_t tp = zsys_get_ticket();

108
appsrc/service/device_check_point_check_service.cpp

@ -1,108 +0,0 @@
#include "device_check_point_check_service.hpp"
#include "service/app/add_liquid_service.hpp"
#include "service/app/air_leak_detect_test.hpp"
#include "service/app/disinfection_ctrl/disinfection_ctrl_service.hpp"
#include "service/app/drain_liquid_service.hpp"
#include "service/hardware/device_io_ctrl_service.hpp"
using namespace iflytop;
void DeviceCheckPointCheckService::initialize() { //
checkPoints.push_back(CheckPoint(kCheckPointCode_evaporationBinWSTrigger, "蒸发仓内液位检查", true));
checkPoints.push_back(CheckPoint(kCheckPointCode_deviceBottomWSTrigger, "硬件仓液位检测", true));
REG_TYPE(CheckPoint);
REG_TYPE(vector<CheckPoint>);
REG_FN_VOID(getAllCheckPoints, vector<CheckPoint>(void));
REG_FN_VOID(isPassed, bool(void));
m_thread.reset(new Thread("DeviceCheckPointCheckServiceThread", [this]() {
while (true) {
sleep(1);
if (!DS->isLogin()) {
resetPassState();
continue;
}
// // 非空闲状态不检查
// if (DS->getDeviceState() != DeviceState::Idle) {
// continue;
// }
bool oldstate = isPassed();
// logger->info("DeviceCheckPointCheckServiceThread");
// 检查各个检查点
for (auto& checkPoint : checkPoints) {
CheckPointCode_t checkPointIndex = checkPoint.index;
try {
if (checkPointIndex == kCheckPointCode_evaporationBinWSTrigger) {
if (GET_SERVICE(DeviceIoControlService)->WaterSensor_readEvaporationBin()) {
checkPoint.passed = false;
checkPoint.ecode = err::kappe_the_evaporation_bin_has_water;
checkPoint.ecodeInfo = ecode2str(checkPoint.ecode);
} else {
checkPoint.passed = true;
checkPoint.ecode = 0;
}
} else if (checkPointIndex == kCheckPointCode_deviceBottomWSTrigger) {
if (GET_SERVICE(DeviceIoControlService)->WaterSensor_readDeviceBottom()) {
checkPoint.passed = false;
checkPoint.ecode = err::kappe_the_bottom_of_the_device_has_water;
checkPoint.ecodeInfo = ecode2str(checkPoint.ecode);
} else {
checkPoint.passed = true;
checkPoint.ecode = 0;
}
}
} catch (const std::exception& e) {
//
// 硬件错误这里不做处理
}
}
bool newstate = isPassed();
if (newstate != oldstate) {
if (!newstate) {
if (DS->getDeviceState() == DeviceState::Disinfection) {
GET_SERVICE(DisinfectionCtrlService)->stop();
} else if (DS->getDeviceState() == DeviceState::AddingLiquid) {
GET_SERVICE(AddLiquidService)->stop();
} else if (DS->getDeviceState() == DeviceState::DrainingLiquid) {
GET_SERVICE(DrainLiquidService)->stop();
} else if (DS->getDeviceState() == DeviceState::AirLeakDetectTesting) {
GET_SERVICE(AirLeakDetectTest)->stop();
}
vector<CheckPoint> errCheckPoints;
for (auto& checkPoint : checkPoints) {
if (!checkPoint.passed) {
errCheckPoints.push_back(checkPoint);
}
}
AppEventBus::ins()->push(make_shared<AppCheckPointCheckFailEvent>(errCheckPoints));
}
}
}
}));
}
vector<CheckPoint> DeviceCheckPointCheckService::getAllCheckPoints() { return checkPoints; }
void DeviceCheckPointCheckService::resetPassState() {
for (auto& checkPoint : checkPoints) {
checkPoint.passed = true;
}
}
bool DeviceCheckPointCheckService::isPassed() {
for (auto& checkPoint : checkPoints) {
if (!checkPoint.passed) {
return false;
}
}
return true;
}

95
appsrc/service/device_monitor_service.cpp

@ -0,0 +1,95 @@
#include "device_monitor_service.hpp"
#include "service/app/add_liquid_service.hpp"
#include "service/app/air_leak_detect_test.hpp"
#include "service/app/disinfection_ctrl/disinfection_ctrl_service.hpp"
#include "service/app/drain_liquid_service.hpp"
#include "service/hardware/device_io_ctrl_service.hpp"
using namespace iflytop;
void DeviceMonitorService::initialize() { //
m_thread.reset(new Thread("DeviceMonitorService-Thread", [this]() {
while (true) {
sleep(1);
if (!DS->isLogin()) {
continue;
}
bool triggerError = false;
{
/*******************************************************************************
* evaporationBinWaterLevel CHECK *
*******************************************************************************/
if (!evaporationBinWaterLevel) {
bool sensorState = deviceIoControlService->WaterSensor_readEvaporationBin();
if (sensorState) {
evaporationBinWaterLevel = true;
logger->error("Evaporation bin water sensor triggered");
triggerError = true;
AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(err::kappe_the_evaporation_bin_has_water));
}
} else {
bool trigger = false;
for (int i = 0; i < 10; i++) {
if (deviceIoControlService->WaterSensor_readEvaporationBin()) {
trigger = true;
break;
}
usleep(100);
}
if (!trigger) {
evaporationBinWaterLevel = false;
logger->info("Evaporation bin water sensor reset");
}
}
}
{
/*******************************************************************************
* deviceBottomWaterLevel check *
*******************************************************************************/
if (!deviceBottomWaterLevel) {
bool sensorState = deviceIoControlService->WaterSensor_readDeviceBottom();
if (sensorState) {
deviceBottomWaterLevel = true;
logger->error("Device bottom water sensor triggered");
triggerError = true;
AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(err::kappe_the_bottom_of_the_device_has_water));
}
} else {
bool trigger = false;
for (int i = 0; i < 10; i++) {
if (deviceIoControlService->WaterSensor_readDeviceBottom()) {
trigger = true;
break;
}
usleep(100);
}
if (!trigger) {
deviceBottomWaterLevel = false;
logger->info("Device bottom water sensor reset");
}
}
}
if (triggerError) {
if (DS->getDeviceState() == DeviceState::Disinfection) {
GET_SERVICE(DisinfectionCtrlService)->stop();
} else if (DS->getDeviceState() == DeviceState::AddingLiquid) {
GET_SERVICE(AddLiquidService)->stop();
} else if (DS->getDeviceState() == DeviceState::DrainingLiquid) {
GET_SERVICE(DrainLiquidService)->stop();
} else if (DS->getDeviceState() == DeviceState::AirLeakDetectTesting) {
GET_SERVICE(AirLeakDetectTest)->stop();
}
}
}
}));
}

17
appsrc/service/device_check_point_check_service.hpp → appsrc/service/device_monitor_service.hpp

@ -10,6 +10,7 @@
#include <vector>
//
#include "baseservice/baseservice.hpp"
#include "service/hardware/device_io_ctrl_service.hpp"
namespace iflytop {
/**
@ -17,23 +18,21 @@ namespace iflytop {
*
*/
class DeviceMonitorService : public enable_shared_from_this<DeviceMonitorService> {
THISCLASS(DeviceMonitorService);
class DeviceCheckPointCheckService : public enable_shared_from_this<DeviceCheckPointCheckService> {
THISCLASS(DeviceCheckPointCheckService);
SERVICE(DeviceIoControlService, deviceIoControlService);
unique_ptr<Thread> m_thread;
vector<CheckPoint> checkPoints;
bool evaporationBinWaterLevel = false;
bool deviceBottomWaterLevel = false;
unique_ptr<Thread> m_thread;
public:
void initialize();
vector<CheckPoint> getAllCheckPoints();
bool isPassed();
private:
void resetPassState();
void checkLoopThread();
};
} // namespace iflytop
Loading…
Cancel
Save