From f823fd14ed10c637d50446ba57241f39cfec273b Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 25 May 2024 06:09:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BF=AE=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=20=E5=B1=8F=E5=B9=95=E5=89=8D=E7=AB=AF=E9=A2=91?= =?UTF-8?q?=E7=B9=81=E4=B8=8B=E5=8F=91getState=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/cmds/device_state_cmd_impl.cpp | 27 +++++++++++++++++++-------- src/main_control_service.cpp | 34 +++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/api/cmds/device_state_cmd_impl.cpp b/src/api/cmds/device_state_cmd_impl.cpp index cc10c2b..78b68a3 100644 --- a/src/api/cmds/device_state_cmd_impl.cpp +++ b/src/api/cmds/device_state_cmd_impl.cpp @@ -68,14 +68,25 @@ json DeviceStateCmdImpl::createSensorDataJson() { #endif #if (defined PROJECT_TYPE_DRAW_BAR_BOX) - report["pressure"][0] = m_deviceIoControlService->getPressureSensorData(1); - report["pressure"][1] = m_deviceIoControlService->getPressureSensorData(2); - report["pressure"][2] = m_deviceIoControlService->getPressureSensorData(3); - report["draw_bar_box_disinfection"]["pressure"][0] = m_deviceIoControlService->getPressureSensorData(1); - report["draw_bar_box_disinfection"]["pressure"][1] = m_deviceIoControlService->getPressureSensorData(2); - report["draw_bar_box_disinfection"]["pressure"][2] = m_deviceIoControlService->getPressureSensorData(3); - report["draw_bar_box_disinfection"]["heatingStrip"]["current"] = m_deviceIoControlService->DBDB__heaterReadElectricCurrent(); // 电流 - report["draw_bar_box_disinfection"]["heatingStrip"]["temperature"] = m_deviceIoControlService->DBDB__heaterReadTemperatureData(); // 温度 + // report["pressure"][0] = m_deviceIoControlService->getPressureSensorData(1); + // report["pressure"][1] = m_deviceIoControlService->getPressureSensorData(2); + // report["pressure"][2] = m_deviceIoControlService->getPressureSensorData(3); + // report["draw_bar_box_disinfection"]["pressure"][0] = m_deviceIoControlService->getPressureSensorData(1); + // report["draw_bar_box_disinfection"]["pressure"][1] = m_deviceIoControlService->getPressureSensorData(2); + // report["draw_bar_box_disinfection"]["pressure"][2] = m_deviceIoControlService->getPressureSensorData(3); + // report["draw_bar_box_disinfection"]["heatingStrip"]["current"] = m_deviceIoControlService->DBDB__heaterReadElectricCurrent(); // 电流 + // report["draw_bar_box_disinfection"]["heatingStrip"]["temperature"] = m_deviceIoControlService->DBDB__heaterReadTemperatureData(); // 温度 + + + report["pressure"][0] = 0; + report["pressure"][1] = 0; + report["pressure"][2] = 0; + report["draw_bar_box_disinfection"]["pressure"][0] = 0; + report["draw_bar_box_disinfection"]["pressure"][1] = 0; + report["draw_bar_box_disinfection"]["pressure"][2] = 0; + report["draw_bar_box_disinfection"]["heatingStrip"]["current"] = 0; + report["draw_bar_box_disinfection"]["heatingStrip"]["temperature"] = 0; + #endif #if (defined PROJECT_TYPE_DRAW_BAR_BOX) diff --git a/src/main_control_service.cpp b/src/main_control_service.cpp index 6c19f7b..dc32546 100644 --- a/src/main_control_service.cpp +++ b/src/main_control_service.cpp @@ -9,9 +9,9 @@ #include "service/disinfection_printer_service.hpp" // #include "api/cmds/device_alert_dectector_service_cmd_impl.hpp" +#include "api/cmds/device_info_cmd_impl.hpp" #include "service/device_alert_dectector_service.hpp" #include "service/light_ctrl_service.hpp" -#include "api/cmds/device_info_cmd_impl.hpp" // #include "version.hpp" @@ -91,9 +91,22 @@ void MainControlService::initialize() { BUILD_AND_REG_SERRVICE(IflytopFrontEndService); GET_SERVICE(IflytopFrontEndService)->initialize("0.0.0.0"); GET_SERVICE(IflytopFrontEndService)->onMessage.connect([this](weak_ptr webSocket, json& cmd, json& receipt) { - string cmdstr = cmd["command"]; - bool disabledump = false; - if (cmdstr == "getState") disabledump = true; + string cmdstr = cmd["command"]; + bool disabledump = false; + static json getStateReceipt; + static bool getStateReceiptIsReady = false; + static zsteady_tp lastcallGetState_tp; + + if (cmdstr == "getState") { + if (getStateReceiptIsReady && zsteady_clock().elapsedTimeMs(lastcallGetState_tp) < 1500) { + receipt = getStateReceipt; + receipt["messageId"] = cmd["messageId"]; + receipt["state"]["isLogin"] = m_deviceStateService->isLogin(); + receipt["state"]["loginuser"] = m_deviceStateService->getLoginUid(); + receipt["state"]["permissionLevel"] = m_deviceStateService->getLoginPermissionLevel(); + return; + } + } if (cmdstr == "DBDBTestPage__heaterCtrlSafeValve") disabledump = true; if (cmdstr == "DBDBTestPage__heaterReadElectricCurrent") disabledump = true; if (cmdstr == "DBDBTestPage__readPressureSensor") disabledump = true; @@ -103,10 +116,21 @@ void MainControlService::initialize() { if (cmdstr == "DeviceIOControlService.airCompressor_getValve1") disabledump = true; if (cmdstr == "DeviceIOControlService.airCompressor_getValve2") disabledump = true; + if (!disabledump) { + logger->info("rx:{}", cmd.dump()); + } - if (!disabledump) logger->info("rx:{}", cmd.dump()); + // else { + // logger->debug("rx:{}", cmd.dump()); + // } m_frontMsgProcesser->processMsg(cmd, receipt); + + if (cmdstr == "getState") { + getStateReceipt = receipt; + getStateReceiptIsReady = true; + lastcallGetState_tp = zsteady_clock().now(); + } }); /*******************************************************************************