20 changed files with 374 additions and 258 deletions
-
4README.md
-
2app_protocols/apperrorcode/apperrorcode.hpp
-
15appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp
-
9appsrc/appbase/appevent/app_disinfection_finished_event.hpp
-
5appsrc/appbase/appevent/app_disinfection_snapshot_event.hpp
-
5appsrc/appbase/appevent/app_disinfection_start_event.hpp
-
2appsrc/appbase/appevent/app_event_type.cpp
-
14appsrc/appbase/appevent/app_event_type.hpp
-
4appsrc/appbase/appevent/app_events.hpp
-
5appsrc/appbase/appevent/app_promopt_event.hpp
-
23appsrc/appbase/appevent/app_warning_promopt_event.hpp
-
13appsrc/appbase/appevent/iapp_event.hpp
-
2appsrc/appsetting/project_port/basic/zappversion.hpp
-
22appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
-
221appsrc/service/app_core.cpp
-
42appsrc/service/app_core.hpp
-
103appsrc/service/debug_page_test_service.cpp
-
12appsrc/service/debug_page_test_service.hpp
-
77appsrc/service/device_check_point_check_service.cpp
-
52appsrc/service/device_check_point_check_service.hpp
@ -0,0 +1,15 @@ |
|||
#pragma once
|
|||
#include "iapp_event.hpp"
|
|||
namespace iflytop { |
|||
|
|||
class AppCheckPointCheckFailEvent : public IAppEvent { |
|||
private: |
|||
public: |
|||
AppCheckPointCheckFailEvent() : IAppEvent(AppEventType::AppCheckPointCheckFailEvent) {} |
|||
virtual ~AppCheckPointCheckFailEvent() {} |
|||
|
|||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(AppCheckPointCheckFailEvent, uuid, type); |
|||
virtual json toJson() { return json(*this); } |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -0,0 +1,2 @@ |
|||
#include "app_event_type.hpp"
|
|||
AppEventType_ZENUM_IMPL |
@ -0,0 +1,14 @@ |
|||
#pragma once
|
|||
|
|||
#include "iflytop/core/components/zenum_template/zenum_template.hpp"
|
|||
|
|||
#define AppEventType_ZENUM_IMPL ZENUM_IMPL(AppEventType, AppEventType_LIST)
|
|||
#define AppEventType_LIST(type, marco) /**/ \
|
|||
marco(type, AppDisinfectionFinishedEvent) /**/ \ |
|||
marco(type, AppDisinfectionSnapshotEvent) /**/ \ |
|||
marco(type, AppDisinfectionStartEvent) /**/ \ |
|||
marco(type, AppPromoptEvent) /**/ \ |
|||
marco(type, AppWarningPromoptEvent) /**/ \ |
|||
marco(type, AppCheckPointCheckFailEvent) /**/ |
|||
|
|||
ZENUM_DECLAR(AppEventType, AppEventType_LIST); |
@ -1,3 +1,3 @@ |
|||
#pragma once
|
|||
#define VERSION "1.2.1"
|
|||
#define VERSION "1.2.2"
|
|||
#define PROJECT_NAME "TRANSMIT_DM"
|
@ -0,0 +1,77 @@ |
|||
#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/hardware/device_io_ctrl_service.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
void DeviceCheckPointCheckService::initialize() { //
|
|||
|
|||
checkPoints.push_back(CheckPoint(kCheckPointCode_evaporationBinWSTrigger, "蒸发仓内液位检查", false)); |
|||
checkPoints.push_back(CheckPoint(kCheckPointCode_deviceBottomWSTrigger, "硬件仓液位检测", false)); |
|||
|
|||
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->getDeviceState() != DeviceState::Idle) {
|
|||
// continue;
|
|||
// }
|
|||
|
|||
bool oldstate = isPassed(); |
|||
// logger->info("DeviceCheckPointCheckServiceThread");
|
|||
|
|||
// 检查各个检查点
|
|||
for (auto& checkPoint : checkPoints) { |
|||
CheckPointCode_t checkPointIndex = checkPoint.index; |
|||
if (checkPointIndex == kCheckPointCode_evaporationBinWSTrigger) { |
|||
if (GET_SERVICE(DeviceIoControlService)->WaterSensor_readEvaporationBin()) { |
|||
checkPoint.passed = true; |
|||
} else { |
|||
checkPoint.passed = false; |
|||
} |
|||
} else if (checkPointIndex == kCheckPointCode_deviceBottomWSTrigger) { |
|||
if (GET_SERVICE(DeviceIoControlService)->WaterSensor_readDeviceBottom()) { |
|||
checkPoint.passed = true; |
|||
} else { |
|||
checkPoint.passed = false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
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(AddLiquidService)->stop(); |
|||
} else if (DS->getDeviceState() == DeviceState::AirLeakDetectTesting) { |
|||
GET_SERVICE(AirLeakDetectTest)->stop(); |
|||
} |
|||
AppEventBus::ins()->push(make_shared<AppCheckPointCheckFailEvent>()); |
|||
} |
|||
} |
|||
} |
|||
})); |
|||
} |
|||
|
|||
vector<CheckPoint> DeviceCheckPointCheckService::getAllCheckPoints() { return checkPoints; } |
|||
|
|||
bool DeviceCheckPointCheckService::isPassed() { |
|||
for (auto& checkPoint : checkPoints) { |
|||
if (checkPoint.passed) { |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
} |
@ -0,0 +1,52 @@ |
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
//
|
|||
#include "baseservice/baseservice.hpp"
|
|||
namespace iflytop { |
|||
|
|||
/**
|
|||
* @brief |
|||
* 设备空闲状态异常监听 |
|||
*/ |
|||
|
|||
typedef enum { |
|||
kCheckPointCode_Unknown = 0, |
|||
kCheckPointCode_evaporationBinWSTrigger, |
|||
kCheckPointCode_deviceBottomWSTrigger, |
|||
} CheckPointCode_t; |
|||
|
|||
class CheckPoint { |
|||
public: |
|||
CheckPointCode_t index; |
|||
string name; |
|||
bool passed; |
|||
|
|||
CheckPoint(CheckPointCode_t index, const string& name, bool passed) : index(index), name(name), passed(passed) {} |
|||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(CheckPoint, index, name, passed); |
|||
}; |
|||
|
|||
class DeviceCheckPointCheckService : public enable_shared_from_this<DeviceCheckPointCheckService> { |
|||
THISCLASS(DeviceCheckPointCheckService); |
|||
|
|||
vector<CheckPoint> checkPoints; |
|||
|
|||
unique_ptr<Thread> m_thread; |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
vector<CheckPoint> getAllCheckPoints(); |
|||
bool isPassed(); |
|||
|
|||
private: |
|||
}; |
|||
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue