diff --git a/api/i_cmdparser.hpp b/api/i_cmdparser.hpp index 7ab825f..b43429c 100644 --- a/api/i_cmdparser.hpp +++ b/api/i_cmdparser.hpp @@ -25,6 +25,21 @@ class ICmdParserACK { uint8_t rawdata[512]; int32_t rawlen; + public: + void setInt32Ack(int32_t ecode, int32_t val) { + this->ecode = ecode; + acktype = kAckType_int32; + rawlen = sizeof(int32_t); + *((int32_t *)rawdata) = val; + } + + void setNoneAck(int32_t ecode) { + this->ecode = ecode; + acktype = kAckType_none; + rawlen = 0; + rawdata[0] = 0; + } + int32_t *getAck(int index) { if (index < 0 || index >= rawlen / (int)sizeof(int32_t)) { return nullptr; diff --git a/api/zi_motor.hpp b/api/zi_motor.hpp index 4888554..11bc028 100644 --- a/api/zi_motor.hpp +++ b/api/zi_motor.hpp @@ -19,7 +19,7 @@ class ZIMotor { virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } - virtual int32_t motor_move_to_with_torque(int32_t pos, int32_t torque) { return err::koperation_not_support; } + virtual int32_t motor_move_to_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } diff --git a/protocol_proxy.hpp b/protocol_proxy.hpp index 62f9cf4..0361d59 100644 --- a/protocol_proxy.hpp +++ b/protocol_proxy.hpp @@ -59,7 +59,7 @@ class ZIProtocolProxy : public ZIMotor, // virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_by(int32_t direction, int32_t motor_velocity, int32_t acc) override; virtual int32_t motor_move_to(int32_t direction, int32_t motor_velocity, int32_t acc) override; - virtual int32_t motor_move_to_with_torque(int32_t pos, int32_t torque) override; + virtual int32_t motor_move_to_with_torque(int32_t direction, int32_t torque) override; virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) override; virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override; diff --git a/zmodule_device_manager.cpp b/zmodule_device_manager.cpp index 7509054..27ee6ec 100644 --- a/zmodule_device_manager.cpp +++ b/zmodule_device_manager.cpp @@ -1,6 +1,7 @@ #include "zmodule_device_manager.hpp" #include +#include using namespace iflytop; using namespace std; diff --git a/zmodule_device_script_cmder_paser.cpp b/zmodule_device_script_cmder_paser.cpp index 13c3a07..a75bb0f 100644 --- a/zmodule_device_script_cmder_paser.cpp +++ b/zmodule_device_script_cmder_paser.cpp @@ -93,41 +93,41 @@ void ZModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZModuleDevi virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; #endif - PROCESS_PACKET_10(module_stop, "module_stop (mid)"); - PROCESS_PACKET_10(module_break, "module_break (mid)"); - PROCESS_PACKET_11(module_get_last_exec_status, "module_get_last_exec_status (mid)"); - PROCESS_PACKET_11(module_get_status, "module_get_status (mid)"); - PROCESS_PACKET_30(module_set_param, "module_set_param (mid, param_id, param_value)"); - PROCESS_PACKET_21(module_get_param, "module_get_param (mid, param_id)"); - PROCESS_PACKET_11(module_readio, "module_readio (mid)"); - PROCESS_PACKET_20(module_writeio, "module_writeio (mid, io)"); - PROCESS_PACKET_21(module_read_adc, "module_read_adc (mid,adc_id, adcindex)"); - PROCESS_PACKET_11(module_get_error, "module_get_error (mid)"); - PROCESS_PACKET_10(module_clear_error, "module_clear_error (mid)"); - PROCESS_PACKET_20(module_set_inited_flag, "module_set_inited_flag (mid, flag)"); - PROCESS_PACKET_11(module_get_inited_flag, "module_get_inited_flag (mid)"); - PROCESS_PACKET_10(module_factory_reset, "module_factory_reset (mid)"); - PROCESS_PACKET_10(module_flush_cfg, "module_flush_cfg (mid)"); - PROCESS_PACKET_10(module_active_cfg, "module_active_cfg (mid)"); - - PROCESS_PACKET_20(motor_enable, "motor_enable (mid, enable)"); - PROCESS_PACKET_40(motor_rotate, "motor_rotate (mid, direction, motor_velocity, acc)"); - PROCESS_PACKET_40(motor_move_by, "motor_move_by (mid, distance, motor_velocity, acc)"); - PROCESS_PACKET_40(motor_move_to, "motor_move_to (mid, position, motor_velocity, acc)"); - - PROCESS_PACKET_40(motor_rotate_acctime, "motor_rotate_acctime (mid, direction, motor_velocity, acctime)"); - PROCESS_PACKET_40(motor_move_by_acctime, "motor_move_by_acctime (mid, distance, motor_velocity, acctime)"); - PROCESS_PACKET_40(motor_move_to_acctime, "motor_move_to_acctime (mid, position, motor_velocity, acctime)"); - - PROCESS_PACKET_30(motor_move_to_with_torque, "motor_move_to_with_torque (mid, pos, torque)"); - PROCESS_PACKET_50(motor_move_to_zero_forward, "motor_move_to_zero_forward (mid, findzerospeed, findzeroedge_speed, acc, overtime)"); - PROCESS_PACKET_50(motor_move_to_zero_backward, "motor_move_to_zero_backward (mid, findzerospeed, findzeroedge_speed, acc, overtime)"); - - PROCESS_PACKET_11(motor_read_pos, "motor_read_pos (mid)"); - PROCESS_PACKET_20(motor_set_current_pos_by_change_shift, "motor_set_current_pos_by_change_shift (mid, pos)"); - - PROCESS_PACKET_50(motor_move_to_zero_forward_and_calculated_shift, "motor_move_to_zero_forward_and_calculated_shift (mid, findzerospeed, findzeroedge_speed, acc, overtime)"); - PROCESS_PACKET_50(motor_move_to_zero_backward_and_calculated_shift, "motor_move_to_zero_backward_and_calculated_shift (mid, findzerospeed, findzeroedge_speed, acc, overtime)"); + PROCESS_PACKET_10(module_stop, "(mid)"); + PROCESS_PACKET_10(module_break, "(mid)"); + PROCESS_PACKET_11(module_get_last_exec_status, "(mid)"); + PROCESS_PACKET_11(module_get_status, "(mid)"); + PROCESS_PACKET_30(module_set_param, "(mid, param_id, param_value)"); + PROCESS_PACKET_21(module_get_param, "(mid, param_id)"); + PROCESS_PACKET_11(module_readio, "(mid)"); + PROCESS_PACKET_20(module_writeio, "(mid, io)"); + PROCESS_PACKET_21(module_read_adc, "(mid,adc_id, adcindex)"); + PROCESS_PACKET_11(module_get_error, "(mid)"); + PROCESS_PACKET_10(module_clear_error, "(mid)"); + PROCESS_PACKET_20(module_set_inited_flag, "(mid, flag)"); + PROCESS_PACKET_11(module_get_inited_flag, "(mid)"); + PROCESS_PACKET_10(module_factory_reset, "(mid)"); + PROCESS_PACKET_10(module_flush_cfg, "(mid)"); + PROCESS_PACKET_10(module_active_cfg, "(mid)"); + + PROCESS_PACKET_20(motor_enable, "(mid, enable)"); + PROCESS_PACKET_40(motor_rotate, "(mid, direction, motor_velocity, acc)"); + PROCESS_PACKET_40(motor_move_by, "(mid, distance, motor_velocity, acc)"); + PROCESS_PACKET_40(motor_move_to, "(mid, position, motor_velocity, acc)"); + + PROCESS_PACKET_40(motor_rotate_acctime, "(mid, direction, motor_velocity, acctime)"); + PROCESS_PACKET_40(motor_move_by_acctime, "(mid, distance, motor_velocity, acctime)"); + PROCESS_PACKET_40(motor_move_to_acctime, "(mid, position, motor_velocity, acctime)"); + + PROCESS_PACKET_30(motor_move_to_with_torque, "(mid, pos, torque)"); + PROCESS_PACKET_50(motor_move_to_zero_forward, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); + PROCESS_PACKET_50(motor_move_to_zero_backward, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); + + PROCESS_PACKET_11(motor_read_pos, "(mid)"); + PROCESS_PACKET_20(motor_set_current_pos_by_change_shift, "(mid, pos)"); + + PROCESS_PACKET_50(motor_move_to_zero_forward_and_calculated_shift, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); + PROCESS_PACKET_50(motor_move_to_zero_backward_and_calculated_shift, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); #if 0 virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; } @@ -137,10 +137,10 @@ void ZModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZModuleDevi virtual int32_t xymotor_move_to_zero_and_calculated_shift() { return err::koperation_not_support; } virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) { return err::koperation_not_support; } #endif - PROCESS_PACKET_20(xymotor_enable, "xymotor_enable (mid, enable)"); - PROCESS_PACKET_40(xymotor_move_by, "xymotor_move_by (mid, dx, dy, motor_velocity)"); - PROCESS_PACKET_40(xymotor_move_to, "xymotor_move_to (mid, x, y, motor_velocity)"); - PROCESS_PACKET_10(xymotor_move_to_zero, "xymotor_move_to_zero (mid)"); - PROCESS_PACKET_10(xymotor_move_to_zero_and_calculated_shift, "xymotor_move_to_zero_and_calculated_shift (mid)"); - PROCESS_PACKET_12(xymotor_read_pos, "xymotor_read_pos (mid)"); + PROCESS_PACKET_20(xymotor_enable, "(mid, enable)"); + PROCESS_PACKET_40(xymotor_move_by, "(mid, dx, dy, motor_velocity)"); + PROCESS_PACKET_40(xymotor_move_to, "(mid, x, y, motor_velocity)"); + PROCESS_PACKET_10(xymotor_move_to_zero, "(mid)"); + PROCESS_PACKET_10(xymotor_move_to_zero_and_calculated_shift, "(mid)"); + PROCESS_PACKET_12(xymotor_read_pos, "(mid)"); }