Browse Source

v2.0.6

master
zhaohe 8 months ago
parent
commit
3bb1c89e65
  1. 2
      README.md
  2. 24
      appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp
  3. 6
      appsrc/appconfig/basic/project_constant.hpp
  4. 2
      appsrc/appconfig/basic/zappversion.hpp
  5. 4
      appsrc/baseservice/db/bean/user_behavior_des.cpp
  6. 2
      appsrc/baseservice/db/bean/user_behavior_des.hpp
  7. 2
      appsrc/baseservice/port/project_port.hpp
  8. 20
      appsrc/service/app/add_liquid_service.cpp
  9. 1
      appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
  10. 46
      appsrc/service/app/drain_liquid_service.cpp
  11. 17
      appsrc/service/app_core.cpp
  12. 7
      appsrc/service/debug_page_test_service.cpp
  13. 17
      appsrc/service/device_check_point_check_service.cpp
  14. 15
      appsrc/service/device_check_point_check_service.hpp
  15. 61
      appsrc/service/device_info_mgr_service.cpp
  16. 6
      appsrc/service/device_info_mgr_service.hpp
  17. 2
      appsrc/service/hardware/disinfectant_weight_update_service.cpp
  18. 10
      appsrc/service/setting/ext_setting_mgr_service.cpp

2
README.md

@ -117,6 +117,8 @@ VERSION 2.0.2
VERSION 2.0.3
1. 增加设备信息配置接口
VERSION 2.0.4
1. 修复部分BUG
TODO:
1. 设备使用时间维护(UI接口已经准备好,考虑是否使用文件袋放在设备中的方案)

24
appsrc/appbase/appevent/app_checkpoint_check_fail_event.hpp

@ -2,10 +2,30 @@
#include "iapp_event.hpp"
namespace iflytop {
typedef enum {
kCheckPointCode_Unknown = 0,
kCheckPointCode_evaporationBinWSTrigger,
kCheckPointCode_deviceBottomWSTrigger,
} CheckPointCode_t;
class CheckPoint {
public:
CheckPointCode_t index;
string name;
bool passed;
int ecode;
string ecodeInfo;
CheckPoint(CheckPointCode_t index, const string& name, bool passed) : index(index), name(name), passed(passed) {}
NLOHMANN_DEFINE_TYPE_INTRUSIVE(CheckPoint, index, ecode, ecodeInfo, name, passed);
};
class AppCheckPointCheckFailEvent : public IAppEvent {
private:
public:
AppCheckPointCheckFailEvent() : IAppEvent(AppEventType::AppCheckPointCheckFailEvent) {}
vector<CheckPoint> errCheckPoints;
public:
AppCheckPointCheckFailEvent(vector<CheckPoint> checkpoint) : IAppEvent(AppEventType::AppCheckPointCheckFailEvent) { errCheckPoints = checkpoint; }
virtual ~AppCheckPointCheckFailEvent() {}
NLOHMANN_DEFINE_TYPE_INTRUSIVE(AppCheckPointCheckFailEvent, uuid, type);

6
appsrc/appconfig/basic/project_constant.hpp

@ -20,8 +20,8 @@
// GPM_TO_SPEED_RADIO
#define LARGE_SPACE_DM__GPM_TO_SPEED_RADIO (11.1250)
#define SMALL_SPACE_DM__GPM_TO_SPEED_RADIO (11.1250)
#define PIPE_DM_GPM_TO_SPEED_RADIO (11.1250)
#define DRAW_BAR_DM_GPM_TO_SPEED_RADIO (41.97)
#define PIPE_DM_GPM_TO_SPEED_RADIO (11.1250)
#define DRAW_BAR_DM_GPM_TO_SPEED_RADIO (41.97)
// EXT_SENSOR_NUM
#define LARGE_SPACE_DM_EXT_SENSOR_NUM (2)
@ -34,5 +34,5 @@
#define LARGE_SPACE_DM__DISINFECTANT_BUCKET_CAPACITY 4800
#define SMALL_SPACE_DM__DISINFECTANT_BUCKET_CAPACITY 2800
#define PIPE_DM__DISINFECTANT_BUCKET_CAPACITY 2500
#define PIPE_DM__DISINFECTANT_BUCKET_CAPACITY 2300
#define DRAW_BAR_DM__DISINFECTANT_BUCKET_CAPACITY 0

2
appsrc/appconfig/basic/zappversion.hpp

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

4
appsrc/baseservice/db/bean/user_behavior_des.cpp

@ -44,6 +44,10 @@ string user_behavior_to_str(user_behavior_t behavior) {
return "导出消毒数据";
case kbehavior_export_user_action_data:
return "导出用户操作数据";
case kbehavior_warning_prompt:
return "警告信息";
case kbehavior_warning_prompt_confirm:
return "警告信息确认";
default:
break;
}

2
appsrc/baseservice/db/bean/user_behavior_des.hpp

@ -32,6 +32,8 @@ typedef enum {
kbehavior_export_disinfection_data = 16,
kbehavior_export_user_action_data = 17,
kbehavior_update_formula_name = 18,
kbehavior_warning_prompt = 19,
kbehavior_warning_prompt_confirm = 20,
} user_behavior_t;
string user_behavior_to_str(user_behavior_t behavior);

2
appsrc/baseservice/port/project_port.hpp

@ -56,7 +56,7 @@ class ProjectPort {
bool isDeviceTypeInited() { return deviceTypeInited; }
bool isBuildInPC() {
#ifdef BUILD_IN_PC
#ifdef BUILD_ON_PC
return true;
#else
return false;

20
appsrc/service/app/add_liquid_service.cpp

@ -30,9 +30,9 @@ void AddLiquidService::start(int stopatg) {
THROW_APP_EXCEPTION(getDeviceBusyReason(nowstate), "");
}
if (zsteady_clock().gets() < SENSOR_PREHEART_TIME_S) {
THROW_APP_EXCEPTION(err::kappe_sensor_is_pre_hearting, "");
}
// if (zsteady_clock().gets() < SENSOR_PREHEART_TIME_S) {
// THROW_APP_EXCEPTION(err::kappe_sensor_is_pre_hearting, "");
// }
if (m_thread && !m_thread->isWaitingForJoin()) {
THROW_APP_EXCEPTION(err::kappe_disinfection_state_is_wrong, "");
@ -50,7 +50,7 @@ void AddLiquidService::start(int stopatg) {
int32_t nowvolume = m_dwus->getWeight();
int maxg = PORT.getDisinfectantBucketCapacity();
if (nowvolume > stopatg) {
if (nowvolume >= stopatg) {
logger->warn("start add liquid fail, nowvolume {} > stopatg {}", nowvolume, stopatg);
THROW_APP_EXCEPTION(err::kappe_adding_liquid_is_already_in_place, "");
}
@ -96,8 +96,12 @@ void AddLiquidService::addLiquidWork(int stopatg, bool& errorflag) {
* @brief
*/
m_dics->setAddFluidChannelSelectorValve(true);
m_dics->AddLiquidPump_addLiquid();
/**
* @brief
*/
while (!thisThread.getExitFlag()) {
int32_t nowvolume = m_dwus->getWeight();
logger->info("replenishingFluids {}g", nowvolume);
@ -115,9 +119,13 @@ void AddLiquidService::addLiquidWork(int stopatg, bool& errorflag) {
thisThread.sleepForMs(300);
}
/**
* @brief
*/
m_dics->AddLiquidPump_stop();
thisThread.sleepForMs(2500);
thisThread.sleepForMs(1500); // 等待泵停止
/**
* @brief
*/

1
appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp

@ -226,6 +226,7 @@ void DisinfectionCtrlService::startWorkThread() {
if (!stopbyusrflag && ThisThread().getExitFlag()) {
stopbyusrflag = true;
sm.changeState(DisinfectionState::finished);
continue;
}
if (sm.getState() == DisinfectionState::finished) {

46
appsrc/service/app/drain_liquid_service.cpp

@ -1,6 +1,6 @@
#include "drain_liquid_service.hpp"
using namespace iflytop;
#define DRAINLIQUID_EXT_TIME_S 50
#define DRAINLIQUID_EXT_TIME_S 25
void DrainLiquidService::initialize() {
logger->info("DrainLiquidService initialize");
@ -29,9 +29,9 @@ void DrainLiquidService::start() {
THROW_APP_EXCEPTION(err::kappe_state_is_busy, "");
}
if (zsteady_clock().gets() < SENSOR_PREHEART_TIME_S) {
THROW_APP_EXCEPTION(err::kappe_sensor_is_pre_hearting, "");
}
// if (zsteady_clock().gets() < SENSOR_PREHEART_TIME_S) {
// THROW_APP_EXCEPTION(err::kappe_sensor_is_pre_hearting, "");
// }
if (m_thread && !m_thread->isWaitingForJoin()) {
THROW_APP_EXCEPTION(err::kappe_disinfection_state_is_wrong, "");
@ -91,7 +91,7 @@ void DrainLiquidService::getServiceConfig(shared_ptr<MsgProcessContext> cxt) {
void DrainLiquidService::workThread() {
ThisThread thisThread;
#if 0
m_dics->setAddFluidChannelSelectorValve(true);
m_dics->AddLiquidPump_drainLiquid();
m_dics->SprayPump_startInRPM(-PORT.getEmptyPipeSprayPumpRPM());
@ -135,7 +135,43 @@ void DrainLiquidService::workThread() {
m_dics->AddLiquidPump_stop();
m_dics->SprayPump_stop();
m_dics->setAddFluidChannelSelectorValve(false);
#endif
m_dics->setAddFluidChannelSelectorValve(true);
m_dics->AddLiquidPump_drainLiquid();
logger->info("startDraining ");
auto startdrainingtime = zsteady_clock().now();
zsteady_tp volumeReachZeroTime;
bool volumeReachZeroFlag = false;
while (!thisThread.getExitFlag()) {
int32_t nowvolume = m_dwus->getWeight();
logger->info("draining remain {} g", nowvolume);
if (!volumeReachZeroFlag && nowvolume <= 0) {
volumeReachZeroTime = zsteady_clock().now();
volumeReachZeroFlag = true;
}
if (m_dics->WaterSensor_readDeviceBottom()) {
AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(err::kappe_the_bottom_of_the_device_has_water));
break;
}
if (volumeReachZeroFlag) {
logger->info("stopDraining after {} s", DRAINLIQUID_EXT_TIME_S - zsteady_clock().elapsedTimeS(volumeReachZeroTime));
if (zsteady_clock().elapsedTimeS(volumeReachZeroTime) > DRAINLIQUID_EXT_TIME_S) {
break;
}
}
thisThread.sleepForMs(500);
}
logger->info("stopDraining");
m_dics->AddLiquidPump_stop();
thisThread.sleepForMs(1000);
m_dics->setAddFluidChannelSelectorValve(false);
}
void DrainLiquidService::getState(shared_ptr<MsgProcessContext> cxt) { cxt->rely = getState(); }

17
appsrc/service/app_core.cpp

@ -25,8 +25,8 @@
//
#include "baseservice/db/device_ext_setting_dao.hpp"
#include "calibration/h2o2_liquid_weight_sensor_calibration_service.hpp"
#include "setting/ext_setting_mgr_service.hpp"
#include "equipment_usage_info_mgr_service.hpp"
#include "setting/ext_setting_mgr_service.hpp"
// DeviceExtSettingDAO
@ -48,7 +48,6 @@ static void installEcodeInfo() {
REG_ENUM_TYPE(AppEventType, AppEventType::getEnumStrList());
REG_ENUM_TYPE(ProjectTypeEnum, ProjectTypeEnum::getEnumStrList());
REG_ENUM_TYPE(DeviceType, DeviceType::getEnumStrList());
AppEcodeInfoMgr::ins().regEcodeInfo(kerr_overtime, "通信超时");
AppEcodeInfoMgr::ins().regEcodeInfo(kerr_invalid_param, "非法参数");
@ -217,6 +216,15 @@ void AppCore::appEventConfirm(shared_ptr<MsgProcessContext> cxt, string evenid)
lock_guard<recursive_mutex> lock(appEventListMutex);
for (auto it = appEventList.begin(); it != appEventList.end(); it++) {
if ((*it)->uuid == evenid) {
if (dynamic_pointer_cast<AppWarningPromoptEvent>(*it)) {
ADD_USER_BEHAVIOR(DS->getLoginName(), kbehavior_warning_prompt_confirm, dynamic_pointer_cast<AppWarningPromoptEvent>(*it)->getDescription());
}
if (dynamic_pointer_cast<AppCheckPointCheckFailEvent>(*it)) {
vector<CheckPoint> checkPoints = dynamic_pointer_cast<AppCheckPointCheckFailEvent>(*it)->errCheckPoints;
for (auto& cp : checkPoints) {
ADD_USER_BEHAVIOR(DS->getLoginName(), kbehavior_warning_prompt_confirm, cp.ecodeInfo);
}
}
appEventList.erase(it);
break;
}
@ -233,8 +241,13 @@ void AppCore::insertAppEvent(shared_ptr<IAppEvent> event) {
if (dynamic_pointer_cast<AppWarningPromoptEvent>(event)) {
GET_SERVICE(WarningLightControler)->setwarningFlag(true);
ADD_USER_BEHAVIOR(DS->getLoginName(), kbehavior_warning_prompt, dynamic_pointer_cast<AppWarningPromoptEvent>(event)->getDescription());
} else if (dynamic_pointer_cast<AppCheckPointCheckFailEvent>(event)) {
GET_SERVICE(WarningLightControler)->setwarningFlag(true);
vector<CheckPoint> checkPoints = dynamic_pointer_cast<AppCheckPointCheckFailEvent>(event)->errCheckPoints;
for (auto& cp : checkPoints) {
ADD_USER_BEHAVIOR(DS->getLoginName(), kbehavior_warning_prompt, cp.ecodeInfo);
}
}
}

7
appsrc/service/debug_page_test_service.cpp

@ -127,5 +127,10 @@ void DebugPageTestService::triggerPromptEvent(shared_ptr<MsgProcessContext> cxt,
AppEventBus::ins()->pushPromoptEvent(message);
}
void DebugPageTestService::triggerAppCheckPointFailEvent(shared_ptr<MsgProcessContext> cxt) { //
AppEventBus::ins()->push(make_shared<AppCheckPointCheckFailEvent>());
vector<CheckPoint> checkPoints;
CheckPoint checkPoint(kCheckPointCode_evaporationBinWSTrigger, "消毒蒸发仓位传感器触发", false);
checkPoint.ecode = err::kappe_the_evaporation_bin_has_water;
checkPoints.push_back(checkPoint);
AppEventBus::ins()->push(make_shared<AppCheckPointCheckFailEvent>(checkPoints));
}

17
appsrc/service/device_check_point_check_service.cpp

@ -37,14 +37,20 @@ void DeviceCheckPointCheckService::initialize() { //
if (checkPointIndex == kCheckPointCode_evaporationBinWSTrigger) {
if (GET_SERVICE(DeviceIoControlService)->WaterSensor_readEvaporationBin()) {
checkPoint.passed = false;
checkPoint.ecode = err::kappe_the_evaporation_bin_has_water;
checkPoint.ecodeInfo = ecode2str(checkPoint.ecode);
} else {
checkPoint.passed = true;
checkPoint.ecode = 0;
}
} else if (checkPointIndex == kCheckPointCode_deviceBottomWSTrigger) {
if (GET_SERVICE(DeviceIoControlService)->WaterSensor_readDeviceBottom()) {
checkPoint.passed = false;
checkPoint.passed = false;
checkPoint.ecode = err::kappe_the_bottom_of_the_device_has_water;
checkPoint.ecodeInfo = ecode2str(checkPoint.ecode);
} else {
checkPoint.passed = true;
checkPoint.ecode = 0;
}
}
} catch (const std::exception& e) {
@ -65,7 +71,14 @@ void DeviceCheckPointCheckService::initialize() { //
} else if (DS->getDeviceState() == DeviceState::AirLeakDetectTesting) {
GET_SERVICE(AirLeakDetectTest)->stop();
}
AppEventBus::ins()->push(make_shared<AppCheckPointCheckFailEvent>());
vector<CheckPoint> errCheckPoints;
for (auto& checkPoint : checkPoints) {
if (!checkPoint.passed) {
errCheckPoints.push_back(checkPoint);
}
}
AppEventBus::ins()->push(make_shared<AppCheckPointCheckFailEvent>(errCheckPoints));
}
}
}

15
appsrc/service/device_check_point_check_service.hpp

@ -17,21 +17,6 @@ namespace iflytop {
*
*/
typedef enum {
kCheckPointCode_Unknown = 0,
kCheckPointCode_evaporationBinWSTrigger,
kCheckPointCode_deviceBottomWSTrigger,
} CheckPointCode_t;
class CheckPoint {
public:
CheckPointCode_t index;
string name;
bool passed;
CheckPoint(CheckPointCode_t index, const string& name, bool passed) : index(index), name(name), passed(passed) {}
NLOHMANN_DEFINE_TYPE_INTRUSIVE(CheckPoint, index, name, passed);
};
class DeviceCheckPointCheckService : public enable_shared_from_this<DeviceCheckPointCheckService> {
THISCLASS(DeviceCheckPointCheckService);

61
appsrc/service/device_info_mgr_service.cpp

@ -9,14 +9,61 @@ void DeviceInfoMgrService::initialize() {
GET_TO_SERVICE(m_ds);
REG_EXTFN_VOID(getDeviceInfo, void());
REG_EXTFN_VOID(getSubDeviceInfo, void());
}
#define CAN_MASTER TransmitDisinfectionCanMaster::ins()
void DeviceInfoMgrService::getDeviceInfo(shared_ptr<MsgProcessContext> cxt) { //
auto& content = cxt->rely;
content["projectType"] = PORT.getProjTypeString();
content["appVersion"] = VERSION;
content["deviceType"] = DeviceExtSettingDAO::ins()->getDeviceExtSetting().deviceType;
content["mircoVersion"] = "3.0.0"; // TODO:换成真实的版本信息
content["ip"] = "192.168.73.10";
content["deviceId"] = DeviceExtSettingDAO::ins()->getDeviceExtSetting().deviceId;
auto& content = cxt->rely;
content["projectType"] = PORT.getProjTypeString();
content["appVersion"] = VERSION;
content["deviceType"] = DeviceExtSettingDAO::ins()->getDeviceExtSetting().deviceType;
// content["mircoVersion"] = "3.0.0"; // TODO:换成真实的版本信息
content["ip"] = "192.168.73.10";
content["deviceId"] = DeviceExtSettingDAO::ins()->getDeviceExtSetting().deviceId;
content["deviceTypeInited"] = PORT.isDeviceTypeInited();
}
json DeviceInfoMgrService::tryConstructBoardInfo(int boardId) {
json boardInfo;
if (boardId == kFixBoardId_LiquidCtrl) {
boardInfo["name"] = "液路板版本信息";
} else if (boardId == kFixBoardId_PowerControl) {
boardInfo["name"] = "功率板版本信息";
} else if (boardId == kFixBoardId_ExtChSelector) {
boardInfo["name"] = "外部通道选择器版本信息";
} else if (boardId >= kFixBoardId_H2O2SensorStart) {
boardInfo["name"] = "H2O2传感器版本信息";
} else {
boardInfo["name"] = "未知板卡";
}
if (PORT.isBuildInPC()) {
boardInfo["version"] = "IN_PC:FAKE_VERSION";
}
else if (!PORT.isDeviceTypeInited()) {
boardInfo["version"] = "主机-设备类型未初始化";
}
else {
try {
ack_read_board_info_data_t info = CAN_MASTER->readboardinfo(boardId);
boardInfo["version"] = fmt::format("BT{:0>2d}HV{:0>2d}-{}", info.boardType, info.hardware_version, info.software_version);
} catch (...) {
boardInfo["version"] = "离线";
}
}
return boardInfo;
}
void DeviceInfoMgrService::getSubDeviceInfo(shared_ptr<MsgProcessContext> cxt) {
json content;
content["versionInfo"].push_back(tryConstructBoardInfo(kFixBoardId_LiquidCtrl));
content["versionInfo"].push_back(tryConstructBoardInfo(kFixBoardId_PowerControl));
cxt->rely = content;
}
void DeviceInfoMgrService::getSubDeviceOSRunState(shared_ptr<MsgProcessContext> cxt) {}

6
appsrc/service/device_info_mgr_service.hpp

@ -22,6 +22,12 @@ class DeviceInfoMgrService : public enable_shared_from_this<DeviceInfoMgrService
private:
void getDeviceInfo(shared_ptr<MsgProcessContext> cxt);
void getSubDeviceInfo(shared_ptr<MsgProcessContext> cxt);
void getSubDeviceOSRunState(shared_ptr<MsgProcessContext> cxt);
private:
json tryConstructBoardInfo(int boardId);
};
} // namespace iflytop

2
appsrc/service/hardware/disinfectant_weight_update_service.cpp

@ -41,7 +41,7 @@ float DisinfectantWeightUpdateService::getRoughWeight() {
void DisinfectantWeightUpdateService::updateWeightThread() {
while (true) {
if (PORT.isLageSpaceDM() || PORT.isSmallSpaceDM() || PORT.isPipeDM()) {
if (!DS->isTestMode()) {
if (DS->isTestMode()) {
setNetWeight(1000);
}

10
appsrc/service/setting/ext_setting_mgr_service.cpp

@ -88,19 +88,19 @@ void ExtSettingMgrService::setDeviceInfo(shared_ptr<MsgProcessContext> cxt, Devi
string deviceIdPrefix;
if (type == DeviceType::DT_600N) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::LargeSpaceDM);
deviceIdPrefix = "DT-600N";
deviceIdPrefix = "DT600N";
} else if (type == DeviceType::DT_300N) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::SmallSpaceDM);
deviceIdPrefix = "DT-300N";
deviceIdPrefix = "DT300N";
} else if (type == DeviceType::DT_300W) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::PipeDM);
deviceIdPrefix = "DT-300W";
deviceIdPrefix = "DT300W";
} else if (type == DeviceType::DT_100N) {
DeviceExtSettingDAO::ins()->setProjectTypes(ProjectTypeEnum::DrawBarDM);
deviceIdPrefix = "DT-100N";
deviceIdPrefix = "DT100N";
}
DeviceExtSettingDAO::ins()->setDeviceType(type);
DeviceExtSettingDAO::ins()->setDeviceId(fmt::format("{}-{:0>2d}{:0>2d}{:0>2d}{:0>3d}", deviceIdPrefix, year, month, day, index));
DeviceExtSettingDAO::ins()->setDeviceId(fmt::format("{}{:0>2d}{:0>2d}{:0>2d}{:0>3d}", deviceIdPrefix, year, month, day, index));
cxt->rely["extSettings"] = DeviceExtSettingDAO::ins()->getDeviceExtSettingAsJson();
}
Loading…
Cancel
Save