7 changed files with 798 additions and 751 deletions
-
103appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
-
40appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp
-
125appsrc/service/app/disinfection_ctrl_service_ext.cpp
-
61appsrc/service/app/disinfection_ctrl_service_ext.hpp
-
2appsrc/service/main_control_service.cpp
@ -0,0 +1,125 @@ |
|||
#include "disinfection_ctrl_service_ext.hpp"
|
|||
|
|||
#include "appcomponents/algo/dvalue_computer.hpp"
|
|||
#include "service/hardware/warning_light_controler.hpp"
|
|||
using namespace iflytop; |
|||
using namespace disinfection; |
|||
|
|||
#define DEFAULT_BLOWSER_LEVEL 90
|
|||
#define DVALUE_COMPUTEPERIOD_TIME_S (10.0)
|
|||
|
|||
#define SETTING_DB SettingDBDao::ins()
|
|||
#define FORMULA_DB FormulaDBDao::ins()
|
|||
|
|||
static string toDisplayName(DisinfectionState state) { |
|||
switch (state.id) { |
|||
case DisinfectionState::kidle: |
|||
return "空闲"; |
|||
case DisinfectionState::kpreheat: |
|||
return "预热"; |
|||
case DisinfectionState::kdisinfection: |
|||
return "消毒中"; |
|||
case DisinfectionState::kdegradation: |
|||
return "降解中"; |
|||
case DisinfectionState::kfinished: |
|||
return "消毒完成"; |
|||
case DisinfectionState::kdehumidificationBeforeDisinfection: |
|||
return "消毒前除湿"; |
|||
case DisinfectionState::kdehumidificationAfterDisinfection: |
|||
return "消毒后除湿"; |
|||
case DisinfectionState::kemptyLiquidFromTheLine: |
|||
return "排空管路"; |
|||
default: |
|||
return "未知"; |
|||
} |
|||
} |
|||
|
|||
void DisinfectionCtrlServiceExt::initialize() { |
|||
GET_TO_SERVICE(db); |
|||
GET_TO_SERVICE(ds); |
|||
GET_TO_SERVICE(gConfig); |
|||
GET_TO_SERVICE(dcs); |
|||
GET_TO_SERVICE(dwus); |
|||
|
|||
REGFNV2(DisinfectionCtrlServiceExt, start); |
|||
REGFNV2(DisinfectionCtrlServiceExt, startWithFormula); |
|||
REGFNV2(DisinfectionCtrlServiceExt, stop); |
|||
REGFNV2(DisinfectionCtrlServiceExt, getState); |
|||
REGFNV2(DisinfectionCtrlServiceExt, getRealtimeConfig); |
|||
REGFNV2(DisinfectionCtrlServiceExt, setRealtimeConfig); |
|||
REGFNV2(DisinfectionCtrlServiceExt, getServiceConfig); |
|||
|
|||
} |
|||
|
|||
void DisinfectionCtrlServiceExt::fn_start(shared_ptr<MsgProcessContext> cxt) { |
|||
// 从setting中获取实时参数
|
|||
m_formulaid = ""; |
|||
auto allrealtimesetting = SETTING_DB->getRealtimeSetting(); |
|||
m_realtimeCfg.clear(); |
|||
for (auto& setting : allrealtimesetting) { |
|||
m_realtimeCfg[string(setting->setting_id)] = setting->val; |
|||
} |
|||
//
|
|||
|
|||
// m_state = DisinfectionState::preheat;
|
|||
} |
|||
void DisinfectionCtrlServiceExt::fn_startWithFormula(shared_ptr<MsgProcessContext> cxt) { //
|
|||
m_formulaid = cxt->params["formula_id"]; |
|||
m_defaultFormulaJson = FORMULA_DB->getFormula(m_formulaid); |
|||
m_realtimeCfg.clear(); |
|||
|
|||
auto allrealtimesetting = SETTING_DB->getRealtimeSetting(); |
|||
for (auto& setting : allrealtimesetting) { |
|||
m_realtimeCfg[string(setting->setting_id)] = m_defaultFormulaJson[string(setting->setting_id)]; |
|||
} |
|||
// m_state = DisinfectionState::preheat;
|
|||
} |
|||
void DisinfectionCtrlServiceExt::fn_stop(shared_ptr<MsgProcessContext> cxt) { |
|||
m_formulaid = ""; |
|||
m_state = DisinfectionState::idle; |
|||
} |
|||
|
|||
void DisinfectionCtrlServiceExt::fn_getRealtimeConfig(shared_ptr<MsgProcessContext> cxt) { |
|||
json& rely = cxt->content; |
|||
for (auto& cfg : m_realtimeCfg) { |
|||
rely[cfg.first] = cfg.second; |
|||
} |
|||
} |
|||
void DisinfectionCtrlServiceExt::fn_setRealtimeConfig(shared_ptr<MsgProcessContext> cxt) { |
|||
string key = cxt->params["key"]; |
|||
string val = cxt->params; |
|||
m_realtimeCfg[key] = val; |
|||
} |
|||
|
|||
void DisinfectionCtrlServiceExt::fn_getState(shared_ptr<MsgProcessContext> cxt) { |
|||
json& rely = cxt->content; |
|||
rely["statedisplayName"] = toDisplayName(m_state); |
|||
rely["state"] = string(m_state); |
|||
rely["curStateRemainTimeS"] = 60; |
|||
rely["tlog"] = "12.0"; |
|||
rely["nlog"] = "3.0"; |
|||
|
|||
json sensordata; |
|||
sensordata[0]["h2o2"] = 11.1; |
|||
sensordata[0]["temp"] = 12.2; |
|||
sensordata[0]["rh"] = 13.3; |
|||
sensordata[0]["rs"] = 14.4; |
|||
|
|||
sensordata[1]["h2o2"] = 21.1; |
|||
sensordata[1]["temp"] = 22.2; |
|||
sensordata[1]["rh"] = 23.3; |
|||
sensordata[1]["rs"] = 24.4; |
|||
|
|||
sensordata[2]["h2o2"] = 31.1; |
|||
sensordata[2]["temp"] = 32.2; |
|||
sensordata[2]["rh"] = 33.3; |
|||
sensordata[2]["rs"] = 34.4; |
|||
|
|||
rely["h2o2SensorData"] = sensordata; |
|||
} |
|||
|
|||
void DisinfectionCtrlServiceExt::fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt) { |
|||
json& rely = cxt->content; |
|||
rely["curveNum"] = 3; |
|||
rely["updatePeriodMs"] = 5000; |
|||
} |
@ -0,0 +1,61 @@ |
|||
#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 "disinfection_ctrl/disinfection_ctrl_service.hpp"
|
|||
#include "baseservice/baseservice.hpp"
|
|||
#include "disinfection_ctrl/disinfection_state_machine.hpp"
|
|||
#include "service/hardware/base/h2o2_sensor_data_mgr.hpp"
|
|||
#include "service/hardware/device_ctrl_service.hpp"
|
|||
#include "service/hardware/disinfectant_weight_update_service.hpp"
|
|||
//
|
|||
namespace iflytop { |
|||
using namespace disinfection; |
|||
|
|||
class DisinfectionCtrlServiceExt : public enable_shared_from_this<DisinfectionCtrlServiceExt> { |
|||
THISCLASS(DisinfectionCtrlServiceExt); |
|||
|
|||
public: |
|||
shared_ptr<DBService> db; |
|||
shared_ptr<DeviceStateService> ds; |
|||
shared_ptr<GConfig> gConfig; |
|||
|
|||
shared_ptr<DeviceIoControlService> dcs; |
|||
shared_ptr<DisinfectantWeightUpdateService> dwus; |
|||
|
|||
DisinfectionState m_state = DisinfectionState::idle; |
|||
|
|||
map<string, string> m_realtimeCfg; |
|||
json m_defaultFormulaJson; |
|||
string m_formulaid; |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
public: |
|||
/*******************************************************************************
|
|||
* 控制 * |
|||
*******************************************************************************/ |
|||
void fn_start(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_startWithFormula(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_stop(shared_ptr<MsgProcessContext> cxt); |
|||
|
|||
void fn_getRealtimeConfig(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_setRealtimeConfig(shared_ptr<MsgProcessContext> cxt); |
|||
/*******************************************************************************
|
|||
* 状态 * |
|||
*******************************************************************************/ |
|||
void fn_getState(shared_ptr<MsgProcessContext> cxt); |
|||
void fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt); |
|||
|
|||
}; |
|||
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue