Browse Source

update

storage-in-realtime
zhaohe 12 months ago
parent
commit
f077ef5439
  1. 3
      appsrc/appbase/dep.hpp
  2. 26
      appsrc/appbase/disinfection_state.hpp
  3. 15
      appsrc/baseservice/db/db_constant.cpp
  4. 64
      appsrc/baseservice/db/db_service.cpp
  5. 16
      appsrc/baseservice/db/db_service.hpp
  6. 140
      appsrc/service/app/disinfection_ctrl_service.cpp
  7. 87
      appsrc/service/app/disinfection_ctrl_service.hpp
  8. 4
      appsrc/service/app/disinfection_service.cpp
  9. 27
      appsrc/service/app/disinfection_service.hpp
  10. 11
      appsrc/service/disinfection_logs_service.hpp
  11. 5
      appsrc/service/main_control_service.cpp
  12. 2
      appsrc/service/setting_mgr_service.cpp

3
appsrc/appbase/dep.hpp

@ -17,4 +17,5 @@
#include "gconfig.hpp"
#include "project_setting.hpp"
#include "project_setting_mgr.hpp"
#include "utils/zdictionary.hpp"
#include "utils/zdictionary.hpp"
#include "disinfection_state.hpp"

26
appsrc/appbase/disinfection_state.hpp

@ -1,4 +1,5 @@
#pragma once
#include <string>
namespace iflytop {
using namespace std;
@ -14,4 +15,27 @@ typedef enum {
kstate_empty_liquid_from_the_line = 8, // 排空管路中的液体
} disinfection_state_t;
}
static string toString(disinfection_state_t state) {
switch (state) {
case kstate_idle:
return "idle";
case kstate_preheat:
return "preheat";
case kstate_disinfection:
return "disinfection";
case kstate_degradation:
return "degradation";
case kstate_finished:
return "finished";
case kstate_dehumidification_before_disinfection:
return "dehumidification_before_disinfection";
case kstate_dehumidification_after_disinfection:
return "dehumidification_after_disinfection";
case kstate_empty_liquid_from_the_line:
return "empty_liquid_from_the_line";
default:
return "unkown";
}
}
} // namespace iflytop

15
appsrc/baseservice/db/db_constant.cpp

@ -0,0 +1,15 @@
#include "db_service.hpp"
const char* ksetting_stoped_gs = "stoped_gs";
const char* ksetting_continued_gs = "continued_gs";
const char* ksetting_stoped_satur = "stoped_satur";
const char* ksetting_continued_satur = "continued_satur";
const char* ksetting_max_humidity = "max_humidity";
const char* ksetting_drainage_pump_speed = "drainage_pump_speed";
const char* ksetting_injection_pump_speed = "injection_pump_speed";
const char* ksetting_pre_heat_time_s = "pre_heat_time_s";
const char* ksetting_stoped_humi = "stoped_humi";
const char* ksetting_continued_humi = "continued_humi";
const char* ksetting_proportional_valve_default_value = "proportional_valve_default_value";
const char* ksetting_record_period_min = "record_period_min";
const char* ksetting_record_printer_period_min = "record_printer_period_min";

64
appsrc/baseservice/db/db_service.cpp

@ -36,7 +36,8 @@ using namespace nlohmann;
make_column("val_type", &Setting::val_type), /**/ \
make_column("val", &Setting::val), /**/ \
make_column("default_val", &Setting::default_val), /**/ \
make_column("is_editable", &Setting::is_editable) /**/ \
make_column("is_editable", &Setting::is_editable), /**/ \
make_column("is_visible", &Setting::is_visible) /**/ \
)
#define FORMULA_DB_STRUCT \
@ -64,39 +65,40 @@ using namespace nlohmann;
* *
*******************************************************************************/
#define SETTING_ITEM(_id, _name, _name_ch, _val_type, _val_lower_limit, _val_upper_limit, _val, _is_editable) \
{ \
/**/ \
.id = _id, /**/ \
.name = _name, /**/ \
.name_ch = _name_ch, /**/ \
.val_type = _val_type, /**/ \
.val_lower_limit = _val_lower_limit, /**/ \
.val_upper_limit = _val_upper_limit, /**/ \
.val = _val, /**/ \
.default_val = _val, /**/ \
.is_editable = _is_editable /**/ \
#define SETTING_ITEM(_id, _name, _name_ch, _val_type, _val_lower_limit, _val_upper_limit, _val, _is_editable, _is_visible) \
{ \
/**/ \
.id = _id, /**/ \
.name = _name, /**/ \
.name_ch = _name_ch, /**/ \
.val_type = _val_type, /**/ \
.val_lower_limit = _val_lower_limit, /**/ \
.val_upper_limit = _val_upper_limit, /**/ \
.val = _val, /**/ \
.default_val = _val, /**/ \
.is_editable = _is_editable, /**/ \
.is_visible = _is_visible /**/ \
}
static Setting config_settings_table[] = {
SETTING_ITEM(1, "stoped_gs", /*********************/ "消毒停止过氧化氢溶度", "int", /**********/ "0", "2000", "300", true), //
SETTING_ITEM(2, "continued_gs", /******************/ "消毒继续过氧化氢溶度", "int", /**********/ "0", "2000", "200", true), //
SETTING_ITEM(3, "stoped_satur", /******************/ "消毒停止过氧化氢相对饱和度", "int", /*****/ "0", "100", "85", true), //
SETTING_ITEM(4, "continued_satur", /***************/ "消毒继续过氧化氢相对饱和度", "int", /*****/ "0", "100", "60", true), //
SETTING_ITEM(5, "max_humidity", /******************/ "允许消毒最大湿度", "int", /*************/ "0", "100", "90", true), //
SETTING_ITEM(6, "drainage_pump_speed", /***********/ "排液蠕动泵最大转速", "int", /************/ "0", "400", "400", true), //
SETTING_ITEM(7, "injection_pump_speed", /**********/ "喷射蠕动泵转速", "int", /***************/ "0", "40", "15", true), //
SETTING_ITEM(8, "pre_heat_time_s", /***************/ "预热时间", "int", /*******************/ "0", "1200", "120", true), //
SETTING_ITEM(9, "stoped_humi", /*******************/ "消毒停止相对湿度", "int", /************/ "0", "100", "85", true), //
SETTING_ITEM(10, "continued_humi", /***************/ "消毒继续相对湿度", "int", /************/ "0", "100", "60", true), //
SETTING_ITEM(11, "proportional_valve_default_value", "正负压默认开合比例", "int", "0", "100", "10", true), //
SETTING_ITEM(12, "record_period_min", "消毒日志记录间隔", "int", "1", "10", "1", true), //
SETTING_ITEM(13, "record_printer_period_min", "消毒日志打印间隔", "int", "1", "10", "3", true), //
SETTING_ITEM(14, "test_string", "字符串类型测试", "string", "", "", "12345", true), //
SETTING_ITEM(15, "test_float", "floag类型测试", "float", "1", "10", "3.4", true), //
SETTING_ITEM(16, "test_string", "字符串类型测试", "string", "", "", "12345", false), //
SETTING_ITEM(17, "test_bool", "bool类型测试", "bool", "false", "true", "false", false), //
SETTING_ITEM(1, "stoped_gs", /*********************/ "消毒停止过氧化氢溶度", "int", /**********/ "0", "2000", "300", true, true), //
SETTING_ITEM(2, "continued_gs", /******************/ "消毒继续过氧化氢溶度", "int", /**********/ "0", "2000", "200", true, true), //
SETTING_ITEM(3, "stoped_satur", /******************/ "消毒停止过氧化氢相对饱和度", "int", /*****/ "0", "100", "85", true, true), //
SETTING_ITEM(4, "continued_satur", /***************/ "消毒继续过氧化氢相对饱和度", "int", /*****/ "0", "100", "60", true, true), //
SETTING_ITEM(5, "max_humidity", /******************/ "允许消毒最大湿度", "int", /*************/ "0", "100", "90", true, true), //
SETTING_ITEM(6, "drainage_pump_speed", /***********/ "排液蠕动泵最大转速", "int", /************/ "0", "400", "400", true, true), //
SETTING_ITEM(7, "injection_pump_speed", /**********/ "喷射蠕动泵转速", "int", /***************/ "0", "40", "15", true, true), //
SETTING_ITEM(8, "pre_heat_time_s", /***************/ "预热时间", "int", /*******************/ "0", "1200", "120", true, true), //
SETTING_ITEM(9, "stoped_humi", /*******************/ "消毒停止相对湿度", "int", /************/ "0", "100", "85", true, true), //
SETTING_ITEM(10, "continued_humi", /***************/ "消毒继续相对湿度", "int", /************/ "0", "100", "60", true, true), //
SETTING_ITEM(11, "proportional_valve_default_value", "正负压默认开合比例", "int", "0", "100", "10", true, true), //
SETTING_ITEM(12, "record_period_min", "消毒日志记录间隔", "int", "1", "10", "1", true, true), //
SETTING_ITEM(13, "record_printer_period_min", "消毒日志打印间隔", "int", "1", "10", "3", true, true), //
SETTING_ITEM(14, "test_string", "字符串类型测试", "string", "", "", "12345", true, true), //
SETTING_ITEM(15, "test_float", "floag类型测试", "float", "1", "10", "3.4", true, true), //
SETTING_ITEM(16, "test_string", "字符串类型测试", "string", "", "", "12345", false, true), //
SETTING_ITEM(17, "test_bool", "bool类型测试", "bool", "false", "true", "false", false, true), //
};
#define ZARRARY_SIZE(val) (sizeof(val) / sizeof(val[0]))

16
appsrc/baseservice/db/db_service.hpp

@ -54,6 +54,20 @@ using namespace core;
using namespace nlohmann;
namespace db {
extern const char* ksetting_stoped_gs;
extern const char* ksetting_continued_gs;
extern const char* ksetting_stoped_satur;
extern const char* ksetting_continued_satur;
extern const char* ksetting_max_humidity;
extern const char* ksetting_drainage_pump_speed;
extern const char* ksetting_injection_pump_speed;
extern const char* ksetting_pre_heat_time_s;
extern const char* ksetting_stoped_humi;
extern const char* ksetting_continued_humi;
extern const char* ksetting_proportional_valve_default_value;
extern const char* ksetting_record_period_min;
extern const char* ksetting_record_printer_period_min;
struct User {
public:
int id;
@ -73,6 +87,8 @@ struct Setting {
string val;
string default_val;
bool is_editable;
bool is_visible;
bool is_supported_by_formula;
};
struct Formula {

140
appsrc/service/app/disinfection_ctrl_service.cpp

@ -0,0 +1,140 @@
#include "disinfection_ctrl_service.hpp"
using namespace iflytop;
static string disinfectionState2DisplayName(disinfection_state_t state) {
switch (state) {
case kstate_idle:
return "空闲";
case kstate_preheat:
return "预热";
case kstate_disinfection:
return "消毒中";
case kstate_degradation:
return "降解中";
case kstate_finished:
return "消毒完成";
case kstate_dehumidification_before_disinfection:
return "消毒前除湿";
case kstate_dehumidification_after_disinfection:
return "消毒后除湿";
case kstate_empty_liquid_from_the_line:
return "排空管路";
default:
return "未知";
}
}
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, getState);
REGFNV2(DisinfectionCtrlService, getServiceConfig);
}
/*******************************************************************************
* *
*******************************************************************************/
// 消毒前除
void DisinfectionCtrlService::fn_enableDehumidifyBD(shared_ptr<MsgProcessContext> cxt) {
//
bool enable = cxt->params["val"];
m_enableDehumidifyBD = enable;
}
void DisinfectionCtrlService::fn_setDehumidifyBDThreshold(shared_ptr<MsgProcessContext> cxt) {
int threshold = cxt->params["val"];
m_dehumidifyBDThreshold = threshold;
}
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_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_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_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;
}
void DisinfectionCtrlService::fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt) {
//
//
}

87
appsrc/service/app/disinfection_ctrl_service.hpp

@ -0,0 +1,87 @@
#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 "baseservice/baseservice.hpp"
namespace iflytop {
class DisinfectionCtrlService : public enable_shared_from_this<DisinfectionCtrlService> {
ENABLE_LOGGER(DisinfectionCtrlService);
typedef struct {
int pre_heat_time_s;
int stoped_gs;
int continued_gs;
int stoped_satur;
int continued_satur;
int stoped_humi;
int continued_humi;
int injection_pump_speed;
} cfg_t;
typedef struct {
bool enable_bf_dinft_dehumidification;
bool enable_af_dinft_dehumidification;
bool enable_degradation;
int bf_dinft_dehumidification_target_val;
int af_dinft_dehumidification_target_val;
int degradation_target_val;
} beforeRunCfg_t;
public:
shared_ptr<DBService> m_db;
shared_ptr<DeviceStateService> m_ds;
shared_ptr<GConfig> m_gConfig;
bool m_enableDehumidifyBD = false;
int m_dehumidifyBDThreshold = 0;
bool m_enableDehumidifyAD = false;
int m_dehumidifyADThreshold = 0;
bool m_enableDegradeAD = false;
cfg_t m_runCfg;
beforeRunCfg_t m_beforeRunCfg;
disinfection_state_t m_state = kstate_idle;
public:
void initialize();
public:
public:
/*******************************************************************************
* *
*******************************************************************************/
void fn_enableDehumidifyBD(shared_ptr<MsgProcessContext> cxt); // 消毒前除湿
void fn_setDehumidifyBDThreshold(shared_ptr<MsgProcessContext> cxt);
void fn_enableDehumidifyAD(shared_ptr<MsgProcessContext> cxt); // 消毒后除湿
void fn_setDehumidifyADThreshold(shared_ptr<MsgProcessContext> cxt);
void fn_enableDegradeAD(shared_ptr<MsgProcessContext> cxt); // 消毒后降解
/*******************************************************************************
* *
*******************************************************************************/
void fn_startDisinfection(shared_ptr<MsgProcessContext> cxt);
void fn_changeDisinfectionParameter(shared_ptr<MsgProcessContext> cxt);
void fn_getDisinfectionConfig(shared_ptr<MsgProcessContext> cxt);
void fn_stopDisinfection(shared_ptr<MsgProcessContext> cxt);
/*******************************************************************************
* *
*******************************************************************************/
void fn_getState(shared_ptr<MsgProcessContext> cxt);
void fn_getServiceConfig(shared_ptr<MsgProcessContext> cxt);
private:
};
} // namespace iflytop

4
appsrc/service/app/disinfection_service.cpp

@ -1,4 +0,0 @@
#include "disinfection_service.hpp"
using namespace iflytop;
void DisinfectionService::initialize() { logger->info("DisinfectionService initialize"); }

27
appsrc/service/app/disinfection_service.hpp

@ -1,27 +0,0 @@
#pragma once
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
//
#include "baseservice/baseservice.hpp"
namespace iflytop {
class DisinfectionService : public enable_shared_from_this<DisinfectionService> {
ENABLE_LOGGER(DisinfectionService);
shared_ptr<DBService> m_db;
shared_ptr<DeviceStateService> m_ds;
shared_ptr<GConfig> m_gConfig;
public:
void initialize();
private:
};
} // namespace iflytop

11
appsrc/service/disinfection_logs_service.hpp

@ -15,17 +15,6 @@
namespace iflytop {
typedef enum {
kstate_idle = 0, // 空闲
kstate_preheat = 1, // 预热
kstate_disinfection = 2, // 消毒中-工作
kstate_degradation = 4, // 降解中
kstate_finished = 5, // 结束
kstate_dehumidification_before_disinfection = 6, // 消毒前除湿
kstate_dehumidification_after_disinfection = 7, // 消毒后除湿
kstate_empty_liquid_from_the_line = 8, // 排空管路中的液体
} disinfection_state_t;
class StateSnapshot {
public:

5
appsrc/service/main_control_service.cpp

@ -13,7 +13,7 @@
//
#include "service/app/add_liquid_service.hpp"
#include "service/app/air_tightness_test.hpp"
#include "service/app/disinfection_service.hpp"
#include "service/app/disinfection_ctrl_service.hpp"
#include "service/app/drain_liquid_service.hpp"
#include "service/app/pipeline_pressure_control.hpp"
@ -36,7 +36,6 @@ void MainControlService::initialize() {
BUILD_AND_REG_SERRVICE(DBService);
BUILD_AND_REG_SERRVICE(DeviceStateService);
BUILD_AND_REG_SERRVICE(PipelinePressureControl);
//
BUILD_AND_REG_SERRVICE(UDiskMgrService);
//
@ -55,7 +54,7 @@ void MainControlService::initialize() {
BUILD_AND_REG_SERRVICE(AddLiquidService);
BUILD_AND_REG_SERRVICE(AirTightnessTest);
BUILD_AND_REG_SERRVICE(DisinfectionService);
BUILD_AND_REG_SERRVICE(DisinfectionCtrlService);
BUILD_AND_REG_SERRVICE(DrainLiquidService);
//

2
appsrc/service/setting_mgr_service.cpp

@ -30,7 +30,7 @@ void SettingMgrService::getAllFormula(shared_ptr<MsgProcessContext> cxt) { cxt->
void SettingMgrService::addNewFormula(shared_ptr<MsgProcessContext> cxt) {
string formula_id = "新建配方";
int loglevel = 3;
int loglevel = 3;//
int stoped_gs = m_db->getSettingVal("stoped_gs");
int continued_gs = m_db->getSettingVal("continued_gs");
int stoped_satur = m_db->getSettingVal("stoped_satur");

Loading…
Cancel
Save