diff --git a/appsrc/appconfig/basic/zappversion.hpp b/appsrc/appconfig/basic/zappversion.hpp index 4019834..982ee91 100644 --- a/appsrc/appconfig/basic/zappversion.hpp +++ b/appsrc/appconfig/basic/zappversion.hpp @@ -1,3 +1,3 @@ #pragma once -#define VERSION "2.5.0" +#define VERSION "2.5.2" #define PROJECT_NAME "TRANSMIT_DM" \ No newline at end of file diff --git a/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp b/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp index 04cbcbe..475b207 100644 --- a/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp +++ b/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp @@ -94,7 +94,7 @@ void FrontMsgProcesser::processMsg(shared_ptr cxt) { logger->debug(" call: end"); if (cxt->ackcode != 0) cxt->receipt["ackcode"] = cxt->ackcode; if (int(cxt->receipt["ackcode"]) != 0) cxt->receipt["message"] = fmt::format("{}", ecode2str(cxt->receipt["ackcode"]) + cxt->ackcodeExtMessage); - if (cxt->rely.empty() == false) cxt->receipt["rely"] = cxt->rely; + cxt->receipt["rely"] = cxt->rely; } catch (const appexception& e) { cxt->receipt["ackcode"] = e.ecode; cxt->receipt["message"] = fmt::format("{}", ecode2str(cxt->receipt["ackcode"]) + e.description); diff --git a/appsrc/service/app/disinfection_ctrl_service_ext.hpp b/appsrc/service/app/disinfection_ctrl_service_ext.hpp index e41c04a..4186d9d 100644 --- a/appsrc/service/app/disinfection_ctrl_service_ext.hpp +++ b/appsrc/service/app/disinfection_ctrl_service_ext.hpp @@ -12,9 +12,9 @@ #include "baseservice/baseservice.hpp" #include "disinfection_ctrl/disinfection_ctrl_service.hpp" #include "disinfection_ctrl/disinfection_state_machine.hpp" -#include "service/hardware/h2o2_sensor_state_sync.hpp" #include "service/hardware/device_io_ctrl_service.hpp" #include "service/hardware/disinfectant_weight_update_service.hpp" +#include "service/hardware/h2o2_sensor_state_sync.hpp" // namespace iflytop { using namespace disinfection; @@ -53,6 +53,9 @@ class DisinfectionCtrlServiceExt : public enable_shared_from_this cxt); json getState(); + + DisinfectionState getDisinfectionState() { return dcs->getState(); } + int64_t getDisinfectionStartTP() { return dcs->getStartTP(); } }; } // namespace iflytop \ No newline at end of file diff --git a/appsrc/service/h2o2_sensor_mgr.cpp b/appsrc/service/h2o2_sensor_mgr.cpp index 8d0cce0..825c9c3 100644 --- a/appsrc/service/h2o2_sensor_mgr.cpp +++ b/appsrc/service/h2o2_sensor_mgr.cpp @@ -1,6 +1,8 @@ #include "h2o2_sensor_mgr.hpp" #include "service/hardware/device_io_ctrl_service.hpp" +// +#include "service/app/disinfection_ctrl/disinfection_ctrl_service.hpp" using namespace iflytop; @@ -39,6 +41,7 @@ void H2O2SensorMgr::initialize() { })); REG_EXTFN(getH2O2DataRecordList, void(H2O2SensorType, int, int64_t, int64_t, int64_t), type, id, since, interval, before); + REG_EXTFN(getDisinfectionH2O2DataRecordList, void(H2O2SensorType, int, int64_t), type, id, interval); REG_EXTFN_VOID(getH2O2SensorList, void()); } @@ -121,7 +124,8 @@ void H2O2SensorMgr::getH2O2DataRecordList(shared_ptr cxt, H2O return; } json dataList = json::array(); - int32_t nextdataTimestamp = since; + int64_t nextdataTimestamp = since; + for (auto& data : recordList->datas) { if (data.timestamp < (nextdataTimestamp - RECORD_PERIOD / 2)) { continue; @@ -134,10 +138,37 @@ void H2O2SensorMgr::getH2O2DataRecordList(shared_ptr cxt, H2O dataList.push_back(data); nextdataTimestamp = data.timestamp + interval; + // logger->info("nextdataTimestamp: {}, data.timestamp: {}, interval: {}", nextdataTimestamp, data.timestamp, interval); } cxt->rely = dataList; } +void H2O2SensorMgr::getDisinfectionH2O2DataRecordList(shared_ptr cxt, H2O2SensorType type, int id, int64_t interval) { // + auto disinfectionCtrlService = GET_SERVICE(DisinfectionCtrlService); + + DisinfectionState disinfectionState; + int64_t startTime = 0; + int64_t endTime = 0; + + disinfectionCtrlService->getStateSafeBlock([&]() { + disinfectionState = disinfectionCtrlService->getState(); + startTime = disinfectionCtrlService->getStartTP(); + endTime = disinfectionCtrlService->getCompleteTP(); + }); + + if (disinfectionState.eq(DisinfectionState::kidle)) { + if (endTime == 0) { + cxt->rely = json::array(); // No disinfection in progress, return empty array + } else { + getH2O2DataRecordList(cxt, type, id, startTime, interval, endTime); + return; + } + } else { + getH2O2DataRecordList(cxt, type, id, startTime, interval, 0); + return; + } +} + shared_ptr H2O2SensorMgr::findRecordList(H2O2SensorType type, int id) { std::lock_guard lock(lock_); for (auto& recordList : h2o2DataRecords) { diff --git a/appsrc/service/h2o2_sensor_mgr.hpp b/appsrc/service/h2o2_sensor_mgr.hpp index 8f371ee..462e9d3 100644 --- a/appsrc/service/h2o2_sensor_mgr.hpp +++ b/appsrc/service/h2o2_sensor_mgr.hpp @@ -65,6 +65,7 @@ class H2O2SensorMgr : public enable_shared_from_this { private: void getH2O2DataRecordList(shared_ptr cxt, H2O2SensorType type, int id, int64_t since, int64_t interval, int64_t before); + void getDisinfectionH2O2DataRecordList(shared_ptr cxt, H2O2SensorType type, int id, int64_t interval); void getH2O2SensorList(shared_ptr cxt); private: diff --git a/appsrc/service/user_mgr_service.cpp b/appsrc/service/user_mgr_service.cpp index f39ea9e..0088f1d 100644 --- a/appsrc/service/user_mgr_service.cpp +++ b/appsrc/service/user_mgr_service.cpp @@ -78,7 +78,7 @@ void UserMgrService::updateUserName(shared_ptr cxt, int id, s } void UserMgrService::getAllUser(shared_ptr cxt) { auto users = UserDao::ins()->getAllUserJson(); - cxt->receipt["rely"] = users; + cxt->rely = users; return; } @@ -86,11 +86,11 @@ void UserMgrService::getLoginUser(shared_ptr cxt) { string loginName = m_deviceStateService->getLoginName(); bool isLogin = m_deviceStateService->isLogin(); - cxt->receipt["rely"]["isLogin"] = isLogin; + cxt->rely["isLogin"] = isLogin; if (isLogin) { - cxt->receipt["rely"]["loginUser"] = UserDao::ins()->getUserJson(loginName); + cxt->rely["loginUser"] = UserDao::ins()->getUserJson(loginName); } else { - cxt->receipt["rely"]["loginUser"] = {}; + cxt->rely["loginUser"] = {}; } return; }