Browse Source

update

storage-in-realtime
zhaohe 11 months ago
parent
commit
17432ffba8
  1. 60
      appsrc/service/app/pipeline_pressure_control.cpp
  2. 17
      appsrc/service/app/pipeline_pressure_control.hpp
  3. 10
      appsrc/service/test_page_mgr_service.cpp

60
appsrc/service/app/pipeline_pressure_control.cpp

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

17
appsrc/service/app/pipeline_pressure_control.hpp

@ -11,6 +11,15 @@
//
#include "baseservice/baseservice.hpp"
#include "service/hardware/device_io_ctrl_service.hpp"
//
#define PressureType_LIST(type, marco) /**/ \
marco(type, constantPressure) /**/ \
marco(type, positivePressure) /**/ \
marco(type, negativePressure) /**/
ZENUM_DECLAR(PressureType, PressureType_LIST);
namespace iflytop {
class PipelinePressureControl : public enable_shared_from_this<PipelinePressureControl> {
THISCLASS(PipelinePressureControl);
@ -48,8 +57,8 @@ class PipelinePressureControl : public enable_shared_from_this<PipelinePressureC
shared_ptr<DeviceIoControlService> m_dics;
shared_ptr<GConfig> m_gConfig;
string m_type;
int m_intensity = 0;
PressureType m_type;
int m_intensity = 0;
public:
void initialize();
@ -58,8 +67,8 @@ class PipelinePressureControl : public enable_shared_from_this<PipelinePressureC
void syncPressureValueState();
private:
void setType(shared_ptr<MsgProcessContext> cxt,string type);
void setIntensity(shared_ptr<MsgProcessContext> cxt,string intensity);
void setType(shared_ptr<MsgProcessContext> cxt, PressureType type);
void setIntensity(shared_ptr<MsgProcessContext> cxt, int intensity);
void getState(shared_ptr<MsgProcessContext> cxt);
void getConfig(shared_ptr<MsgProcessContext> cxt);

10
appsrc/service/test_page_mgr_service.cpp

@ -173,11 +173,10 @@ void TestPageMgrService::initialize() {
m_dict->insert("NegaPressurePropCtrl", "负压比例阀控制");
m_dict->insert("NegaPressurePropCtrl.set", "设置");
m_dict->insert("NegaPressurePropCtrl.close", "关闭");
m_dict->insert("proportionalOpenPercent", "数值");
m_dict->insert("PosiPressurePropCtrl.percent", "百分比");
m_testPageItemMgr.installParamType("proportionalOpenPercent", "%", {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"});
m_testPageItemMgr.insertButtons("PosiPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
m_testPageItemMgr.installParamType("PosiPressurePropCtrl.percent", "%", {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"});
m_testPageItemMgr.insertButtons("PosiPressurePropCtrl", {"percent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
logger->info("PosiPressurePropCtrl buttonName:{} params:{}", buttonName, param);
if (buttonName == "set") {
dcs->PosiPressureProp_setValve(atoi(param[0].c_str()));
@ -187,7 +186,8 @@ void TestPageMgrService::initialize() {
});
// 比例阀控制 13
m_testPageItemMgr.insertButtons("NegaPressurePropCtrl", {"proportionalOpenPercent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
m_testPageItemMgr.installParamType("NegaPressurePropCtrl.percent", "%", {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"});
m_testPageItemMgr.insertButtons("NegaPressurePropCtrl", {"percent"}, {"set", "close"}, [this](string buttonName, vector<string> param) { //
logger->info("NegaPressurePropCtrl buttonName:{},params:{}", buttonName, param);
if (buttonName == "set") {
dcs->NegaPressureProp_setValve(atoi(param[0].c_str()));

Loading…
Cancel
Save