|
|
@ -11,42 +11,62 @@ void PipetteModule::initialize(SMTP2 *smtp2, // |
|
|
|
|
|
|
|
int32_t PipetteModule::enable(u8 enable) { //
|
|
|
|
m_stepMotor->enable(enable); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t PipetteModule::stop(u8 stop_type) { |
|
|
|
m_stepMotor->stop(0); |
|
|
|
m_smtp2->stop(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModule::zero_pos_calibrate(function<void(action_cb_status_t status)> exec_complete_cb) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
*/ |
|
|
|
|
|
|
|
m_thread.stop(); |
|
|
|
m_thread.start([this, exec_complete_cb]() { |
|
|
|
// 移液枪复位
|
|
|
|
// 移液枪复位完成后,开始进行零点校准
|
|
|
|
// m_stepMotor->move_to_zero_with_calibrate();
|
|
|
|
action_cb_status_t action_status = {0}; |
|
|
|
|
|
|
|
int32_t exec_ret = m_stepMotor->move_to_zero_with_calibrate(0, [&](I_StepMotorCtrlModule::move_to_zero_with_calibrate_cb_status_t &status) { |
|
|
|
action_status.exec_status = status.exec_status; |
|
|
|
if (exec_complete_cb) exec_complete_cb(action_status); |
|
|
|
}); |
|
|
|
|
|
|
|
if (exec_ret != 0) { |
|
|
|
ZLOGE(TAG, "move_to_zero_with_calibrate fail, exec_ret = %d", exec_ret); |
|
|
|
m_stepMotor->stop(0); |
|
|
|
action_status.exec_status = exec_ret; |
|
|
|
if (exec_complete_cb) exec_complete_cb(action_status); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
ZLOGI(TAG, "Waiting for SMTP2 to complete the reset"); |
|
|
|
if (!m_stepMotor->isbusy()) break; |
|
|
|
m_thread.sleep(1000); |
|
|
|
} |
|
|
|
|
|
|
|
ZLOGI(TAG, "zero_pos_calibrate complete"); |
|
|
|
m_stepMotor->stop(0); |
|
|
|
}); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t PipetteModule::reset_device(function<void(action_cb_status_t status)> exec_complete_cb) { |
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
*/ |
|
|
|
|
|
|
|
m_thread.stop(); |
|
|
|
m_thread.start([this, exec_complete_cb]() { |
|
|
|
action_cb_status_t report_status = {0}; |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* m_smtp2 * |
|
|
|
*******************************************************************************/ |
|
|
|
// 移液枪复位
|
|
|
|
int ret = m_smtp2->init_device(); |
|
|
|
if (ret != 0) { |
|
|
|
ZLOGE(TAG, "init_device fail"); |
|
|
|
report_status.exec_status = ret; |
|
|
|
if (exec_complete_cb) exec_complete_cb(report_status); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 等待移液枪复位完成
|
|
|
|
while (true && !m_thread.getExitFlag()) { |
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
int32_t state = m_smtp2->getState(); |
|
|
|
if (state == 0) { |
|
|
|
break; |
|
|
@ -54,9 +74,42 @@ int32_t PipetteModule::reset_device(function<void(action_cb_status_t status)> ex |
|
|
|
m_thread.sleep(1000); |
|
|
|
ZLOGI(TAG, "Waiting for SMTP2 to complete the reset"); |
|
|
|
} |
|
|
|
|
|
|
|
m_smtp2->stop(); |
|
|
|
|
|
|
|
ZLOGI(TAG, "SMTP2 reset complete"); |
|
|
|
if (m_thread.getExitFlag()) { |
|
|
|
ZLOGW(TAG, "break reset_device"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* m_stepMotor * |
|
|
|
*******************************************************************************/ |
|
|
|
ret = m_stepMotor->move_to_zero_with_calibrate(0, [&](I_StepMotorCtrlModule::move_to_zero_with_calibrate_cb_status_t &status) { //
|
|
|
|
ret = status.exec_status; |
|
|
|
}); |
|
|
|
|
|
|
|
while (!m_thread.getExitFlag()) { |
|
|
|
if (!m_stepMotor->isbusy()) break; |
|
|
|
m_thread.sleep(1000); |
|
|
|
ZLOGI(TAG, "Waiting for Z axis to complete the reset"); |
|
|
|
} |
|
|
|
m_stepMotor->stop(0); |
|
|
|
if (m_thread.getExitFlag()) { |
|
|
|
ZLOGW(TAG, "break reset_device"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (ret != 0) { |
|
|
|
ZLOGE(TAG, "move_to_zero_with_calibrate fail, ret = %d", ret); |
|
|
|
report_status.exec_status = ret; |
|
|
|
if (exec_complete_cb) exec_complete_cb(report_status); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 移液枪复位完成后,开始进行零点校准
|
|
|
|
ZLOGI(TAG, "Z axis reset complete"); |
|
|
|
report_status.exec_status = 0; |
|
|
|
if (exec_complete_cb) exec_complete_cb(report_status); |
|
|
|
}); |
|
|
|
return 0; |
|
|
|
} |