You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
7.5 KiB
132 lines
7.5 KiB
#pragma once
|
|
#include <map>
|
|
|
|
#include "api/api.hpp"
|
|
#include "api\i_zcan_cmder_master.hpp"
|
|
#include "cmdid.hpp"
|
|
|
|
namespace iflytop {
|
|
class ZIProtocolProxy : public ZIMotor, //
|
|
public ZIXYMotor, //
|
|
public ZIModule {
|
|
private:
|
|
IZcanCmderMaster *m_cancmder;
|
|
int32_t m_id = 0;
|
|
|
|
public:
|
|
void initialize(int32_t moduleId, IZcanCmderMaster *cancmder) {
|
|
m_cancmder = cancmder;
|
|
m_id = moduleId;
|
|
}
|
|
|
|
virtual int32_t getid(int32_t *id) {
|
|
*id = m_id;
|
|
return 0;
|
|
};
|
|
|
|
/*******************************************************************************
|
|
* ZIModule *
|
|
*******************************************************************************/
|
|
#if 0
|
|
virtual int32_t module_set_state(int32_t state_id, int32_t state_value) { return err::koperation_not_support; }
|
|
virtual int32_t module_get_state(int32_t state_id, int32_t *state_value) { return err::koperation_not_support; }
|
|
#endif
|
|
virtual int32_t module_stop() override;
|
|
virtual int32_t module_break() override;
|
|
virtual int32_t module_get_last_exec_status(int32_t *status) override;
|
|
virtual int32_t module_get_status(int32_t *status) override;
|
|
|
|
virtual int32_t module_set_param(int32_t param_id, int32_t param_value) override;
|
|
virtual int32_t module_get_param(int32_t param_id, int32_t *param_value) override;
|
|
|
|
virtual int32_t module_readio(int32_t *io) override;
|
|
virtual int32_t module_writeio(int32_t io) override;
|
|
|
|
virtual int32_t module_read_adc(int32_t adcindex, int32_t *adc) override;
|
|
|
|
virtual int32_t module_get_error(int32_t *iserror) override;
|
|
virtual int32_t module_clear_error() override;
|
|
|
|
virtual int32_t module_set_inited_flag(int32_t flag) override;
|
|
virtual int32_t module_get_inited_flag(int32_t *flag) override;
|
|
|
|
virtual int32_t module_factory_reset() override;
|
|
virtual int32_t module_flush_cfg() override;
|
|
virtual int32_t module_active_cfg() override;
|
|
|
|
virtual int32_t module_set_state(int32_t state_id, int32_t state_value) override;
|
|
virtual int32_t module_get_state(int32_t state_id, int32_t *state_value) override;
|
|
|
|
virtual int32_t module_read_raw(int32_t startadd, uint8_t *data, int32_t *len) override;
|
|
|
|
/*******************************************************************************
|
|
* ZIMotor *
|
|
*******************************************************************************/
|
|
#if 0
|
|
virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; }
|
|
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; }
|
|
virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; }
|
|
virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; }
|
|
|
|
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; }
|
|
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_rotate_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; }
|
|
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) { 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; }
|
|
|
|
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(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_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; }
|
|
|
|
virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; }
|
|
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // Ò»°ãÓÃÓÚ¶æ»ú
|
|
|
|
#endif
|
|
|
|
virtual int32_t motor_enable(int32_t enable) override;
|
|
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_rotate_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;
|
|
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) override;
|
|
|
|
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override;
|
|
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override;
|
|
|
|
virtual int32_t motor_read_pos(int32_t *pos) override;
|
|
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) override;
|
|
|
|
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override;
|
|
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;
|
|
|
|
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) override;
|
|
|
|
/*******************************************************************************
|
|
* ZIXYMotor *
|
|
*******************************************************************************/
|
|
#if 0
|
|
virtual ~ZIXYMotor() {}
|
|
virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; }
|
|
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) { return err::koperation_not_support; }
|
|
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) { return err::koperation_not_support; }
|
|
virtual int32_t xymotor_move_to_zero() { return err::koperation_not_support; }
|
|
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; }
|
|
virtual int32_t xymotor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; }
|
|
#endif
|
|
virtual int32_t xymotor_enable(int32_t enable) override;
|
|
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) override;
|
|
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) override;
|
|
virtual int32_t xymotor_move_to_zero() override;
|
|
virtual int32_t xymotor_move_to_zero_and_calculated_shift() override;
|
|
virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) override;
|
|
virtual int32_t xymotor_calculated_pos_by_move_to_zero() override;
|
|
};
|
|
|
|
} // namespace iflytop
|