|
|
@ -1,5 +1,7 @@ |
|
|
|
#include "disinfection_ctrl_service.hpp"
|
|
|
|
using namespace iflytop; |
|
|
|
#define SETTING_DB SettingDBDao::ins()
|
|
|
|
#define FORMULA_DB FormulaDBDao::ins()
|
|
|
|
|
|
|
|
static string disinfectionState2DisplayName(disinfection_state_t state) { |
|
|
|
switch (state) { |
|
|
@ -25,116 +27,51 @@ static string disinfectionState2DisplayName(disinfection_state_t state) { |
|
|
|
} |
|
|
|
|
|
|
|
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, start); |
|
|
|
REGFNV2(DisinfectionCtrlService, startWithFormula); |
|
|
|
REGFNV2(DisinfectionCtrlService, stop); |
|
|
|
REGFNV2(DisinfectionCtrlService, getState); |
|
|
|
REGFNV2(DisinfectionCtrlService, getServiceConfig); |
|
|
|
REGFNV2(DisinfectionCtrlService, getRealtimeConfig); |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 配置 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
// 消毒前除
|
|
|
|
void DisinfectionCtrlService::fn_enableDehumidifyBD(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
//
|
|
|
|
bool enable = cxt->params["val"]; |
|
|
|
m_enableDehumidifyBD = enable; |
|
|
|
void DisinfectionCtrlService::fn_start(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
// 从setting中获取实时参数
|
|
|
|
m_formulaid = ""; |
|
|
|
auto allrealtimesetting = SETTING_DB->getRealtimeSetting(); |
|
|
|
for (auto& setting : allrealtimesetting) { |
|
|
|
m_realtimeCfg[string(setting->setting_id)] = setting->val; |
|
|
|
} |
|
|
|
m_state = kstate_preheat; |
|
|
|
} |
|
|
|
void DisinfectionCtrlService::fn_setDehumidifyBDThreshold(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
int threshold = cxt->params["val"]; |
|
|
|
m_dehumidifyBDThreshold = threshold; |
|
|
|
void DisinfectionCtrlService::fn_startWithFormula(shared_ptr<MsgProcessContext> cxt) { //
|
|
|
|
m_formulaid = cxt->params["formula_id"]; |
|
|
|
m_defaultFormulaJson = FORMULA_DB->getFormula(m_formulaid); |
|
|
|
auto allrealtimesetting = SETTING_DB->getRealtimeSetting(); |
|
|
|
for (auto& setting : allrealtimesetting) { |
|
|
|
m_realtimeCfg[string(setting->setting_id)] = m_defaultFormulaJson[string(setting->setting_id)]; |
|
|
|
} |
|
|
|
m_state = kstate_preheat; |
|
|
|
} |
|
|
|
|
|
|
|
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_stop(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
m_formulaid = ""; |
|
|
|
m_state = kstate_idle; |
|
|
|
} |
|
|
|
|
|
|
|
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_getRealtimeConfig(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
json& rely = cxt->content; |
|
|
|
for (auto& cfg : m_realtimeCfg) { |
|
|
|
rely[cfg.first] = cfg.second; |
|
|
|
} |
|
|
|
} |
|
|
|
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_setRealtimeConfig(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
string key = cxt->params["key"]; |
|
|
|
string val = cxt->params["val"]; |
|
|
|
m_realtimeCfg[key] = val; |
|
|
|
} |
|
|
|
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; |
|
|
|
json& rely = cxt->content; |
|
|
|
rely["statedisplayName"] = disinfectionState2DisplayName(m_state); |
|
|
|
rely["state"] = toString(m_state); |
|
|
|
} |
|
|
|
void DisinfectionCtrlService::fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
//
|
|
|
|
//
|
|
|
|
} |
|
|
|
void DisinfectionCtrlService::fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt) { json& rely = cxt->content; } |