Browse Source

update

master
zhaohe 2 years ago
parent
commit
46b99dd9fd
  1. 81
      components/pipette_module/pipette_ctrl_module.cpp
  2. 3
      components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  3. 2
      components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  4. 2
      components/zprotocols/zcancmder

81
components/pipette_module/pipette_ctrl_module.cpp

@ -11,42 +11,62 @@ void PipetteModule::initialize(SMTP2 *smtp2, //
int32_t PipetteModule::enable(u8 enable) { // int32_t PipetteModule::enable(u8 enable) { //
m_stepMotor->enable(enable); m_stepMotor->enable(enable);
return 0;
} }
int32_t PipetteModule::stop(u8 stop_type) { int32_t PipetteModule::stop(u8 stop_type) {
m_stepMotor->stop(0); m_stepMotor->stop(0);
m_smtp2->stop(); m_smtp2->stop();
return 0;
} }
int32_t PipetteModule::zero_pos_calibrate(function<void(action_cb_status_t status)> exec_complete_cb) { int32_t PipetteModule::zero_pos_calibrate(function<void(action_cb_status_t status)> exec_complete_cb) {
/**
* @brief
*/
m_thread.stop(); m_thread.stop();
m_thread.start([this, exec_complete_cb]() { 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) { int32_t PipetteModule::reset_device(function<void(action_cb_status_t status)> exec_complete_cb) {
/**
* @brief
*/
m_thread.stop(); m_thread.stop();
m_thread.start([this, exec_complete_cb]() { m_thread.start([this, exec_complete_cb]() {
action_cb_status_t report_status = {0}; action_cb_status_t report_status = {0};
/*******************************************************************************
* m_smtp2 *
*******************************************************************************/
// 移液枪复位 // 移液枪复位
int ret = m_smtp2->init_device(); int ret = m_smtp2->init_device();
if (ret != 0) { if (ret != 0) {
ZLOGE(TAG, "init_device fail"); ZLOGE(TAG, "init_device fail");
report_status.exec_status = ret; report_status.exec_status = ret;
if (exec_complete_cb) exec_complete_cb(report_status); 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(); int32_t state = m_smtp2->getState();
if (state == 0) { if (state == 0) {
break; break;
@ -54,9 +74,42 @@ int32_t PipetteModule::reset_device(function<void(action_cb_status_t status)> ex
m_thread.sleep(1000); m_thread.sleep(1000);
ZLOGI(TAG, "Waiting for SMTP2 to complete the reset"); ZLOGI(TAG, "Waiting for SMTP2 to complete the reset");
} }
m_smtp2->stop();
ZLOGI(TAG, "SMTP2 reset complete"); 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;
} }

3
components/step_motor_ctrl_module/step_motor_ctrl_module.cpp

@ -26,6 +26,9 @@ void StepMotorCtrlModule::initialize(int id, IStepperMotor* stepM, ZGPIO* zero_g
set_run_to_zero_param(run_to_zero_param); set_run_to_zero_param(run_to_zero_param);
set_warning_limit_param(warning_limit_param); set_warning_limit_param(warning_limit_param);
} }
bool StepMotorCtrlModule::isbusy() { return m_thread.isworking(); }
int32_t StepMotorCtrlModule::move_to(int32_t tox, function<void(move_to_cb_status_t& status)> status_cb) { // int32_t StepMotorCtrlModule::move_to(int32_t tox, function<void(move_to_cb_status_t& status)> status_cb) { //
zlock_guard lock(m_lock); zlock_guard lock(m_lock);

2
components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

@ -47,6 +47,8 @@ class StepMotorCtrlModule : public I_StepMotorCtrlModule {
public: public:
void initialize(int id, IStepperMotor* stepM, ZGPIO* zero_gpio, ZGPIO* end_gpio); void initialize(int id, IStepperMotor* stepM, ZGPIO* zero_gpio, ZGPIO* end_gpio);
virtual bool isbusy() override;
virtual int32_t move_to(int32_t x, function<void(move_to_cb_status_t& status)> status_cb) override; virtual int32_t move_to(int32_t x, function<void(move_to_cb_status_t& status)> status_cb) override;
virtual int32_t move_by(int32_t dx, function<void(move_by_cb_status_t& status)> status_cb) override; virtual int32_t move_by(int32_t dx, function<void(move_by_cb_status_t& status)> status_cb) override;
virtual int32_t move_to_zero(function<void(move_to_zero_cb_status_t& status)> status_cb) override; virtual int32_t move_to_zero(function<void(move_to_zero_cb_status_t& status)> status_cb) override;

2
components/zprotocols/zcancmder

@ -1 +1 @@
Subproject commit 40bae4b887cc873eea0d37ba581669363fdc6f27
Subproject commit ce0623df5d4dd3ab8ffe1e068fa7af86e8d8c44a
Loading…
Cancel
Save