Browse Source

V2.5.2| h2o2_sensor_mgr添加获取消毒时刻的传感器数据

master
zhaohe 1 month ago
parent
commit
4950f75c1e
  1. 2
      appsrc/appconfig/basic/zappversion.hpp
  2. 2
      appsrc/baseservice/front_msg_processer/front_msg_processer.cpp
  3. 5
      appsrc/service/app/disinfection_ctrl_service_ext.hpp
  4. 33
      appsrc/service/h2o2_sensor_mgr.cpp
  5. 1
      appsrc/service/h2o2_sensor_mgr.hpp
  6. 8
      appsrc/service/user_mgr_service.cpp

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

2
appsrc/baseservice/front_msg_processer/front_msg_processer.cpp

@ -94,7 +94,7 @@ void FrontMsgProcesser::processMsg(shared_ptr<MsgProcessContext> 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);

5
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<DisinfectionCt
void stopStateReport(shared_ptr<MsgProcessContext> cxt);
json getState();
DisinfectionState getDisinfectionState() { return dcs->getState(); }
int64_t getDisinfectionStartTP() { return dcs->getStartTP(); }
};
} // namespace iflytop

33
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<MsgProcessContext> 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<MsgProcessContext> 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<MsgProcessContext> 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<H2O2DataRecordList> H2O2SensorMgr::findRecordList(H2O2SensorType type, int id) {
std::lock_guard<std::recursive_mutex> lock(lock_);
for (auto& recordList : h2o2DataRecords) {

1
appsrc/service/h2o2_sensor_mgr.hpp

@ -65,6 +65,7 @@ class H2O2SensorMgr : public enable_shared_from_this<H2O2SensorMgr> {
private:
void getH2O2DataRecordList(shared_ptr<MsgProcessContext> cxt, H2O2SensorType type, int id, int64_t since, int64_t interval, int64_t before);
void getDisinfectionH2O2DataRecordList(shared_ptr<MsgProcessContext> cxt, H2O2SensorType type, int id, int64_t interval);
void getH2O2SensorList(shared_ptr<MsgProcessContext> cxt);
private:

8
appsrc/service/user_mgr_service.cpp

@ -78,7 +78,7 @@ void UserMgrService::updateUserName(shared_ptr<MsgProcessContext> cxt, int id, s
}
void UserMgrService::getAllUser(shared_ptr<MsgProcessContext> cxt) {
auto users = UserDao::ins()->getAllUserJson();
cxt->receipt["rely"] = users;
cxt->rely = users;
return;
}
@ -86,11 +86,11 @@ void UserMgrService::getLoginUser(shared_ptr<MsgProcessContext> 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;
}
Loading…
Cancel
Save