Browse Source

update

master
zhaohe 8 months ago
parent
commit
51af98fb47
  1. 7
      README.md
  2. 3
      appdep/iflytop/core/spdlogfactory/logger_factory.cpp
  3. 3
      appsrc/appbase/appbase.hpp
  4. 2
      appsrc/appbase/appbean/device_type_enum.cpp
  5. 11
      appsrc/appbase/appbean/device_type_enum.hpp
  6. 2
      appsrc/appconfig/basic/zappversion.hpp
  7. 4
      appsrc/baseservice/db/device_ext_setting_dao.cpp
  8. 4
      appsrc/baseservice/db/device_ext_setting_dao.hpp
  9. 2
      appsrc/service/app_core.cpp
  10. 11
      appsrc/service/calibration/h2o2_liquid_weight_sensor_calibration_service.cpp
  11. 1
      appsrc/service/device_info_mgr_service.cpp
  12. 17
      appsrc/service/hardware/disinfectant_weight_update_service.cpp
  13. 9
      appsrc/service/hardware/disinfectant_weight_update_service.hpp
  14. 29
      appsrc/service/setting/ext_setting_mgr_service.cpp
  15. 4
      appsrc/service/setting/ext_setting_mgr_service.hpp

7
README.md

@ -111,6 +111,13 @@ VERSION 2.0.1
4. 支持液体重量传感器校准接口。 4. 支持液体重量传感器校准接口。
5. 支持设备类型 UI 修改。 5. 支持设备类型 UI 修改。
VERSION 2.0.2
1. 添加毛重,净重
VERSION 2.0.3
1. 增加设备信息配置接口
TODO: TODO:
1. 设备使用时间维护(UI接口已经准备好,考虑是否使用文件袋放在设备中的方案) 1. 设备使用时间维护(UI接口已经准备好,考虑是否使用文件袋放在设备中的方案)
2. 升级方案 2. 升级方案

3
appdep/iflytop/core/spdlogfactory/logger_factory.cpp

@ -145,6 +145,9 @@ static string default_config = R"(
"name": "infologger", "name": "infologger",
"type": "rotating_file_sink_mt", "type": "rotating_file_sink_mt",
"filename": "logs/infolog.log", "filename": "logs/infolog.log",
"max_file_size":10485760,
"max_files":3,
"rotate_on_open":true,
"level" : 2 "level" : 2
}, },
{ {

3
appsrc/appbase/appbase.hpp

@ -15,4 +15,5 @@
#include "appbean/device_state.hpp" #include "appbean/device_state.hpp"
#include "appbase/appbean/h2o2_sensor_data_snapshot.hpp" #include "appbase/appbean/h2o2_sensor_data_snapshot.hpp"
#include "appbase/appbean/air_leak_test_mode.hpp" #include "appbase/appbean/air_leak_test_mode.hpp"
#include "appbase/appbean/project_type_enum.hpp"
#include "appbase/appbean/project_type_enum.hpp"
#include "appbase/appbean/device_type_enum.hpp"

2
appsrc/appbase/appbean/device_type_enum.cpp

@ -0,0 +1,2 @@
#include "device_type_enum.hpp"
DeviceTypeZENUM_IMPL

11
appsrc/appbase/appbean/device_type_enum.hpp

@ -0,0 +1,11 @@
#pragma once
#include "iflytop/core/components/zenum_template/zenum_template.hpp"
#define DeviceTypeZENUM_IMPL ZENUM_IMPL(DeviceType, DeviceTypeLIST)
#define DeviceTypeLIST(type, marco) /**/ \
marco(type, DT_600N) /*大空间*/ \
marco(type, DT_300N) /*小空间*/ \
marco(type, DT_300W) /*管道式*/ \
marco(type, DT_100N) /*拉杆箱*/
ZENUM_DECLAR(DeviceType, DeviceTypeLIST);

2
appsrc/appconfig/basic/zappversion.hpp

@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION "2.0.2"
#define VERSION "2.0.3"
#define PROJECT_NAME "TRANSMIT_DM" #define PROJECT_NAME "TRANSMIT_DM"

4
appsrc/baseservice/db/device_ext_setting_dao.cpp

@ -42,6 +42,7 @@ DeviceExtSetting DeviceExtSettingDAO::getDeviceExtSetting() { //
setting.dvalueCoefficient = get("printerBaudrate", 2); setting.dvalueCoefficient = get("printerBaudrate", 2);
setting.projectTypes = get("projectTypes", ""); setting.projectTypes = get("projectTypes", "");
setting.h2o2SensorExpireTimeMonth = get("h2o2SensorExpireTimeMonth", 12); setting.h2o2SensorExpireTimeMonth = get("h2o2SensorExpireTimeMonth", 12);
setting.deviceType = get("deviceType", "");
return setting; return setting;
} }
@ -57,4 +58,5 @@ void DeviceExtSettingDAO::setCanIF(string canIF) { set("canIF", canIF); }
void DeviceExtSettingDAO::setCanBitrate(int32_t canBitrate) { set("canBitrate", to_string(canBitrate)); } void DeviceExtSettingDAO::setCanBitrate(int32_t canBitrate) { set("canBitrate", to_string(canBitrate)); }
void DeviceExtSettingDAO::setPrinterUartPath(string printerUartPath) { set("printerUartPath", printerUartPath); } void DeviceExtSettingDAO::setPrinterUartPath(string printerUartPath) { set("printerUartPath", printerUartPath); }
void DeviceExtSettingDAO::setDvalueCoefficient(float dvalueCoefficient) { set("dvalueCoefficient", to_string(dvalueCoefficient)); } void DeviceExtSettingDAO::setDvalueCoefficient(float dvalueCoefficient) { set("dvalueCoefficient", to_string(dvalueCoefficient)); }
void DeviceExtSettingDAO::setH2o2SensorExpireTimeMonth(int32_t h2o2SensorExpireTimeMonth) { set("h2o2SensorExpireTimeMonth", to_string(h2o2SensorExpireTimeMonth)); }
void DeviceExtSettingDAO::setH2o2SensorExpireTimeMonth(int32_t h2o2SensorExpireTimeMonth) { set("h2o2SensorExpireTimeMonth", to_string(h2o2SensorExpireTimeMonth)); }
void DeviceExtSettingDAO::setDeviceType(string deviceType) { set("deviceType", deviceType); }

4
appsrc/baseservice/db/device_ext_setting_dao.hpp

@ -39,6 +39,7 @@ class DeviceExtSetting {
public: public:
string deviceId; // 设备ID string deviceId; // 设备ID
string projectTypes; // 项目类型 string projectTypes; // 项目类型
string deviceType; // 设备类型,只做展示用,不做业务逻辑
string canIF; // can接口 string canIF; // can接口
int32_t canBitrate; // can波特率 int32_t canBitrate; // can波特率
@ -49,7 +50,7 @@ class DeviceExtSetting {
int32_t h2o2SensorExpireTimeMonth; // h2o2传感器过期时间,单位月 int32_t h2o2SensorExpireTimeMonth; // h2o2传感器过期时间,单位月
NLOHMANN_DEFINE_TYPE_INTRUSIVE(DeviceExtSetting, deviceId, projectTypes, canIF, canBitrate, printerUartPath, dvalueCoefficient,h2o2SensorExpireTimeMonth);
NLOHMANN_DEFINE_TYPE_INTRUSIVE(DeviceExtSetting, deviceId, projectTypes, deviceType, canIF, canBitrate, printerUartPath, dvalueCoefficient, h2o2SensorExpireTimeMonth);
}; };
} // namespace db } // namespace db
@ -88,6 +89,7 @@ class DeviceExtSettingDAO : public KeyValDBV2Dao {
void setPrinterUartPath(string printerUartPath); void setPrinterUartPath(string printerUartPath);
void setDvalueCoefficient(float dvalueCoefficient); void setDvalueCoefficient(float dvalueCoefficient);
void setH2o2SensorExpireTimeMonth(int32_t h2o2SensorExpireTimeMonth); void setH2o2SensorExpireTimeMonth(int32_t h2o2SensorExpireTimeMonth);
void setDeviceType(string deviceType);
// void setTestMode(bool testMode); // void setTestMode(bool testMode);
}; };

2
appsrc/service/app_core.cpp

@ -47,6 +47,8 @@ static void installEcodeInfo() {
REG_ENUM_TYPE(UsrRoleType, UsrRoleType::getEnumStrList()); REG_ENUM_TYPE(UsrRoleType, UsrRoleType::getEnumStrList());
REG_ENUM_TYPE(AppEventType, AppEventType::getEnumStrList()); REG_ENUM_TYPE(AppEventType, AppEventType::getEnumStrList());
REG_ENUM_TYPE(ProjectTypeEnum, ProjectTypeEnum::getEnumStrList()); REG_ENUM_TYPE(ProjectTypeEnum, ProjectTypeEnum::getEnumStrList());
REG_ENUM_TYPE(DeviceType, DeviceType::getEnumStrList());
AppEcodeInfoMgr::ins().regEcodeInfo(kerr_overtime, "通信超时"); AppEcodeInfoMgr::ins().regEcodeInfo(kerr_overtime, "通信超时");
AppEcodeInfoMgr::ins().regEcodeInfo(kerr_invalid_param, "非法参数"); AppEcodeInfoMgr::ins().regEcodeInfo(kerr_invalid_param, "非法参数");

11
appsrc/service/calibration/h2o2_liquid_weight_sensor_calibration_service.cpp

@ -6,16 +6,19 @@ using namespace core;
void H2O2LiquidWeightSensorCalibrationService::initialize() { void H2O2LiquidWeightSensorCalibrationService::initialize() {
GET_TO_SERVICE(m_disinfectantWeightUpdateService); GET_TO_SERVICE(m_disinfectantWeightUpdateService);
REG_EXTFN_VOID(tare, void(void)); // 去皮
REG_EXTFN_VOID(getWeight, float(void)); // 单位g
REG_EXTFN_VOID(tare, void(void)); // 去皮
REG_EXTFN_VOID(getWeight, json(void)); //
REG_EXTFN_VOID(getBias, json(void)); //
} }
void H2O2LiquidWeightSensorCalibrationService::tare(shared_ptr<MsgProcessContext> cxt) { // void H2O2LiquidWeightSensorCalibrationService::tare(shared_ptr<MsgProcessContext> cxt) { //
float weight = m_disinfectantWeightUpdateService->getWeight(); float weight = m_disinfectantWeightUpdateService->getWeight();
CalibrationInfoDao::ins()->setH2O2LiquidWeightSensorZeroBias(weight); CalibrationInfoDao::ins()->setH2O2LiquidWeightSensorZeroBias(weight);
} }
void H2O2LiquidWeightSensorCalibrationService::getWeight(shared_ptr<MsgProcessContext> cxt) { void H2O2LiquidWeightSensorCalibrationService::getWeight(shared_ptr<MsgProcessContext> cxt) {
float weight = m_disinfectantWeightUpdateService->getWeight();
cxt->rely["weight"] = weight;
float weight = m_disinfectantWeightUpdateService->getWeight();
float roughWeight = m_disinfectantWeightUpdateService->getRoughWeight();
cxt->rely["weight"] = weight;
cxt->rely["roughWeight"] = roughWeight;
} }
void H2O2LiquidWeightSensorCalibrationService::getBias(shared_ptr<MsgProcessContext> cxt) { void H2O2LiquidWeightSensorCalibrationService::getBias(shared_ptr<MsgProcessContext> cxt) {

1
appsrc/service/device_info_mgr_service.cpp

@ -15,6 +15,7 @@ void DeviceInfoMgrService::getDeviceInfo(shared_ptr<MsgProcessContext> cxt) { /
auto& content = cxt->rely; auto& content = cxt->rely;
content["projectType"] = PORT.getProjTypeString(); content["projectType"] = PORT.getProjTypeString();
content["appVersion"] = VERSION; content["appVersion"] = VERSION;
content["deviceType"] = DeviceExtSettingDAO::ins()->getDeviceExtSetting().deviceType;
content["mircoVersion"] = "3.0.0"; // TODO:换成真实的版本信息 content["mircoVersion"] = "3.0.0"; // TODO:换成真实的版本信息
content["ip"] = "192.168.73.10"; content["ip"] = "192.168.73.10";
content["deviceId"] = DeviceExtSettingDAO::ins()->getDeviceExtSetting().deviceId; content["deviceId"] = DeviceExtSettingDAO::ins()->getDeviceExtSetting().deviceId;

17
appsrc/service/hardware/disinfectant_weight_update_service.cpp

@ -30,8 +30,14 @@ float DisinfectantWeightUpdateService::getWeight() { //
throw m_e; throw m_e;
} }
} }
return netWeight;
return m_netWeight;
} }
float DisinfectantWeightUpdateService::getRoughWeight() {
lock_guard<mutex> lock(m_mutex);
return m_roughWeight;
}
void DisinfectantWeightUpdateService::updateWeightThread() { void DisinfectantWeightUpdateService::updateWeightThread() {
while (true) { while (true) {
if (PORT.isLageSpaceDM() || PORT.isSmallSpaceDM() || PORT.isPipeDM()) { if (PORT.isLageSpaceDM() || PORT.isSmallSpaceDM() || PORT.isPipeDM()) {
@ -70,7 +76,7 @@ void DisinfectantWeightUpdateService::updateWeight() {
setNetWeight(weight_g); setNetWeight(weight_g);
m_errorFlag = false; m_errorFlag = false;
logger->debug("updateWeightThread: pa={}, weight_g={}", pa, netWeight);
logger->debug("updateWeightThread: pa={}, weight_g={}", pa, m_netWeight);
} catch (const appexception& e) { } catch (const appexception& e) {
if (!m_errorFlag) { if (!m_errorFlag) {
{ {
@ -88,11 +94,10 @@ void DisinfectantWeightUpdateService::updateWeight() {
void DisinfectantWeightUpdateService::setNetWeight(float roughWeight) { void DisinfectantWeightUpdateService::setNetWeight(float roughWeight) {
float bias = CalibrationInfoDao::ins()->getH2O2LiquidWeightSensorZeroBias(); float bias = CalibrationInfoDao::ins()->getH2O2LiquidWeightSensorZeroBias();
float netWeight = roughWeight - bias; float netWeight = roughWeight - bias;
if (netWeight < 0) {
netWeight = 0;
}
if (netWeight < 0) netWeight = 0;
{ {
lock_guard<mutex> lock(m_mutex); lock_guard<mutex> lock(m_mutex);
this->netWeight = netWeight;
m_roughWeight = roughWeight;
this->m_netWeight = netWeight;
} }
} }

9
appsrc/service/hardware/disinfectant_weight_update_service.hpp

@ -39,8 +39,8 @@ class DisinfectantWeightUpdateService : public enable_shared_from_this<Disinfect
shared_ptr<DeviceIoControlService> deviceIoControlService; shared_ptr<DeviceIoControlService> deviceIoControlService;
MovingAverageFilter filter = {5}; MovingAverageFilter filter = {5};
float weightCache = 0;
float netWeight = 0;
float m_roughWeight = 0;
float m_netWeight = 0;
bool m_errorFlag = false; bool m_errorFlag = false;
appexception m_e; appexception m_e;
@ -50,12 +50,13 @@ class DisinfectantWeightUpdateService : public enable_shared_from_this<Disinfect
public: public:
void initialize(); void initialize();
float getWeight(); float getWeight();
float getRoughWeight();
float getWeightNoExpection(); float getWeightNoExpection();
public: public:
void updateWeightThread();
void updateWeight();
void updateWeightThread();
void updateWeight();
void setNetWeight(float roughWeight); void setNetWeight(float roughWeight);
}; };

29
appsrc/service/setting/ext_setting_mgr_service.cpp

@ -9,8 +9,11 @@ void ExtSettingMgrService::initialize() {
REG_EXTFN_VOID(showHelp, json(void)); // 单位g REG_EXTFN_VOID(showHelp, json(void)); // 单位g
REG_EXTFN_VOID(getSetting, json(void)); // 单位g REG_EXTFN_VOID(getSetting, json(void)); // 单位g
REG_EXTFN(setDeviceId, void(string));
REG_EXTFN(setProjectTypes, void(ProjectTypeEnum));
// REG_EXTFN(setDeviceId, void(string));
// REG_EXTFN(setProjectTypes, void(ProjectTypeEnum));
// REG_EXTFN(setDeviceType, void(DeviceType));
REG_EXTFN(setDeviceInfo, json(DeviceType, int, int, int, int, int), deviceType, year, month, day, index);
REG_EXTFN(setCanIF, void(string)); REG_EXTFN(setCanIF, void(string));
REG_EXTFN(setCanBitrate, void(int32_t)); REG_EXTFN(setCanBitrate, void(int32_t));
REG_EXTFN(setPrinterUartPath, void(string)); REG_EXTFN(setPrinterUartPath, void(string));
@ -63,6 +66,7 @@ void ExtSettingMgrService::showHelp(shared_ptr<MsgProcessContext> cxt) {
void ExtSettingMgrService::getSetting(shared_ptr<MsgProcessContext> cxt) { // void ExtSettingMgrService::getSetting(shared_ptr<MsgProcessContext> cxt) { //
cxt->rely["extSettings"] = DeviceExtSettingDAO::ins()->getDeviceExtSettingAsJson(); cxt->rely["extSettings"] = DeviceExtSettingDAO::ins()->getDeviceExtSettingAsJson();
} }
void ExtSettingMgrService::setDeviceType(shared_ptr<MsgProcessContext> cxt, DeviceType deviceType) { DeviceExtSettingDAO::ins()->setDeviceType(deviceType); }
void ExtSettingMgrService::setDeviceId(shared_ptr<MsgProcessContext> cxt, string deviceId) { DeviceExtSettingDAO::ins()->setDeviceId(deviceId); } void ExtSettingMgrService::setDeviceId(shared_ptr<MsgProcessContext> cxt, string deviceId) { DeviceExtSettingDAO::ins()->setDeviceId(deviceId); }
@ -79,3 +83,24 @@ void ExtSettingMgrService::setDvalueCoefficient(shared_ptr<MsgProcessContext> cx
void ExtSettingMgrService::setH2o2SensorExpireTimeMonth(shared_ptr<MsgProcessContext> cxt, int32_t h2o2SensorExpireTimeMonth) { DeviceExtSettingDAO::ins()->setH2o2SensorExpireTimeMonth(h2o2SensorExpireTimeMonth); } void ExtSettingMgrService::setH2o2SensorExpireTimeMonth(shared_ptr<MsgProcessContext> cxt, int32_t h2o2SensorExpireTimeMonth) { DeviceExtSettingDAO::ins()->setH2o2SensorExpireTimeMonth(h2o2SensorExpireTimeMonth); }
void ExtSettingMgrService::rebootDevice(shared_ptr<MsgProcessContext> cxt) { system("reboot"); } void ExtSettingMgrService::rebootDevice(shared_ptr<MsgProcessContext> cxt) { system("reboot"); }
void ExtSettingMgrService::setDeviceInfo(shared_ptr<MsgProcessContext> cxt, DeviceType type, int year, int month, int day, int index) {
string deviceIdPrefix;
if (type == DeviceType::DT_600N) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::LargeSpaceDM);
deviceIdPrefix = "DT-600N";
} else if (type == DeviceType::DT_300N) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::SmallSpaceDM);
deviceIdPrefix = "DT-300N";
} else if (type == DeviceType::DT_300W) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::PipeDM);
deviceIdPrefix = "DT-300W";
} else if (type == DeviceType::DT_100N) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::DrawBarDM);
deviceIdPrefix = "DT-100N";
}
DeviceExtSettingDAO::ins()->setDeviceType(type);
DeviceExtSettingDAO::ins()->setDeviceId(fmt::format("{}-{:0>2d}{:0>2d}{:0>2d}{:0>3d}", deviceIdPrefix, year, month, day, index));
cxt->rely["extSettings"] = DeviceExtSettingDAO::ins()->getDeviceExtSettingAsJson();
}

4
appsrc/service/setting/ext_setting_mgr_service.hpp

@ -25,8 +25,12 @@ class ExtSettingMgrService : public enable_shared_from_this<ExtSettingMgrService
void getSetting(shared_ptr<MsgProcessContext> cxt); void getSetting(shared_ptr<MsgProcessContext> cxt);
void showHelp(shared_ptr<MsgProcessContext> cxt); void showHelp(shared_ptr<MsgProcessContext> cxt);
void setDeviceInfo(shared_ptr<MsgProcessContext> cxt, DeviceType type, int year, int month, int day, int index);
void setDeviceId(shared_ptr<MsgProcessContext> cxt, string deviceId); void setDeviceId(shared_ptr<MsgProcessContext> cxt, string deviceId);
void setProjectTypes(shared_ptr<MsgProcessContext> cxt, ProjectTypeEnum projectTypes); void setProjectTypes(shared_ptr<MsgProcessContext> cxt, ProjectTypeEnum projectTypes);
void setDeviceType(shared_ptr<MsgProcessContext> cxt, DeviceType deviceType);
void setCanIF(shared_ptr<MsgProcessContext> cxt, string canIF); void setCanIF(shared_ptr<MsgProcessContext> cxt, string canIF);
void setCanBitrate(shared_ptr<MsgProcessContext> cxt, int32_t canBitrate); void setCanBitrate(shared_ptr<MsgProcessContext> cxt, int32_t canBitrate);
void setPrinterUartPath(shared_ptr<MsgProcessContext> cxt, string printerUartPath); void setPrinterUartPath(shared_ptr<MsgProcessContext> cxt, string printerUartPath);

Loading…
Cancel
Save