From 1842b1602ff5f522a6be8087c661b8bcbaae8cb4 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 28 May 2025 10:20:59 +0800 Subject: [PATCH] update --- .../pipette_module/base/constant_cfg.hpp | 2 +- .../base/pipette_pressure_sample_data.hpp | 4 ++-- .../pipette_module/pipette_ctrl_module.cpp | 15 +++++++++++- .../pipette_module/pipette_ctrl_module.hpp | 2 ++ .../pipette_module/pipette_ctrl_module_test.cpp | 13 ++++++++++ .../pipette_module/pipette_ctrl_module_utils.cpp | 28 ++++++++++++++++++---- 6 files changed, 56 insertions(+), 8 deletions(-) diff --git a/sdk/components/pipette_module/base/constant_cfg.hpp b/sdk/components/pipette_module/base/constant_cfg.hpp index d47874d..82e6593 100644 --- a/sdk/components/pipette_module/base/constant_cfg.hpp +++ b/sdk/components/pipette_module/base/constant_cfg.hpp @@ -1,6 +1,6 @@ #pragma once -#define PIPETTEMODULE_SAMPLE_BUF_SIZE 300 +#define PIPETTEMODULE_SAMPLE_BUF_SIZE 600 /*********************************************************************************************************************** * 配置份数 * diff --git a/sdk/components/pipette_module/base/pipette_pressure_sample_data.hpp b/sdk/components/pipette_module/base/pipette_pressure_sample_data.hpp index 61789bc..9482e56 100644 --- a/sdk/components/pipette_module/base/pipette_pressure_sample_data.hpp +++ b/sdk/components/pipette_module/base/pipette_pressure_sample_data.hpp @@ -1,6 +1,6 @@ #pragma once #include typedef struct { - int32_t motor_pos; // 电机位置 - int32_t pressure_val; // 压力值 + int16_t motor_pos; // 电机位置 + int16_t pressure_val; // 压力值 } pipette_pressure_sample_data_t; diff --git a/sdk/components/pipette_module/pipette_ctrl_module.cpp b/sdk/components/pipette_module/pipette_ctrl_module.cpp index 11c930d..52b1947 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module.cpp @@ -311,6 +311,8 @@ int32_t PipetteModule::pipette_pump_deposit_tip() { return 0; } int32_t PipetteModule::pipette_pump_pierce_through(int32_t container_info_index, int32_t container_pos) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); + thread_start_work(__FUNCTION__, [this, container_info_index, container_pos]() { // check param check_container_info_cpyid(container_info_index); @@ -390,6 +392,7 @@ int32_t PipetteModule::pipette_pump_aspirate() { clearPipetteGunState(); zm_move_to_zero_quick_block(); + adjust_container_pos(&acfg->container_pos, m_state.platinfo_cpyid); if (acfg->lld_enable) { _do_lld(acfg->container_pos, platform_info, container_cfg, liquidinfo); // 液面探测 @@ -441,6 +444,13 @@ void PipetteModule::_do_lld(int32_t container_pos, platinfo_t *platform_info, co m_smtp2.pump_get_pressure(&start_pressure); ZLOGI(TAG, "-->start lld , start_pressure is %d", start_pressure); + if (m_common_cfg.pressure_record_enable) { + int32_t nopos = zm_get_now_pos(); + int32_t pressure = 0; + m_smtp2.pump_get_pressure(&pressure); + push_pressure_sample_data(nopos, pressure); + } + #if 1 pump_do_lld(liquidinfo->plld_threshold, 200, liquidinfo->plld_pm_vcpyid); // lld延时200ms,速度为plld_zm_vel osDelay(110); // 等待lld启动 @@ -479,9 +489,11 @@ void PipetteModule::_do_lld(int32_t container_pos, platinfo_t *platform_info, co if (!m_common_cfg.pressure_record_enable) { ZLOGI(TAG, "...wait for lld trigger, now zm pos %d", zm_get_now_pos()); } else { + int32_t nopos = zm_get_now_pos(); int32_t pressure = 0; m_smtp2.pump_get_pressure(&pressure); - ZLOGI(TAG, "...wait for lld trigger, now zm pos %d, pressure %d dpressure %d", zm_get_now_pos(), pressure, pressure - start_pressure); + ZLOGI(TAG, "...wait for lld trigger, now zm pos %d, pressure %d dpressure %d", nopos, pressure, pressure - start_pressure); + push_pressure_sample_data(nopos, pressure); } #else if (m_zm->isStoped()) { @@ -710,6 +722,7 @@ int32_t PipetteModule::pipette_pump_distribu_all() { dump("liquid_info", liquidinfo); dump("liquid_in_gun_info", liquidInGun_info); + adjust_container_pos(&dcfg->container_pos, m_state.platinfo_cpyid); int32_t container_pos = dcfg->container_pos; if (dcfg->distribu_type == 0) { diff --git a/sdk/components/pipette_module/pipette_ctrl_module.hpp b/sdk/components/pipette_module/pipette_ctrl_module.hpp index 243563d..a0fc5d7 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module.hpp +++ b/sdk/components/pipette_module/pipette_ctrl_module.hpp @@ -244,6 +244,8 @@ class PipetteModule : public ZIModule { void push_pressure_sample_data(int32_t motor_pos, int32_t pressure_val); int32_t calibrate_liquid_volume(liquid_info_t *liquidinfo, int32_t volumex100nl); + void adjust_container_pos(int32_t *container_pos, int32_t platinfo_index); + void dump(const char *title, platinfo_t *info); void dump(const char *title, liquid_info_t *info); void dump(const char *title, container_info_t *info); diff --git a/sdk/components/pipette_module/pipette_ctrl_module_test.cpp b/sdk/components/pipette_module/pipette_ctrl_module_test.cpp index 47dfcb6..3e0a65a 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_test.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_test.cpp @@ -30,6 +30,7 @@ int32_t PipetteModule::pipette_test_pump_move_to_x100nl(int32_t x100nl, int32_t return 0; } int32_t PipetteModule::pipette_test_lld(int32_t container_pos, int32_t container_cpyid, int32_t liquid_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid, liquid_cpyid]() { ZLOGI(TAG, "pipette_pump_aspirate"); if (pump_read_tip_state() == 0) { @@ -51,6 +52,7 @@ int32_t PipetteModule::pipette_test_lld(int32_t container_pos, int32_t container } int32_t PipetteModule::pipette_test_move_to_container_bottom(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); @@ -59,6 +61,7 @@ int32_t PipetteModule::pipette_test_move_to_container_bottom(int32_t container_p return 0; } int32_t PipetteModule::pipette_test_move_to_container_bottom_section_begin(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); @@ -67,6 +70,7 @@ int32_t PipetteModule::pipette_test_move_to_container_bottom_section_begin(int32 return 0; } int32_t PipetteModule::pipette_test_move_to_immersion_pos(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); @@ -75,6 +79,7 @@ int32_t PipetteModule::pipette_test_move_to_immersion_pos(int32_t container_pos, return 0; } int32_t PipetteModule::pipette_test_move_to_leaving_height_pos(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); @@ -83,6 +88,8 @@ int32_t PipetteModule::pipette_test_move_to_leaving_height_pos(int32_t container return 0; } int32_t PipetteModule::pipette_test_move_to_jet_pos(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); + thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); @@ -91,6 +98,8 @@ int32_t PipetteModule::pipette_test_move_to_jet_pos(int32_t container_pos, int32 return 0; } int32_t PipetteModule::pipette_test_move_to_lld_start_search_pos(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); + thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); @@ -99,6 +108,8 @@ int32_t PipetteModule::pipette_test_move_to_lld_start_search_pos(int32_t contain return 0; } int32_t PipetteModule::pipette_test_move_to_fix_water_level_pos(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); + thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); @@ -107,6 +118,8 @@ int32_t PipetteModule::pipette_test_move_to_fix_water_level_pos(int32_t containe return 0; } int32_t PipetteModule::pipette_test_move_to_pierce_pos(int32_t container_pos, int32_t container_cpyid) { + adjust_container_pos(&container_pos, m_state.platinfo_cpyid); + thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { container_info_t *container_info = get_container_info_smart(container_cpyid, &m_now_container_info); check_container_info_cpyid(container_cpyid); diff --git a/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp b/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp index e197780..40d142a 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp @@ -97,10 +97,22 @@ void PipetteModule::push_pressure_sample_data(int32_t motor_pos, int32_t pressur return; } - ZLOGI(TAG, "sample %2d mpos:%2d pressure_val:%4d", capturedata_num, motor_pos, pressure_val); - capturedata_buf[capturedata_num].motor_pos = motor_pos; - capturedata_buf[capturedata_num].pressure_val = pressure_val; - capturedata_num++; + // ZLOGI(TAG, "sample %2d mpos:%2d pressure_val:%4d", capturedata_num, motor_pos, pressure_val); + if (capturedata_num == 0) { + capturedata_buf[capturedata_num].motor_pos = motor_pos; + capturedata_buf[capturedata_num].pressure_val = pressure_val; + capturedata_num++; + } else { + if (motor_pos == capturedata_buf[capturedata_num - 1].motor_pos) { + // 如果位置相同,则更新压力值 + capturedata_buf[capturedata_num - 1].pressure_val = pressure_val; + } else { + // 否则,添加新的样本 + capturedata_buf[capturedata_num].motor_pos = motor_pos; + capturedata_buf[capturedata_num].pressure_val = pressure_val; + capturedata_num++; + } + } } void PipetteModule::dump(const char *title, platinfo_t *info) { @@ -191,3 +203,11 @@ int32_t PipetteModule::calibrate_liquid_volume(liquid_info_t *liquidinfo, int32_ liquidinfo->volume_calibration_coefficient_b * 0.001; return x100nl; } + +void PipetteModule::adjust_container_pos(int32_t *container_pos, int32_t platinfo_index) { + int32_t default_work_ref_pos = m_platinfo[0].work_ref_pos; + int32_t work_ref_pos = m_platinfo[platinfo_index].work_ref_pos; + + int32_t diff = work_ref_pos - default_work_ref_pos; + *container_pos += diff; +}