6 changed files with 417 additions and 249 deletions
-
43service/bak
-
325service/disinfection_ctl_service.cpp
-
71service/disinfection_ctl_service.hpp
-
5service/disinfection_printer_service.cpp
-
51service/disinfection_printer_service.hpp
-
129service/disinfection_state.hpp
@ -0,0 +1,43 @@ |
|||
/** |
|||
* @brief |
|||
* = = = = = = = = = = = = = = = |
|||
* 全思美特 |
|||
* 操作人 XXXXX |
|||
* 开始时间 2021-03-10 10:00:00 |
|||
* 结束时间 2021-03-10 10:00:00 |
|||
* 总耗时 01:59 |
|||
* 目标LOG 6 |
|||
* 实际LOG 6 |
|||
* = = = = = = = = = = = = = = = |
|||
* |
|||
*/ |
|||
|
|||
auto dio = m_deviceIoControlService; |
|||
auto ds = GET_SERVICE(DeviceStateService); |
|||
auto& cx = m_context; |
|||
int32_t disinfectant_usage = cx.beforeDisinfectantVolume_g - cx.afterDisinfectantVolume_g; |
|||
if (disinfectant_usage < 0) disinfectant_usage = 0; |
|||
|
|||
// m_context.m_endtp_str = getTime(); |
|||
int totaltime = zsystem_clock().elapsedTimeS(cx.disinfection_start_tp) / 60; |
|||
|
|||
dio->printerPrintf(fmt::format("= = = = = = = = = = = = = = = \n")); |
|||
dio->printerPrintf(fmt::format(" 全思美特\n")); |
|||
dio->printerPrintf(fmt::format("操作人 {}\n", ds->getLoginUid())); |
|||
dio->printerPrintf(fmt::format("开始时间 {}\n", format_zsystem_tp(cx.disinfection_start_tp))); |
|||
dio->printerPrintf(fmt::format("结束时间 {}\n", format_zsystem_tp(cx.disinfection_complete_tp))); |
|||
dio->printerPrintf(fmt::format("总耗时 {}:{}\n", totaltime / 60, totaltime % 60)); |
|||
dio->printerPrintf(fmt::format("消毒液使用 {}g\n", disinfectant_usage)); |
|||
dio->printerPrintf(fmt::format("目标LOG {}\n", (int)m_context.m_targetLoglevel)); |
|||
dio->printerPrintf(fmt::format("实际LOG {}\n", (int)m_context.m_nowLoglevel)); |
|||
dio->printerPrintf(fmt::format("= = = = = = = = = = = = = = = \n")); |
|||
|
|||
for (size_t i = 0; i < count; i++) |
|||
{ |
|||
/* code */ |
|||
} |
|||
|
|||
|
|||
dio->printerPrintf(fmt::format("\n")); |
|||
dio->printerPrintf(fmt::format("\n")); |
|||
dio->printerPrintf(fmt::format("\n")); |
@ -0,0 +1,5 @@ |
|||
#include "disinfection_printer_service.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
void DisinfectionPrinterService::initialize() {} |
|||
void DisinfectionPrinterService::pushPrintTask(shared_ptr<DisinfectionPrinterTask> task) {} |
@ -0,0 +1,51 @@ |
|||
//
|
|||
// Created by zwsd
|
|||
//
|
|||
|
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <mutex>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
#include "disinfection_logs_manager.hpp"
|
|||
#include "disinfection_state.hpp"
|
|||
#include "iflytop/components/zcanreceiver/zcanhost.hpp"
|
|||
#include "iflytop/core/core.hpp"
|
|||
#include "service/device_io_control_service.hpp"
|
|||
#include "utils/dvalue_computer.hpp"
|
|||
#include "zservice_container/zservice_container.hpp"
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* service: 消毒打印服务 |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace core; |
|||
|
|||
class DisinfectionPrinterService : public enable_shared_from_this<DisinfectionPrinterService> { |
|||
ENABLE_LOGGER(DisinfectionPrinterService); |
|||
|
|||
private: |
|||
recursive_mutex lock_; |
|||
|
|||
unique_ptr<Thread> m_workThread; |
|||
list<shared_ptr<DisinfectionPrinterTask>> tasks; |
|||
|
|||
public: |
|||
DisinfectionPrinterService() {} |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
void pushPrintTask(shared_ptr<DisinfectionPrinterTask> task); |
|||
}; |
|||
} // namespace iflytop
|
@ -0,0 +1,129 @@ |
|||
//
|
|||
// Created by zwsd
|
|||
//
|
|||
|
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <mutex>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
#include "configs/project_setting.hpp"
|
|||
#include "iflytop/core/components/timeutils.hpp"
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* service: DisinfectionCtrlService |
|||
* |
|||
* 监听事件: |
|||
* 依赖状态: |
|||
* 依赖服务: |
|||
* 作用: |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace core; |
|||
|
|||
class DisinfectionLogger; |
|||
|
|||
typedef enum { |
|||
kstate_idle = 0, // 空闲
|
|||
kstate_preheat = 1, // 预热
|
|||
kstate_disinfection = 2, // 消毒中-工作
|
|||
kstate_degradation = 4, // 降解中
|
|||
kstate_finished = 5, // 结束
|
|||
} disinfection_state_t; |
|||
|
|||
class StateSnapshot { |
|||
public: |
|||
disinfection_state_t state; |
|||
zsystem_tp time; |
|||
|
|||
int32_t h2o2[MAX_H2O2_SENSOR_NUM]; // ppm
|
|||
int32_t humid[MAX_H2O2_SENSOR_NUM]; // %RH
|
|||
int32_t temp[MAX_H2O2_SENSOR_NUM]; // °C
|
|||
int32_t saturation[MAX_H2O2_SENSOR_NUM]; // %RS
|
|||
|
|||
int min_h2o2; |
|||
int max_h2o2; |
|||
int max_humid; |
|||
int max_saturation; |
|||
}; |
|||
|
|||
class DisinfectionPrinterTask { |
|||
public: |
|||
list<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
|
|||
|
|||
int disinfectantUsage; // 消毒剂使用量
|
|||
|
|||
zsystem_tp start_tp; |
|||
zsystem_tp complete_tp; |
|||
|
|||
bool stoped_by_usr = false; |
|||
}; |
|||
|
|||
class DisinfectionContext { |
|||
public: |
|||
string m_disinfectionID; |
|||
disinfection_state_t m_state = kstate_idle; |
|||
|
|||
zsteady_tp m_lastComputeDvalueTp; |
|||
zsteady_tp m_lastlogTp; |
|||
zsteady_tp disinfection_start_steady_tp; |
|||
|
|||
int m_remaintime = 0; |
|||
float m_targetLoglevel = 0; |
|||
float m_nowLoglevel = 0; |
|||
float dvalue = 0; |
|||
|
|||
int injection_pump_speed; |
|||
bool injection_pump_speed_changed = false; |
|||
|
|||
int pre_heat_time_s = 0; |
|||
int stoped_gs = 0; |
|||
int continued_gs = 0; |
|||
int stoped_satur = 0; |
|||
int continued_satur = 0; |
|||
int stoped_humi = 0; |
|||
int continued_humi = 0; |
|||
|
|||
shared_ptr<DisinfectionLogger> csvlogger; |
|||
|
|||
bool isDisinfectionTakeBreak; // 消毒工作中是否暂停工作
|
|||
/*******************************************************************************
|
|||
* 传感器信息 * |
|||
*******************************************************************************/ |
|||
|
|||
int32_t h2o2[MAX_H2O2_SENSOR_NUM]; // ppm
|
|||
int32_t humid[MAX_H2O2_SENSOR_NUM]; // %RH
|
|||
int32_t temp[MAX_H2O2_SENSOR_NUM]; // °C
|
|||
int32_t saturation[MAX_H2O2_SENSOR_NUM]; // %RS
|
|||
|
|||
int min_h2o2; |
|||
int max_h2o2; |
|||
int max_humid; |
|||
int max_saturation; |
|||
|
|||
/*******************************************************************************
|
|||
* 消毒统计信息 * |
|||
*******************************************************************************/ |
|||
list<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
|
|||
|
|||
int beforeDisinfectantVolume_g; // 消毒前消毒剂量
|
|||
int afterDisinfectantVolume_g; // 消毒后消毒剂量
|
|||
|
|||
zsystem_tp disinfection_start_tp; |
|||
zsystem_tp disinfection_complete_tp; |
|||
|
|||
bool stoped_by_usr = false; |
|||
}; |
|||
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue