diff --git a/api/i_xyrobot_ctrl_module.hpp b/api/i_xyrobot_ctrl_module.hpp index fe2cfb6..67ff5a8 100644 --- a/api/i_xyrobot_ctrl_module.hpp +++ b/api/i_xyrobot_ctrl_module.hpp @@ -17,28 +17,6 @@ class I_XYRobotCtrlModule { * ACTION * *******************************************************************************/ #pragma pack(1) - typedef struct { - int32_t exec_status; - int32_t tox; - int32_t toy; - } move_to_cb_status_t; - - typedef struct { - int32_t exec_status; - int32_t dx; - int32_t dy; - } move_by_cb_status_t; - - typedef struct { - int32_t exec_status; - } move_to_zero_cb_status_t; - - typedef struct { - int32_t exec_status; - int32_t zero_shift_x; - int32_t zero_shift_y; - } move_to_zero_with_calibrate_cb_status_t; - /******************************************************************************* * READ * *******************************************************************************/ @@ -65,52 +43,55 @@ class I_XYRobotCtrlModule { *******************************************************************************/ typedef struct { - u8 robot_type; - u8 x_shaft; - u8 y_shaft; - u8 ihold; - u8 irun; - u16 iholddelay; + s32 robot_type; + s32 x_shaft; + s32 y_shaft; + s32 ihold; + s32 irun; + s32 iholddelay; s32 distance_scale; // 0.001 s32 shift_x; s32 shift_y; + + // limit s32 acc; s32 dec; + s32 breakdec; s32 maxspeed; s32 min_x; s32 max_x; s32 min_y; s32 max_y; - } run_param_t; + + s32 run_to_zero_max_d; + s32 leave_from_zero_max_d; + s32 run_to_zero_speed; + s32 run_to_zero_dec; + } base_param_t; typedef struct { uint8_t pad; } warning_limit_param_t; - typedef struct { - u32 move_to_zero_max_d; - u32 leave_from_zero_max_d; - u32 speed; - u32 dec; - } run_to_zero_param_t; - #pragma pack() public: - virtual int32_t move_to(int32_t x, int32_t y, function status_cb) = 0; - virtual int32_t move_by(int32_t dx, int32_t dy, function status_cb) = 0; - virtual int32_t move_to_zero(function status_cb) = 0; - virtual int32_t move_to_zero_with_calibrate(int32_t x, int32_t y, function status_cb) = 0; - virtual int32_t enable(bool venable) = 0; - virtual int32_t stop(uint8_t stopType) = 0; - virtual int32_t force_change_current_pos(int32_t x, int32_t y) = 0; - - virtual int32_t read_version(version_t& version) = 0; - virtual int32_t read_status(status_t& status) = 0; + virtual int32_t move_to(int32_t x, int32_t y, action_cb_status_t status_cb) = 0; + virtual int32_t move_by(int32_t dx, int32_t dy, action_cb_status_t status_cb) = 0; + virtual int32_t move_to_zero(action_cb_status_t status_cb) = 0; + virtual int32_t move_to_zero_with_calibrate(int32_t x, int32_t y, action_cb_status_t status_cb) = 0; + + virtual int32_t enable(bool venable) = 0; + virtual int32_t stop(uint8_t stopType) = 0; + virtual int32_t force_change_current_pos(int32_t x, int32_t y) = 0; + + virtual int32_t read_version(version_t& version) = 0; + virtual int32_t read_status(status_t& status) = 0; virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0; - virtual int32_t set_run_param(uint8_t operation, const run_param_t& param, run_param_t& ack) = 0; - virtual int32_t set_run_to_zero_param(uint8_t operation, const run_to_zero_param_t& param, run_to_zero_param_t& ack) = 0; - virtual int32_t set_warning_limit_param(uint8_t operation, const warning_limit_param_t& param, warning_limit_param_t& ack) = 0; + virtual int32_t set_base_param(const base_param_t& param) = 0; + virtual int32_t get_base_param(base_param_t& ack) = 0; + // virtual int32_t set_run_to_zero_param(uint8_t operation, const run_to_zero_param_t& param, run_to_zero_param_t& ack) = 0; + // virtual int32_t set_warning_limit_param(uint8_t operation, const warning_limit_param_t& param, warning_limit_param_t& ack) = 0; }; } // namespace iflytop \ No newline at end of file diff --git a/zcancmder_protocol.hpp b/zcancmder_protocol.hpp index ff86b98..09b4c3c 100644 --- a/zcancmder_protocol.hpp +++ b/zcancmder_protocol.hpp @@ -37,9 +37,10 @@ typedef enum { kcmd_xy_robot_ctrl_read_status = CMDID(1006, 51), // 读取模块精简状态信息 kcmd_xy_robot_ctrl_read_detailed_status = CMDID(1006, 52), // 读取模块详细状态信息 - kcmd_xy_robot_ctrl_set_run_param = CMDID(1006, 100), // 设置运行参数 - kcmd_xy_robot_ctrl_set_warning_limit_param = CMDID(1006, 101), // 设置控制限制参数 - kcmd_xy_robot_ctrl_set_run_to_zero_param = CMDID(1006, 102), // 设置归零参数 + kcmd_xy_robot_ctrl_set_base_param = CMDID(1006, 100), // 设置运行参数 + kcmd_xy_robot_ctrl_get_base_param = CMDID(1006, 101), // 设置运行参数 + // kcmd_xy_robot_ctrl_set_warning_limit_param = CMDID(1006, 101), // 设置控制限制参数 + // kcmd_xy_robot_ctrl_set_run_to_zero_param = CMDID(1006, 102), // 设置归零参数 /******************************************************************************* * |Module_1007:步进电机控制模组 * @@ -215,19 +216,20 @@ ZPACKET_CMD_ACK(kcmd_readadc_raw, // // ACTION ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_enable, CMD(u8 id; u8 enable;), ACK(u8 id;)); ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_stop, CMD(u8 id; u8 stop_type;), ACK(u8 id;)); -ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to_zero, CMD(u8 id;), ACK(u8 id;), REPORT(u8 id; I_XYRobotCtrlModule::move_to_zero_cb_status_t status;)); -ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, CMD(u8 id; s32 nowx; s32 nowy;), ACK(u8 id;), REPORT(u8 id; I_XYRobotCtrlModule::move_to_zero_with_calibrate_cb_status_t status;)); -ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to, CMD(u8 id; s32 x; s32 y; s32 speed;), ACK(u8 id;), REPORT(u8 id; I_XYRobotCtrlModule::move_to_cb_status_t status;)); -ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_by, CMD(u8 id; s32 dx; s32 dy; s32 speed;), ACK(u8 id;), REPORT(u8 id; I_XYRobotCtrlModule::move_by_cb_status_t status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to_zero, CMD(u8 id;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, CMD(u8 id; s32 nowx; s32 nowy;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_to, CMD(u8 id; s32 x; s32 y; s32 speed;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); +ZPACKET_CMD_ACK_AND_REPORT(kcmd_xy_robot_ctrl_move_by, CMD(u8 id; s32 dx; s32 dy; s32 speed;), ACK(u8 id;), REPORT(u8 id; int32_t exec_status;)); ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_force_change_current_pos, CMD(u8 id; s32 x; s32 y;), ACK(u8 id;)); // READ ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_read_version, CMD(u8 id;), ACK(u8 id; I_XYRobotCtrlModule::version_t ack;)); ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_read_status, CMD(u8 id;), ACK(u8 id; I_XYRobotCtrlModule::status_t ack;)); ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_read_detailed_status, CMD(u8 id;), ACK(u8 id; I_XYRobotCtrlModule::detailed_status_t ack;)); // SET -ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_run_param, CMD(u8 id; u8 opt_type; I_XYRobotCtrlModule::run_param_t param;), ACK(u8 id; I_XYRobotCtrlModule::run_param_t ack;)); -ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_warning_limit_param, CMD(u8 id; u8 opt_type; I_XYRobotCtrlModule::warning_limit_param_t param;), ACK(u8 id; I_XYRobotCtrlModule::warning_limit_param_t ack;)); -ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_run_to_zero_param, CMD(u8 id; u8 opt_type; I_XYRobotCtrlModule::run_to_zero_param_t param;), ACK(u8 id; I_XYRobotCtrlModule::run_to_zero_param_t ack;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_base_param, CMD(u8 id; I_XYRobotCtrlModule::base_param_t param;), ACK(u8 id;)); +ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_get_base_param, CMD(u8 id;), ACK(u8 id; I_XYRobotCtrlModule::base_param_t ack;)); +// ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_warning_limit_param, CMD(u8 id; u8 opt_type; I_XYRobotCtrlModule::warning_limit_param_t param;), ACK(u8 id; I_XYRobotCtrlModule::warning_limit_param_t ack;)); +// ZPACKET_CMD_ACK(kcmd_xy_robot_ctrl_set_run_to_zero_param, CMD(u8 id; u8 opt_type; I_XYRobotCtrlModule::run_to_zero_param_t param;), ACK(u8 id; I_XYRobotCtrlModule::run_to_zero_param_t ack;)); /******************************************************************************* * |Module_1007:步进电机控制模组 *