Browse Source

v1.2.1

storage-in-realtime
zhaohe 11 months ago
parent
commit
c734b027ef
  1. 8
      README.md
  2. 2
      app_protocols/transmit_disfection_protocol
  3. 14
      appdep/iflytop/core/basic/nlohmann/README.md
  4. 2
      appsrc/appsetting/project_port/basic/zappversion.hpp
  5. 3
      appsrc/service/app_core.cpp
  6. 24
      appsrc/service/front_end_realtime_display_content_mgr.cpp
  7. 1
      appsrc/service/front_end_realtime_display_content_mgr.hpp
  8. 42
      appsrc/service/hardware/base/h2o2_sensor_data_mgr.cpp
  9. 32
      appsrc/service/hardware/base/h2o2_sensor_data_mgr.hpp

8
README.md

@ -76,8 +76,12 @@ VERSION 1.1.8
VERSION 1.1.9
1. 添加底层复位检测
VERSION 1.2.0
1. 排液时,多排
VERSION 1.2.1
1. 支持H2O2传感器全部数据的读取和打印
TODO:
添加用户增加用户查重检查
1.添加用户增加用户查重检查
2.添加
```

2
app_protocols/transmit_disfection_protocol

@ -1 +1 @@
Subproject commit 0edd82d824736ca1d4d2f113a382204e702709bc
Subproject commit c1c23f522c5daa18dc89587ff25310d526aa2ca3

14
appdep/iflytop/core/basic/nlohmann/README.md

@ -32,4 +32,18 @@ use function at() to access the object values rather than operator[]. In case a
```c++
json["value"] = b1;
```
4. 自动类型转换
```c++
class Buttons {
public:
vector<Parameter> params;
vector<KeyName> buttons;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Buttons, type, name, params, buttons);
};
```

2
appsrc/appsetting/project_port/basic/zappversion.hpp

@ -1,3 +1,3 @@
#pragma once
#define VERSION "1.2.0"
#define VERSION "1.2.1"
#define PROJECT_NAME "TRANSMIT_DM"

3
appsrc/service/app_core.cpp

@ -291,7 +291,8 @@ void AppCore::ForTest_startGenFakeH2O2Data(shared_ptr<MsgProcessContext> cxt, js
float rs = cache.random[i] ? (rand() % 100) : cache.rs[i];
logger->debug("genFakeH2O2DataThread: h2o2={}, rh={}, temp={}, rs={}", h2o2, rh, temp, rs);
m_dics->getH2O2SensorMgr()->updateH2o2SensorData(i, h2o2, rh, temp, rs);
H2O2ReportData data;
m_dics->getH2O2SensorMgr()->updateH2o2SensorData(i, &data, h2o2, rh, temp, rs);
}
}
}

24
appsrc/service/front_end_realtime_display_content_mgr.cpp

@ -5,10 +5,10 @@ using namespace iflytop;
void FrontEndRealtimeDisplayContentMgr::initialize() { //
REG_EXTFN_VOID(readH2O2SensorData, json());
REG_EXTFN_VOID(readH2O2SensorRawData, json());
}
void FrontEndRealtimeDisplayContentMgr::readH2O2SensorData(shared_ptr<MsgProcessContext> cxt) {
auto h2o2Mgr = GET_SERVICE(DeviceIoControlService)->getH2O2SensorMgr();
// h2o2Mgr->getCacheData()
@ -35,4 +35,24 @@ void FrontEndRealtimeDisplayContentMgr::readH2O2SensorData(shared_ptr<MsgProcess
}
cxt->rely["val"] = sensordata;
}
}
void FrontEndRealtimeDisplayContentMgr::readH2O2SensorRawData(shared_ptr<MsgProcessContext> cxt) {
auto h2o2Mgr = GET_SERVICE(DeviceIoControlService)->getH2O2SensorMgr();
// h2o2Mgr->getCacheData()
json sensordata = json::array();
if (PORT.getExtH2O2SensorNum() >= 0) {
sensordata[0] = !h2o2Mgr->isDataExpired(0) ? json(h2o2Mgr->getCacheData(0)->reportData) : json();
}
if (PORT.getExtH2O2SensorNum() >= 1) {
sensordata[1] = !h2o2Mgr->isDataExpired(1) ? json(h2o2Mgr->getCacheData(1)->reportData) : json();
}
if (PORT.getExtH2O2SensorNum() >= 2) {
sensordata[2] = !h2o2Mgr->isDataExpired(2) ? json(h2o2Mgr->getCacheData(2)->reportData) : json();
}
cxt->rely["val"] = sensordata;
}

1
appsrc/service/front_end_realtime_display_content_mgr.hpp

@ -23,6 +23,7 @@ class FrontEndRealtimeDisplayContentMgr : public enable_shared_from_this<FrontEn
private:
void readH2O2SensorData(shared_ptr<MsgProcessContext> cxt);
void readH2O2SensorRawData(shared_ptr<MsgProcessContext> cxt);
};
} // namespace iflytop

42
appsrc/service/hardware/base/h2o2_sensor_data_mgr.cpp

@ -73,37 +73,56 @@ shared_ptr<H2O2SensorDataCache> H2O2SensorDataMgr::getSensorDataCache(uint8_t se
return sensor_data;
}
void H2O2SensorDataMgr::updateH2o2SensorData(uint8_t sensorId, report_h2o2_data_t* h2o2data) {
void H2O2SensorDataMgr::convertH2o2Data(report_h2o2_data_t* from, H2O2ReportData* to) {
to->sensor_error = from->sensor_error;
to->h2o2 = from->h2o2;
to->rh = from->rh;
to->temp = from->temp;
to->rs = from->rs;
to->h2o2adc = from->h2o2adc;
to->df_ptemp = from->df_ptemp;
to->ah = from->ah;
to->mr = from->mr;
to->wet_bulb_temp = from->wet_bulb_temp;
to->enthalpy = from->enthalpy;
}
void H2O2SensorDataMgr::updateH2o2SensorData(uint8_t sensorId, report_h2o2_data_t* _h2o2data) {
lock_guard<recursive_mutex> lock(m_lock);
H2O2ReportData h2o2data;
convertH2o2Data(_h2o2data, &h2o2data);
// 打印10次日志,以后的调试通过前端读取获取
static int logcnt = 0;
logcnt++;
if (logcnt < 10) logger->info("update h2o2 : sensorId = {}, h2o2 = {}, temp = {}, rh = {}, rs = {}", sensorId, h2o2data->h2o2, h2o2data->temp, h2o2data->rh, h2o2data->rs);
if (logcnt < 10 || GET_SERVICE(DeviceStateService)->getDeviceState() == DeviceState::Disinfection) {
logger->info("update h2o2 : {}", sensorId, json(h2o2data));
}
if (zsteady_clock().gets() > SENSOR_PREHEART_TIME_S) {
float h2o2 = h2o2data->h2o2;
float temp = h2o2data->temp / 10.0;
float rh = h2o2data->rh / 10.0;
float h2o2 = h2o2data.h2o2;
float temp = h2o2data.temp / 10.0;
float rh = h2o2data.rh / 10.0;
float rs = 0;
if (h2o2data->rs == 0) {
if (h2o2data.rs == 0) {
rs = zh2o2_compute_rs(h2o2, zh2o2_t2k(temp), rh, AIR_PRESSURE);
}
if (h2o2 < 30) {
h2o2 = 0;
}
updateH2o2SensorData(sensorId, h2o2, rh, temp, rs);
updateH2o2SensorData(sensorId, &h2o2data, h2o2, rh, temp, rs);
} else {
float h2o2 = 0;
float temp = h2o2data->temp / 10.0;
float temp = h2o2data.temp / 10.0;
float rh = 0;
float rs = 0;
updateH2o2SensorData(sensorId, h2o2, rh, temp, rs);
updateH2o2SensorData(sensorId, &h2o2data, h2o2, rh, temp, rs);
}
}
void H2O2SensorDataMgr::updateH2o2SensorData(uint8_t sensorId, float h2o2, float rh, float temp, float rs) {
void H2O2SensorDataMgr::updateH2o2SensorData(uint8_t sensorId, H2O2ReportData* reportdata, float h2o2, float rh, float temp, float rs) {
lock_guard<recursive_mutex> lock(m_lock);
auto dataCache = getSensorDataCache(sensorId);
@ -112,6 +131,7 @@ void H2O2SensorDataMgr::updateH2o2SensorData(uint8_t sensorId, float h2o2, float
dataCache->rh = rh;
dataCache->rs = rs;
dataCache->updatetime = zsys_get_ticket();
dataCache->reportData = *reportdata;
statisticsSensorData();
}

32
appsrc/service/hardware/base/h2o2_sensor_data_mgr.hpp

@ -29,15 +29,35 @@ namespace iflytop {
using namespace std;
using namespace core;
class H2O2ReportData {
public:
uint8_t sensor_error; // 传感器异常
uint16_t h2o2; // ppm * 10
uint16_t rh; // %RH * 10
uint16_t temp; // °C * 10
uint16_t rs; // %RS * 10
uint16_t h2o2adc; // adc_val
int16_t df_ptemp; // Dew/frost point temperature °C * 10
int16_t ah; // Absolute humidity g/m3 * 10
int16_t mr; // Mixing ratio g/kg * 10
int16_t wet_bulb_temp; // Wet-bulb temperature °C * 10
int16_t enthalpy; // Enthalpy kJ/kg * 10
NLOHMANN_DEFINE_TYPE_INTRUSIVE(H2O2ReportData, sensor_error, h2o2, rh, temp, rs, h2o2adc, df_ptemp, ah, mr, wet_bulb_temp, enthalpy);
};
class H2O2SensorDataCache {
public:
uint8_t sensorId = 0;
int64_t updatetime = 0;
float h2o2 = -1; // ppm
float rh = -1; // %RH
float temp = -1; // °C
float rs = -1; // %RS
float h2o2 = -1; // ppm
float rh = -1; // %RH
float temp = -1; // °C
float rs = -1; // %RS
H2O2ReportData reportData;
};
class H2O2SensorDataMgr : public enable_shared_from_this<H2O2SensorDataMgr> {
@ -64,8 +84,10 @@ class H2O2SensorDataMgr : public enable_shared_from_this<H2O2SensorDataMgr> {
int getMaxSaturation();
public:
void convertH2o2Data(report_h2o2_data_t* h2o2data, H2O2ReportData* reportData);
void updateH2o2SensorData(uint8_t sensorId, report_h2o2_data_t* h2o2data);
void updateH2o2SensorData(uint8_t sensorId, float h2o2, float rh, float temp, float rs);
void updateH2o2SensorData(uint8_t sensorId, H2O2ReportData* reportdata, float h2o2, float rh, float temp, float rs);
private:
shared_ptr<H2O2SensorDataCache> getSensorDataCache(uint8_t sensorId);

Loading…
Cancel
Save