|
|
@ -60,6 +60,10 @@ void PipetteModuleV2::initialize(int32_t id, config_t *config, hardward_config_t |
|
|
|
m_zm = hardwaredcfg->zmotor; |
|
|
|
m_zm0p = hardwaredcfg->zmotor_0point; |
|
|
|
|
|
|
|
// m_smtp2.pump_init(m_cfg.pump_vmax);
|
|
|
|
// osDelay(3000);
|
|
|
|
// m_smtp2.write_cmd("/1?23R\r");
|
|
|
|
|
|
|
|
m_zm->getGState(); // 读取状态,清空下复位标识
|
|
|
|
module_active_cfg(); |
|
|
|
} |
|
|
@ -75,7 +79,7 @@ void PipetteModuleV2::create_default_cfg(config_t *defaultcfg) { |
|
|
|
defaultcfg->aspirate_zmotor_max_move_by = 400; // 50mm,tip头的长度
|
|
|
|
defaultcfg->lld_pump_vel = 100; // lld推荐使用速度为50->200,这里
|
|
|
|
defaultcfg->lld_motor_vel_rpm = 200; |
|
|
|
defaultcfg->lld_detect_period_ms = 10; // 100ms
|
|
|
|
defaultcfg->lld_detect_period_ms = 5; // 100ms
|
|
|
|
defaultcfg->lld_prepare_pos = PIPETTE_PREPARE_POS; |
|
|
|
defaultcfg->lld_prepare_pre_distribut_ul = LLD_PREPARE_DISTRIBUT_POS; |
|
|
|
|
|
|
@ -324,9 +328,15 @@ int32_t PipetteModuleV2::pipette_put_tip() { |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModuleV2::pipette_lld_prepare() { |
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
|
|
|
|
THREAD_START_WORK([this]() { |
|
|
|
ZLOGI(TAG, "zmotor move to zero"); |
|
|
|
zm_move_to(0, m_cfg.zm_default_velocity); |
|
|
|
zm_waitfor_stop(); |
|
|
|
ZLOGI(TAG, "pump move to 0 pos"); |
|
|
|
DO_IN_THREAD(m_smtp2.pump_move_to_ul(m_cfg.pump_vmax, 0)); // 移动到零点
|
|
|
|
pump_waitfor_stop(); |
|
|
|
|
|
|
|
ZLOGI(TAG, "pump move to lld_prepare_pos %d", m_cfg.lld_prepare_pos); |
|
|
|
DO_IN_THREAD(m_smtp2.pump_move_to_ul(m_cfg.pump_vmax, m_cfg.lld_prepare_pos)); // 移动到中点
|
|
|
|
pump_waitfor_stop(); |
|
|
|
m_state.lld_prepared = 1; |
|
|
@ -335,17 +345,11 @@ int32_t PipetteModuleV2::pipette_lld_prepare() { |
|
|
|
} |
|
|
|
int32_t PipetteModuleV2::pipette_lld(int32_t lldtype, int32_t zdpos, int32_t c_threshold, int32_t p_threshold) { |
|
|
|
// 检查泵机是否初始化过
|
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
|
|
|
|
if (lldtype < 0 || lldtype > klldtypemax) { |
|
|
|
return err::kparam_out_of_range; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查tip头状态
|
|
|
|
int32_t tipstate = 0; |
|
|
|
DO(m_smtp2.pump_get_tip_state(&tipstate)); |
|
|
|
if (tipstate != 0) return err::kpipette_error_tipisload_when_lld_prepare; |
|
|
|
|
|
|
|
THREAD_START_WORK([this, lldtype, zdpos, c_threshold, p_threshold]() { //
|
|
|
|
m_state.lld_prepared = 0; // 失效m_state.lld_prepared
|
|
|
|
|
|
|
@ -435,9 +439,12 @@ int32_t PipetteModuleV2::pipette_lld(int32_t lldtype, int32_t zdpos, int32_t c_t |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModuleV2::pipette_aspirate_prepare() { |
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
int32_t PipetteModuleV2::pipette_lld_is_detect_liquid(int32_t *detect) { |
|
|
|
*detect = m_state.detected_liquid; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModuleV2::pipette_aspirate_prepare() { |
|
|
|
THREAD_START_WORK([this]() { //
|
|
|
|
ZLOGI(TAG, "pipette_aspirate_prepare"); |
|
|
|
m_state.aspirate_cfg_eigen_time = 0; |
|
|
@ -473,8 +480,6 @@ int32_t PipetteModuleV2::pipette_aspirate_set_operation_verifi_tolerance(int32_t |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModuleV2::pipette_aspirate(int32_t ul) { |
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
|
|
|
|
THREAD_START_WORK([this, ul]() { |
|
|
|
m_state.lld_prepared = 0; |
|
|
|
|
|
|
@ -501,8 +506,6 @@ int32_t PipetteModuleV2::pipette_aspirate(int32_t ul) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t PipetteModuleV2::pipette_aspirate_and_verify(int32_t ul) { |
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
|
|
|
|
THREAD_START_WORK([this, ul]() { |
|
|
|
m_state.lld_prepared = 0; |
|
|
|
|
|
|
@ -525,8 +528,6 @@ int32_t PipetteModuleV2::pipette_aspirate_and_verify(int32_t ul) { |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModuleV2::pipette_shake_up(int32_t ul, int32_t times) { |
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
|
|
|
|
THREAD_START_WORK([this, ul, times]() { |
|
|
|
//
|
|
|
|
int32_t dpos = 0; |
|
|
@ -566,8 +567,6 @@ int32_t PipetteModuleV2::pipette_shake_up(int32_t ul, int32_t times) { |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModuleV2::pipette_aspirate_infer_pressure(int32_t ul) { |
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
|
|
|
|
THREAD_START_WORK([this, ul]() { |
|
|
|
//
|
|
|
|
ZLOGI(TAG, "pipette_aspirate_infer_pressure %d", ul); |
|
|
@ -584,8 +583,6 @@ int32_t PipetteModuleV2::pipette_get_aspirate_infer_pressure_result(int32_t *res |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t PipetteModuleV2::pipette_aspirate_infer_eigen_time(int32_t ul) { |
|
|
|
if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; |
|
|
|
|
|
|
|
//
|
|
|
|
THREAD_START_WORK([this, ul]() { |
|
|
|
//
|
|
|
@ -820,39 +817,38 @@ int32_t PipetteModuleV2::bfcall(int32_t cmdid, uint8_t *param, int32_t len) { |
|
|
|
MODULE_BFCALL_DUMP_FN_CALL(cmdid, param32, paramNum); |
|
|
|
} |
|
|
|
|
|
|
|
if (cmdid == kpipette_zmotor_move_zero) goto check; |
|
|
|
if (cmdid == kpipette_zmotor_move_to_zero_point_quick) { |
|
|
|
if (m_state.has_move_to_zero == 0) return err::kstep_motor_not_move_to_zero; |
|
|
|
goto check; |
|
|
|
} |
|
|
|
if (cmdid == kpipette_zmotor_measure_distance) goto check; |
|
|
|
if (cmdid == kpipette_zmotor_read_measure_distance_result) goto check; |
|
|
|
if (cmdid == kpipette_zmotor_move_by) goto check; |
|
|
|
if (cmdid == kpipette_zmotor_move_to) { |
|
|
|
if (m_state.has_move_to_zero == 0) return err::kstep_motor_not_move_to_zero; |
|
|
|
goto check; |
|
|
|
} |
|
|
|
if (cmdid == kpipette_zmotor_move_zero) goto motor_check_bf_run; |
|
|
|
if (cmdid == kpipette_zmotor_move_to_zero_point_quick) goto motor_move_to_check; |
|
|
|
if (cmdid == kpipette_zmotor_measure_distance) goto motor_move_to_check; |
|
|
|
if (cmdid == kpipette_zmotor_move_by) goto motor_check_bf_run; |
|
|
|
if (cmdid == kpipette_zmotor_move_to) goto motor_move_to_check; |
|
|
|
|
|
|
|
if (cmdid == kpipette_init_device) goto check; |
|
|
|
if (cmdid == kpipette_put_tip) goto check; |
|
|
|
if (cmdid == kpipette_lld_prepare) goto check; |
|
|
|
if (cmdid == kpipette_lld) goto check; |
|
|
|
if (cmdid == kpipette_lld) goto motor_check_bf_run; |
|
|
|
if (cmdid == kpipette_aspirate_prepare) goto check; |
|
|
|
if (cmdid == kpipette_aspirate_set_llf_velocity) goto check; |
|
|
|
if (cmdid == kpipette_aspirate_set_operation_verifi_p_thre) goto check; |
|
|
|
if (cmdid == kpipette_aspirate_set_operation_verifi_eigen_time) goto check; |
|
|
|
if (cmdid == kpipette_aspirate_set_operation_verifi_tolerance) goto check; |
|
|
|
if (cmdid == kpipette_aspirate) goto check; |
|
|
|
if (cmdid == kpipette_aspirate_and_verify) goto check; |
|
|
|
if (cmdid == kpipette_shake_up) goto check; |
|
|
|
if (cmdid == kpipette_aspirate) goto motor_check_bf_run; |
|
|
|
if (cmdid == kpipette_aspirate_and_verify) goto motor_check_bf_run; |
|
|
|
if (cmdid == kpipette_shake_up) goto motor_check_bf_run; |
|
|
|
if (cmdid == kpipette_aspirate_infer_pressure) goto check; |
|
|
|
if (cmdid == kpipette_aspirate_infer_eigen_time) goto check; |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
motor_move_to_check: |
|
|
|
if (m_state.has_move_to_zero == 0) return err::kstep_motor_not_move_to_zero; |
|
|
|
goto motor_check_bf_run; |
|
|
|
|
|
|
|
motor_check_bf_run: |
|
|
|
if (m_state.enable == 0) return err::kstep_motor_not_enable; |
|
|
|
goto check; |
|
|
|
|
|
|
|
check: |
|
|
|
if (!m_state.enable) { |
|
|
|
return err::kstep_motor_not_enable; |
|
|
|
} |
|
|
|
if (creg.module_errorcode == err::kstep_motor_subic_reset) { |
|
|
|
return creg.module_errorcode; |
|
|
|
} else if (creg.module_errorcode == err::kstep_motor_drv_err) { |
|
|
@ -899,17 +895,17 @@ void PipetteModuleV2::runingcheck() { |
|
|
|
|
|
|
|
// 检查电机状态
|
|
|
|
{ |
|
|
|
// auto state = m_zm->getGState();
|
|
|
|
// if (state.reset) {
|
|
|
|
// ZLOGE(TAG, "motor reset when run");
|
|
|
|
// throw zapp_exception(err::kstep_motor_subic_reset);
|
|
|
|
// } else if (state.uv_cp) {
|
|
|
|
// ZLOGE(TAG, "motor uv_cp when run");
|
|
|
|
// throw zapp_exception(err::kstep_motor_uv_cp);
|
|
|
|
// } else if (state.drv_err) {
|
|
|
|
// ZLOGE(TAG, "motor drv_err when run");
|
|
|
|
// throw zapp_exception(err::kstep_motor_drv_err);
|
|
|
|
// }
|
|
|
|
auto state = m_zm->getGState(); |
|
|
|
if (state.reset) { |
|
|
|
ZLOGE(TAG, "motor reset when run"); |
|
|
|
throw zapp_exception(err::kstep_motor_subic_reset); |
|
|
|
} else if (state.uv_cp) { |
|
|
|
ZLOGE(TAG, "motor uv_cp when run"); |
|
|
|
throw zapp_exception(err::kstep_motor_uv_cp); |
|
|
|
} else if (state.drv_err) { |
|
|
|
ZLOGE(TAG, "motor drv_err when run"); |
|
|
|
throw zapp_exception(err::kstep_motor_drv_err); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -925,6 +921,10 @@ void PipetteModuleV2::thread_start_work(const char *fnname, function<void()> fn) |
|
|
|
creg.module_status = 1; |
|
|
|
creg.module_errorcode = 0; |
|
|
|
|
|
|
|
m_state.detected_liquid = 0; |
|
|
|
m_asynchronous_result.result0 = 0; |
|
|
|
m_asynchronous_result.result1 = 0; |
|
|
|
|
|
|
|
m_thread.start([this, fnname, fn]() { |
|
|
|
osDelay(1); |
|
|
|
ZLOGI(TAG, "start work -> %s", fnname); |
|
|
@ -958,7 +958,6 @@ void PipetteModuleV2::thread_start_work(const char *fnname, function<void()> fn) |
|
|
|
m_smtp2.pump_stop(); |
|
|
|
creg.module_errorcode = e.ecode(); |
|
|
|
} |
|
|
|
|
|
|
|
creg.module_status = 0; |
|
|
|
ZLOGI(TAG, "<- end work"); |
|
|
|
}); |
|
|
|