|
|
@ -1,6 +1,7 @@ |
|
|
|
#include "pump_ctrl_service.hpp"
|
|
|
|
|
|
|
|
#include "remote_controler.hpp"
|
|
|
|
#include "valve_state_ctrl_service.hpp"
|
|
|
|
|
|
|
|
using namespace iflytop; |
|
|
|
#define TAG "PumpCtrlService"
|
|
|
@ -79,66 +80,75 @@ void PumpCtrlService::reflux() { |
|
|
|
ZLOGI(TAG, "reflux"); |
|
|
|
if (m_pumpCfgUpdateFlag) updateMotorSetting(); |
|
|
|
|
|
|
|
m_thread.start([this]() { |
|
|
|
int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML); |
|
|
|
int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel)); |
|
|
|
|
|
|
|
for (size_t i = 0; i < PUMP_NUM; i++) { |
|
|
|
TMC51X0* cur_motor = m_motors[i]; |
|
|
|
cur_motor->stop(); |
|
|
|
cur_motor->setXACTUAL(0); |
|
|
|
ZLOGI(TAG, "pump %d move %f ml", i, -pipeLenML); |
|
|
|
cur_motor->moveBy((int32_t)-pipeLenML * 1000, vel); |
|
|
|
} |
|
|
|
m_thread.start( |
|
|
|
[this]() { |
|
|
|
ValveStateSyncService::ins()->setValveState(1); |
|
|
|
int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML); |
|
|
|
int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel)); |
|
|
|
|
|
|
|
for (size_t i = 0; i < PUMP_NUM; i++) { |
|
|
|
TMC51X0* cur_motor = m_motors[i]; |
|
|
|
cur_motor->stop(); |
|
|
|
cur_motor->setXACTUAL(0); |
|
|
|
ZLOGI(TAG, "pump %d move %f ml", i, -pipeLenML); |
|
|
|
cur_motor->moveBy((int32_t)-pipeLenML * 1000, vel); |
|
|
|
} |
|
|
|
|
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
if (isAllReachTarget()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
osDelay(10); |
|
|
|
} |
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
if (isAllReachTarget()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
osDelay(10); |
|
|
|
} |
|
|
|
|
|
|
|
stopAll(); |
|
|
|
ZLOGI(TAG, "reflux end"); |
|
|
|
}); |
|
|
|
stopAll(); |
|
|
|
ZLOGI(TAG, "reflux end"); |
|
|
|
}, |
|
|
|
[]() { |
|
|
|
ValveStateSyncService::ins()->setValveState(0); |
|
|
|
}); |
|
|
|
} |
|
|
|
void PumpCtrlService::acidPrefilling() { |
|
|
|
ZLOGI(TAG, "acidPrefilling"); |
|
|
|
if (m_pumpCfgUpdateFlag) updateMotorSetting(); |
|
|
|
|
|
|
|
m_thread.start([this]() { |
|
|
|
int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML); |
|
|
|
int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel)); |
|
|
|
|
|
|
|
for (size_t i = 0; i < PUMP_NUM; i++) { |
|
|
|
TMC51X0* cur_motor = m_motors[i]; |
|
|
|
cur_motor->stop(); |
|
|
|
cur_motor->setXACTUAL(0); |
|
|
|
ZLOGI(TAG, "pump %d move %f ml", i, pipeLenML); |
|
|
|
cur_motor->moveBy((int32_t)pipeLenML * 1000, vel); |
|
|
|
} |
|
|
|
m_thread.start( |
|
|
|
[this]() { |
|
|
|
ValveStateSyncService::ins()->setValveState(1); |
|
|
|
|
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
if (isAllReachTarget()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
osDelay(10); |
|
|
|
} |
|
|
|
int32_t pipeLenML = getCfgInt(kcfg_pipeLengthML); |
|
|
|
int32_t vel = getCfgInt(config_index_t(kcfg_pumpDefVel)); |
|
|
|
|
|
|
|
// ¶Ì»ØÁ÷
|
|
|
|
for (size_t i = 0; i < PUMP_NUM; i++) { |
|
|
|
int32_t vel = getCfgInt(kcfg_pumpDefVel); |
|
|
|
TMC51X0* cur_motor = m_motors[i]; |
|
|
|
cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, vel); |
|
|
|
} |
|
|
|
for (size_t i = 0; i < PUMP_NUM; i++) { |
|
|
|
TMC51X0* cur_motor = m_motors[i]; |
|
|
|
cur_motor->stop(); |
|
|
|
cur_motor->setXACTUAL(0); |
|
|
|
ZLOGI(TAG, "pump %d move %f ml", i, pipeLenML); |
|
|
|
cur_motor->moveBy((int32_t)pipeLenML * 1000, vel); |
|
|
|
} |
|
|
|
|
|
|
|
while (!isAllReachTarget()) { |
|
|
|
osDelay(10); |
|
|
|
} |
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
if (isAllReachTarget()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
osDelay(10); |
|
|
|
} |
|
|
|
|
|
|
|
stopAll(); |
|
|
|
ZLOGI(TAG, "acidPrefilling end"); |
|
|
|
}); |
|
|
|
// ¶Ì»ØÁ÷
|
|
|
|
for (size_t i = 0; i < PUMP_NUM; i++) { |
|
|
|
int32_t vel = getCfgInt(kcfg_pumpDefVel); |
|
|
|
TMC51X0* cur_motor = m_motors[i]; |
|
|
|
cur_motor->moveBy(-(int32_t)(APPEND_ML) * 1000, vel); |
|
|
|
} |
|
|
|
|
|
|
|
while (!isAllReachTarget()) { |
|
|
|
osDelay(10); |
|
|
|
} |
|
|
|
|
|
|
|
stopAll(); |
|
|
|
ZLOGI(TAG, "acidPrefilling end"); |
|
|
|
}, |
|
|
|
[]() { ValveStateSyncService::ins()->setValveState(0); }); |
|
|
|
} |
|
|
|
|
|
|
|
void PumpCtrlService::autoMoveMutiTimes() { |
|
|
@ -180,6 +190,7 @@ bool PumpCtrlService::isWorking() { return m_thread.isworking(); } |
|
|
|
void PumpCtrlService::doMoveOnce() { |
|
|
|
//
|
|
|
|
ZLOGI(TAG, "do moveOnce ..."); |
|
|
|
ValveStateSyncService::ins()->setValveState(1); |
|
|
|
|
|
|
|
for (size_t i = 0; i < PUMP_NUM; i++) { |
|
|
|
bool pumpselect = GSM->getPumpSelectState(i); |
|
|
@ -218,6 +229,7 @@ void PumpCtrlService::doMoveOnce() { |
|
|
|
|
|
|
|
ZLOGI(TAG, "do moveOnce finish"); |
|
|
|
stopAll(); |
|
|
|
ValveStateSyncService::ins()->setValveState(0); |
|
|
|
} |
|
|
|
|
|
|
|
bool PumpCtrlService::isAllReachTarget() { |
|
|
|