Browse Source

v3.1.7 |不允许在设备忙的情况下 登陆和登出 不允许在已登陆的情况下, 重复登陆。

try_support_dt100n
zhaohe 4 weeks ago
parent
commit
75e3568881
  1. 7
      app_protocols/apperrorcode/apperrorcode.hpp
  2. 2
      appsrc/appconfig/basic/zappversion.hpp
  3. 2
      appsrc/baseservice/devicestate/device_state_service.hpp
  4. 20
      appsrc/internationalization.cpp
  5. 4
      appsrc/internationalization.hpp
  6. 11
      appsrc/service/app_core.cpp
  7. 1
      appsrc/service/app_core.hpp
  8. 7
      appsrc/service/hardware/device_io_ctrl_service.cpp
  9. 9
      appsrc/service/user_mgr_service.cpp

7
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, // 设备底部有水

2
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"

2
appsrc/baseservice/devicestate/device_state_service.hpp

@ -72,6 +72,8 @@ class DeviceStateService : public enable_shared_from_this<DeviceStateService> {
DeviceState getDeviceState() { return state; }
void setDeviceState(DeviceState s) { state = s; }
bool isBusy() { return !state.eq(DeviceState::kIdle); }
/*******************************************************************************
* exception *
*******************************************************************************/

20
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);
}

4
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);
};

11
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<AppLoginOutEvent>(event)) {
if (dynamic_pointer_cast<AppLoginOutEvent>(event) && !DS->isBusy()) {
initHardwareState(false);
}
if (dynamic_pointer_cast<AppLoginEvent>(event)) {
if (dynamic_pointer_cast<AppLoginEvent>(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();

1
appsrc/service/app_core.hpp

@ -45,6 +45,7 @@ class AppCore : public enable_shared_from_this<AppCore> {
unique_ptr<Thread> stateUpdateThread;
unique_ptr<Thread> stateUpdateThread2;
public:
AppCore() {};
void initialize();

7
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;

9
appsrc/service/user_mgr_service.cpp

@ -27,6 +27,10 @@ void UserMgrService::login(shared_ptr<MsgProcessContext> 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<MsgProcessContext> cxt, string name, strin
return;
}
void UserMgrService::unlogin(shared_ptr<MsgProcessContext> 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");

Loading…
Cancel
Save