From 39e4fd64f6ec6b0356fce5eeb66f672f1c5be18c Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 8 Jul 2025 17:14:43 +0800 Subject: [PATCH] fix some bug --- app_protocols/appexception/appexception.hpp | 8 ++++++-- appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp | 5 ++--- appsrc/service/app/air_leak_detect_test.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app_protocols/appexception/appexception.hpp b/app_protocols/appexception/appexception.hpp index 5820f74..cb8e839 100644 --- a/app_protocols/appexception/appexception.hpp +++ b/app_protocols/appexception/appexception.hpp @@ -140,11 +140,15 @@ class appexception : public std::exception { return ret; } }; +} + #define APPCHECK(expr, ecode, info) \ if (!(expr)) { \ THROW_APP_EXCEPTION(ecode, info); \ } -#define THROW_APP_EXCEPTION(ecode, info) throw appexception(ecode, info); -} // namespace iflytop \ No newline at end of file +#define THROW_APP_EXCEPTION(ecode, _info) \ + {logger->error("throw exception {}", _info);\ + throw appexception(ecode, _info); } + diff --git a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp index ba81845..4d2c4c4 100644 --- a/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp +++ b/appsrc/appcomponents/canchannel/com/zscanprotocol_com.cpp @@ -104,7 +104,7 @@ shared_ptr ZSCanProtocolCom::base_callcmd(int32_t to, int32_t cmdid, ui if (m_receipt_frame->ptype == kerror_receipt) { int32_t ecode = *(int32_t *)m_receipt_frame->params; - THROW_APP_EXCEPTION(ecode, Internationalization::ecode2description(ecode, cmdid, to, param, paramLen)); + THROW_APP_EXCEPTION(ecode, Internationalization::ecode2description(ecode, to, cmdid, param, paramLen)); } shared_ptr receipt = make_shared(); @@ -146,7 +146,7 @@ shared_ptr ZSCanProtocolCom::callcmd(int32_t to, int32_t cmdid, uint8_t break; } - THROW_APP_EXCEPTION(ecode, Internationalization::ecode2description(ecode, cmdid, to, param, paramLen)); + THROW_APP_EXCEPTION(ecode, Internationalization::ecode2description(ecode, to, cmdid, param, paramLen)); return nullptr; } shared_ptr ZSCanProtocolCom::callcmd0(int32_t to, int32_t cmdid, int32_t overtime) { return callcmd(to, cmdid, nullptr, 0, overtime); } @@ -186,7 +186,6 @@ shared_ptr ZSCanProtocolCom::callcmd5(int32_t to, int32_t cmdid, int32_ return callcmd(to, cmdid, (uint8_t *)param, 20, overtime); } - void ZSCanProtocolCom::callOnReport(uint8_t from, uint8_t *hex, uint32_t hexlen) { shared_ptr hexbin = make_shared(hex, hexlen); m_wq->enQueue([this, from, hexbin]() { onReport(from, (uint8_t *)hexbin->data(), hexbin->size()); }); diff --git a/appsrc/service/app/air_leak_detect_test.cpp b/appsrc/service/app/air_leak_detect_test.cpp index 475a6c7..cd50c24 100644 --- a/appsrc/service/app/air_leak_detect_test.cpp +++ b/appsrc/service/app/air_leak_detect_test.cpp @@ -22,7 +22,7 @@ void AirLeakDetectTest::initialize() { stateUpdateThread.reset(new Thread("AirLeakDetectTest-stateUpdateThread", [this]() { while (!ThisThread().getExitFlag()) { - try { + try { SEND_CLASS_REPORT(thisClass.className, "stateUpdate", getState()); } catch (const std::exception& e) { logger->error("stateUpdateThread error:{}", e.what()); @@ -211,9 +211,9 @@ json AirLeakDetectTest::getState() { diffPressurePa = 0; } - state["pressure"] = fmt::format("{:.2f}", toDisplayPressure(pressurePa)); - state["initialPressure"] = fmt::format("{:.2f}", toDisplayPressure(initialPressurePa)); - state["diffPressurePa"] = fmt::format("{:.2f}", toDisplayPressure(diffPressurePa)); + state["pressure"] = toDisplayPressure(pressurePa); + state["initialPressure"] = toDisplayPressure(initialPressurePa); + state["diffPressurePa"] = toDisplayPressure(diffPressurePa); state["workState"] = state2str(getWorkstate()); state["workStateDisplay"] = state2chstr(getWorkstate()); return state;