diff --git a/sdk/components/pipette_module/base/constant_cfg.hpp b/sdk/components/pipette_module/base/constant_cfg.hpp index 82e6593..dd38566 100644 --- a/sdk/components/pipette_module/base/constant_cfg.hpp +++ b/sdk/components/pipette_module/base/constant_cfg.hpp @@ -1,6 +1,7 @@ #pragma once -#define PIPETTEMODULE_SAMPLE_BUF_SIZE 600 +#define PIPETTEMODULE_LLD_PRESSURE_SAMPLE_BUF_SIZE 600 +#define PIPETTEMODULE_ASP_PRESSURE_SAMPLE_BUF_SIZE 800 /*********************************************************************************************************************** * 配置份数 * diff --git a/sdk/components/pipette_module/base/pipette_cfg.hpp b/sdk/components/pipette_module/base/pipette_cfg.hpp index 913089a..afbc2eb 100644 --- a/sdk/components/pipette_module/base/pipette_cfg.hpp +++ b/sdk/components/pipette_module/base/pipette_cfg.hpp @@ -16,15 +16,17 @@ typedef struct { int32_t pressure_record_enable; - int32_t platform_info_cpyid; // 平台信息的副本ID - int32_t each_action_delay_time; // 每个动作之间的延时,单位ms (动作调试使用) + int32_t platform_info_cpyid; // 平台信息的副本ID + int32_t each_action_delay_time; // 每个动作之间的延时,单位ms (动作调试使用) + int32_t aspirate_pressure_report_extend_time; // 吸取时,额外压力上报时长 int32_t max; } common_cfg_t; typedef enum { kpipette_common_cfg_pressure_record_enable, - kpipette_common_cfg_platform_info_cpyid, // 平台信息的副本ID - kpipette_common_cfg_each_action_delay_time, // 每个动作之间的延时,单位ms (动作调试使用) + kpipette_common_cfg_platform_info_cpyid, // 平台信息的副本ID + kpipette_common_cfg_each_action_delay_time, // 每个动作之间的延时,单位ms (动作调试使用) + kpipette_common_cfg_aspirate_pressure_report_extend_time, // 吸取时,额外压力上报时长 kpipette_common_cfg_max, } pipette_common_cfg_index_t; @@ -33,6 +35,7 @@ static inline const char *common_cfg_index_to_string(pipette_common_cfg_index_t CASE_ENUM_TO_STRING(kpipette_common_cfg_pressure_record_enable) CASE_ENUM_TO_STRING(kpipette_common_cfg_platform_info_cpyid) // 平台信息的副本ID CASE_ENUM_TO_STRING(kpipette_common_cfg_each_action_delay_time) // 每个动作之间的延时,单位ms (动作调试使用) + CASE_ENUM_TO_STRING(kpipette_common_cfg_aspirate_pressure_report_extend_time) // 吸取时,额外压力上报时长 CASE_ENUM_TO_STRING(kpipette_common_cfg_max) } return "unknown"; 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 9482e56..aced672 100644 --- a/sdk/components/pipette_module/base/pipette_pressure_sample_data.hpp +++ b/sdk/components/pipette_module/base/pipette_pressure_sample_data.hpp @@ -4,3 +4,5 @@ typedef struct { 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 20c2e61..bcb3b3b 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module.cpp @@ -665,7 +665,7 @@ void PipetteModule::_do_sapirate(platinfo_t *platform_info, container_info_t *co if (acfg->llf_enable > 0) { zm_move_to(acfg->container_pos + container_cfg->container_depth, kzm_v_llf, compute_zm_llf_vel(aspiration_pm_index, container_cfg)); } - pump_move_by_x100nl_block(x100nl, aspiration_pm_index); + pump_move_by_x100nl_accurate_block(x100nl, aspiration_pm_index); if (acfg->llf_enable > 0) zm_stop(); } @@ -856,12 +856,25 @@ int32_t PipetteModule::pipette_zmotor_read_enc_pos(int32_t *pos) { } int32_t PipetteModule::pipette_get_sensor_sample_data(int32_t index, int32_t *motor_pos, int32_t *pval) { - if (index > capturedata_num) return err::kparam_out_of_range; - *motor_pos = capturedata_buf[index].motor_pos; - *pval = capturedata_buf[index].pressure_val; + if (index > lld_pressure_record_buf_num) return err::kparam_out_of_range; + *motor_pos = lld_pressure_record_buf[index].motor_pos; + *pval = lld_pressure_record_buf[index].pressure_val; return 0; } int32_t PipetteModule::pipette_get_sensor_sample_data_num(int32_t *num) { - *num = capturedata_num; + *num = lld_pressure_record_buf_num; + return 0; +} + +int32_t PipetteModule::pipette_get_asp_pressure_data(int32_t index, int16_t *pressure, int32_t *datanum) { // + int32_t startoff = index * (*datanum); + if (startoff >= asp_pressure_cache_num) { + *datanum = 0; + return 0; + } + int32_t cpynum = asp_pressure_cache_num - startoff; + if (cpynum > *datanum) cpynum = *datanum; + memcpy(pressure, &asp_pressure_cache[startoff], cpynum * sizeof(int16_t)); + *datanum = cpynum; return 0; } diff --git a/sdk/components/pipette_module/pipette_ctrl_module.hpp b/sdk/components/pipette_module/pipette_ctrl_module.hpp index fa2a7f8..2f50ad7 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module.hpp +++ b/sdk/components/pipette_module/pipette_ctrl_module.hpp @@ -83,6 +83,8 @@ class PipetteModule : public ZIModule { SmtpPressureStreamProcesser smtpPressureStreamProcesser; + int32_t m_last_pump_operation_diff_val; + /*********************************************************************************************************************** * Config * ***********************************************************************************************************************/ @@ -104,8 +106,11 @@ class PipetteModule : public ZIModule { /*********************************************************************************************************************** * datacache * ***********************************************************************************************************************/ - pipette_pressure_sample_data_t capturedata_buf[PIPETTEMODULE_SAMPLE_BUF_SIZE]; - int32_t capturedata_num = 0; + pipette_pressure_sample_data_t lld_pressure_record_buf[PIPETTEMODULE_LLD_PRESSURE_SAMPLE_BUF_SIZE]; + int32_t lld_pressure_record_buf_num = 0; + + int16_t asp_pressure_cache[PIPETTEMODULE_ASP_PRESSURE_SAMPLE_BUF_SIZE]; + int32_t asp_pressure_cache_num = 0; public: void initialize(int32_t id, hardward_config_t *hardwaredcfg); @@ -222,10 +227,17 @@ class PipetteModule : public ZIModule { void pump_waitfor_lld_is_ready(int32_t *zpos); void _pump_move_to_x100nl(double x100nl, int32_t vcfgcpyid); void pump_do_lld(int32_t pressure_threshold, int32_t ___, int32_t vcfgidx); - void pump_move_to_x100nl_block(double x100nl, int32_t vcfgindex, int32_t *diff = nullptr); - void pump_move_by_x100nl_block(double x100nl, int32_t vcfgindex); void pump_start_lld(double target_x100nl, int32_t vcfgindex); + void _pump_move_to_x100nl_block(bool accurate, double x100nl, int32_t vcfgcpyid); + void _pump_move_by_x100nl_block(bool accurate, double x100nl, int32_t vcfgcpyid); + + void pump_move_to_x100nl_block(double x100nl, int32_t vcfgcpyid); + void pump_move_by_x100nl_block(double x100nl, int32_t vcfgcpyid); + + void pump_move_to_x100nl_accurate_block(double x100nl, int32_t vcfgcpyid); + void pump_move_by_x100nl_accurate_block(double x100nl, int32_t vcfgcpyid); + /*********************************************************************************************************************** * UTILS * ***********************************************************************************************************************/ @@ -242,6 +254,9 @@ class PipetteModule : public ZIModule { int32_t compute_zm_llf_vel(int32_t pm_vindex, container_info_t *container_info); void push_pressure_sample_data(int32_t motor_pos, int32_t pressure_val); + void push_aspiration_pressure_sample_data(int32_t pressure_val); + void clear_aspiration_pressure_sample_data(); + int32_t calibrate_liquid_volume(liquid_info_t *liquidinfo, int32_t volumex100nl); void adjust_container_pos(int32_t *container_pos, int32_t platinfo_index); @@ -304,6 +319,8 @@ class PipetteModule : public ZIModule { virtual int32_t pipette_read_pressure(int32_t *pressure); virtual int32_t pipette_read_capacitance(int32_t *capacitance); + virtual int32_t pipette_get_asp_pressure_data(int32_t index, int16_t *pressure, int32_t *datanum); + // TEST CMD virtual int32_t pipette_test_pump_move_to_x100nl(int32_t x100nl, int32_t vcfgindex); virtual int32_t pipette_test_lld(int32_t container_pos, int32_t container_cpyid, int32_t liquid_cpyid); diff --git a/sdk/components/pipette_module/pipette_ctrl_module_pm_ctrl.cpp b/sdk/components/pipette_module/pipette_ctrl_module_pm_ctrl.cpp index d80a428..5bcf62b 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_pm_ctrl.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_pm_ctrl.cpp @@ -42,35 +42,85 @@ void PipetteModule::pump_do_lld(int32_t pressure_threshold, int32_t ___, int32_t DO_IN_THREAD(m_smtp2.pump_aspirate_plld(pressure_threshold, &vcfg)); } -void PipetteModule::pump_move_to_x100nl_block(double x100nl, int32_t vcfgcpyid, int32_t *diff) { +void PipetteModule::_pump_move_to_x100nl_block(bool accurate, double x100nl, int32_t vcfgcpyid) { ZLOGI(TAG, "pump_move_to_x100nl_block %f nl, in %s", x100nl, get_pm_vcpyid_name((pm_vcpyid_t)vcfgcpyid)); - int32_t diff_pos = 0; + int32_t refTryDiff = 0; + int32_t maxDiff = 0; + + if (accurate) { + refTryDiff = 100; // 精确模式,允许误差100nl + maxDiff = 200; // 精确模式,最大误差200nl + clear_aspiration_pressure_sample_data(); // 清除吸取压力采样数据 + } else { + refTryDiff = 300; // 非精确模式,允许误差300nl + maxDiff = 500; // 非精确模式,最大误差500nl + } + + int32_t diff_pos = 0; + int32_t first_pressrure = 0; + smtpPressureStreamProcesser.clearPressure(); + m_smtp2.set_aspirate_pressure_report_extend_time(m_common_cfg.aspirate_pressure_report_extend_time); + for (size_t i = 0; i < 4; i++) { int32_t vcpyid = vcfgcpyid; - // if (i != 0) { - // vcpyid = kpm_v_slow_lv1; - // } + + if (accurate && i == 0) { + DO_IN_THREAD(m_smtp2.pump_get_pressure(&first_pressrure)); + push_aspiration_pressure_sample_data(first_pressrure); + } _pump_move_to_x100nl(x100nl, vcpyid); - pump_waitfor_stop(); - int32_t targetpos = x100nl * 100; - int32_t after_pos = pump_read_pos_nl(); - diff_pos = targetpos - after_pos; - if (diff) *diff = diff_pos; + int32_t pressure = 0; + int32_t pressure_uuid = 0; + int32_t pressure_uuid_is_change = 0; + int32_t pressure_uuid_is_change_cnt = 0; + int32_t isbusy; + while (true) { + if (!smtpPressureStreamProcesser.isReady()) { + thread_delay(3); + continue; + } + + smtpPressureStreamProcesser.getPressure(&pressure, &pressure_uuid, &pressure_uuid_is_change); + if (pressure_uuid_is_change) { + pressure_uuid_is_change_cnt = 0; + ZLOGI(TAG, "pressure:%d (%d)", pressure, pressure_uuid); + if (accurate && i == 0) { + push_aspiration_pressure_sample_data(pressure); + } + } else { + pressure_uuid_is_change_cnt++; + if (pressure_uuid_is_change_cnt >= 3) { + DO_IN_THREAD(m_smtp2.pump_get_state(&isbusy)); + if (isbusy == 0) { + break; // 停止了 + } + } + } + + m_thread.sleep(5); + if (m_thread.getExitFlag()) throw zapp_thread_stoped_exception(); + } + push_aspiration_pressure_sample_data(-1); // 结束标志 + + int32_t targetpos = x100nl * 100; + int32_t after_pos = pump_read_pos_nl(); + diff_pos = targetpos - after_pos; + m_last_pump_operation_diff_val = diff_pos; ZLOGI(TAG, "pump target %d nl, now pos %d nl diff %d", targetpos, after_pos, diff_pos); - if (abs(diff_pos) > 100) { + if (abs(diff_pos) > refTryDiff) { ZLOGW(TAG, "pump move to x100nl %d failed, diff is too large retrying...", x100nl); continue; } break; } - if (abs(diff_pos) > 300) { + if (abs(diff_pos) > maxDiff) { module_detail_errorcode = diff_pos; throw zapp_exception(err::kpipette_pm_positioning_abnormality); } } -void PipetteModule::pump_move_by_x100nl_block(double x100nl, int32_t vcfgcpyid) { +void PipetteModule::_pump_move_by_x100nl_block(bool accurate, double x100nl, int32_t vcfgcpyid) { int32_t startpos = pump_read_pos_nl(); if (startpos > 1500000) { // 参考 https://iflytop1.feishu.cn/wiki/IWn1waKCXiUvzfkOru5c0F3HnJf @@ -81,9 +131,15 @@ void PipetteModule::pump_move_by_x100nl_block(double x100nl, int32_t vcfgcpyid) if (targetpos < 0) { targetpos = 0; } - pump_move_to_x100nl_block(targetpos / 100, vcfgcpyid); + _pump_move_to_x100nl_block(accurate, targetpos / 100, vcfgcpyid); } +void PipetteModule::pump_move_to_x100nl_block(double x100nl, int32_t vcfgcpyid) { _pump_move_to_x100nl_block(false, x100nl, vcfgcpyid); } +void PipetteModule::pump_move_by_x100nl_block(double x100nl, int32_t vcfgcpyid) { _pump_move_by_x100nl_block(false, x100nl, vcfgcpyid); } + +void PipetteModule::pump_move_to_x100nl_accurate_block(double x100nl, int32_t vcfgcpyid) { _pump_move_to_x100nl_block(true, x100nl, vcfgcpyid); } +void PipetteModule::pump_move_by_x100nl_accurate_block(double x100nl, int32_t vcfgcpyid) { _pump_move_by_x100nl_block(true, x100nl, vcfgcpyid); } + void PipetteModule::pump_start_lld(double target_x100nl, int32_t vcfgindex) { // _pump_move_to_x100nl(target_x100nl, vcfgindex); } diff --git a/sdk/components/pipette_module/pipette_ctrl_module_test.cpp b/sdk/components/pipette_module/pipette_ctrl_module_test.cpp index e68038b..1214732 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_test.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_test.cpp @@ -23,9 +23,8 @@ int32_t PipetteModule::pipette_test_pump_move_to_x100nl(int32_t x100nl, int32_t DO_IN_THREAD(m_smtp2.pump_set_back_clearance(0)); // 设置背隙为0 DO_IN_THREAD(m_smtp2.pump_set_io1_mode(0)); // lld输入高 - int32_t diff = 0; - pump_move_to_x100nl_block(x100nl, vcfgcpyid, &diff); // - m_state.asynchronous_result0 = diff; + pump_move_by_x100nl_accurate_block(x100nl, vcfgcpyid); // + m_state.asynchronous_result0 = m_last_pump_operation_diff_val; }); return 0; } @@ -127,7 +126,7 @@ int32_t PipetteModule::pipette_test_move_to_pierce_pos(int32_t container_pos, in }); return 0; } - int32_t PipetteModule::pipette_test_move_to_lld_end_pos(int32_t container_pos, int32_t container_cpyid){ +int32_t PipetteModule::pipette_test_move_to_lld_end_pos(int32_t container_pos, int32_t container_cpyid) { adjust_container_pos(&container_pos, m_common_cfg.platform_info_cpyid); thread_start_work(__FUNCTION__, [this, container_pos, container_cpyid]() { @@ -136,4 +135,4 @@ int32_t PipetteModule::pipette_test_move_to_pierce_pos(int32_t container_pos, in zm_move_to_lld_end_pos_block(container_pos, container_info, kzm_v_default, 0); // 移动到lld结束位置 }); return 0; - } +} diff --git a/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp b/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp index c031c0b..a014de5 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_utils.cpp @@ -78,7 +78,7 @@ void PipetteModule::check_pipette_pump_aspirate_params() { ZLOGE(TAG, "pipette_pump_aspirate_set_param x100nl %d out of range", acfg->volumeX100nl); throw zapp_exception(err::kparam_out_of_range); } - check_platinfo_cpyid( m_common_cfg.platform_info_cpyid); + check_platinfo_cpyid(m_common_cfg.platform_info_cpyid); check_container_info_cpyid(acfg->container_info_index); check_liquid_info_cpyid(acfg->liquid_cfg_index); } @@ -92,29 +92,44 @@ int32_t PipetteModule::compute_zm_llf_vel(int32_t pm_vindex, container_info_t *c } void PipetteModule::push_pressure_sample_data(int32_t motor_pos, int32_t pressure_val) { - if (capturedata_num >= PIPETTEMODULE_SAMPLE_BUF_SIZE) { - ZLOGW(TAG, "capturedata_buf overflow"); + if (lld_pressure_record_buf_num >= PIPETTEMODULE_LLD_PRESSURE_SAMPLE_BUF_SIZE) { + ZLOGW(TAG, "lld_pressure_record_buf overflow"); return; } - // 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++; + // ZLOGI(TAG, "sample %2d mpos:%2d pressure_val:%4d", lld_pressure_record_buf_num, motor_pos, pressure_val); + if (lld_pressure_record_buf_num == 0) { + lld_pressure_record_buf[lld_pressure_record_buf_num].motor_pos = motor_pos; + lld_pressure_record_buf[lld_pressure_record_buf_num].pressure_val = pressure_val; + lld_pressure_record_buf_num++; } else { - if (motor_pos == capturedata_buf[capturedata_num - 1].motor_pos) { + if (motor_pos == lld_pressure_record_buf[lld_pressure_record_buf_num - 1].motor_pos) { // 如果位置相同,则更新压力值 - capturedata_buf[capturedata_num - 1].pressure_val = pressure_val; + lld_pressure_record_buf[lld_pressure_record_buf_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++; + lld_pressure_record_buf[lld_pressure_record_buf_num].motor_pos = motor_pos; + lld_pressure_record_buf[lld_pressure_record_buf_num].pressure_val = pressure_val; + lld_pressure_record_buf_num++; } } } +void PipetteModule::push_aspiration_pressure_sample_data(int32_t pressure_val) { + if (asp_pressure_cache_num >= PIPETTEMODULE_ASP_PRESSURE_SAMPLE_BUF_SIZE) { + return; + } + // ZLOGI(TAG, "sample %2d pressure_val:%4d", aspiration_pressure_record_buf_num, pressure_val); + asp_pressure_cache[asp_pressure_cache_num] = pressure_val; + asp_pressure_cache_num++; +} +void PipetteModule::clear_aspiration_pressure_sample_data() { + for (int i = 0; i < PIPETTEMODULE_ASP_PRESSURE_SAMPLE_BUF_SIZE; i++) { + asp_pressure_cache[i] = 0; + } + asp_pressure_cache_num = 0; +} + void PipetteModule::dump(const char *title, platinfo_t *info) { ZLOGI(TAG, "-------------------------- %s --------------------------", title); ZLOGI(TAG, "work_ref_pos: %d", info->work_ref_pos); @@ -212,7 +227,7 @@ void PipetteModule::adjust_container_pos(int32_t *container_pos, int32_t platinf *container_pos += diff; } -void PipetteModule::action_delay(){ +void PipetteModule::action_delay() { if (m_common_cfg.each_action_delay_time > 0) { thread_delay(m_common_cfg.each_action_delay_time); } diff --git a/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp b/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp index 95ad444..c42f0b6 100644 --- a/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp +++ b/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp @@ -38,7 +38,7 @@ bool SMTP2V2::pump_ping() { } int32_t SMTP2V2::pump_get_state(int32_t* isbusy) { size_t rxlen = 0; - int ret = readstate(true, "/1QR\r"); + int ret = readstate(false, "/1QR\r"); if (ret != 0) return ret; uint8_t errorcode = (uint8_t)m_rxbuf[2]; @@ -140,8 +140,8 @@ int32_t SMTP2V2::_pump_move_to_nl(VelCfg* vcfg, int32_t nl) { ZLOGI(TAG, " vcfg acc %d dec %d vstart %d vstop %d vmax %d", vcfg->acc, vcfg->dec, vcfg->vstart, vcfg->vstop, vcfg->vmax); fix_vcfg(vcfg); if (nl < 0) nl = 0; - return runaction(true, "/1N2L%d,%dv%dc%dV%df1A%df0R\r", // - vcfg->acc, vcfg->dec, vcfg->vstart * 1000, vcfg->vstop * 1000, vcfg->vmax * 1000, nl); + return runaction(true, "/1N2L%d,%dv%dc%dV%df1+%dA%df0R\r", // + vcfg->acc, vcfg->dec, vcfg->vstart * 1000, vcfg->vstop * 1000, vcfg->vmax * 1000, aspirate_pressure_report_extend_time, nl); } int32_t SMTP2V2::pump_move_to_nl(VelCfg* vcfg, int32_t nl) { ZLOGI(TAG, " pump_move_to_nl %d", nl); @@ -259,8 +259,10 @@ int32_t SMTP2V2::pump_aspirate_plld(int32_t pressure_threshold, VelCfg* vcfg) { if (ret != 0) { return ret; } - return runaction(true, "/1N2L%d,%dv%dc%dV%df1t%d,1f0R\r", // + + return runaction(true, "/1N2L%d,%dv%dc%dV%df1t%d,1f0R\r", // vcfg->acc, vcfg->dec, vcfg->vstart * 1000, vcfg->vstop * 1000, vcfg->vmax * 1000, // + // pressure_threshold); } int32_t SMTP2V2::pump_aspirate_plld_get_state(int32_t* detected) { diff --git a/sdk/components/sensors/smtp2_v2/smtp2_v2.hpp b/sdk/components/sensors/smtp2_v2/smtp2_v2.hpp index 6e90cac..2f6f329 100644 --- a/sdk/components/sensors/smtp2_v2/smtp2_v2.hpp +++ b/sdk/components/sensors/smtp2_v2/smtp2_v2.hpp @@ -182,12 +182,23 @@ class SMTP2V2 { char m_rxprocessbuf[SMTP2_BUF_LEN] = {0}; + int32_t aspirate_pressure_report_extend_time = 0; // 吸取时压力数据流输出延时 + public: void initialize(UART_HandleTypeDef* uart, uint8_t id, DMA_HandleTypeDef* hdma_rx, DMA_HandleTypeDef* hdma_tx); bool pump_ping(); /*********************************************************************************************************************** + * LOCAL_CONFIG * + ***********************************************************************************************************************/ + + void set_aspirate_pressure_report_extend_time(int32_t time_ms) { + if (time_ms < 1) time_ms = 1; // 确保时间不小于0 + aspirate_pressure_report_extend_time = time_ms; + } // 吸取时压力数据流输出延时 + + /*********************************************************************************************************************** * CONFIG * ***********************************************************************************************************************/ int32_t pump_set_plld_start_delay(int32_t delay_ms); @@ -219,7 +230,7 @@ class SMTP2V2 { int32_t pump_init(); // 泵机初始化(归零) int32_t pump_put_tip(); // 丢弃TIP int32_t pump_factory_reset(); // 泵机复位 - int32_t pump_reset(); // 泵机复位 + int32_t pump_reset(); // 泵机复位 int32_t pump_stop(); // 停止 int32_t _pump_move_to_nl(VelCfg* vcfg, int32_t nl); int32_t pump_move_to_nl(VelCfg* vcfg, int32_t nl); // diff --git a/sdk/components/sensors/smtp2_v2/smtp_pressure_stream_processer.hpp b/sdk/components/sensors/smtp2_v2/smtp_pressure_stream_processer.hpp index bf9e6b4..dc1e91b 100644 --- a/sdk/components/sensors/smtp2_v2/smtp_pressure_stream_processer.hpp +++ b/sdk/components/sensors/smtp2_v2/smtp_pressure_stream_processer.hpp @@ -27,7 +27,6 @@ class SmtpPressureStreamProcesser { m_rxnum++; if (m_rxbuf[m_rxnum - 1] == 0x0a && m_rxbuf[m_rxnum - 2] == 0x0d && m_rxbuf[1] == '0') { - if ((m_rxnum - 6) != 4) return; memcpy(m_pressure_cache, &m_rxbuf[3], 4); @@ -38,11 +37,36 @@ class SmtpPressureStreamProcesser { m_is_ready_flag = true; } } - void getPressure(int32_t *pressure, int32_t *pressureuuid) const { + void getPressure(int32_t *pressure, int32_t *pressureuuid, int32_t *uuidIsChange) const { __disable_irq(); if (pressure) *pressure = m_pressure; - if (pressureuuid) *pressureuuid = m_pressure_uuid; + if (pressureuuid) { + if (*pressureuuid != m_pressure_uuid) { + if (uuidIsChange) *uuidIsChange = 1; + *pressureuuid = m_pressure_uuid; + } else { + if (uuidIsChange) *uuidIsChange = 0; + } + } + __enable_irq(); + } + + void clearPressure() { + __disable_irq(); + m_is_ready_flag = false; + m_pressure = 0; + m_pressure_uuid = 0; + memset(m_rxbuf, 0, sizeof(m_rxbuf)); + m_rxnum = 0; + __enable_irq(); + } + + bool isReady() const { + bool ret; + __disable_irq(); + ret = m_is_ready_flag; __enable_irq(); + return ret; } }; } // namespace iflytop diff --git a/sdk/components/zcan_protocol_parser/zcan_protocol_parser.cpp b/sdk/components/zcan_protocol_parser/zcan_protocol_parser.cpp index b323a62..a644124 100644 --- a/sdk/components/zcan_protocol_parser/zcan_protocol_parser.cpp +++ b/sdk/components/zcan_protocol_parser/zcan_protocol_parser.cpp @@ -193,6 +193,7 @@ void ZCanProtocolParser::initialize(ZCanReceiver* cancmder) { REGFN(pipette_pump_distribu_all_set_param); REGFN(pipette_pump_distribu_all); REGFN(pipette_zmotor_move_to_tip_deposit); + REGFN(pipette_get_asp_pressure_data); REGFN(pipette_zmotor_read_pos); REGFN(pipette_zmotor_read_enc_pos); @@ -663,7 +664,7 @@ int32_t ZCanProtocolParser::code_scaner_get_result_length(cmdcontxt_t* cxt) { int32_t ZCanProtocolParser::code_scaner_read_scaner_result(cmdcontxt_t* cxt) { CHECK_AND_GET_MODULE(0); - cxt->acklen = ZCANCMD_PACKET_MAX_LEN; + cxt->acklen = ZCANCMD_DATA_MAX_LEN; int32_t suc = module->code_scaner_read_scaner_result(cxt->ackbuf, &cxt->acklen); if (suc != 0) { cxt->acklen = 0; @@ -778,7 +779,7 @@ int32_t ZCanProtocolParser::xymotor_read_enc_direct(cmdcontxt_t* cxt) { #define MODULE_CLASS OpticalModuleV2 int32_t ZCanProtocolParser::a8000_optical_read_raw(cmdcontxt_t* cxt) { CHECK_AND_GET_MODULE(1); - cxt->acklen = ZCANCMD_PACKET_MAX_LEN; + cxt->acklen = ZCANCMD_DATA_MAX_LEN; int32_t suc = module->a8000_optical_read_raw(cxt->params[0], cxt->ackbuf, &cxt->acklen); if (suc != 0) { cxt->acklen = 0; @@ -833,7 +834,7 @@ int32_t ZCanProtocolParser::a8k_opt_v2_f_readVal(cmdcontxt_t* cxt) { #define MODULE_CLASS EEPROMService int32_t ZCanProtocolParser::a8000_idcard_reader_read_raw(cmdcontxt_t* cxt) { CHECK_AND_GET_MODULE(1); - cxt->acklen = ZCANCMD_PACKET_MAX_LEN; + cxt->acklen = ZCANCMD_DATA_MAX_LEN; int32_t suc = module->a8000_idcard_reader_read_raw(cxt->params[0], cxt->ackbuf, &cxt->acklen); if (suc != 0) { cxt->acklen = 0; @@ -873,7 +874,7 @@ int32_t ZCanProtocolParser::a8000_idcard_earse_unlock(cmdcontxt_t* cxt) { // int32_t ZCanProtocolParser::plate_code_scaner_read_result(cmdcontxt_t* cxt) { // CHECK_AND_GET_MODULE(1); -// cxt->acklen = ZCANCMD_PACKET_MAX_LEN; +// cxt->acklen = ZCANCMD_DATA_MAX_LEN; // int32_t suc = module->plate_code_scaner_read_result(cxt->params[0], cxt->ackbuf, &cxt->acklen); // if (suc != 0) { // cxt->acklen = 0; @@ -1265,4 +1266,18 @@ int32_t ZCanProtocolParser::pipette_get_common_cfg(cmdcontxt_t* cxt) { return module->pipette_get_common_cfg((pipette_common_cfg_index_t)cxt->params[0], &ack[0]); } +// pipette_get_asp_pressure_data +int32_t ZCanProtocolParser::pipette_get_asp_pressure_data(cmdcontxt_t* cxt) { + CHECK_AND_GET_MODULE(1); + int32_t* ack = (int32_t*)cxt->ackbuf; + int32_t maxdatanum = ZCANCMD_DATA_MAX_LEN / 2; + int32_t ret = module->pipette_get_asp_pressure_data(cxt->params[0], (int16_t*)&ack[0], &maxdatanum); + if (ret == 0) { + cxt->acklen = maxdatanum * 2; + } else { + cxt->acklen = 0; + } + return ret; +} + #undef MODULE_CLASS \ No newline at end of file diff --git a/sdk/components/zcan_protocol_parser/zcan_protocol_parser.hpp b/sdk/components/zcan_protocol_parser/zcan_protocol_parser.hpp index 09fe93e..82ba540 100644 --- a/sdk/components/zcan_protocol_parser/zcan_protocol_parser.hpp +++ b/sdk/components/zcan_protocol_parser/zcan_protocol_parser.hpp @@ -222,6 +222,7 @@ class ZCanProtocolParser : public IZCanRxProcesser { CMDFN(pipette_pump_distribu_all_set_param); CMDFN(pipette_pump_distribu_all); + CMDFN(pipette_get_asp_pressure_data); CMDFN(pipette_test_pump_move_to_x100nl); CMDFN(pipette_test_lld); diff --git a/usrc/a8000_protocol/protocol/cmdid.cpp b/usrc/a8000_protocol/protocol/cmdid.cpp index 1dc267c..119a8f4 100644 --- a/usrc/a8000_protocol/protocol/cmdid.cpp +++ b/usrc/a8000_protocol/protocol/cmdid.cpp @@ -168,6 +168,7 @@ static cmdinfo_t table[] = { CMD_ITERM(kpipette_read_capacitance), CMD_ITERM(kpipette_pump_distribu_all_set_param), CMD_ITERM(kpipette_pump_distribu_all), + CMD_ITERM(kpipette_get_asp_pressure_data), CMD_ITERM(kpipette_test_pump_move_to_x100nl), CMD_ITERM(kpipette_test_lld), @@ -180,7 +181,7 @@ static cmdinfo_t table[] = { CMD_ITERM(kpipette_test_move_to_fix_water_level_pos), CMD_ITERM(kpipette_test_move_to_pierce_pos), CMD_ITERM(kpipette_test_move_to_lld_end_pos), - + }; const char* cmdid2str(int32_t code) { diff --git a/usrc/a8000_protocol/protocol/cmdid.hpp b/usrc/a8000_protocol/protocol/cmdid.hpp index 67a9e12..e4deaf5 100644 --- a/usrc/a8000_protocol/protocol/cmdid.hpp +++ b/usrc/a8000_protocol/protocol/cmdid.hpp @@ -162,7 +162,7 @@ typedef enum { kpipette_zmotor_read_dev_status_cache = 0x7508, kpipette_zmotor_read_pos = 0x7509, kpipette_zmotor_read_enc_pos = 0x750A, - kpipette_zmotor_move_to_tip_deposit = 0x750B, + kpipette_zmotor_move_to_tip_deposit = 0x750B, kpipette_pump_init_device = 0x7580, kpipette_pump_take_tip = 0x7581, @@ -179,6 +179,7 @@ typedef enum { kpipette_read_capacitance = 0x758D, // ack:{state} kpipette_pump_distribu_all_set_param = 0x758E, // {paramid,val}, ack:{} kpipette_pump_distribu_all = 0x758F, // {}, ack:{} + kpipette_get_asp_pressure_data = 0x7590, kpipette_test_pump_move_to_x100nl = 0x7600, // int32_t x100nl, int32_t vcfgindex kpipette_test_lld = 0x7601, // int32_t container_pos, int32_t container_cpyid, int32_t liquid_cpyid diff --git a/usrc/a8000_protocol/protocol/packet.hpp b/usrc/a8000_protocol/protocol/packet.hpp index cef74fe..a41156d 100644 --- a/usrc/a8000_protocol/protocol/packet.hpp +++ b/usrc/a8000_protocol/protocol/packet.hpp @@ -1,6 +1,7 @@ #pragma once #include -#define ZCANCMD_PACKET_MAX_LEN 64 +#define ZCANCMD_PACKET_MAX_LEN 100 +#define ZCANCMD_DATA_MAX_LEN 64 namespace iflytop {