|
@ -1,9 +1,10 @@ |
|
|
#include "pipeline_pressure_control.hpp"
|
|
|
#include "pipeline_pressure_control.hpp"
|
|
|
using namespace iflytop; |
|
|
using namespace iflytop; |
|
|
|
|
|
|
|
|
static vector<string> pressureEnum = {"constantPressure", "positivePressure", "negativePressure"}; |
|
|
|
|
|
static vector<string> pressureEnumDisplay = {"恒压", "正压", "负压"}; |
|
|
static vector<string> pressureEnumDisplay = {"恒压", "正压", "负压"}; |
|
|
|
|
|
|
|
|
|
|
|
ZENUM_IMPL(PressureType, PressureType_LIST); |
|
|
|
|
|
|
|
|
static bool isInStrings(const string& s, const vector<string>& v) { |
|
|
static bool isInStrings(const string& s, const vector<string>& v) { |
|
|
for (auto& i : v) { |
|
|
for (auto& i : v) { |
|
|
if (i == s) { |
|
|
if (i == s) { |
|
@ -18,27 +19,33 @@ void PipelinePressureControl::initialize() { |
|
|
GET_TO_SERVICE(m_ds); |
|
|
GET_TO_SERVICE(m_ds); |
|
|
GET_TO_SERVICE(m_dics); |
|
|
GET_TO_SERVICE(m_dics); |
|
|
GET_TO_SERVICE(m_gConfig); |
|
|
GET_TO_SERVICE(m_gConfig); |
|
|
|
|
|
REG_ENUM_TYPE(PressureType, PressureType::getEnumStrList()); |
|
|
|
|
|
|
|
|
REG_EXTFN(setType, void(string), type); |
|
|
|
|
|
REG_EXTFN(setIntensity, void(string), intensity); |
|
|
|
|
|
|
|
|
REG_EXTFN(setType, void(PressureType), type); |
|
|
|
|
|
REG_EXTFN(setIntensity, void(int), intensity); |
|
|
REG_EXTFN_VOID(getState, void(void)); |
|
|
REG_EXTFN_VOID(getState, void(void)); |
|
|
REG_EXTFN_VOID(getConfig, void(void)); |
|
|
REG_EXTFN_VOID(getConfig, void(void)); |
|
|
|
|
|
|
|
|
m_type = "constantPressure"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_type = PressureType::constantPressure; |
|
|
m_intensity = 0; |
|
|
m_intensity = 0; |
|
|
syncPressureValueState(); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
syncPressureValueState(); |
|
|
|
|
|
} catch (const appexception& e) { |
|
|
|
|
|
logger->error("syncPressureValueState error:{}", e.what()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void PipelinePressureControl::syncPressureValueState() { |
|
|
void PipelinePressureControl::syncPressureValueState() { |
|
|
if (PORT.isPipeDM()) { |
|
|
if (PORT.isPipeDM()) { |
|
|
logger->info("syncPressureValueState m_type:{} m_intensity:{}", m_type, m_intensity); |
|
|
logger->info("syncPressureValueState m_type:{} m_intensity:{}", m_type, m_intensity); |
|
|
if (m_type == "constantPressure") { |
|
|
|
|
|
|
|
|
if (m_type == PressureType::constantPressure) { |
|
|
m_dics->PosiPressureProp_setValve(0); |
|
|
m_dics->PosiPressureProp_setValve(0); |
|
|
m_dics->NegaPressureProp_setValve(0); |
|
|
m_dics->NegaPressureProp_setValve(0); |
|
|
} else if (m_type == "positivePressure") { |
|
|
|
|
|
|
|
|
} else if (m_type == PressureType::positivePressure) { |
|
|
m_dics->PosiPressureProp_setValve(m_intensity); |
|
|
m_dics->PosiPressureProp_setValve(m_intensity); |
|
|
m_dics->NegaPressureProp_setValve(0); |
|
|
m_dics->NegaPressureProp_setValve(0); |
|
|
} else if (m_type == "negativePressure") { |
|
|
|
|
|
|
|
|
} else if (m_type == PressureType::negativePressure) { |
|
|
m_dics->PosiPressureProp_setValve(0); |
|
|
m_dics->PosiPressureProp_setValve(0); |
|
|
m_dics->NegaPressureProp_setValve(m_intensity); |
|
|
m_dics->NegaPressureProp_setValve(m_intensity); |
|
|
} |
|
|
} |
|
@ -48,48 +55,41 @@ void PipelinePressureControl::syncPressureValueState() { |
|
|
void PipelinePressureControl::getConfig(shared_ptr<MsgProcessContext> cxt) { |
|
|
void PipelinePressureControl::getConfig(shared_ptr<MsgProcessContext> cxt) { |
|
|
json cfg; |
|
|
json cfg; |
|
|
|
|
|
|
|
|
cfg["types"] = pressureEnum; |
|
|
|
|
|
|
|
|
cfg["types"] = PressureType::getEnumStrList(); |
|
|
cfg["typeDisplayNames"] = pressureEnumDisplay; |
|
|
cfg["typeDisplayNames"] = pressureEnumDisplay; |
|
|
cfg["intensitys"]["constantPressure"] = {}; |
|
|
cfg["intensitys"]["constantPressure"] = {}; |
|
|
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->rely = cfg; |
|
|
|
|
|
|
|
|
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->rely = cfg; |
|
|
} |
|
|
} |
|
|
void PipelinePressureControl::setType(shared_ptr<MsgProcessContext> cxt, string type) { |
|
|
|
|
|
|
|
|
void PipelinePressureControl::setType(shared_ptr<MsgProcessContext> cxt, PressureType type) { |
|
|
m_type = cxt->params["type"]; |
|
|
m_type = cxt->params["type"]; |
|
|
if (!isInStrings(m_type, pressureEnum)) { |
|
|
|
|
|
|
|
|
if (!isInStrings(m_type, PressureType::getEnumStrList())) { |
|
|
cxt->ackcode = err::kappe_param_value_err; |
|
|
cxt->ackcode = err::kappe_param_value_err; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (m_type == "constantPressure") { |
|
|
|
|
|
|
|
|
if (m_type == PressureType::constantPressure) { |
|
|
m_intensity = 0; |
|
|
m_intensity = 0; |
|
|
} |
|
|
|
|
|
if (m_type == "positivePressure") { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (m_type == PressureType::positivePressure) { |
|
|
m_intensity = 10; |
|
|
m_intensity = 10; |
|
|
} |
|
|
|
|
|
if (m_type == "negativePressure") { |
|
|
|
|
|
|
|
|
} else if (m_type == PressureType::negativePressure) { |
|
|
m_intensity = 10; |
|
|
m_intensity = 10; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
syncPressureValueState(); |
|
|
syncPressureValueState(); |
|
|
cxt->rely["type"] = m_type; |
|
|
cxt->rely["type"] = m_type; |
|
|
cxt->rely["intensity"] = fmt::format("{}%", m_intensity); |
|
|
|
|
|
|
|
|
cxt->rely["intensity"] = m_intensity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void PipelinePressureControl::setIntensity(shared_ptr<MsgProcessContext> cxt, string intensity) { |
|
|
|
|
|
|
|
|
void PipelinePressureControl::setIntensity(shared_ptr<MsgProcessContext> cxt, int intensity) { |
|
|
// 解析字符串 10% -> 10
|
|
|
// 解析字符串 10% -> 10
|
|
|
auto 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()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_intensity = intensity; |
|
|
syncPressureValueState(); |
|
|
syncPressureValueState(); |
|
|
} |
|
|
} |
|
|
void PipelinePressureControl::getState(shared_ptr<MsgProcessContext> cxt) { |
|
|
void PipelinePressureControl::getState(shared_ptr<MsgProcessContext> cxt) { |
|
|
cxt->rely["type"] = m_type; |
|
|
cxt->rely["type"] = m_type; |
|
|
cxt->rely["intensity"] = fmt::format("{}%", m_intensity); |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
cxt->rely["intensity"] = m_intensity; |
|
|
} |
|
|
} |