9 changed files with 224 additions and 39 deletions
-
7app_protocols/apperrorcode/apperrorcode.hpp
-
13appdep/iflytop/core/components/zenum_template/zenum_template.hpp
-
8appsrc/appbase/utils/zdictionary.hpp
-
96appsrc/service/app/air_leak_detect_test.cpp
-
23appsrc/service/app/air_leak_detect_test.hpp
-
3appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
-
87appsrc/service/app/pipeline_pressure_control.cpp
-
15appsrc/service/app/pipeline_pressure_control.hpp
-
11doc/后端测试.md
@ -1,33 +1,96 @@ |
|||
#include "pipeline_pressure_control.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
static vector<string> pressureEnum = {"constantPressure", "positivePressure", "negativePressure"}; |
|||
static vector<string> pressureEnumDisplay = {"恒压", "正压", "负压"}; |
|||
|
|||
static bool isInStrings(const string& s, const vector<string>& v) { |
|||
for (auto& i : v) { |
|||
if (i == s) { |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
void PipelinePressureControl::initialize() { |
|||
GET_TO_SERVICE(m_db); |
|||
GET_TO_SERVICE(m_ds); |
|||
GET_TO_SERVICE(m_dics); |
|||
GET_TO_SERVICE(m_gConfig); |
|||
|
|||
REGFNV2(PipelinePressureControl, setType); |
|||
REGFNV2(PipelinePressureControl, setIntensity); |
|||
REGFNV2(PipelinePressureControl, getState); |
|||
REGFNV2(PipelinePressureControl, getConfig); |
|||
|
|||
m_type = "positivePressure"; |
|||
m_intensity = "10%"; |
|||
m_type = "constantPressure"; |
|||
m_intensity = 0; |
|||
syncPressureValueState(); |
|||
} |
|||
|
|||
void PipelinePressureControl::syncPressureValueState() { |
|||
if (PORT.isPipeDM()) { |
|||
logger->info("syncPressureValueState m_type:{} m_intensity:{}", m_type, m_intensity); |
|||
if (m_type == "constantPressure") { |
|||
m_dics->PosiPressureProp_setValve(0); |
|||
m_dics->NegaPressureProp_setValve(0); |
|||
} else if (m_type == "positivePressure") { |
|||
m_dics->PosiPressureProp_setValve(m_intensity); |
|||
m_dics->NegaPressureProp_setValve(0); |
|||
} else if (m_type == "negativePressure") { |
|||
m_dics->PosiPressureProp_setValve(0); |
|||
m_dics->NegaPressureProp_setValve(m_intensity); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void PipelinePressureControl::fn_setType(shared_ptr<MsgProcessContext> cxt) { m_type = cxt->params["type"]; } |
|||
void PipelinePressureControl::fn_getConfig(shared_ptr<MsgProcessContext> cxt) { |
|||
json cfg; |
|||
|
|||
cfg["types"] = {"constantPressure", "positivePressure", "negativePressure"}; |
|||
cfg["typeDisplayNames"] = {"恒压", "正压", "负压"}; |
|||
cfg["types"] = pressureEnum; |
|||
cfg["typeDisplayNames"] = pressureEnumDisplay; |
|||
cfg["intensitys"]["constantPressure"] = {}; |
|||
cfg["intensitys"]["positivePressure"] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"}; |
|||
cfg["intensitys"]["negativePressure"] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"}; |
|||
cfg["intensitys"]["positivePressure"] = {"10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"}; |
|||
cfg["intensitys"]["negativePressure"] = {"10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"}; |
|||
cxt->content = cfg; |
|||
} |
|||
void PipelinePressureControl::fn_setType(shared_ptr<MsgProcessContext> cxt) { |
|||
m_type = cxt->params["type"]; |
|||
if (!isInStrings(m_type, pressureEnum)) { |
|||
cxt->ackcode = err::kappe_param_value_err; |
|||
return; |
|||
} |
|||
|
|||
if (m_type == "constantPressure") { |
|||
m_intensity = 0; |
|||
} |
|||
if (m_type == "positivePressure") { |
|||
m_intensity = 10; |
|||
} |
|||
if (m_type == "negativePressure") { |
|||
m_intensity = 10; |
|||
} |
|||
|
|||
syncPressureValueState(); |
|||
cxt->content["type"] = m_type; |
|||
cxt->content["intensity"] = fmt::format("{}%", m_intensity); |
|||
} |
|||
|
|||
void PipelinePressureControl::fn_setIntensity(shared_ptr<MsgProcessContext> cxt) { |
|||
string intensity = cxt->params["intensity"]; |
|||
m_intensity = intensity; |
|||
// 解析字符串 10% -> 10
|
|||
int pos = intensity.find("%"); |
|||
if (pos == string::npos) { |
|||
cxt->ackcode = err::kappe_param_value_err; |
|||
return; |
|||
} |
|||
intensity = intensity.substr(0, pos); |
|||
m_intensity = atoi(intensity.c_str()); |
|||
syncPressureValueState(); |
|||
} |
|||
void PipelinePressureControl::fn_getState(shared_ptr<MsgProcessContext> cxt) { |
|||
json state; |
|||
state["type"] = m_type; |
|||
state["intensity"] = m_intensity; |
|||
cxt->content = state; |
|||
cxt->content["type"] = m_type; |
|||
cxt->content["intensity"] = fmt::format("{}%", m_intensity); |
|||
; |
|||
} |
@ -0,0 +1,11 @@ |
|||
# 后端测试 |
|||
|
|||
``` |
|||
加液 |
|||
排液 |
|||
消毒 |
|||
|
|||
|
|||
|
|||
|
|||
``` |
Write
Preview
Loading…
Cancel
Save
Reference in new issue