Browse Source

fix some bug

master
zhaohe 1 year ago
parent
commit
a3adda1902
  1. 4
      src/service/device_io_control_service_test.cpp
  2. 31
      src/service/disfection_ctl/disinfection_service.cpp
  3. 5
      src/service/disinfection_printer_service.cpp

4
src/service/device_io_control_service_test.cpp

@ -164,7 +164,7 @@ void DeviceIoControlServiceTest::replenishingFluidsPump_close_for_test() { drain
static int sprayLiquidPump_rpm;
void DeviceIoControlServiceTest::sprayLiquidPump_open(int gpm) {
logger->info("sprayLiquidPump_open:{}", gpm);
sprayLiquidPump_rpm = 123;
sprayLiquidPump_rpm = gpm;
}
void DeviceIoControlServiceTest::sprayLiquidPump_close() {
logger->info("sprayLiquidPump_close");
@ -172,7 +172,7 @@ void DeviceIoControlServiceTest::sprayLiquidPump_close() {
}
int DeviceIoControlServiceTest::sprayLiquidPump_getState() { return sprayLiquidPump_rpm; }
int DeviceIoControlServiceTest::sprayLiquidPump_getRPM() { return sprayLiquidPump_rpm; }
int DeviceIoControlServiceTest::sprayLiquidPump_getGPM() { return sprayLiquidPump_rpm * 2; }
int DeviceIoControlServiceTest::sprayLiquidPump_getGPM() { return sprayLiquidPump_rpm; }
void DeviceIoControlServiceTest::sprayLiquidPump_open_for_test(int gpm) { sprayLiquidPump_rpm = gpm; }
void DeviceIoControlServiceTest::sprayLiquidPump_close_for_test() { sprayLiquidPump_rpm = 0; }

31
src/service/disfection_ctl/disinfection_service.cpp

@ -13,7 +13,8 @@ using namespace std;
#define DVALUE_COMPUTEPERIOD_TIME_S (10.0)
#define DUMP_LOG_PERIOD (5 * 60.0)
#define DBDB_MINI_PWM_BLOWER_VAL 50
// #define DUMP_LOG_PERIOD (10.0)
#define DBDB_MINI_PWM_BLOWER_VAL 50
namespace iflytop {
extern bool g_in_test;
@ -278,6 +279,7 @@ void DisinfectionService::takeStateSnapshot() {
void DisinfectionService::tryLogSatate(bool force) {
if (force || zsteady_clock().elapsedTimeS(context.lastlog_tp) > DUMP_LOG_PERIOD) {
context.lastlog_tp = zsteady_clock().now();
logger->info("dumping state snapshot to csv");
takeStateSnapshot();
dumpDisinfectionLogsToCSV();
logstate();
@ -667,6 +669,7 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event)
m_deviceIoControlService->airCompressor_setState(true);
usleep(1000 * 1000);
m_deviceIoControlService->sprayLiquidPump_open(cfg.injection_pump_speed);
m_deviceIoControlService->heartingPlate_setPower(true);
#endif
#if (defined PROJECT_TYPE_DRAW_BAR_BOX)
@ -689,25 +692,22 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event)
else if (event->event == kdisinfection_event_exit_state) {
context.dvalue = 0;
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
m_deviceIoControlService->airBlower_setState(false);
usleep(1000 * 1000);
m_deviceIoControlService->airCompressor_setState(false);
usleep(1000 * 1000);
m_deviceIoControlService->sprayLiquidPump_close();
#elif (defined PROJECT_TYPE_PIPE_DISINFECTION)
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
#if (defined PROJECT_TYPE_PIPE_DISINFECTION)
m_deviceIoControlService->airCompressor_channelSelect(1);
m_deviceIoControlService->airCompressor_setValve1(1);
m_deviceIoControlService->airCompressor_setValve2(1);
#endif
m_deviceIoControlService->airBlower_setState(false);
usleep(1000 * 1000);
m_deviceIoControlService->airCompressor_setState(false);
usleep(1000 * 1000);
m_deviceIoControlService->sprayLiquidPump_close();
m_deviceIoControlService->heartingPlate_setPower(false);
#endif
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
#if (defined PROJECT_TYPE_DRAW_BAR_BOX)
m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(0);
usleep(100 * 1000);
m_deviceIoControlService->DBDB__heaterCtrl(0);
@ -716,7 +716,6 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event)
usleep(100 * 1000);
m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(0);
usleep(100 * 1000);
#else
#endif
}
@ -832,18 +831,24 @@ void DisinfectionService::processStateFinished(disinfection_event_t* event) {
}
void DisinfectionService::processStateDegradation(disinfection_event_t* event) {
//
if (event->event == kdisinfection_event_enter_state) {
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
m_deviceIoControlService->airBlower_setState(true);
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
#endif
} else if (event->event == kdisinfection_event_exit_state) {
}
//
else if (event->event == kdisinfection_event_exit_state) {
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
m_deviceIoControlService->airBlower_setState(false);
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
#endif
} else if (event->event == kdisinfection_event_tmr_1s) {
}
//
else if (event->event == kdisinfection_event_tmr_1s) {
logger->info("waitting for h2o2 concentration to safe value {}=>{}", context.max_h2o2, 1);
if (context.max_h2o2 < 1) {
logger->info("h2o2 concentration to safe value");

5
src/service/disinfection_printer_service.cpp

@ -27,7 +27,7 @@ void DisinfectionPrinterService::initialize() {
}
}
if (!task) {
this_thread::sleep_for(chrono::milliseconds(1000));
this_thread::sleep_for(chrono::milliseconds(100));
continue;
}
@ -82,9 +82,10 @@ void DisinfectionPrinterService::printTask(shared_ptr<DisinfectionPrinterTask> t
dio->printerPrintf(fmt::format("{}ppm {}%RS {}%RH {:.2f}Log\n", ss->min_h2o2, ss->max_saturation, ss->max_humid, ss->dloglevel));
state = now_state;
} else {
if (now_state == kstate_degradation) {
if (now_state == kstate_disinfection) {
dio->printerPrintf(fmt::format("{}\n", format_zsystem_tp(ss->time)));
dio->printerPrintf(fmt::format("{}ppm {}%RS {}%RH {}Log\n", ss->min_h2o2, ss->max_saturation, ss->max_humid, ss->dloglevel));
this_thread::sleep_for(chrono::milliseconds(200));
}
}
}

Loading…
Cancel
Save