27 changed files with 820 additions and 144 deletions
-
15README.md
-
1appsrc/appbase/appbase.hpp
-
2appsrc/appbase/appbean/project_type_enum.cpp
-
13appsrc/appbase/appbean/project_type_enum.hpp
-
9appsrc/baseservice/baseservice.hpp
-
54appsrc/baseservice/db/base/keyvaldbv2.cpp
-
91appsrc/baseservice/db/base/keyvaldbv2.hpp
-
49appsrc/baseservice/db/calibrate_info_dao.cpp
-
75appsrc/baseservice/db/calibrate_info_dao.hpp
-
62appsrc/baseservice/db/device_ext_setting_dao.cpp
-
55appsrc/baseservice/db/device_ext_setting_dao.hpp
-
58appsrc/baseservice/db/equipment_usage_info_dao.cpp
-
82appsrc/baseservice/db/equipment_usage_info_dao.hpp
-
2appsrc/baseservice/front_msg_processer/front_msg_processer.cpp
-
8appsrc/baseservice/port/project_port.hpp
-
3appsrc/service/app/add_liquid_service.cpp
-
21appsrc/service/app_core.cpp
-
24appsrc/service/calibration/h2o2_liquid_weight_sensor_calibration_service.cpp
-
30appsrc/service/calibration/h2o2_liquid_weight_sensor_calibration_service.hpp
-
3appsrc/service/device_info_mgr_service.cpp
-
59appsrc/service/equipment_usage_info_mgr_service.cpp
-
29appsrc/service/equipment_usage_info_mgr_service.hpp
-
91appsrc/service/hardware/disinfectant_weight_update_service.cpp
-
5appsrc/service/hardware/disinfectant_weight_update_service.hpp
-
2appsrc/service/os_mgr_service.cpp
-
81appsrc/service/setting/ext_setting_mgr_service.cpp
-
40appsrc/service/setting/ext_setting_mgr_service.hpp
@ -0,0 +1,2 @@ |
|||
#include "project_type_enum.hpp"
|
|||
ProjectTypeEnumZENUM_IMPL |
@ -0,0 +1,13 @@ |
|||
#pragma once
|
|||
#include "iflytop/core/components/zenum_template/zenum_template.hpp"
|
|||
|
|||
|
|||
|
|||
#define ProjectTypeEnumZENUM_IMPL ZENUM_IMPL(ProjectTypeEnum, ProjectTypeEnumLIST)
|
|||
#define ProjectTypeEnumLIST(type, marco) /**/ \
|
|||
marco(type, LargeSpaceDM) /**/ \ |
|||
marco(type, SmallSpaceDM) /**/ \ |
|||
marco(type, PipeDM) /**/ \ |
|||
marco(type, DrawBarDM) /**/ |
|||
|
|||
ZENUM_DECLAR(ProjectTypeEnum, ProjectTypeEnumLIST); |
@ -0,0 +1,54 @@ |
|||
#include <sqlite3.h>
|
|||
|
|||
//
|
|||
#include <stdio.h>
|
|||
#include <time.h>
|
|||
|
|||
#include "keyvaldbv2.hpp"
|
|||
|
|||
//
|
|||
|
|||
using namespace std; |
|||
using namespace iflytop; |
|||
using namespace iflytop::db; |
|||
using namespace sqlite_orm; |
|||
using namespace nlohmann; |
|||
|
|||
bool KeyValDBV2Dao::set(string key, string val) { |
|||
lock_guard<recursive_mutex> lock(lock_); |
|||
|
|||
try { |
|||
auto all = storage.get_all<KeyValDBV2>(where(c(&KeyValDBV2::key) == key)); |
|||
if (all.size() == 0) { |
|||
storage.insert(KeyValDBV2{0, key, val}); |
|||
} else { |
|||
all[0].val = val; |
|||
storage.update(all[0]); |
|||
} |
|||
return true; |
|||
} catch (const std::exception& e) { |
|||
return false; |
|||
} |
|||
} |
|||
string KeyValDBV2Dao::get(string key, string defaultVal) { |
|||
lock_guard<recursive_mutex> lock(lock_); |
|||
|
|||
|
|||
try { |
|||
auto all = storage.get_all<KeyValDBV2>(where(c(&KeyValDBV2::key) == key)); |
|||
if (all.size() == 0) { |
|||
return defaultVal; |
|||
} |
|||
return all[0].val; |
|||
} catch (const std::exception& e) { |
|||
return defaultVal; |
|||
} |
|||
} |
|||
|
|||
int KeyValDBV2Dao::get(string key, int defaultVal) { return atoi(get(key, to_string(defaultVal)).c_str()); } |
|||
double KeyValDBV2Dao::get(string key, double defaultVal) { return atof(get(key, to_string(defaultVal)).c_str()); } |
|||
bool KeyValDBV2Dao::get(string key, bool defaultVal) { return get(key, defaultVal ? string("true") : string("false")) == "true"; } |
|||
|
|||
bool KeyValDBV2Dao::set(string key, int val) { return set(key, to_string(val)); } |
|||
bool KeyValDBV2Dao::set(string key, double val) { return set(key, to_string(val)); } |
|||
bool KeyValDBV2Dao::set(string key, bool val) { return set(key, val ? string("true") : string("false")); } |
@ -0,0 +1,91 @@ |
|||
#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 "appbase/appbasedep.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace std; |
|||
using namespace core; |
|||
using namespace nlohmann; |
|||
|
|||
/*******************************************************************************
|
|||
* DB STRUCT * |
|||
*******************************************************************************/ |
|||
|
|||
namespace db { |
|||
|
|||
struct KeyValDBV2 { |
|||
int id; |
|||
string key; |
|||
string val; |
|||
}; |
|||
|
|||
#define ZDB_TABLE(dbname) \
|
|||
sqlite_orm::make_table(dbname, /**/ \ |
|||
sqlite_orm::make_column("id", &KeyValDBV2::id, sqlite_orm::primary_key().autoincrement()), /**/ \ |
|||
sqlite_orm::make_column("key", &KeyValDBV2::key), /**/ \ |
|||
sqlite_orm::make_column("val", &KeyValDBV2::val) /**/ /**/ \ |
|||
) |
|||
|
|||
#define ZDB_MAKE_TABLE(dbpath, dbname) sqlite_orm::make_storage(dbpath, ZDB_TABLE(dbname))
|
|||
|
|||
} // namespace db
|
|||
using namespace db; |
|||
|
|||
/*******************************************************************************
|
|||
* DAO_IMPL * |
|||
*******************************************************************************/ |
|||
|
|||
class KeyValDBV2Dao { |
|||
THISCLASS(KeyValDBV2Dao); |
|||
|
|||
public: |
|||
recursive_mutex lock_; |
|||
bool inited = false; |
|||
|
|||
decltype(ZDB_MAKE_TABLE("", "")) storage; |
|||
|
|||
public: |
|||
KeyValDBV2Dao(string dbpath, string dbname) : storage(ZDB_MAKE_TABLE(dbpath, dbname)) {} |
|||
|
|||
public: |
|||
bool set(string key, string val); |
|||
bool set(string key, const char* val) { return set(key, string(val)); } |
|||
string get(string key, string defaultVal); |
|||
string get(string key, const char* defaultVal) { return get(key, string(defaultVal)).c_str(); } |
|||
|
|||
bool set(string key, int val); |
|||
bool set(string key, double val); |
|||
bool set(string key, bool val); |
|||
bool set(string key, float val) { return set(key, (double)val); } |
|||
|
|||
int get(string key, int defaultVal); |
|||
bool get(string key, bool defaultVal); |
|||
double get(string key, double defaultVal); |
|||
float get(string key, float defaultVal) { return get(key, (double)defaultVal); } |
|||
}; |
|||
|
|||
}; // namespace iflytop
|
|||
|
|||
#undef ZDB_TABLE
|
|||
#undef ZDB_MAKE_TABLE
|
@ -0,0 +1,49 @@ |
|||
#include <sqlite3.h>
|
|||
|
|||
//
|
|||
#include <stdio.h>
|
|||
#include <time.h>
|
|||
|
|||
#include "appconfig/appconfig.hpp"
|
|||
#include "calibrate_info_dao.hpp"
|
|||
//
|
|||
|
|||
using namespace std; |
|||
using namespace iflytop; |
|||
using namespace iflytop::db; |
|||
using namespace sqlite_orm; |
|||
using namespace nlohmann; |
|||
|
|||
CalibrationInfoDao::CalibrationInfoDao() : KeyValDBV2Dao("db/calibration_info", "calibration_info") {} |
|||
|
|||
void CalibrationInfoDao::initialize() { |
|||
mkdir("db", 0755); |
|||
|
|||
while (true) { |
|||
try { |
|||
logger->info("init {}", storage.filename()); |
|||
storage.sync_schema(); |
|||
break; |
|||
} catch (const std::exception& e) { |
|||
// 删除文件
|
|||
logger->error("init {} failed: {}", storage.filename(), e.what()); |
|||
system(fmt::format("rm -rf {}", storage.filename()).c_str()); |
|||
sleep(1); |
|||
} |
|||
} |
|||
} |
|||
|
|||
CalibrationInfo CalibrationInfoDao::getCalibrationInfo() { |
|||
CalibrationInfo info = {0}; |
|||
info.h2O2LiquidWeightSensorZeroBias = get("h2O2LiquidWeightSensorZeroBias", 0.0); |
|||
return info; |
|||
} |
|||
json CalibrationInfoDao::getCalibrationInfoJson() { |
|||
CalibrationInfo info = getCalibrationInfo(); |
|||
json j; |
|||
j["h2O2LiquidWeightSensorZeroBias"] = info.h2O2LiquidWeightSensorZeroBias; |
|||
return j; |
|||
} |
|||
|
|||
void CalibrationInfoDao::setH2O2LiquidWeightSensorZeroBias(float bias) { set("h2O2LiquidWeightSensorZeroBias", bias); } |
|||
float CalibrationInfoDao::getH2O2LiquidWeightSensorZeroBias() { return get("h2O2LiquidWeightSensorZeroBias", 0.0); } |
@ -0,0 +1,75 @@ |
|||
#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 "appbase/appbasedep.hpp"
|
|||
#include "base/keyvaldbv2.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace std; |
|||
using namespace core; |
|||
using namespace nlohmann; |
|||
|
|||
/*******************************************************************************
|
|||
* DB STRUCT * |
|||
*******************************************************************************/ |
|||
|
|||
namespace db { |
|||
typedef struct { |
|||
int id; |
|||
float h2O2LiquidWeightSensorZeroBias; // H2O2液体重量传感器零点偏差
|
|||
} CalibrationInfo; |
|||
} // namespace db
|
|||
using namespace db; |
|||
/*******************************************************************************
|
|||
* DAO_IMPL * |
|||
*******************************************************************************/ |
|||
|
|||
class CalibrationInfoDao : public KeyValDBV2Dao { |
|||
THISCLASS(CalibrationInfoDao); |
|||
|
|||
public: |
|||
CalibrationInfoDao(); |
|||
|
|||
static CalibrationInfoDao* ins() { |
|||
static CalibrationInfoDao instance; |
|||
if (!instance.inited) instance.initialize(); |
|||
instance.inited = true; |
|||
return &instance; |
|||
} |
|||
static void daoInit() { ins(); } |
|||
|
|||
public: |
|||
CalibrationInfo getCalibrationInfo(); |
|||
json getCalibrationInfoJson(); |
|||
|
|||
void setH2O2LiquidWeightSensorZeroBias(float bias); |
|||
float getH2O2LiquidWeightSensorZeroBias(); |
|||
|
|||
private: |
|||
void initialize(); |
|||
}; |
|||
|
|||
}; // namespace iflytop
|
|||
|
|||
#undef ZDB_MAKE_TABLE
|
|||
#undef TABLE_NAME
|
@ -0,0 +1,58 @@ |
|||
#include <sqlite3.h>
|
|||
|
|||
//
|
|||
#include <stdio.h>
|
|||
#include <time.h>
|
|||
|
|||
#include "appconfig/appconfig.hpp"
|
|||
#include "equipment_usage_info_dao.hpp"
|
|||
//
|
|||
|
|||
using namespace std; |
|||
using namespace iflytop; |
|||
using namespace iflytop::db; |
|||
using namespace sqlite_orm; |
|||
using namespace nlohmann; |
|||
|
|||
EquipmentUsageInfoDao::EquipmentUsageInfoDao(/* args */) : KeyValDBV2Dao("db/equipment_usage_info", "equipment_usage_info") {} |
|||
void EquipmentUsageInfoDao::initialize() { |
|||
mkdir("db", 0755); |
|||
|
|||
while (true) { |
|||
try { |
|||
logger->info("init {}", storage.filename()); |
|||
storage.sync_schema(); |
|||
break; |
|||
} catch (const std::exception& e) { |
|||
// 删除文件
|
|||
logger->error("init {} failed: {}", storage.filename(), e.what()); |
|||
system(fmt::format("rm -rf {}", storage.filename()).c_str()); |
|||
sleep(1); |
|||
} |
|||
} |
|||
} |
|||
|
|||
EquipmentUsageInfo EquipmentUsageInfoDao::getEquipmentUsageInfo() { |
|||
EquipmentUsageInfo info = {0}; |
|||
info.deviceUsageTimeSumaryS = get("deviceUsageTimeSumaryS", 0); |
|||
info.deviceFactoryTime = get("deviceFactoryTime", ""); |
|||
info.h2o2SensorUsageTimeSumaryS = get("h2o2SensorUsageTimeSumaryS", 0); |
|||
info.timeSinceLastDeviceMaintenanceS = get("timeSinceLastDeviceMaintenanceS", 0); |
|||
return info; |
|||
} |
|||
|
|||
void EquipmentUsageInfoDao::setCurrentTimeAsFactoryTime() { |
|||
string factoryTime = tu_sys::fmt(zsystem_clock().now(), "%Y-%m-%d"); |
|||
logger->info("setCurrentTimeAsFactoryTime {}", factoryTime); |
|||
set("deviceFactoryTime", factoryTime); |
|||
} |
|||
|
|||
void EquipmentUsageInfoDao::resetHO2SensorUsageTimeSumaryS() { |
|||
logger->info("resetHO2SensorUsageTimeSumaryS"); |
|||
set("h2o2SensorUsageTimeSumaryS", 0); |
|||
} |
|||
|
|||
void EquipmentUsageInfoDao::resetTimeSinceLastDeviceMaintenanceS() { |
|||
logger->info("resetTimeSinceLastDeviceMaintenanceS"); |
|||
set("timeSinceLastDeviceMaintenanceS", 0); |
|||
} |
@ -0,0 +1,82 @@ |
|||
#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 "appbase/appbasedep.hpp"
|
|||
#include "base/keyvaldbv2.hpp"
|
|||
#include "user_behavior_des.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace std; |
|||
using namespace core; |
|||
using namespace nlohmann; |
|||
|
|||
/*******************************************************************************
|
|||
* DB STRUCT * |
|||
*******************************************************************************/ |
|||
|
|||
namespace db { |
|||
|
|||
class EquipmentUsageInfo { |
|||
public: |
|||
// 设备使用时间汇总(秒)
|
|||
uint32_t deviceUsageTimeSumaryS; |
|||
// 设备出厂时间
|
|||
string deviceFactoryTime; |
|||
//
|
|||
uint32_t h2o2SensorUsageTimeSumaryS; |
|||
//
|
|||
uint32_t timeSinceLastDeviceMaintenanceS; |
|||
}; |
|||
|
|||
} // namespace db
|
|||
using namespace db; |
|||
/*******************************************************************************
|
|||
* DAO_IMPL * |
|||
*******************************************************************************/ |
|||
|
|||
class EquipmentUsageInfoDao : public KeyValDBV2Dao { |
|||
THISCLASS(EquipmentUsageInfoDao); |
|||
|
|||
public: |
|||
EquipmentUsageInfoDao(); |
|||
|
|||
static EquipmentUsageInfoDao* ins() { |
|||
static EquipmentUsageInfoDao instance; |
|||
if (!instance.inited) instance.initialize(); |
|||
instance.inited = true; |
|||
return &instance; |
|||
} |
|||
static void daoInit() { ins(); } |
|||
|
|||
private: |
|||
void initialize(); |
|||
|
|||
public: |
|||
EquipmentUsageInfo getEquipmentUsageInfo(); |
|||
|
|||
void setCurrentTimeAsFactoryTime(); |
|||
void resetHO2SensorUsageTimeSumaryS(); |
|||
void resetTimeSinceLastDeviceMaintenanceS(); |
|||
}; |
|||
|
|||
}; // namespace iflytop
|
@ -0,0 +1,24 @@ |
|||
#include "h2o2_liquid_weight_sensor_calibration_service.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
using namespace core; |
|||
|
|||
void H2O2LiquidWeightSensorCalibrationService::initialize() { |
|||
GET_TO_SERVICE(m_disinfectantWeightUpdateService); |
|||
REG_EXTFN_VOID(tare, void(void)); // 去皮
|
|||
REG_EXTFN_VOID(getWeight, float(void)); // 单位g
|
|||
} |
|||
void H2O2LiquidWeightSensorCalibrationService::tare(shared_ptr<MsgProcessContext> cxt) { //
|
|||
float weight = m_disinfectantWeightUpdateService->getWeight(); |
|||
CalibrationInfoDao::ins()->setH2O2LiquidWeightSensorZeroBias(weight); |
|||
} |
|||
void H2O2LiquidWeightSensorCalibrationService::getWeight(shared_ptr<MsgProcessContext> cxt) { |
|||
float weight = m_disinfectantWeightUpdateService->getWeight(); |
|||
cxt->rely["weight"] = weight; |
|||
} |
|||
|
|||
void H2O2LiquidWeightSensorCalibrationService::getBias(shared_ptr<MsgProcessContext> cxt) { |
|||
float bias = CalibrationInfoDao::ins()->getH2O2LiquidWeightSensorZeroBias(); |
|||
cxt->rely["bias"] = bias; |
|||
} |
@ -0,0 +1,30 @@ |
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
//
|
|||
#include "baseservice/baseservice.hpp"
|
|||
#include "service/hardware/disinfectant_weight_update_service.hpp"
|
|||
namespace iflytop { |
|||
class H2O2LiquidWeightSensorCalibrationService : public enable_shared_from_this<H2O2LiquidWeightSensorCalibrationService> { |
|||
THISCLASS(H2O2LiquidWeightSensorCalibrationService); |
|||
|
|||
shared_ptr<UDiskMgrService> m_udiskMgr; |
|||
shared_ptr<DisinfectantWeightUpdateService> m_disinfectantWeightUpdateService; |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
private: |
|||
void tare(shared_ptr<MsgProcessContext> cxt); |
|||
void getWeight(shared_ptr<MsgProcessContext> cxt); |
|||
void getBias(shared_ptr<MsgProcessContext> cxt); |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -0,0 +1,59 @@ |
|||
#include "equipment_usage_info_mgr_service.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
using namespace core; |
|||
|
|||
void EquipmentUsageInfoMgrService::initialize() { |
|||
REG_EXTFN_VOID(showHelp, json(void)); //
|
|||
REG_EXTFN_VOID(setCurTimeAsFactoryTime, void(void)); //
|
|||
REG_EXTFN_VOID(resetHO2SensorUsageTimeSumaryS, float(void)); //
|
|||
REG_EXTFN_VOID(resetTimeSinceLastDeviceMaintenanceS, void(void)); |
|||
} |
|||
|
|||
void EquipmentUsageInfoMgrService::getEquipmentUsageInfo(shared_ptr<MsgProcessContext> cxt) { //
|
|||
auto var = EquipmentUsageInfoDao::ins()->getEquipmentUsageInfo(); |
|||
auto exsetting = DeviceExtSettingDAO::ins()->getDeviceExtSetting(); |
|||
|
|||
cxt->rely["equipmentUsageInfo"]["deviceUsageTimeSumaryS"] = var.deviceUsageTimeSumaryS; |
|||
cxt->rely["equipmentUsageInfo"]["deviceFactoryTime"] = var.deviceFactoryTime; |
|||
cxt->rely["equipmentUsageInfo"]["h2o2SensorUsageTimeSumaryS"] = var.h2o2SensorUsageTimeSumaryS; |
|||
cxt->rely["equipmentUsageInfo"]["h2o2SensorExpired"] = var.h2o2SensorUsageTimeSumaryS > (exsetting.h2o2SensorExpireTimeMonth * 30 * 24 * 60 * 60); |
|||
} |
|||
|
|||
void EquipmentUsageInfoMgrService::showHelp(shared_ptr<MsgProcessContext> cxt) { |
|||
json helpiterm; |
|||
helpiterm["name"] = "deviceUsageTimeSumaryS"; |
|||
helpiterm["chname"] = "设备使用时间(S)"; |
|||
helpiterm["desc"] = "设备使用时间(S)"; |
|||
cxt->rely["help"].push_back(helpiterm); |
|||
|
|||
helpiterm["name"] = "deviceFactoryTime"; |
|||
helpiterm["chname"] = "设备出厂时间"; |
|||
helpiterm["desc"] = "设备出厂时间"; |
|||
cxt->rely["help"].push_back(helpiterm); |
|||
|
|||
helpiterm["name"] = "h2o2SensorUsageTimeSumaryS"; |
|||
helpiterm["chname"] = "H2O2传感器使用时间(S)"; |
|||
helpiterm["desc"] = "H2O2传感器使用时间(S)"; |
|||
cxt->rely["help"].push_back(helpiterm); |
|||
|
|||
helpiterm["name"] = "h2o2SensorExpired"; |
|||
helpiterm["chname"] = "H2O2传感器是否过期"; |
|||
helpiterm["desc"] = "H2O2传感器是否过期"; |
|||
cxt->rely["help"].push_back(helpiterm); |
|||
|
|||
helpiterm["name"] = "setCurTimeAsFactoryTime"; |
|||
helpiterm["chname"] = "设置当前时间为出厂时间"; |
|||
helpiterm["desc"] = "设置当前时间为出厂时间"; |
|||
cxt->rely["help"].push_back(helpiterm); |
|||
|
|||
helpiterm["name"] = "resetHO2SensorUsageTimeSumaryS"; |
|||
helpiterm["chname"] = "重置H2O2传感器使用时间"; |
|||
helpiterm["desc"] = "重置H2O2传感器使用时间"; |
|||
cxt->rely["help"].push_back(helpiterm); |
|||
} |
|||
|
|||
void EquipmentUsageInfoMgrService::setCurTimeAsFactoryTime(shared_ptr<MsgProcessContext> cxt) { EquipmentUsageInfoDao::ins()->setCurrentTimeAsFactoryTime(); } |
|||
void EquipmentUsageInfoMgrService::resetHO2SensorUsageTimeSumaryS(shared_ptr<MsgProcessContext> cxt) { EquipmentUsageInfoDao::ins()->resetHO2SensorUsageTimeSumaryS(); } |
|||
void EquipmentUsageInfoMgrService::resetTimeSinceLastDeviceMaintenanceS(shared_ptr<MsgProcessContext> cxt) { EquipmentUsageInfoDao::ins()->resetTimeSinceLastDeviceMaintenanceS(); } |
@ -0,0 +1,29 @@ |
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
//
|
|||
#include "baseservice/baseservice.hpp"
|
|||
#include "service/hardware/disinfectant_weight_update_service.hpp"
|
|||
namespace iflytop { |
|||
class EquipmentUsageInfoMgrService : public enable_shared_from_this<EquipmentUsageInfoMgrService> { |
|||
THISCLASS(EquipmentUsageInfoMgrService); |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
private: |
|||
void showHelp(shared_ptr<MsgProcessContext> cxt); |
|||
void getEquipmentUsageInfo(shared_ptr<MsgProcessContext> cxt); |
|||
void setCurTimeAsFactoryTime(shared_ptr<MsgProcessContext> cxt); |
|||
void resetHO2SensorUsageTimeSumaryS(shared_ptr<MsgProcessContext> cxt); |
|||
void resetTimeSinceLastDeviceMaintenanceS(shared_ptr<MsgProcessContext> cxt); |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -0,0 +1,81 @@ |
|||
#include "ext_setting_mgr_service.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
using namespace core; |
|||
|
|||
void ExtSettingMgrService::initialize() { |
|||
GET_TO_SERVICE(m_disinfectantWeightUpdateService); |
|||
|
|||
REG_EXTFN_VOID(showHelp, json(void)); // 单位g
|
|||
REG_EXTFN_VOID(getSetting, json(void)); // 单位g
|
|||
REG_EXTFN(setDeviceId, void(string)); |
|||
REG_EXTFN(setProjectTypes, void(ProjectTypeEnum)); |
|||
REG_EXTFN(setCanIF, void(string)); |
|||
REG_EXTFN(setCanBitrate, void(int32_t)); |
|||
REG_EXTFN(setPrinterUartPath, void(string)); |
|||
REG_EXTFN(setDvalueCoefficient, void(float)); |
|||
REG_EXTFN_VOID(rebootDevice, void(void)); //
|
|||
REG_EXTFN(setH2o2SensorExpireTimeMonth, void(int32_t)); |
|||
|
|||
// REG_EXTFN(setTestMode, void(bool));
|
|||
} |
|||
|
|||
void ExtSettingMgrService::showHelp(shared_ptr<MsgProcessContext> cxt) { |
|||
json helpinfo; |
|||
|
|||
helpinfo["name"] = "DeviceId"; |
|||
helpinfo["chname"] = "设备ID"; |
|||
helpinfo["desc"] = "设备ID,需要重启生效"; |
|||
cxt->rely["help"].push_back(helpinfo); |
|||
|
|||
helpinfo["name"] = "ProjectTypes"; |
|||
helpinfo["chname"] = "项目类型"; |
|||
helpinfo["desc"] = "项目类型,需要重启生效"; |
|||
cxt->rely["help"].push_back(helpinfo); |
|||
|
|||
helpinfo["name"] = "CanIF"; |
|||
helpinfo["chname"] = "CAN接口"; |
|||
helpinfo["desc"] = "CAN接口,需要重启生效"; |
|||
cxt->rely["help"].push_back(helpinfo); |
|||
|
|||
helpinfo["name"] = "CanBitrate"; |
|||
helpinfo["chname"] = "CAN波特率"; |
|||
helpinfo["desc"] = "CAN波特率,需要重启生效"; |
|||
cxt->rely["help"].push_back(helpinfo); |
|||
|
|||
helpinfo["name"] = "PrinterUartPath"; |
|||
helpinfo["chname"] = "打印机串口地址"; |
|||
helpinfo["desc"] = "打印机串口地址,需要重启生效"; |
|||
cxt->rely["help"].push_back(helpinfo); |
|||
|
|||
helpinfo["name"] = "DvalueCoefficient"; |
|||
helpinfo["chname"] = "D值系数"; |
|||
helpinfo["desc"] = "D值系数,需要重启生效"; |
|||
cxt->rely["help"].push_back(helpinfo); |
|||
|
|||
helpinfo["name"] = "H2o2SensorExpireTimeMonth"; |
|||
helpinfo["chname"] = "H2O2传感器有效期(月)"; |
|||
helpinfo["desc"] = "H2O2传感器有效期,需要重启生效"; |
|||
cxt->rely["help"].push_back(helpinfo); |
|||
} |
|||
|
|||
void ExtSettingMgrService::getSetting(shared_ptr<MsgProcessContext> cxt) { //
|
|||
cxt->rely["extSettings"] = DeviceExtSettingDAO::ins()->getDeviceExtSettingAsJson(); |
|||
} |
|||
|
|||
void ExtSettingMgrService::setDeviceId(shared_ptr<MsgProcessContext> cxt, string deviceId) { DeviceExtSettingDAO::ins()->setDeviceId(deviceId); } |
|||
|
|||
void ExtSettingMgrService::setProjectTypes(shared_ptr<MsgProcessContext> cxt, ProjectTypeEnum projectTypes) { DeviceExtSettingDAO::ins()->setProjectTypes(projectTypes); } |
|||
|
|||
void ExtSettingMgrService::setCanIF(shared_ptr<MsgProcessContext> cxt, string canIF) { DeviceExtSettingDAO::ins()->setCanIF(canIF); } |
|||
|
|||
void ExtSettingMgrService::setCanBitrate(shared_ptr<MsgProcessContext> cxt, int32_t canBitrate) { DeviceExtSettingDAO::ins()->setCanBitrate(canBitrate); } |
|||
|
|||
void ExtSettingMgrService::setPrinterUartPath(shared_ptr<MsgProcessContext> cxt, string printerUartPath) { DeviceExtSettingDAO::ins()->setPrinterUartPath(printerUartPath); } |
|||
|
|||
void ExtSettingMgrService::setDvalueCoefficient(shared_ptr<MsgProcessContext> cxt, float dvalueCoefficient) { DeviceExtSettingDAO::ins()->setDvalueCoefficient(dvalueCoefficient); } |
|||
|
|||
void ExtSettingMgrService::setH2o2SensorExpireTimeMonth(shared_ptr<MsgProcessContext> cxt, int32_t h2o2SensorExpireTimeMonth) { DeviceExtSettingDAO::ins()->setH2o2SensorExpireTimeMonth(h2o2SensorExpireTimeMonth); } |
|||
|
|||
void ExtSettingMgrService::rebootDevice(shared_ptr<MsgProcessContext> cxt) { system("reboot"); } |
@ -0,0 +1,40 @@ |
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
//
|
|||
#include "baseservice/baseservice.hpp"
|
|||
#include "service/hardware/disinfectant_weight_update_service.hpp"
|
|||
namespace iflytop { |
|||
class ExtSettingMgrService : public enable_shared_from_this<ExtSettingMgrService> { |
|||
THISCLASS(ExtSettingMgrService); |
|||
|
|||
shared_ptr<UDiskMgrService> m_udiskMgr; |
|||
shared_ptr<DisinfectantWeightUpdateService> m_disinfectantWeightUpdateService; |
|||
|
|||
public: |
|||
void initialize(); |
|||
|
|||
private: |
|||
void getSetting(shared_ptr<MsgProcessContext> cxt); |
|||
void showHelp(shared_ptr<MsgProcessContext> cxt); |
|||
|
|||
void setDeviceId(shared_ptr<MsgProcessContext> cxt, string deviceId); |
|||
void setProjectTypes(shared_ptr<MsgProcessContext> cxt, ProjectTypeEnum projectTypes); |
|||
void setCanIF(shared_ptr<MsgProcessContext> cxt, string canIF); |
|||
void setCanBitrate(shared_ptr<MsgProcessContext> cxt, int32_t canBitrate); |
|||
void setPrinterUartPath(shared_ptr<MsgProcessContext> cxt, string printerUartPath); |
|||
void setDvalueCoefficient(shared_ptr<MsgProcessContext> cxt, float dvalueCoefficient); |
|||
void setH2o2SensorExpireTimeMonth(shared_ptr<MsgProcessContext> cxt, int32_t h2o2SensorExpireTimeMonth); |
|||
// void setTestMode(shared_ptr<MsgProcessContext> cxt, bool testMode);
|
|||
|
|||
void rebootDevice(shared_ptr<MsgProcessContext> cxt); |
|||
}; |
|||
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue