20 changed files with 161 additions and 238 deletions
-
2appdep/iflytop/core/components/zenum_template/enumtest.cpp
-
10appdep/iflytop/core/components/zenum_template/enumtest.hpp
-
61appdep/iflytop/core/components/zenum_template/zenum_template.hpp
-
2appsrc/appbase/appbean/disinfection_state.cpp
-
15appsrc/appbase/appbean/disinfection_state.hpp
-
2appsrc/appbase/appbean/setting_id.cpp
-
26appsrc/appbase/appbean/setting_id.hpp
-
3appsrc/appbase/dep.hpp
-
36appsrc/appbase/disinfection_state.hpp
-
89appsrc/baseservice/db/base/dbbase.cpp
-
74appsrc/baseservice/db/base/dbbase.hpp
-
6appsrc/main.cpp
-
53appsrc/service/app/disinfection_ctrl_service.cpp
-
2appsrc/service/app/disinfection_ctrl_service.hpp
-
16appsrc/service/disinfection_logs_service.cpp
-
2appsrc/service/disinfection_logs_service.hpp
-
0appsrc/service/hardware/device_ctrl_service.cpp
-
0appsrc/service/hardware/device_ctrl_service.hpp
@ -0,0 +1,2 @@ |
|||
#include "enumtest.hpp"
|
|||
ZENUM_IMPL(ETest, ETest_LIST); |
@ -0,0 +1,10 @@ |
|||
#include "iflytop/core/components/zenum_template/zenum_template.hpp"
|
|||
|
|||
#define ETest_LIST(type, marco) /**/ \
|
|||
marco(type, a1) /**/ \ |
|||
marco(type, a2) /**/ \ |
|||
marco(type, a3) /**/ \ |
|||
marco(type, a4) /**/ \ |
|||
marco(type, a5) |
|||
|
|||
ZENUM_DECLAR(ETest, ETest_LIST); |
@ -0,0 +1,61 @@ |
|||
#pragma once
|
|||
|
|||
#include <sqlite3.h>
|
|||
#include <stdio.h>
|
|||
|
|||
#include <fstream>
|
|||
#include <functional>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <mutex>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
#include "iflytop/core/basic/nlohmann/json.hpp"
|
|||
|
|||
#define ZENUM_IMPL1(type, enumname) k##enumname,
|
|||
|
|||
#define ZENUM_IMPL2(type, enumname) const static type enumname;
|
|||
#define ZENUM_IMPL3(type, enumname) const type type::enumname = {k##enumname};
|
|||
|
|||
#define ZENUM_TO_STR_IMPL(type, enumname) \
|
|||
case k##enumname: \ |
|||
return #enumname; |
|||
|
|||
#define ZENUM_TO_ENUM_IMPL(type, enumname) \
|
|||
if (str == #enumname) { \ |
|||
return k##enumname; \ |
|||
} |
|||
|
|||
#define ZENUM_DECLAR(name, elist) \
|
|||
namespace iflytop { \ |
|||
using namespace std; \ |
|||
using namespace nlohmann; \ |
|||
class name { \ |
|||
public: \ |
|||
typedef enum { elist(name, ZENUM_IMPL1) kunkown } enum_val_t; \ |
|||
enum_val_t id; \ |
|||
elist(name, ZENUM_IMPL2) public : name() {} \ |
|||
name(enum_val_t id) : id(id) {} \ |
|||
name(string str) : id(toEnum(str)) {} \ |
|||
enum_val_t getId() const { return id; } \ |
|||
static string toString(enum_val_t enu) { \ |
|||
switch (enu) { elist(name, ZENUM_TO_STR_IMPL) default : return "unknown"; } \ |
|||
} \ |
|||
static enum_val_t toEnum(string str) { elist(name, ZENUM_TO_ENUM_IMPL) return kunkown; } \ |
|||
operator string() const { return toString(id); } \ |
|||
operator int() const { return int(id); } \ |
|||
bool operator==(const name& setid) const { return id == setid.id; } \ |
|||
}; \ |
|||
static inline void to_json(json& j, const name& setid) { j = setid.toString(setid.getId()); } \ |
|||
static inline void from_json(const json& j, name& setid) { setid = name(string(j)); } \ |
|||
} |
|||
|
|||
#define ZENUM_IMPL(name, elist) \
|
|||
namespace iflytop { \ |
|||
elist(name, ZENUM_IMPL3) \ |
|||
} |
@ -0,0 +1,2 @@ |
|||
#include "disinfection_state.hpp"
|
|||
DisinfectionState_ZENUM_IMPL |
@ -0,0 +1,15 @@ |
|||
#include "iflytop/core/components/zenum_template/zenum_template.hpp"
|
|||
|
|||
|
|||
#define DisinfectionState_ZENUM_IMPL ZENUM_IMPL(DisinfectionState, DisinfectionState_LIST)
|
|||
#define DisinfectionState_LIST(type, marco) /**/ \
|
|||
marco(type, idle) /**/ \ |
|||
marco(type, preheat) /**/ \ |
|||
marco(type, disinfection) /**/ \ |
|||
marco(type, degradation) /**/ \ |
|||
marco(type, finished) /**/ \ |
|||
marco(type, dehumidification_before_disinfection) /**/ \ |
|||
marco(type, dehumidification_after_disinfection) /**/ \ |
|||
marco(type, empty_liquid_from_the_line) /**/ |
|||
|
|||
ZENUM_DECLAR(DisinfectionState, DisinfectionState_LIST); |
@ -0,0 +1,2 @@ |
|||
#include "setting_id.hpp"
|
|||
SettingId_ZENUM_IMPL |
@ -0,0 +1,26 @@ |
|||
#include "iflytop/core/components/zenum_template/zenum_template.hpp"
|
|||
|
|||
#define SettingId_ZENUM_IMPL ZENUM_IMPL(SettingId, SettingId_LIST)
|
|||
#define SettingId_LIST(type, marco) /**/ \
|
|||
marco(type, stoped_gs) /**/ \ |
|||
marco(type, continued_gs) /**/ \ |
|||
marco(type, stoped_satur) /**/ \ |
|||
marco(type, continued_satur) /**/ \ |
|||
marco(type, max_humidity) /**/ \ |
|||
marco(type, drainage_pump_speed) /**/ \ |
|||
marco(type, injection_pump_speed) /**/ \ |
|||
marco(type, pre_heat_time_s) /**/ \ |
|||
marco(type, stoped_humi) /**/ \ |
|||
marco(type, continued_humi) /**/ \ |
|||
marco(type, proportional_valve_default_value) /**/ \ |
|||
marco(type, record_period_min) /**/ \ |
|||
marco(type, record_printer_period_min) /**/ \ |
|||
marco(type, loglevel) /*消毒等级*/ \ |
|||
marco(type, enable_bd_dehumidify) /*是否启用BD除湿*/ \ |
|||
marco(type, bd_dehumidify_threshold) /*BD除湿阈值*/ \ |
|||
marco(type, enable_ad_dehumidify) /*是否启用AD除湿*/ \ |
|||
marco(type, ad_dehumidify_threshold) /*AD除湿阈值*/ \ |
|||
marco(type, enable_ad_degrade) /*是否启用AD降解*/ \ |
|||
marco(type, ad_degrade_threshold) /*AD降解阈值*/ |
|||
|
|||
ZENUM_DECLAR(SettingId, SettingId_LIST); |
@ -1,41 +1,7 @@ |
|||
#pragma once
|
|||
#include <string>
|
|||
#include "appbase/appbean/disinfection_state.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
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; |
|||
|
|||
static inline 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
|
@ -1,91 +1,2 @@ |
|||
#include "dbbase.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace core; |
|||
using namespace nlohmann; |
|||
namespace db { |
|||
|
|||
#define CR(val) \
|
|||
case val: \ |
|||
return #val; |
|||
|
|||
#define STR2INT(val) \
|
|||
if (str == #val) { \ |
|||
return val; \ |
|||
} |
|||
|
|||
string SettingId::toString(settingid_t enu) { |
|||
switch (enu) { |
|||
CR(stoped_gs) |
|||
CR(continued_gs) |
|||
CR(stoped_satur) |
|||
CR(continued_satur) |
|||
CR(max_humidity) |
|||
CR(drainage_pump_speed) |
|||
CR(injection_pump_speed) |
|||
CR(pre_heat_time_s) |
|||
CR(stoped_humi) |
|||
CR(continued_humi) |
|||
CR(proportional_valve_default_value) |
|||
CR(record_period_min) |
|||
CR(record_printer_period_min) |
|||
CR(loglevel) |
|||
CR(enable_bd_dehumidify) |
|||
CR(bd_dehumidify_threshold) |
|||
CR(enable_ad_dehumidify) |
|||
CR(ad_dehumidify_threshold) |
|||
CR(enable_ad_degrade) |
|||
CR(ad_degrade_threshold) |
|||
|
|||
default: |
|||
return "unknown"; |
|||
} |
|||
} |
|||
SettingId::settingid_t SettingId::toEnum(string str) { |
|||
STR2INT(stoped_gs); |
|||
STR2INT(continued_gs); |
|||
STR2INT(stoped_satur); |
|||
STR2INT(continued_satur); |
|||
STR2INT(max_humidity); |
|||
STR2INT(drainage_pump_speed); |
|||
STR2INT(injection_pump_speed); |
|||
STR2INT(pre_heat_time_s); |
|||
STR2INT(stoped_humi); |
|||
STR2INT(continued_humi); |
|||
STR2INT(proportional_valve_default_value); |
|||
STR2INT(record_period_min); |
|||
STR2INT(record_printer_period_min); |
|||
STR2INT(loglevel); |
|||
STR2INT(enable_bd_dehumidify); |
|||
STR2INT(bd_dehumidify_threshold); |
|||
STR2INT(enable_ad_dehumidify); |
|||
STR2INT(ad_dehumidify_threshold); |
|||
STR2INT(enable_ad_degrade); |
|||
STR2INT(ad_degrade_threshold); |
|||
return (SettingId::settingid_t )0; |
|||
} |
|||
|
|||
SettingId SettingId::kstoped_gs = {stoped_gs}; |
|||
SettingId SettingId::kcontinued_gs = {continued_gs}; |
|||
SettingId SettingId::kstoped_satur = {stoped_satur}; |
|||
SettingId SettingId::kcontinued_satur = {continued_satur}; |
|||
SettingId SettingId::kmax_humidity = {max_humidity}; |
|||
SettingId SettingId::kdrainage_pump_speed = {drainage_pump_speed}; |
|||
SettingId SettingId::kinjection_pump_speed = {injection_pump_speed}; |
|||
SettingId SettingId::kpre_heat_time_s = {pre_heat_time_s}; |
|||
SettingId SettingId::kstoped_humi = {stoped_humi}; |
|||
SettingId SettingId::kcontinued_humi = {continued_humi}; |
|||
SettingId SettingId::kproportional_valve_default_value = {proportional_valve_default_value}; |
|||
SettingId SettingId::krecord_period_min = {record_period_min}; |
|||
SettingId SettingId::krecord_printer_period_min = {record_printer_period_min}; |
|||
SettingId SettingId::kloglevel = {loglevel}; |
|||
SettingId SettingId::kenable_bd_dehumidify = {enable_bd_dehumidify}; |
|||
SettingId SettingId::kbd_dehumidify_threshold = {bd_dehumidify_threshold}; |
|||
SettingId SettingId::kenable_ad_dehumidify = {enable_ad_dehumidify}; |
|||
SettingId SettingId::kad_dehumidify_threshold = {ad_dehumidify_threshold}; |
|||
SettingId SettingId::kenable_ad_degrade = {enable_ad_degrade}; |
|||
SettingId SettingId::kad_degrade_threshold = {ad_degrade_threshold}; |
|||
|
|||
} // namespace db
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue