|
|
@ -13,6 +13,7 @@ using namespace std; |
|
|
|
|
|
|
|
#define DVALUE_COMPUTEPERIOD_TIME_S (10.0)
|
|
|
|
#define DUMP_LOG_PERIOD (5 * 60.0)
|
|
|
|
#define DBDB_MINI_PWM_BLOWER_VAL 50
|
|
|
|
|
|
|
|
namespace iflytop { |
|
|
|
extern bool g_in_test; |
|
|
@ -36,7 +37,6 @@ void DisinfectionService::initialize() { |
|
|
|
m_deviceIoControlService->airBlower_setState(false); |
|
|
|
m_deviceIoControlService->airCompressor_setState(false); |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sm.regStateProcesser(kstate_idle, bind(&DisinfectionService::processStateIdle, this, placeholders::_1)); |
|
|
@ -46,6 +46,8 @@ void DisinfectionService::initialize() { |
|
|
|
sm.regStateProcesser(kstate_finished, bind(&DisinfectionService::processStateFinished, this, placeholders::_1)); |
|
|
|
sm.regStateProcesser(kstate_dehumidification_before_disinfection, bind(&DisinfectionService::processStateDehumidification_before_disinfection, this, placeholders::_1)); |
|
|
|
sm.regStateProcesser(kstate_dehumidification_after_disinfection, bind(&DisinfectionService::processStateDehumidification_after_disinfection, this, placeholders::_1)); |
|
|
|
|
|
|
|
sm.regBfStateProcess(bind(&DisinfectionService::beforeStateProcess, this)); |
|
|
|
sm.startProcess(); |
|
|
|
} |
|
|
|
|
|
|
@ -100,47 +102,37 @@ 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); |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
|
|
|
|
_logger->write( |
|
|
|
fmt::format("{}," |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#else
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#endif
|
|
|
|
" {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {}" |
|
|
|
"\n", |
|
|
|
ZIconv::noChange("时间"), //
|
|
|
|
ZIconv::noChange("时间"), |
|
|
|
#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-相对饱和度"), //
|
|
|
|
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)"))); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PROJECT_TYPE_PIPE_DISINFECTION
|
|
|
|
|
|
|
|
_logger->write( |
|
|
|
fmt::format(" {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} " |
|
|
|
"\n", |
|
|
|
ZIconv::noChange("时间"), //
|
|
|
|
#else
|
|
|
|
ZIconv::noChange("仓内-气化过氧化氢浓度"), ZIconv::noChange("仓内-温度"), ZIconv::noChange("仓内-相对湿度"), ZIconv::noChange("仓内-相对饱和度"), //
|
|
|
|
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)"))); |
|
|
|
|
|
|
|
#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; |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::logstate() { |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
|
|
|
|
auto& cx = context; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
@ -154,56 +146,37 @@ void DisinfectionService::logstate() { |
|
|
|
|
|
|
|
logger->info( |
|
|
|
fmt::format("{}," |
|
|
|
|
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
"s0({},{},{},{})," |
|
|
|
"s1({},{},{},{})," |
|
|
|
"s2({},{},{},{})," |
|
|
|
"min_h2o2:{},max_h2o2:{},max_hum:{},max_sa:{}," |
|
|
|
"dv:{},log:{},tlog:{}," |
|
|
|
"h:{},airB:{},airC:{},pump:{}," |
|
|
|
"g:{},remainS:{}" |
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
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], //
|
|
|
|
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))); |
|
|
|
#endif
|
|
|
|
#ifdef PROJECT_TYPE_PIPE_DISINFECTION
|
|
|
|
auto& cx = context; |
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
if (context.dvalue <= 0) { |
|
|
|
dvalue = 0; |
|
|
|
} else { |
|
|
|
dvalue = context.dvalue; |
|
|
|
} |
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
|
#else
|
|
|
|
"s2({},{},{},{})," |
|
|
|
|
|
|
|
logger->info( |
|
|
|
fmt::format("{}," |
|
|
|
"s0({},{},{},{})," |
|
|
|
#endif
|
|
|
|
"min_h2o2:{},max_h2o2:{},max_hum:{},max_sa:{}," |
|
|
|
"dv:{},log:{},tlog:{}," |
|
|
|
"h:{},airB:{},airC:{},pump:{}," |
|
|
|
"g:{},remainS:{}" |
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
cx.h2o2[0], cx.temp[0], cx.humid[0], cx.saturation[0], //
|
|
|
|
"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], //
|
|
|
|
#else
|
|
|
|
cx.h2o2[0], cx.temp[0], cx.humid[0], cx.saturation[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))); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
auto& cx = context; |
|
|
|
string h2o2str[MAX_H2O2_SENSOR_NUM]; |
|
|
@ -234,73 +207,51 @@ void DisinfectionService::dumpDisinfectionLogsToCSV() { |
|
|
|
} |
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
|
|
|
|
|
context.csvlogger->write( |
|
|
|
fmt::format(" {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} " |
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
h2o2str[0], tempstr[0], humidstr[0], satstr[0], //
|
|
|
|
h2o2str[1], tempstr[1], humidstr[1], satstr[1], //
|
|
|
|
h2o2str[2], tempstr[2], humidstr[2], satstr[2], //
|
|
|
|
(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 (context.csvlogger) |
|
|
|
context.csvlogger->write( |
|
|
|
fmt::format(" {} ," |
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#else
|
|
|
|
" {} , {} , {} , {} ," |
|
|
|
#endif
|
|
|
|
" {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} " |
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
|
|
|
|
#ifdef PROJECT_TYPE_PIPE_DISINFECTION
|
|
|
|
|
|
|
|
static_assert(MAX_H2O2_SENSOR_NUM == 1, "MAX_H2O2_SENSOR_NUM must be 1"); |
|
|
|
|
|
|
|
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]; |
|
|
|
|
|
|
|
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 (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], //
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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"; |
|
|
|
} |
|
|
|
(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))); |
|
|
|
} |
|
|
|
|
|
|
|
auto ds = m_deviceIoControlService; |
|
|
|
float dvalue = 0; |
|
|
|
if (context.dvalue <= 0) { |
|
|
|
dvalue = 0; |
|
|
|
} else { |
|
|
|
dvalue = context.dvalue; |
|
|
|
} |
|
|
|
void DisinfectionService::pushDisinfectionPrinterTask() { //
|
|
|
|
shared_ptr<DisinfectionPrinterTask> task = make_shared<DisinfectionPrinterTask>(); |
|
|
|
auto ds = GET_SERVICE(DeviceStateService); |
|
|
|
auto dio = m_deviceIoControlService; |
|
|
|
|
|
|
|
int remaintime = getEstimatedRemainingTimeS(); |
|
|
|
task->start_tp = context.start_tp; |
|
|
|
task->complete_tp = context.complete_tp; |
|
|
|
task->stateSnapshotList = context.stateSnapshotList; |
|
|
|
task->disinfectantUsage = context.beforeDisinfectantVolume_g - context.afterDisinfectantVolume_g; |
|
|
|
task->disinfection_id = context.id; |
|
|
|
task->usr = ds->getLoginUid(); |
|
|
|
|
|
|
|
context.csvlogger->write( |
|
|
|
fmt::format(" {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} , {} ," |
|
|
|
" {} , {} , {} , {} ," |
|
|
|
" {} , {} " |
|
|
|
"\n", |
|
|
|
getTime(), //
|
|
|
|
h2o2str[0], tempstr[0], humidstr[0], satstr[0], //
|
|
|
|
(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))); |
|
|
|
task->targetLog = cfg.targetLoglevel; |
|
|
|
task->actualLog = context.now_loglevel; |
|
|
|
|
|
|
|
#endif
|
|
|
|
m_disinfectionPrinterService->pushPrintTask(task); |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::takeStateSnapshot() { |
|
|
@ -398,11 +349,22 @@ void DisinfectionService::startDisinfection() { |
|
|
|
disinfection_event_t event; |
|
|
|
event.event = kdisinfection_event_start; |
|
|
|
sm.pushEvent(event); |
|
|
|
|
|
|
|
while (sm.getState() == kstate_finished) { |
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
|
|
|
} |
|
|
|
} |
|
|
|
void DisinfectionService::stopDisinfection() { |
|
|
|
if (sm.getState() == kstate_finished) return; |
|
|
|
if (sm.getState() == kstate_idle) return; |
|
|
|
|
|
|
|
disinfection_event_t event; |
|
|
|
event.event = kdisinfection_event_stop; |
|
|
|
sm.pushEvent(event); |
|
|
|
|
|
|
|
while (sm.getState() != kstate_finished) { |
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
|
|
|
} |
|
|
|
} |
|
|
|
void DisinfectionService::updateDisinfectionCfg() { |
|
|
|
disinfection_event_t event; |
|
|
@ -522,58 +484,6 @@ float DisinfectionService::computeNowLogLevel() { |
|
|
|
return context.now_loglevel; |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::beforeStateProcess() { updateH2O2SensorData(); } |
|
|
|
|
|
|
|
void DisinfectionService::processStateIdle(disinfection_event_t* event) { sm.changeState(kstate_finished); } |
|
|
|
void DisinfectionService::processStatePreheat(disinfection_event_t* event) { |
|
|
|
/**
|
|
|
|
* @brief 状态逻辑 |
|
|
|
* 1. 记录日志 |
|
|
|
* 2. 检查是否预热完成 |
|
|
|
*/ |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 进入状态 * |
|
|
|
*******************************************************************************/ |
|
|
|
if (event->event == kdisinfection_event_enter_state) { |
|
|
|
logger->info("preheat state enter"); |
|
|
|
tryLogSatate(true); |
|
|
|
|
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
|
|
|
|
m_deviceIoControlService->heartingPlate_setPower(true); |
|
|
|
m_deviceIoControlService->airBlower_setState(true); |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 离开状态 * |
|
|
|
*******************************************************************************/ |
|
|
|
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->heartingPlate_setPower(false); |
|
|
|
m_deviceIoControlService->airBlower_setState(false); |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 状态周期调度事件 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
else if (event->event == kdisinfection_event_tmr_1s) { |
|
|
|
if (sm.getStateHasPassedTimeMs() > cfg.pre_heat_time_s * 1000) { |
|
|
|
/**
|
|
|
|
* @brief 退出预热状态,进入消毒状态 |
|
|
|
*/ |
|
|
|
sm.changeState(kstate_disinfection); |
|
|
|
} |
|
|
|
tryLogSatate(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::updateRemainTime() { |
|
|
|
/**
|
|
|
|
* @brief 计算Dvalue |
|
|
@ -593,7 +503,7 @@ void DisinfectionService::updateRemainTime() { |
|
|
|
//
|
|
|
|
} |
|
|
|
|
|
|
|
logger->info("computeRemainTime minh2o2 {} dvalue {}", context.min_h2o2, dvalue); |
|
|
|
// logger->info("computeRemainTime minh2o2 {} dvalue {}", context.min_h2o2, dvalue);
|
|
|
|
} |
|
|
|
|
|
|
|
bool DisinfectionService::isTimeToPauseDisinfection() { |
|
|
@ -603,9 +513,25 @@ bool DisinfectionService::isTimeToPauseDisinfection() { |
|
|
|
float nowSatur = context.max_saturation; |
|
|
|
float nowh2o2 = context.max_h2o2; |
|
|
|
float humid = context.max_humid; |
|
|
|
if (nowSatur > cfg.stoped_satur || nowh2o2 > cfg.stoped_gs || humid > cfg.stoped_humi) { |
|
|
|
// if (nowSatur > cfg.stoped_satur || nowh2o2 > cfg.stoped_gs || humid > cfg.stoped_humi) {
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (nowSatur > cfg.stoped_satur) { |
|
|
|
logger->info("nowSatur {} > cfg.stoped_satur {}", nowSatur, cfg.stoped_satur); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (nowh2o2 > cfg.stoped_gs) { |
|
|
|
logger->info("nowh2o2 {} > cfg.stoped_gs {}", nowh2o2, cfg.stoped_gs); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (humid > cfg.stoped_humi) { |
|
|
|
logger->info("humid {} > cfg.stoped_humi {}", humid, cfg.stoped_humi); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
bool DisinfectionService::isTimeToResumeDisinfection() { |
|
|
@ -617,8 +543,12 @@ bool DisinfectionService::isTimeToResumeDisinfection() { |
|
|
|
float humid = context.max_humid; |
|
|
|
|
|
|
|
if (nowSatur < cfg.continued_satur && nowh2o2 < cfg.continued_gs && humid < cfg.continued_humi) { |
|
|
|
logger->info("nowSatur {} < cfg.continued_satur {} && nowh2o2 {} < cfg.continued_gs {} && humid {} < cfg.continued_humi {}", //
|
|
|
|
nowSatur, cfg.continued_satur, nowh2o2, cfg.continued_gs, humid, cfg.continued_humi); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
@ -652,6 +582,65 @@ void DisinfectionService::updateSprayLiquidPumpSpeed() { |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::beforeStateProcess() { updateH2O2SensorData(); } |
|
|
|
|
|
|
|
void DisinfectionService::processStateIdle(disinfection_event_t* event) { sm.changeState(kstate_finished); } |
|
|
|
void DisinfectionService::processStatePreheat(disinfection_event_t* event) { |
|
|
|
/**
|
|
|
|
* @brief 状态逻辑 |
|
|
|
* 1. 记录日志 |
|
|
|
* 2. 检查是否预热完成 |
|
|
|
*/ |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 进入状态 * |
|
|
|
*******************************************************************************/ |
|
|
|
if (event->event == kdisinfection_event_enter_state) { |
|
|
|
logger->info("preheat state enter"); |
|
|
|
tryLogSatate(true); |
|
|
|
|
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION) || (defined PROJECT_TYPE_PIPE_DISINFECTION)
|
|
|
|
m_deviceIoControlService->heartingPlate_setPower(true); |
|
|
|
m_deviceIoControlService->airBlower_setState(true); |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 离开状态 * |
|
|
|
*******************************************************************************/ |
|
|
|
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->heartingPlate_setPower(false); |
|
|
|
m_deviceIoControlService->airBlower_setState(false); |
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 状态周期调度事件 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
else if (event->event == kdisinfection_event_tmr_1s) { |
|
|
|
if (sm.getStateHasPassedTimeMs() > cfg.pre_heat_time_s * 1000) { |
|
|
|
/**
|
|
|
|
* @brief 退出预热状态,进入消毒状态 |
|
|
|
*/ |
|
|
|
sm.changeState(kstate_disinfection); |
|
|
|
} |
|
|
|
tryLogSatate(false); |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 结束消毒 * |
|
|
|
*******************************************************************************/ |
|
|
|
else if (event->event == kdisinfection_event_stop) { |
|
|
|
sm.changeState(kstate_finished); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::processStateDisinfection(disinfection_event_t* event) { |
|
|
|
/**
|
|
|
|
* @brief 状态逻辑 |
|
|
@ -664,36 +653,32 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) |
|
|
|
*******************************************************************************/ |
|
|
|
if (event->event == kdisinfection_event_enter_state) { |
|
|
|
tryLogSatate(true); |
|
|
|
context.is_disinfection_take_break = false; |
|
|
|
|
|
|
|
#if (defined PROJECT_TYPE_LARGE_SPACE_DISINFECTION) || (defined PROJECT_TYPE_SMALL_SPACE_DISINFECTION)
|
|
|
|
m_deviceIoControlService->airBlower_setState(true); |
|
|
|
usleep(1000 * 1000); |
|
|
|
m_deviceIoControlService->airCompressor_setState(true); |
|
|
|
usleep(1000 * 1000); |
|
|
|
m_deviceIoControlService->sprayLiquidPump_open(cfg.injection_pump_speed); |
|
|
|
#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(true); |
|
|
|
usleep(1000 * 1000); |
|
|
|
m_deviceIoControlService->airCompressor_setState(true); |
|
|
|
usleep(1000 * 1000); |
|
|
|
m_deviceIoControlService->sprayLiquidPump_open(cfg.injection_pump_speed); |
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
#if (defined PROJECT_TYPE_DRAW_BAR_BOX)
|
|
|
|
m_deviceIoControlService->DBDB__sprayAirCompressorPowerCtrl(1); |
|
|
|
usleep(1000 * 1000); |
|
|
|
m_deviceIoControlService->DBDB__heaterCtrl(1); |
|
|
|
usleep(100 * 1000); |
|
|
|
m_deviceIoControlService->DBDB__heaterCtrlSafeValve(1); |
|
|
|
usleep(100 * 1000); |
|
|
|
m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(1); |
|
|
|
m_deviceIoControlService->DBDB__miniPwmBlowerCtrl(DBDB_MINI_PWM_BLOWER_VAL); // 风量
|
|
|
|
usleep(100 * 1000); |
|
|
|
m_deviceIoControlService->DBDB__extValveCtrl(IF_DeviceIoContrlService::kExtValveChannel_disinfectionChannel); |
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} |
|
|
@ -760,10 +745,12 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) |
|
|
|
|
|
|
|
if (!context.is_disinfection_take_break) { |
|
|
|
if (isTimeToPauseDisinfection()) { |
|
|
|
logstate(); |
|
|
|
pauseDisinfection(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (isTimeToResumeDisinfection()) { |
|
|
|
logstate(); |
|
|
|
resumeDisinfection(); |
|
|
|
} |
|
|
|
} |
|
|
@ -782,11 +769,17 @@ void DisinfectionService::processStateDisinfection(disinfection_event_t* event) |
|
|
|
updateSprayLiquidPumpSpeed(); |
|
|
|
} |
|
|
|
} |
|
|
|
/*******************************************************************************
|
|
|
|
* 结束消毒 * |
|
|
|
*******************************************************************************/ |
|
|
|
else if (event->event == kdisinfection_event_stop) { |
|
|
|
sm.changeState(kstate_finished); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void DisinfectionService::processStateFinished(disinfection_event_t* event) { |
|
|
|
if (event->event == kdisinfection_event_enter_state) { |
|
|
|
if (event->enterState.last != kstate_idle) { |
|
|
|
if (event->enterState.last != kstate_idle && event->enterState.last != kstate_finished) { |
|
|
|
/**
|
|
|
|
* @brief 消毒结束 |
|
|
|
*/ |
|
|
@ -860,21 +853,3 @@ void DisinfectionService::processStateDegradation(disinfection_event_t* event) { |
|
|
|
} |
|
|
|
void DisinfectionService::processStateDehumidification_before_disinfection(disinfection_event_t* event) {} |
|
|
|
void DisinfectionService::processStateDehumidification_after_disinfection(disinfection_event_t* event) {} |
|
|
|
|
|
|
|
void DisinfectionService::pushDisinfectionPrinterTask() { //
|
|
|
|
shared_ptr<DisinfectionPrinterTask> task = make_shared<DisinfectionPrinterTask>(); |
|
|
|
auto ds = GET_SERVICE(DeviceStateService); |
|
|
|
auto dio = m_deviceIoControlService; |
|
|
|
|
|
|
|
task->start_tp = context.start_tp; |
|
|
|
task->complete_tp = context.complete_tp; |
|
|
|
task->stateSnapshotList = context.stateSnapshotList; |
|
|
|
task->disinfectantUsage = context.beforeDisinfectantVolume_g - context.afterDisinfectantVolume_g; |
|
|
|
task->disinfection_id = context.id; |
|
|
|
task->usr = ds->getLoginUid(); |
|
|
|
|
|
|
|
task->targetLog = cfg.targetLoglevel; |
|
|
|
task->actualLog = context.now_loglevel; |
|
|
|
|
|
|
|
m_disinfectionPrinterService->pushPrintTask(task); |
|
|
|
} |