From 75e356888161b5838414dfebe76b58f6592a84c7 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 9 Jul 2025 15:03:09 +0800 Subject: [PATCH] =?UTF-8?q?v3.1.7=20|=E4=B8=8D=E5=85=81=E8=AE=B8=E5=9C=A8?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=BF=99=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=20=E7=99=BB=E9=99=86=E5=92=8C=E7=99=BB=E5=87=BA=20=E4=B8=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=9C=A8=E5=B7=B2=E7=99=BB=E9=99=86=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=20=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=99=BB=E9=99=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_protocols/apperrorcode/apperrorcode.hpp | 7 ++++--- appsrc/appconfig/basic/zappversion.hpp | 2 +- .../baseservice/devicestate/device_state_service.hpp | 2 ++ appsrc/internationalization.cpp | 20 ++++++++++++++++++++ appsrc/internationalization.hpp | 4 ++++ appsrc/service/app_core.cpp | 11 +++-------- appsrc/service/app_core.hpp | 1 + appsrc/service/hardware/device_io_ctrl_service.cpp | 7 +++++-- appsrc/service/user_mgr_service.cpp | 9 +++++++++ 9 files changed, 49 insertions(+), 14 deletions(-) diff --git a/app_protocols/apperrorcode/apperrorcode.hpp b/app_protocols/apperrorcode/apperrorcode.hpp index 2897883..feed012 100644 --- a/app_protocols/apperrorcode/apperrorcode.hpp +++ b/app_protocols/apperrorcode/apperrorcode.hpp @@ -28,9 +28,10 @@ typedef enum { kappe_param_value_err = 10009, // 参数值错误 kappe_device_type_not_init = 10010, // deviceTypeNot - kappe_user_not_exist = 10101, // 用户不存在 - kappe_passwd_error = 10102, // 密码错误 - kappe_user_exist = 10103, // 用户已存在 + kappe_user_not_exist = 10101, // 用户不存在 + kappe_passwd_error = 10102, // 密码错误 + kappe_user_exist = 10103, // 用户已存在 + kappe_login_fail_device_islogined = 10104, // 登陆失败, 设备已登录 kappe_disinfectant_insufficient = 10201, // 消毒液不足 kappe_the_bottom_of_the_device_has_water = 10202, // 设备底部有水 diff --git a/appsrc/appconfig/basic/zappversion.hpp b/appsrc/appconfig/basic/zappversion.hpp index bcbd4ca..41bb7b3 100644 --- a/appsrc/appconfig/basic/zappversion.hpp +++ b/appsrc/appconfig/basic/zappversion.hpp @@ -1,3 +1,3 @@ #pragma once -#define VERSION "3.1.6" +#define VERSION "3.1.7" #define PROJECT_NAME "TRANSMIT_DM" \ No newline at end of file diff --git a/appsrc/baseservice/devicestate/device_state_service.hpp b/appsrc/baseservice/devicestate/device_state_service.hpp index 34cdf98..d133ee7 100644 --- a/appsrc/baseservice/devicestate/device_state_service.hpp +++ b/appsrc/baseservice/devicestate/device_state_service.hpp @@ -72,6 +72,8 @@ class DeviceStateService : public enable_shared_from_this { DeviceState getDeviceState() { return state; } void setDeviceState(DeviceState s) { state = s; } + bool isBusy() { return !state.eq(DeviceState::kIdle); } + /******************************************************************************* * exception * *******************************************************************************/ diff --git a/appsrc/internationalization.cpp b/appsrc/internationalization.cpp index 103daa4..51812d2 100644 --- a/appsrc/internationalization.cpp +++ b/appsrc/internationalization.cpp @@ -55,6 +55,7 @@ static EcodeInfo chEcodeInfo[] = { {kappe_user_not_exist, "用户不存在"}, {kappe_passwd_error, "密码错误"}, {kappe_user_exist, "用户已存在"}, + {kappe_login_fail_device_islogined, "登陆失败,设备已登录"}, {kappe_disinfectant_insufficient, "消毒液不足"}, {kappe_the_bottom_of_the_device_has_water, "硬件仓内有液体"}, {kappe_the_evaporation_bin_has_water, "蒸发仓内有液体"}, @@ -173,3 +174,22 @@ string Internationalization::ecode2description(int ecode, int32_t toboard, int32 } return fmt::format("{},执行{}错误", ecode, cmdid2str(cmdid)); } +string Internationalization::deviceBusyError2description(int ecode, DeviceState deviceState) { + if (ecode == kappe_state_is_busy) { + switch (deviceState) { + case DeviceState::kIdle: + return "设备空闲"; + case DeviceState::kAddingLiquid: + return "操作不允许, 设备正在加液"; + case DeviceState::kDrainingLiquid: + return "操作不允许, 设备正在排液"; + case DeviceState::kDisinfection: + return "操作不允许, 设备正在消毒"; + case DeviceState::kAirLeakDetectTesting: + return "操作不允许, 设备正在气密性测试"; + default: + return "设备状态未知"; + } + } + return ecode2description(ecode); +} diff --git a/appsrc/internationalization.hpp b/appsrc/internationalization.hpp index 818de72..6bb20e1 100644 --- a/appsrc/internationalization.hpp +++ b/appsrc/internationalization.hpp @@ -10,6 +10,9 @@ #include "app_protocols/transmit_disfection_protocol/transmit_disfection_protocol.hpp" #include "iflytop/core/spdlogfactory/logger_factory.hpp" +// +#include "appbase/appbean/device_state.hpp" + namespace iflytop { using namespace std; @@ -18,6 +21,7 @@ class Internationalization { static string cmdid2str(int cmdid); static string ecode2description(int ecode); + static string deviceBusyError2description(int ecode, DeviceState deviceState); static string ecode2description(int ecode, int32_t toboard, int32_t cmdid, uint8_t* param, int32_t paramLen); }; diff --git a/appsrc/service/app_core.cpp b/appsrc/service/app_core.cpp index 737dbca..ca55eec 100644 --- a/appsrc/service/app_core.cpp +++ b/appsrc/service/app_core.cpp @@ -44,9 +44,7 @@ void AppCore::dosystem(string order, bool dump) { system(order.c_str()); } -static void installEcodeInfo() { - -} +static void installEcodeInfo() {} void AppCore::initialize() { REG_CLASS("AppCore"); @@ -158,10 +156,10 @@ void AppCore::initialize() { insertAppEvent(event); return; } - if (dynamic_pointer_cast(event)) { + if (dynamic_pointer_cast(event) && !DS->isBusy()) { initHardwareState(false); } - if (dynamic_pointer_cast(event)) { + if (dynamic_pointer_cast(event) && !DS->isBusy()) { initHardwareState(true); } }); @@ -191,9 +189,6 @@ void AppCore::initHardwareState(bool reportEvent) { auto deviceIoControlService = GET_SERVICE(DeviceIoControlService); try { if (PORT.isDT600B() || PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) { - // CAN_MASTER->clearResetFlag(kFixBoardId_LiquidCtrl); - // CAN_MASTER->clearResetFlag(kFixBoardId_PowerControl); - deviceIoControlService->AddLiquidPump_stop(); deviceIoControlService->SprayPump_stop(); deviceIoControlService->Blower_close(); diff --git a/appsrc/service/app_core.hpp b/appsrc/service/app_core.hpp index 052c579..82336a1 100644 --- a/appsrc/service/app_core.hpp +++ b/appsrc/service/app_core.hpp @@ -45,6 +45,7 @@ class AppCore : public enable_shared_from_this { unique_ptr stateUpdateThread; unique_ptr stateUpdateThread2; + public: AppCore() {}; void initialize(); diff --git a/appsrc/service/hardware/device_io_ctrl_service.cpp b/appsrc/service/hardware/device_io_ctrl_service.cpp index 53be677..6074371 100644 --- a/appsrc/service/hardware/device_io_ctrl_service.cpp +++ b/appsrc/service/hardware/device_io_ctrl_service.cpp @@ -111,7 +111,10 @@ void DeviceIoControlService::initialize() { } })); - // heartThread-> + if (PORT.isDT600B() || PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W() || PORT.isDT100N()) { + CAN_MASTER->clearResetFlag(FIXBOARDID_LC_BOARD); + CAN_MASTER->clearResetFlag(FIXBOARDID_PC_BOARD); + } } #define TRY_DO(func) \ @@ -177,7 +180,7 @@ int DeviceIoControlService::processReportMsg(uint8_t from, uint8_t *hex, uint32_ } else if (packet->fnid == kreport_exception_error) { report_exeception_data_t *ack = (report_exeception_data_t *)packet->params; logger->error(" REPORT [Exception][FROM:{}] subid:{:x} ecode:{}", from, ack->subid, Internationalization::ecode2description(ack->ecode)); - AppEventBus::ins()->pushWarningPromptEvent(ack->ecode,""); + AppEventBus::ins()->pushWarningPromptEvent(ack->ecode, ""); } else if (packet->fnid == kreport_pressure_data) { report_pressure_data_t *ack = (report_pressure_data_t *)packet->params; string info; diff --git a/appsrc/service/user_mgr_service.cpp b/appsrc/service/user_mgr_service.cpp index 1d539b3..f78c3b8 100644 --- a/appsrc/service/user_mgr_service.cpp +++ b/appsrc/service/user_mgr_service.cpp @@ -27,6 +27,10 @@ void UserMgrService::login(shared_ptr cxt, string name, strin // return; // } + if(m_deviceStateService->isLogin()){ + THROW_APP_EXCEPTION(err::kappe_user_exist, "用户已登录"); + } + if (!UserDao::ins()->isUserExist(name)) // THROW_APP_EXCEPTION(err::kappe_user_not_exist, ""); if (!UserDao::ins()->ispasswdCorrect(name, pwd)) // @@ -41,6 +45,11 @@ void UserMgrService::login(shared_ptr cxt, string name, strin return; } void UserMgrService::unlogin(shared_ptr cxt) { + if (!m_deviceStateService->getDeviceState().eq(DeviceState::kIdle)) { + THROW_APP_EXCEPTION(err::kappe_state_is_busy, // + Internationalization::deviceBusyError2description(err::kappe_state_is_busy, m_deviceStateService->getDeviceState())); + } + string name = m_deviceStateService->getLoginName(); m_deviceStateService->unlogin(); logger->info("user unlogin success");