Browse Source

update

master
zhaohe 1 year ago
parent
commit
a1a105443c
  1. 6
      src/service/device_io_control_service.cpp
  2. 1
      src/service/device_io_control_service.hpp
  3. 8
      src/service/device_io_control_service_test.cpp
  4. 1
      src/service/device_io_control_service_test.hpp
  5. 212
      src/service/disfection_ctl/disinfection_service.cpp
  6. 2
      src/service/disfection_ctl/disinfection_service.hpp
  7. 1
      src/service/if_devoce_io_contrl_service.hpp

6
src/service/device_io_control_service.cpp

@ -535,7 +535,8 @@ float DeviceIoControlService::airCompressor_getPressureDirect() {
/*******************************************************************************
* - *
*******************************************************************************/
void DeviceIoControlService::DBDB__sprayLiquidPump_run(int gpm) {
static int DBDB__sprayLiquidPump_run_gpm = 0;
void DeviceIoControlService::DBDB__sprayLiquidPump_run(int gpm) {
logger->info("DBDB__sprayLiquidPump_run run {}", gpm);
int speed = GPM_TO_SPEED(gpm);
if (speed > 400) {
@ -543,9 +544,12 @@ void DeviceIoControlService::DBDB__sprayLiquidPump_run(int gpm) {
} else if (speed < -400) {
speed = -400;
}
DBDB__sprayLiquidPump_run_gpm = gpm;
m_zcanHost->pumpctrl_c1004(2, 100, speed, 1, 15);
}
int DeviceIoControlService::DBDB__sprayLiquidPump_readSpeed() { return DBDB__sprayLiquidPump_run_gpm; }
int32_t DeviceIoControlService::DBDB__readPressureSensor(int index) {
int32_t ackcontent = 0;
int ecode = m_zcanHost->call(kcmd_dbdb_liquid_path_ctrl_board_read_pressure_sensor, index, &ackcontent);

1
src/service/device_io_control_service.hpp

@ -213,6 +213,7 @@ class DeviceIoControlService : public IF_DeviceIoContrlService {
* - *
*******************************************************************************/
virtual void DBDB__sprayLiquidPump_run(int gpm) override;
virtual int DBDB__sprayLiquidPump_readSpeed() override;
virtual int32_t DBDB__readPressureSensor(int index) override;
virtual int32_t DBDB__sprayAirCompressorPowerCtrl(int index) override;

8
src/service/device_io_control_service_test.cpp

@ -248,12 +248,16 @@ int32_t DeviceIoControlServiceTest::AirProportionalValve_isBusy(int32_t* isbusy)
/*******************************************************************************
* - *
*******************************************************************************/
int32_t DBDB__sprayLiquidPump_state;
int32_t DBDB__sprayLiquidPump_gpm;
void DeviceIoControlServiceTest::DBDB__sprayLiquidPump_run(int gpm) {
logger->info("DBDB__sprayLiquidPump_run gpm:{}", gpm);
DBDB__sprayLiquidPump_state = 1;
DBDB__sprayLiquidPump_gpm = gpm;
}
int DeviceIoControlServiceTest::DBDB__sprayLiquidPump_readSpeed() { return DBDB__sprayLiquidPump_gpm; }
int32_t DeviceIoControlServiceTest::DBDB__readPressureSensor(int index) { return index; }
int32_t DeviceIoControlServiceTest::DBDB__sprayAirCompressorPowerCtrl(int power) {
logger->info("DBDB__sprayAirCompressorPowerCtrl power:{}", power);

1
src/service/device_io_control_service_test.hpp

@ -157,6 +157,7 @@ class DeviceIoControlServiceTest : public IF_DeviceIoContrlService {
* - *
*******************************************************************************/
virtual void DBDB__sprayLiquidPump_run(int gpm) override;
virtual int DBDB__sprayLiquidPump_readSpeed() override;
virtual int32_t DBDB__readPressureSensor(int index) override;
virtual int32_t DBDB__sprayAirCompressorPowerCtrl(int index) override;

212
src/service/disfection_ctl/disinfection_service.cpp

@ -104,101 +104,114 @@ static bool zfeq(float a, float b, float eps = 0.01) {
shared_ptr<DisinfectionLogger> DisinfectionService::createCSVLogger(string log_file_name) {
shared_ptr<DisinfectionLogger> _logger = m_disinfectionLogsManager->createNewLogger(log_file_name);
_logger->write(
fmt::format("{},"
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
return _logger;
}
" {} , {} , {} , {} ,"
" {} , {} , {} , {} ,"
" {} , {} , {} , {} ,"
#else
" {} , {} , {} , {} ,"
#endif
" {} , {} , {} ,"
" {} , {} , {} , {} ,"
" {} , {}"
"\n",
ZIconv::noChange("时间"),
void DisinfectionService::__dumpDisinfectionLogsToCSV(bool header) {
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度"), //
ZIconv::noChange("环境1-气化过氧化氢浓度"), ZIconv::noChange("环境1-温度"), ZIconv::noChange("环境1-相对湿度"), ZIconv::noChange("环境1-相对饱和度"), //
ZIconv::noChange("环境2-气化过氧化氢浓度"), ZIconv::noChange("环境2-温度"), ZIconv::noChange("环境2-相对湿度"), ZIconv::noChange("环境2-相对饱和度"), //
#else
ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度"), //
static_assert(MAX_H2O2_SENSOR_NUM == 3, "MAX_H2O2_SENSOR_NUM must be 3");
#endif
ZIconv::noChange("D值"), ZIconv::noChange("当前LOG"), ZIconv::noChange("目标LOG"), //
ZIconv::noChange("加热器电源"), ZIconv::noChange("风机电源"), ZIconv::noChange("空压机电源"), ZIconv::noChange("喷液泵(g/min)"), //
ZIconv::noChange("消毒剩余剂量(g)"), ZIconv::noChange("剩余时间(s)")));
return _logger;
}
if (!context.csvlogger) return;
void DisinfectionService::logstate() {
auto& cx = context;
auto ds = m_deviceIoControlService;
float dvalue = 0;
if (context.dvalue <= 0) {
dvalue = 0;
} else {
dvalue = context.dvalue;
}
auto& cx = context;
string h2o2str[MAX_H2O2_SENSOR_NUM];
string tempstr[MAX_H2O2_SENSOR_NUM];
string humidstr[MAX_H2O2_SENSOR_NUM];
string satstr[MAX_H2O2_SENSOR_NUM];
auto ds = m_deviceIoControlService;
float dvalue = 0;
int remaintime = 0;
if (!header) {
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) {
h2o2str[i] = fmt::format("{}", cx.h2o2[i]);
tempstr[i] = fmt::format("{}", cx.temp[i]);
humidstr[i] = fmt::format("{}", cx.humid[i]);
satstr[i] = fmt::format("{}", cx.saturation[i]);
}
int remaintime = getEstimatedRemainingTimeS();
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) {
if (cx.h2o2[i] < 0) h2o2str[i] = "N/A";
if (cx.temp[i] < 0) tempstr[i] = "N/A";
if (cx.humid[i] < 0) humidstr[i] = "N/A";
if (cx.saturation[i] < 0) satstr[i] = "N/A";
}
logger->info(
fmt::format("{},"
if (context.dvalue <= 0) {
dvalue = 0;
} else {
dvalue = context.dvalue;
}
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
"s0({},{},{},{}),"
"s1({},{},{},{}),"
"s2({},{},{},{}),"
#else
"s2({},{},{},{}),"
remaintime = getEstimatedRemainingTimeS();
}
string content;
if (header) {
content += fmt::format("{},", ZIconv::noChange("时间"));
} else {
content += fmt::format("{}", getTime());
}
#endif
"min_h2o2:{},max_h2o2:{},max_hum:{},max_sa:{},"
"dv:{},log:{},tlog:{},"
"h:{},airB:{},airC:{},pump:{},"
"g:{},remainS:{}",
getTime(), //
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
cx.h2o2[0], cx.temp[0], cx.humid[0], cx.saturation[0], //
cx.h2o2[1], cx.temp[1], cx.humid[1], cx.saturation[1], //
cx.h2o2[2], cx.temp[2], cx.humid[2], cx.saturation[2], //
if (header) {
content += fmt::format(" {} , {} , {} , {} ,", ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度"));
content += fmt::format(" {} , {} , {} , {} ,", ZIconv::noChange("环境1-气化过氧化氢浓度"), ZIconv::noChange("环境1-温度"), ZIconv::noChange("环境1-相对湿度"), ZIconv::noChange("环境1-相对饱和度"));
content += fmt::format(" {} , {} , {} , {} ,", ZIconv::noChange("环境2-气化过氧化氢浓度"), ZIconv::noChange("环境2-温度"), ZIconv::noChange("环境2-相对湿度"), ZIconv::noChange("环境2-相对饱和度"));
} else {
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) {
content += fmt::format(" {} , {} , {} , {} ,", h2o2str[i], tempstr[i], humidstr[i], satstr[i]);
}
}
#else
cx.h2o2[0], cx.temp[0], cx.humid[0], cx.saturation[0], //
if (header) {
content += fmt::format(" {} , {} , {} ,", ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"));
} else {
content += fmt::format(" {} , {} , {} ,", h2o2str[0], tempstr[0], humidstr[0]);
}
#endif
context.min_h2o2, context.max_h2o2, context.max_humid, context.max_saturation, //
(int32_t)dvalue, context.now_loglevel, (int32_t)cfg.targetLoglevel, //
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime)));
}
void DisinfectionService::dumpDisinfectionLogsToCSV() {
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
static_assert(MAX_H2O2_SENSOR_NUM == 3, "MAX_H2O2_SENSOR_NUM must be 3");
#endif
if (header) {
content += fmt::format(" {} , {} , {} ,", ZIconv::noChange("D值"), ZIconv::noChange("当前LOG"), ZIconv::noChange("目标LOG"));
} else {
content += fmt::format(" {} , {} , {} ,", (int32_t)dvalue, (int32_t)context.now_loglevel, (int32_t)cfg.targetLoglevel);
}
auto& cx = context;
string h2o2str[MAX_H2O2_SENSOR_NUM];
string tempstr[MAX_H2O2_SENSOR_NUM];
string humidstr[MAX_H2O2_SENSOR_NUM];
string satstr[MAX_H2O2_SENSOR_NUM];
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
if (header) {
content += fmt::format(" {} ,", ZIconv::noChange("喷液泵(g/min)"));
} else {
content += fmt::format(" {} ,", ds->sprayLiquidPump_getGPM());
}
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) {
h2o2str[i] = fmt::format("{}", cx.h2o2[i]);
tempstr[i] = fmt::format("{}", cx.temp[i]);
humidstr[i] = fmt::format("{}", cx.humid[i]);
satstr[i] = fmt::format("{}", cx.saturation[i]);
if (header) {
content += fmt::format(" {} ,", ZIconv::noChange("消毒剂剩余量(g)"));
} else {
content += fmt::format(" {} ,", m_deviceIoControlService->getDisinfectantVolume_g());
}
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) {
if (cx.h2o2[i] < 0) h2o2str[i] = "N/A";
if (cx.temp[i] < 0) tempstr[i] = "N/A";
if (cx.humid[i] < 0) humidstr[i] = "N/A";
if (cx.saturation[i] < 0) satstr[i] = "N/A";
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
if (header) {
content += fmt::format(" {} ,", ZIconv::noChange("喷液泵(g/min)"));
} else {
content += fmt::format(" {} ,", ds->DBDB__sprayLiquidPump_readSpeed());
}
#endif
if (header) {
content += fmt::format(" {}\n", ZIconv::noChange("预计剩余时间"));
} else {
content += fmt::format(" {}\n", formattimeS(remaintime));
}
context.csvlogger->write(content);
}
void DisinfectionService::dumpDisinfectionLogsToCSV() { __dumpDisinfectionLogsToCSV(false); }
void DisinfectionService::logstate() {
auto& cx = context;
auto ds = m_deviceIoControlService;
float dvalue = 0;
if (context.dvalue <= 0) {
@ -208,33 +221,25 @@ void DisinfectionService::dumpDisinfectionLogsToCSV() {
}
int remaintime = getEstimatedRemainingTimeS();
if (context.csvlogger)
context.csvlogger->write(
fmt::format(" {} ,"
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
" {} , {} , {} , {} ,"
" {} , {} , {} , {} ,"
" {} , {} , {} , {} ,"
#else
" {} , {} , {} , {} ,"
#endif
" {} , {} , {} ,"
" {} , {} , {} , {} ,"
" {} , {} "
"\n",
getTime(), //
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
h2o2str[0], tempstr[0], humidstr[0], satstr[0], //
h2o2str[1], tempstr[1], humidstr[1], satstr[1], //
h2o2str[2], tempstr[2], humidstr[2], satstr[2], //
#else
h2o2str[0], tempstr[0], humidstr[0], satstr[0], //
string logval;
logval += fmt::format("{},", getTime());
for (int i = 0; i < MAX_H2O2_SENSOR_NUM; i++) {
logval += fmt::format("s{}({},{},{},{}) ,", i, cx.h2o2[i], cx.temp[i], cx.humid[i], cx.saturation[i]);
}
logval += fmt::format("min_h2o2:{},max_h2o2:{},max_hum:{},max_sa:{},", context.min_h2o2, context.max_h2o2, context.max_humid, context.max_saturation);
logval += fmt::format("dv:{},log:{},tlog:{},", (int32_t)dvalue, context.now_loglevel, (int32_t)cfg.targetLoglevel);
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
logval += fmt::format("h:{},airB:{},airC:{},pump:{},", ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM());
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
logval += fmt::format("pump:{},", ds->DBDB__sprayLiquidPump_readSpeed());
#endif
(int32_t)dvalue, (int32_t)context.now_loglevel, (int32_t)cfg.targetLoglevel, //
ds->heatingStrip_getstate(), ds->airBlower_getstate(), ds->airCompressor_getstate(), ds->sprayLiquidPump_getGPM(), //
m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime)));
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
logval += fmt::format("g:{},remainS:{}", m_deviceIoControlService->getDisinfectantVolume_g(), formattimeS(remaintime));
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
logval += fmt::format("remainS:{}", formattimeS(remaintime));
#endif
logger->info(logval);
}
void DisinfectionService::pushDisinfectionPrinterTask() { //
@ -420,7 +425,8 @@ void DisinfectionService::initState() {
#else
#endif
context.csvlogger = createCSVLogger(context.id);
context.csvlogger = createCSVLogger(context.id);
__dumpDisinfectionLogsToCSV(true);
m_disinfectionWorkState = 1;
}

2
src/service/disfection_ctl/disinfection_service.hpp

@ -62,7 +62,6 @@ class DisinfectionService : public enable_shared_from_this<DisinfectionService>
int af_dinft_dehumidification_target_val = 50; // 消毒后除湿目标湿度
int degradation_target_val = 0; //
} config_t;
typedef struct {
@ -197,6 +196,7 @@ class DisinfectionService : public enable_shared_from_this<DisinfectionService>
void logstate();
void takeStateSnapshot();
void dumpDisinfectionLogsToCSV();
void __dumpDisinfectionLogsToCSV(bool header);
void tryLogSatate(bool force = false);

1
src/service/if_devoce_io_contrl_service.hpp

@ -178,6 +178,7 @@ class IF_DeviceIoContrlService {
* - *
*******************************************************************************/
virtual void DBDB__sprayLiquidPump_run(int gpm) = 0;
virtual int DBDB__sprayLiquidPump_readSpeed() = 0;
virtual int32_t DBDB__readPressureSensor(int index) = 0;
virtual int32_t DBDB__sprayAirCompressorPowerCtrl(int index) = 0;

Loading…
Cancel
Save