Browse Source

update

master
zhaohe 2 years ago
parent
commit
0d6ba3fdeb
  1. 2
      iflytoplinuxsdk
  2. 43
      src/service/disinfection_ctl_service.cpp
  3. 1
      src/service/disinfection_ctl_service.hpp

2
iflytoplinuxsdk

@ -1 +1 @@
Subproject commit 6b330dc02a70689893c404afaf5f567fcee93c42
Subproject commit a1bb46e362110d2bfe93d4eff8cc073b7278e75f

43
src/service/disinfection_ctl_service.cpp

@ -54,9 +54,9 @@ static string getTime() {
time_t t = time(nullptr);
struct tm* tmp = localtime_r(&t, &tm);
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
tm.tm_mon + 1, //
tm.tm_mday, //
tm.tm_hour, //
tm.tm_mon + 1, //
tm.tm_mday, //
tm.tm_hour, //
tm.tm_min, tm.tm_sec);
}
@ -118,6 +118,16 @@ float DisinfectionCtrlService::getDisinfectionDValue(float ppm) {
}
return dvalue;
}
float DisinfectionCtrlService::computeNowLogLevel(DisinfectionContext& context) {
float dvalue = context.dvalue;
if (dvalue > 0) {
/**
* @brief m_nowLoglevel
*/
return context.m_nowLoglevel + DVALUE_COMPUTEPERIOD_TIME_S / (dvalue * 60);
}
return context.m_nowLoglevel;
}
void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) {
/**
@ -129,7 +139,6 @@ void DisinfectionCtrlService::computeRemainTime(DisinfectionContext& context) {
/**
* @brief m_nowLoglevel
*/
context.m_nowLoglevel += DVALUE_COMPUTEPERIOD_TIME_S / (dvalue * 60);
if (context.m_targetLoglevel >= context.m_nowLoglevel) {
context.m_remaintime = (context.m_targetLoglevel - context.m_nowLoglevel) * (dvalue * 60);
} else {
@ -201,20 +210,26 @@ void DisinfectionCtrlService::initContext(DisinfectionContext& context,
// m_context.m_remaintime
context.csvlogger->write(
"date," //
"hydrogen_peroxide_volume(ppm),temperature(C),relative_humidity(%RH),h2o_h2o2_rs(%RS)," //
"Date," //
"Hydrogen peroxide volume(ppm),Temperature(C),Relative humidity(%RH),H2O H2O2 RS(%RS)," //
// "h2o22,temp2,humi2,saturation2," //
// "h2o23,temp3,humi3,saturation3," //
"dvalue,loglevel,targetloglevel," //
"heating,blower,compressor,pump(g/min)," //
"disinfectantVolume(g)," //
"remaintime(s)\n" //
"Dvalue,Loglevel,Targetloglevel," //
"Heating,Blower,Compressor,Pump(g/min)," //
"Disinfectant Volume(g)," //
"Remaining time (s)\n" //
);
}
static string formattimeS(int sec) { return fmt::format("{:0>2}:{:0>2}:{:0>2}", sec / 3600, sec % 3600 / 60, sec % 60); }
void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionContext& context) {
auto* sensors = &m_context.h2o2data.h2o2sensor_data[0];
auto ds = m_deviceIoControlService;
float dvalue = 0;
if (m_context.dvalue <= 0) {
dvalue = 0;
} else {
dvalue = m_context.dvalue;
}
context.csvlogger->write(
fmt::format("{}," //
"{},{},{},{}," //
@ -230,7 +245,7 @@ void DisinfectionCtrlService::dumpDisinfectionLogsToCSV(DisinfectionCon
sensors[0].h2o2, sensors[0].temp, sensors[0].humid, sensors[0].saturation, //
// sensors[1].h2o2, sensors[1].temp, sensors[1].humid, sensors[1].saturation, //
// sensors[2].h2o2, sensors[2].temp, sensors[2].humid, sensors[2].saturation, //
m_context.dvalue, m_context.m_nowLoglevel, m_context.m_targetLoglevel, //
dvalue, m_context.m_nowLoglevel, m_context.m_targetLoglevel, //
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
m_deviceIoControlService->getDisinfectantVolume_g(), //
formattimeS(m_context.m_remaintime)));
@ -378,7 +393,11 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) {
if (zsteady_clock().elapsedTimeS(m_context.m_lastComputeDvalueTp) > DVALUE_COMPUTEPERIOD_TIME_S) {
m_context.m_lastComputeDvalueTp = zsteady_clock().now();
computeRemainTime(m_context);
//
if (m_context.m_state == kdisinfection || m_context.m_state == kdisinfection_take_a_break) {
m_context.m_nowLoglevel = computeNowLogLevel(m_context);
computeRemainTime(m_context);
}
}
if (m_context.m_state == kpreheat) {

1
src/service/disinfection_ctl_service.hpp

@ -170,6 +170,7 @@ public:
float continued_humi //
);
void computeRemainTime(DisinfectionContext& context);
float computeNowLogLevel(DisinfectionContext& context);
void processPreheatState(DisinfectionContext& context);
void processDisinfectionState(DisinfectionContext& context);
void dumpDisinfectionLogs(DisinfectionContext& context);

Loading…
Cancel
Save