From 7be6aafbd44d3276331b77f49b1a04dcd65b2e12 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 5 Oct 2023 17:56:09 +0800 Subject: [PATCH] add --- api/i_pipette_module.hpp | 4 +- zcancmder_protocol.hpp | 136 ++++++++++--------------------------------- zcancmder_protocol_basic.hpp | 8 +++ 3 files changed, 42 insertions(+), 106 deletions(-) diff --git a/api/i_pipette_module.hpp b/api/i_pipette_module.hpp index a9df333..253729a 100644 --- a/api/i_pipette_module.hpp +++ b/api/i_pipette_module.hpp @@ -43,8 +43,8 @@ class I_PipetteModule { virtual int32_t move_to(s16 vel, s16 height_mm, action_cb_status_t status_cb) = 0; virtual int32_t move_to_with_lld(s16 vel, s16 lld_cap_thr, s16 lld_max_hight_mm, s16 lld_rela_hight_mm, action_cb_status_t status_cb) = 0; - virtual int32_t shake_volume(s16 shake_times, s16 shake_volume, action_cb_status_t status_cb) = 0; - virtual int32_t take_and_split_liquid(s16 take_volume_mm, action_cb_status_t status_cb) = 0; + virtual int32_t shake(s16 shake_times, s16 shake_volume, action_cb_status_t status_cb) = 0; + virtual int32_t pipette_move_to_ul(s16 take_volume_mm, action_cb_status_t status_cb) = 0; /******************************************************************************* * ReadStatus * diff --git a/zcancmder_protocol.hpp b/zcancmder_protocol.hpp index 1294ad9..1961949 100644 --- a/zcancmder_protocol.hpp +++ b/zcancmder_protocol.hpp @@ -5,6 +5,7 @@ #include "api/i_mini_servo_module.hpp" #include "api/i_step_motor_ctrl_module.hpp" #include "api/i_xyrobot_ctrl_module.hpp" +#include "api/i_pipette_module.hpp" #include "zcancmder_protocol_basic.hpp" namespace iflytop { namespace zcr { @@ -167,69 +168,32 @@ typedef enum { kcmd_serial_module_read_status = CMDID(1015, 50), // 读取模块状态信息 kcmd_serial_module_set_cfg = CMDID(1015, 100), // 串口透传设置配置 -// 移液枪控制 -/******************************************************************************* - * |Module_1016:移液枪控制 * - *******************************************************************************/ - -#if 0 - virtual int32_t enable(u8 enable) = 0; - virtual int32_t stop(u8 stop_type) = 0; - - virtual int32_t zero_pos_calibrate(action_cb_status_t status_cb) = 0; - virtual int32_t reset_device(action_cb_status_t status_cb) = 0; - - virtual int32_t take_tip(s16 vel, s16 height_mm, s16 tip_hight_mm, action_cb_status_t status_cb) = 0; - virtual int32_t remove_tip(s16 vel, s16 height_mm, action_cb_status_t status_cb) = 0; - - virtual int32_t move_to(s16 vel, s16 height_mm, action_cb_status_t status_cb) = 0; - virtual int32_t move_to_with_lld(s16 vel, s16 lld_cap_thr, s16 lld_max_hight_mm, s16 lld_rela_hight_mm, action_cb_status_t status_cb) = 0; - virtual int32_t shake_volume(s16 shake_times, s16 shake_volume, action_cb_status_t status_cb) = 0; - virtual int32_t take_and_split_liquid(s16 take_volume_mm, action_cb_status_t status_cb) = 0; - - /******************************************************************************* - * ReadStatus * - *******************************************************************************/ - virtual int32_t get_status(status_t &status) = 0; - + // 移液枪控制 /******************************************************************************* - * SETTING * + * |Module_1016:移液枪控制 * *******************************************************************************/ - virtual int32_t set_z_motor_para(const I_StepMotorCtrlModule::base_param_t &z_motor_param) = 0; - virtual int32_t get_z_motor_para(I_StepMotorCtrlModule::base_param_t &z_motor_param) = 0; - virtual int32_t set_base_param(const base_param_t &base_param) = 0; - virtual int32_t get_base_param(base_param_t &base_param) = 0; -#endif - kcmd_pipette_module_enable = CMDID(1016, 0), // 使能 kcmd_pipette_module_stop = CMDID(1016, 1), // 停止 kcmd_pipette_module_zero_pos_calibrate = CMDID(1016, 2), // 回零并校准 - kcmd_barcode_reader_reset_device = CMDID(1016, 3), // 重置设备,归零,并弹出tip头 - - + kcmd_pipeete_module_zmotor_reset = CMDID(1016, 3), // Z轴复位 + kcmd_pipeete_module_pipette_reset = CMDID(1016, 4), // 移液枪复位 -#if 0 - kcmd_pipette_module_z_motor_enable = CMDID(1016, 0), // 使能 - kcmd_pipette_module_z_motor_move_to = CMDID(1016, 1), // 移动到 - kcmd_pipette_module_z_motor_move_to_zero = CMDID(1016, 2), // 归零 - kcmd_pipette_module_z_motor_move_to_zero_with_calibrate = CMDID(1016, 3), // 归零并校准 - kcmd_pipette_module_z_motor_stop = CMDID(1016, 4), // 停止 + kcmd_pipette_module_take_tip = CMDID(1016, 5), // 取tip + kcmd_pipette_module_remove_tip = CMDID(1016, 6), // 移除tip - kcmd_pipette_module_take_liquid = CMDID(1016, 4), // 取液体 - kcmd_pipette_module_split_liquid = CMDID(1016, 5), // 吐液体 - kcmd_pipette_module_take_tip = CMDID(1016, 6), // 取tip - kcmd_pipette_module_remove_tip = CMDID(1016, 7), // 移除tip + kcmd_pipette_module_move_to = CMDID(1016, 7), // 移动到 + kcmd_pipette_module_move_to_with_lld = CMDID(1016, 8), // 移动到 + kcmd_pipette_module_shake = CMDID(1016, 9), // 吸吐摇匀 + kcmd_pipette_module_pipette_move_to_ul = CMDID(1016, 10), // 取液 - kcmd_pipette_module_read_version = CMDID(1016, 50), // 读取模块型号版本信息 - kcmd_pipette_module_read_status = CMDID(1016, 51), // 读取模块精简状态信息 - kcmd_pipette_module_read_detailed_status = CMDID(1016, 52), // 读取模块详细状态信息 + kcmd_pipette_module_get_status = CMDID(1016, 50), // 读取模块精简状态信息 - kcmd_pipette_module_set_run_param = CMDID(1016, 100), // 设置运行参数 - kcmd_pipette_module_set_warning_limit_param = CMDID(1016, 101), // 设置限制参数 - kcmd_pipette_module_set_run_to_zero_param = CMDID(1016, 102), // 设置归零参数 -#endif + kcmd_pipette_module_set_z_motor_para = CMDID(1016, 100), // 设置Z轴电机参数 + kcmd_pipette_module_get_z_motor_para = CMDID(1016, 101), // 读取Z轴电机参数 + kcmd_pipette_module_set_base_param = CMDID(1016, 102), // 设置运行参数 + kcmd_pipette_module_get_base_param = CMDID(1016, 103), // 读取运行参数 } CmdID_t; @@ -472,62 +436,26 @@ ZPACKET_CMD_ACK(kcmd_fan_module_fan_read_detailed_status, * |Module_1016:移液枪控制 * *******************************************************************************/ -ZPACKET_CMD_ACK(kcmd_pipette_module_motor_enable, - CMD(u8 id; u8 enable;), // - ACK(u8 id;)); -ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_motor_move_to, - CMD(u8 id; u8 motor_id; s32 pos; s32 speed;), // - ACK(u8 id;), // - REPORT(u8 id; u8 status; s32 pos;)); -ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_motor_move_to_zero, - CMD(u8 id; u8 motor_id;), // - ACK(u8 id;), // - REPORT(u8 id; u8 status;)); -ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_motor_move_to_zero_with_calibrate, - CMD(u8 id; u8 motor_id; s32 now_pos;), // - ACK(u8 id;), // - REPORT(u8 id; u8 status; s32 zero_shift;)); -ZPACKET_CMD_ACK(kcmd_pipette_module_motor_stop, - CMD(u8 id; u8 motor_id;), // - ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_enable, CMD(u8 id; u8 enable;), ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_stop, CMD(u8 id; u8 stop_type;), ACK(u8 id;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_zero_pos_calibrate, CMD(u8 id;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipeete_module_zmotor_reset, CMD(u8 id;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipeete_module_pipette_reset, CMD(u8 id;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); -ZPACKET_CMD_ACK(kcmd_pipette_module_take_liquid, - CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // - ACK(u8 id;)); -ZPACKET_CMD_ACK(kcmd_pipette_module_split_liquid, - CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // - ACK(u8 id;)); -ZPACKET_CMD_ACK(kcmd_pipette_module_take_tip, - CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // - ACK(u8 id;)); -ZPACKET_CMD_ACK(kcmd_pipette_module_remove_tip, - CMD(u8 id; u8 motor_id; s32 speed; s32 pos;), // - ACK(u8 id;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_take_tip, CMD(u8 id; s16 vel; s16 height_mm; s16 tip_hight_mm;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_remove_tip, CMD(u8 id; s16 vel; s16 height_mm;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); -#if 0 - kcmd_pipette_module_read_status = CMDID(1016, 51), // 读取模块精简状态信息 - kcmd_pipette_module_read_detailed_status = CMDID(1016, 52), // 读取模块详细状态信息 +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_move_to, CMD(u8 id; s16 vel; s16 height_mm;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_move_to_with_lld, CMD(u8 id; s16 vel; s16 lld_cap_thr; s16 lld_max_hight_mm; s16 lld_rela_hight_mm;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_shake, CMD(u8 id; s16 shake_times; s16 shake_volume;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_pipette_module_pipette_move_to_ul, CMD(u8 id; s16 take_volume_mm;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); - kcmd_pipette_module_set_run_param = CMDID(1016, 100), // 设置运行参数 - kcmd_pipette_module_set_warning_limit_param = CMDID(1016, 101), // 设置限制参数 - kcmd_pipette_module_set_run_to_zero_param = CMDID(1016, 102), // 设置归零参数 -#endif +ZPACKET_CMD_ACK(kcmd_pipette_module_get_status, CMD(u8 id;), ACK(u8 id; I_PipetteModule::status_t ack;)); -ZPACKET_CMD_ACK(kcmd_pipette_module_read_version, - CMD(u8 id;), // - ACK(u8 id;)); -ZPACKET_CMD_ACK(kcmd_pipette_module_read_status, - CMD(u8 id;), // - ACK(u8 id; u8 status; s32 pos[2];)); -ZPACKET_CMD_ACK(kcmd_pipette_module_read_detailed_status, - CMD(u8 id;), // - ACK(u8 id; u8 status; s32 pos[2]; s32 acc[2]; s32 speed[2];)); -ZPACKET_CMD_ACK(kcmd_pipette_module_set_run_param, - CMD(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];), // - ACK(u8 id; u8 opt_type; s32 acc[2]; s32 dec[2]; s32 max_speed[2]; s32 min_pos[2]; s32 max_pos[2];)); -ZPACKET_CMD_ACK(kcmd_pipette_module_set_warning_limit_param, - CMD(u8 id; u8 opt_type; s32 pad;), // - ACK(u8 id; u8 opt_type; s32 pad;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_set_z_motor_para, CMD(u8 id; I_StepMotorCtrlModule::base_param_t param;), ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_get_z_motor_para, CMD(u8 id;), ACK(u8 id; I_StepMotorCtrlModule::base_param_t ack;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_set_base_param, CMD(u8 id; I_PipetteModule::base_param_t param;), ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_pipette_module_get_base_param, CMD(u8 id;), ACK(u8 id; I_PipetteModule::base_param_t ack;)); #pragma pack(pop) diff --git a/zcancmder_protocol_basic.hpp b/zcancmder_protocol_basic.hpp index 49bff4b..660ed50 100644 --- a/zcancmder_protocol_basic.hpp +++ b/zcancmder_protocol_basic.hpp @@ -34,6 +34,14 @@ if (cmd->id == varid) { \ ack->id = cmd->id; +#define PROCESS_REPORT(type) \ + osDelay(5); \ + type##_report_t report = {0}; \ + ZLOGI(TAG, #type " exec_status:%d", status); \ + report.id = m_id; \ + report.exec_status = status; \ + m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); + #define END_PROCESS_PACKET() \ if (errorcode == 0) { \ m_cancmder->sendAck(rxcmd->get_cmdheader(), m_txbuf, sizeof(*ack)); \