12 changed files with 321 additions and 79 deletions
-
3appsrc/appbase/dep.hpp
-
26appsrc/appbase/disinfection_state.hpp
-
15appsrc/baseservice/db/db_constant.cpp
-
64appsrc/baseservice/db/db_service.cpp
-
16appsrc/baseservice/db/db_service.hpp
-
140appsrc/service/app/disinfection_ctrl_service.cpp
-
87appsrc/service/app/disinfection_ctrl_service.hpp
-
4appsrc/service/app/disinfection_service.cpp
-
27appsrc/service/app/disinfection_service.hpp
-
11appsrc/service/disinfection_logs_service.hpp
-
5appsrc/service/main_control_service.cpp
-
2appsrc/service/setting_mgr_service.cpp
@ -0,0 +1,15 @@ |
|||
#include "db_service.hpp"
|
|||
|
|||
const char* ksetting_stoped_gs = "stoped_gs"; |
|||
const char* ksetting_continued_gs = "continued_gs"; |
|||
const char* ksetting_stoped_satur = "stoped_satur"; |
|||
const char* ksetting_continued_satur = "continued_satur"; |
|||
const char* ksetting_max_humidity = "max_humidity"; |
|||
const char* ksetting_drainage_pump_speed = "drainage_pump_speed"; |
|||
const char* ksetting_injection_pump_speed = "injection_pump_speed"; |
|||
const char* ksetting_pre_heat_time_s = "pre_heat_time_s"; |
|||
const char* ksetting_stoped_humi = "stoped_humi"; |
|||
const char* ksetting_continued_humi = "continued_humi"; |
|||
const char* ksetting_proportional_valve_default_value = "proportional_valve_default_value"; |
|||
const char* ksetting_record_period_min = "record_period_min"; |
|||
const char* ksetting_record_printer_period_min = "record_printer_period_min"; |
@ -0,0 +1,140 @@ |
|||
#include "disinfection_ctrl_service.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
static string disinfectionState2DisplayName(disinfection_state_t state) { |
|||
switch (state) { |
|||
case kstate_idle: |
|||
return "空闲"; |
|||
case kstate_preheat: |
|||
return "预热"; |
|||
case kstate_disinfection: |
|||
return "消毒中"; |
|||
case kstate_degradation: |
|||
return "降解中"; |
|||
case kstate_finished: |
|||
return "消毒完成"; |
|||
case kstate_dehumidification_before_disinfection: |
|||
return "消毒前除湿"; |
|||
case kstate_dehumidification_after_disinfection: |
|||
return "消毒后除湿"; |
|||
case kstate_empty_liquid_from_the_line: |
|||
return "排空管路"; |
|||
default: |
|||
return "未知"; |
|||
} |
|||
} |
|||
|
|||
void DisinfectionCtrlService::initialize() { |
|||
REGFNV2(DisinfectionCtrlService, enableDehumidifyBD); |
|||
REGFNV2(DisinfectionCtrlService, setDehumidifyBDThreshold); |
|||
REGFNV2(DisinfectionCtrlService, enableDehumidifyAD); |
|||
REGFNV2(DisinfectionCtrlService, setDehumidifyADThreshold); |
|||
REGFNV2(DisinfectionCtrlService, enableDegradeAD); |
|||
REGFNV2(DisinfectionCtrlService, startDisinfection); |
|||
REGFNV2(DisinfectionCtrlService, changeDisinfectionParameter); |
|||
REGFNV2(DisinfectionCtrlService, getDisinfectionConfig); |
|||
REGFNV2(DisinfectionCtrlService, stopDisinfection); |
|||
REGFNV2(DisinfectionCtrlService, getState); |
|||
REGFNV2(DisinfectionCtrlService, getServiceConfig); |
|||
} |
|||
|
|||
/*******************************************************************************
|
|||
* 配置 * |
|||
*******************************************************************************/ |
|||
|
|||
// 消毒前除
|
|||
void DisinfectionCtrlService::fn_enableDehumidifyBD(shared_ptr<MsgProcessContext> cxt) { |
|||
//
|
|||
bool enable = cxt->params["val"]; |
|||
m_enableDehumidifyBD = enable; |
|||
} |
|||
void DisinfectionCtrlService::fn_setDehumidifyBDThreshold(shared_ptr<MsgProcessContext> cxt) { |
|||
int threshold = cxt->params["val"]; |
|||
m_dehumidifyBDThreshold = threshold; |
|||
} |
|||
|
|||
void DisinfectionCtrlService::fn_enableDehumidifyAD(shared_ptr<MsgProcessContext> cxt) { |
|||
bool enable = cxt->params["val"]; |
|||
m_enableDehumidifyAD = enable; |
|||
} // 消毒后除
|
|||
void DisinfectionCtrlService::fn_setDehumidifyADThreshold(shared_ptr<MsgProcessContext> cxt) { |
|||
int threshold = cxt->params["val"]; |
|||
m_dehumidifyADThreshold = threshold; |
|||
} |
|||
|
|||
void DisinfectionCtrlService::fn_enableDegradeAD(shared_ptr<MsgProcessContext> cxt) { |
|||
bool enable = cxt->params["val"]; |
|||
m_enableDegradeAD = enable; |
|||
} // 消毒后降
|
|||
|
|||
/*******************************************************************************
|
|||
* 控制 * |
|||
*******************************************************************************/ |
|||
void DisinfectionCtrlService::fn_startDisinfection(shared_ptr<MsgProcessContext> cxt) { //
|
|||
m_state = kstate_preheat; |
|||
} |
|||
void DisinfectionCtrlService::fn_changeDisinfectionParameter(shared_ptr<MsgProcessContext> cxt) { |
|||
|
|||
int injection_pump_speed = m_runCfg.injection_pump_speed; |
|||
int stoped_gs = m_runCfg.stoped_gs; |
|||
int continued_gs = m_runCfg.continued_gs; |
|||
int stoped_satur = m_runCfg.stoped_satur; |
|||
int continued_satur = m_runCfg.continued_satur; |
|||
int stoped_humi = m_runCfg.stoped_humi; |
|||
int continued_humi = m_runCfg.continued_humi; |
|||
|
|||
// if (cmd.find("injection_pump_speed") != cmd.end()) {
|
|||
// injection_pump_speed = jsonGet<int>(cmd["injection_pump_speed"]);
|
|||
// }
|
|||
// if (cmd.find("stoped_gs") != cmd.end()) {
|
|||
// stoped_gs = jsonGet<int>(cmd["stoped_gs"]);
|
|||
// }
|
|||
// if (cmd.find("continued_gs") != cmd.end()) {
|
|||
// continued_gs = jsonGet<int>(cmd["continued_gs"]);
|
|||
// }
|
|||
// if (cmd.find("stoped_satur") != cmd.end()) {
|
|||
// stoped_satur = jsonGet<int>(cmd["stoped_satur"]);
|
|||
// }
|
|||
// if (cmd.find("continued_satur") != cmd.end()) {
|
|||
// continued_satur = jsonGet<int>(cmd["continued_satur"]);
|
|||
// }
|
|||
// if (cmd.find("stoped_humi") != cmd.end()) {
|
|||
// stoped_humi = jsonGet<int>(cmd["stoped_humi"]);
|
|||
// }
|
|||
// if (cmd.find("continued_humi") != cmd.end()) {
|
|||
// continued_humi = jsonGet<int>(cmd["continued_humi"]);
|
|||
// }
|
|||
|
|||
// dfs->setInjectionPumpSpeed(injection_pump_speed);
|
|||
// dfs->setStopedGS(stoped_gs);
|
|||
// dfs->setContinuedGS(continued_gs);
|
|||
// dfs->setStopedSatur(stoped_satur);
|
|||
// dfs->setContinuedSatur(continued_satur);
|
|||
// dfs->setStopedHumi(stoped_humi);
|
|||
// dfs->setContinuedHumi(continued_humi);
|
|||
|
|||
// m_disinfectionCtrlService->changeDisinfectionParameter();
|
|||
return; |
|||
} |
|||
void DisinfectionCtrlService::fn_getDisinfectionConfig(shared_ptr<MsgProcessContext> cxt) {} |
|||
void DisinfectionCtrlService::fn_stopDisinfection(shared_ptr<MsgProcessContext> cxt) {} |
|||
/*******************************************************************************
|
|||
* 状态 * |
|||
*******************************************************************************/ |
|||
void DisinfectionCtrlService::fn_getState(shared_ptr<MsgProcessContext> cxt) { |
|||
json content; |
|||
content["cfg"]["enableDehumidifyBD"] = m_enableDehumidifyBD; |
|||
content["cfg"]["dehumidifyBDThreshold"] = m_dehumidifyBDThreshold; |
|||
content["cfg"]["enableDehumidifyAD"] = m_enableDehumidifyAD; |
|||
content["cfg"]["dehumidifyADThreshold"] = m_dehumidifyADThreshold; |
|||
content["cfg"]["enableDegradeAD"] = m_enableDegradeAD; |
|||
content["state"]["disinfectionState"] = disinfectionState2DisplayName(m_state); |
|||
content["state"]["dval"] = 12.3; |
|||
content["state"]["nlog"] = 1.0; |
|||
content["state"]["tlog"] = 3.0; |
|||
cxt->content = content; |
|||
} |
|||
void DisinfectionCtrlService::fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt) { |
|||
//
|
|||
//
|
|||
} |
@ -0,0 +1,87 @@ |
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
//
|
|||
#include "appbase/disinfection_state.hpp"
|
|||
#include "baseservice/baseservice.hpp"
|
|||
|
|||
namespace iflytop { |
|||
class DisinfectionCtrlService : public enable_shared_from_this<DisinfectionCtrlService> { |
|||
ENABLE_LOGGER(DisinfectionCtrlService); |
|||
typedef struct { |
|||
int pre_heat_time_s; |
|||
int stoped_gs; |
|||
int continued_gs; |
|||
int stoped_satur; |
|||
int continued_satur; |
|||
int stoped_humi; |
|||
int continued_humi; |
|||
int injection_pump_speed; |
|||
} cfg_t; |
|||
|
|||
typedef struct { |
|||
bool enable_bf_dinft_dehumidification; |
|||
bool enable_af_dinft_dehumidification; |
|||
bool enable_degradation; |
|||
int bf_dinft_dehumidification_target_val; |
|||
int af_dinft_dehumidification_target_val; |
|||
int degradation_target_val; |
|||
} beforeRunCfg_t; |
|||
|
|||
public: |
|||
shared_ptr<DBService> m_db; |
|||
shared_ptr<DeviceStateService> m_ds; |
|||
shared_ptr<GConfig> m_gConfig; |
|||
|
|||
bool m_enableDehumidifyBD = false; |
|||
int m_dehumidifyBDThreshold = 0; |
|||
bool m_enableDehumidifyAD = false; |
|||
int m_dehumidifyADThreshold = 0; |
|||
bool m_enableDegradeAD = false; |
|||
|
|||
cfg_t m_runCfg; |
|||
beforeRunCfg_t m_beforeRunCfg; |
|||
|
|||
disinfection_state_t m_state = kstate_idle; |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
public: |
|||
public: |
|||
/*******************************************************************************
|
|||
* 配置 * |
|||
*******************************************************************************/ |
|||
|
|||
void fn_enableDehumidifyBD(shared_ptr<MsgProcessContext> cxt); // 消毒前除湿
|
|||
void fn_setDehumidifyBDThreshold(shared_ptr<MsgProcessContext> cxt); |
|||
|
|||
void fn_enableDehumidifyAD(shared_ptr<MsgProcessContext> cxt); // 消毒后除湿
|
|||
void fn_setDehumidifyADThreshold(shared_ptr<MsgProcessContext> cxt); |
|||
|
|||
void fn_enableDegradeAD(shared_ptr<MsgProcessContext> cxt); // 消毒后降解
|
|||
|
|||
/*******************************************************************************
|
|||
* 控制 * |
|||
*******************************************************************************/ |
|||
void fn_startDisinfection(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_changeDisinfectionParameter(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_getDisinfectionConfig(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_stopDisinfection(shared_ptr<MsgProcessContext> cxt); |
|||
/*******************************************************************************
|
|||
* 状态 * |
|||
*******************************************************************************/ |
|||
void fn_getState(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt); |
|||
|
|||
private: |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -1,4 +0,0 @@ |
|||
#include "disinfection_service.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
void DisinfectionService::initialize() { logger->info("DisinfectionService initialize"); } |
@ -1,27 +0,0 @@ |
|||
#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 { |
|||
class DisinfectionService : public enable_shared_from_this<DisinfectionService> { |
|||
ENABLE_LOGGER(DisinfectionService); |
|||
|
|||
shared_ptr<DBService> m_db; |
|||
shared_ptr<DeviceStateService> m_ds; |
|||
shared_ptr<GConfig> m_gConfig; |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
private: |
|||
}; |
|||
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue