|
|
@ -2,6 +2,9 @@ |
|
|
|
|
|
|
|
#include "pipeline_pressure_control.hpp"
|
|
|
|
using namespace iflytop; |
|
|
|
|
|
|
|
#define DEFAULT_INFLATION_TIME_MS 300
|
|
|
|
|
|
|
|
void AirLeakDetectTest::initialize() { |
|
|
|
logger->info("AirLeakDetectTest initialize"); |
|
|
|
|
|
|
@ -10,13 +13,13 @@ void AirLeakDetectTest::initialize() { |
|
|
|
GET_TO_SERVICE(m_gConfig) |
|
|
|
GET_TO_SERVICE(m_dics) |
|
|
|
|
|
|
|
REG_EXTFN_VOID(start, void()); |
|
|
|
REG_EXTFN(start, void(int), inflationTimeMs); |
|
|
|
REG_EXTFN_VOID(stop, void()); |
|
|
|
REG_EXTFN_VOID(getState, void()); |
|
|
|
REG_EXTFN_VOID(getServiceConfig, void()); |
|
|
|
} |
|
|
|
|
|
|
|
void AirLeakDetectTest::start() { |
|
|
|
void AirLeakDetectTest::start(int inflationTimeMs) { |
|
|
|
logger->info("AirLeakDetectTest start"); |
|
|
|
auto nowstate = m_ds->getDeviceState(); |
|
|
|
if (nowstate != DeviceState::Idle) { |
|
|
@ -26,16 +29,16 @@ void AirLeakDetectTest::start() { |
|
|
|
|
|
|
|
m_workstate = kinitDevice; |
|
|
|
DS->setDeviceState(DeviceState::AirLeakDetectTesting); |
|
|
|
m_thread.reset(new Thread("AirLeakDetectTestThread", [this]() { |
|
|
|
m_thread.reset(new Thread("AirLeakDetectTestThread", [this, inflationTimeMs]() { |
|
|
|
try { |
|
|
|
airLeakDetectTestThread(); |
|
|
|
airLeakDetectTestThread(inflationTimeMs); |
|
|
|
} catch (const appexception& e) { |
|
|
|
AppEventBus::ins()->push(make_shared<AppWarningPromoptEvent>(e)); |
|
|
|
} |
|
|
|
GET_SERVICE(PipelinePressureControl)->syncPressureValueState(); |
|
|
|
|
|
|
|
try { |
|
|
|
// if (PORT.isPipeDM()) m_dics->AirLeakDetectTestModeCtrl_setMode(0);
|
|
|
|
if (PORT.isPipeDM()) m_dics->AirLeakDetectTestModeCtrl_setMode(AirLeakTestMode::disinfection); |
|
|
|
} catch (...) { |
|
|
|
} |
|
|
|
|
|
|
@ -52,12 +55,13 @@ void AirLeakDetectTest::stop() { |
|
|
|
} |
|
|
|
AirLeakDetectTest::state_t AirLeakDetectTest::getWorkstate() { return m_workstate; } |
|
|
|
|
|
|
|
void AirLeakDetectTest::airLeakDetectTestThread() { |
|
|
|
void AirLeakDetectTest::airLeakDetectTestThread(int inflationTimeMs) { |
|
|
|
if (PORT.isPipeDM()) { |
|
|
|
m_workstate = kinitDevice; |
|
|
|
// 初始化设备,关闭比例法
|
|
|
|
m_dics->PosiPressureProp_setValve(0); |
|
|
|
m_dics->NegaPressureProp_setValve(0); |
|
|
|
m_dics->AirLeakDetectTestModeCtrl_setMode(AirLeakTestMode::inflation); |
|
|
|
|
|
|
|
// 等待比例法关闭
|
|
|
|
while (!ThisThread().getExitFlag()) { |
|
|
@ -73,10 +77,11 @@ void AirLeakDetectTest::airLeakDetectTestThread() { |
|
|
|
// 开始充气
|
|
|
|
logger->info("inflate....."); |
|
|
|
m_workstate = kinflating; |
|
|
|
m_dics->AC_ctrl(1); |
|
|
|
ThisThread().sleepForMs(100); // 充气时间
|
|
|
|
m_dics->AC_ctrl(0); |
|
|
|
// m_dics->AirLeakDetectTestModeCtrl_setMode(1);
|
|
|
|
m_dics->AC_ctrlNoDelay(1); |
|
|
|
if (inflationTimeMs == 0) inflationTimeMs = DEFAULT_INFLATION_TIME_MS; |
|
|
|
ThisThread().sleepForMs(inflationTimeMs); // 充气时间
|
|
|
|
m_dics->AC_close(); |
|
|
|
m_dics->AirLeakDetectTestModeCtrl_setMode(AirLeakTestMode::leakTest); |
|
|
|
|
|
|
|
if (ThisThread().getExitFlag()) return; |
|
|
|
// 等待充气完成
|
|
|
@ -92,8 +97,8 @@ void AirLeakDetectTest::airLeakDetectTestThread() { |
|
|
|
* EXT * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
void AirLeakDetectTest::start(shared_ptr<MsgProcessContext> cxt) { //
|
|
|
|
start(); |
|
|
|
void AirLeakDetectTest::start(shared_ptr<MsgProcessContext> cxt, int inflationTimeMs) { //
|
|
|
|
start(inflationTimeMs); |
|
|
|
} |
|
|
|
void AirLeakDetectTest::stop(shared_ptr<MsgProcessContext> cxt) { stop(); } |
|
|
|
void AirLeakDetectTest::getState(shared_ptr<MsgProcessContext> cxt) { //
|
|
|
@ -107,10 +112,11 @@ void AirLeakDetectTest::getState(shared_ptr<MsgProcessContext> cxt) { // |
|
|
|
void AirLeakDetectTest::getServiceConfig(shared_ptr<MsgProcessContext> cxt) { |
|
|
|
if (PORT.isPipeDM()) { |
|
|
|
json cfg; |
|
|
|
cfg["pressureUint"] = "kPa"; |
|
|
|
cfg["pressureMax"] = 8.0; |
|
|
|
cfg["show"] = true; |
|
|
|
cfg["updatePeriod"] = 300; |
|
|
|
cxt->rely = cfg; |
|
|
|
cfg["pressureUint"] = "kPa"; |
|
|
|
cfg["pressureMax"] = 8.0; |
|
|
|
cfg["show"] = true; |
|
|
|
cfg["updatePeriod"] = 300; |
|
|
|
cfg["inflationTimeMs"] = DEFAULT_INFLATION_TIME_MS; |
|
|
|
cxt->rely = cfg; |
|
|
|
} |
|
|
|
} |