9 changed files with 506 additions and 380 deletions
-
6.cproject
-
2.settings/language.settings.xml
-
2sdk
-
193usrc/app_zmodule_device_manager.cpp
-
78usrc/app_zmodule_device_manager.hpp
-
448usrc/intelligent_winding_robot_ctrl.cpp
-
151usrc/intelligent_winding_robot_ctrl.hpp
-
5usrc/main.cpp
-
1usrc/project_configs.h
@ -1 +1 @@ |
|||
Subproject commit 74b48f099c773a5cd6d4f402a671746792e57851 |
|||
Subproject commit d4c0048415ea76a2baf4cf731b7ae7d97298b22d |
@ -0,0 +1,193 @@ |
|||
#include "app_zmodule_device_manager.hpp"
|
|||
|
|||
#include "sdk/os/zos.hpp"
|
|||
|
|||
#define TAG "APPDM"
|
|||
|
|||
#define DM ZModuleDeviceManager
|
|||
|
|||
using namespace iflytop; |
|||
void APPDM::initialize(IZcanCmderMaster *m_cancmder) { //
|
|||
DM::initialize(m_cancmder); |
|||
} |
|||
|
|||
void APPDM::registerModule(ZIModule *module) { DM::registerModule(module); } |
|||
/*******************************************************************************
|
|||
* ZIModule * |
|||
*******************************************************************************/ |
|||
|
|||
#define DOCMD(exptr) \
|
|||
{ \ |
|||
int32_t errcode = exptr; \ |
|||
if (errcode != 0) { \ |
|||
ZLOGE(TAG, "do %s fail,errcode %s(%d)", #exptr, err::error2str(errcode), errcode); \ |
|||
} \ |
|||
return errcode; \ |
|||
} |
|||
|
|||
int32_t APPDM::module_stop(uint16_t id) { //
|
|||
ZLOGI(TAG, "module_stop %d", id); |
|||
DOCMD(DM::module_stop(id)); |
|||
} |
|||
int32_t APPDM::module_break(uint16_t id) { //
|
|||
|
|||
ZLOGI(TAG, "module_break %d", id); |
|||
DOCMD(DM::module_break(id)); |
|||
} |
|||
|
|||
int32_t APPDM::module_get_last_exec_status(uint16_t id, int32_t *status) { //
|
|||
DOCMD(DM::module_get_last_exec_status(id, status)); |
|||
} |
|||
int32_t APPDM::module_get_status(uint16_t id, int32_t *status) { //
|
|||
DOCMD(DM::module_get_status(id, status)); |
|||
} |
|||
|
|||
int32_t APPDM::module_set_param(uint16_t id, int32_t param_id, int32_t param_value) { //
|
|||
ZLOGI(TAG, "module_set_param %d %d", id, param_value); |
|||
DOCMD(DM::module_set_param(id, param_id, param_value)); |
|||
} |
|||
int32_t APPDM::module_get_param(uint16_t id, int32_t param_id, int32_t *param_value) { //
|
|||
DOCMD(DM::module_get_param(id, param_id, param_value)); |
|||
} |
|||
|
|||
int32_t APPDM::module_readio(uint16_t id, int32_t *io) { //
|
|||
DOCMD(DM::module_readio(id, io)); |
|||
} |
|||
int32_t APPDM::module_writeio(uint16_t id, int32_t io) { //
|
|||
|
|||
ZLOGI(TAG, "module_writeio %d %d", id, io); |
|||
DOCMD(DM::module_writeio(id, io)); |
|||
} |
|||
|
|||
int32_t APPDM::module_read_adc(uint16_t id, int32_t adcindex, int32_t *adc) { //
|
|||
DOCMD(DM::module_read_adc(id, adcindex, adc)); |
|||
} |
|||
|
|||
int32_t APPDM::module_get_error(uint16_t id, int32_t *iserror) { //
|
|||
DOCMD(DM::module_get_error(id, iserror)); |
|||
} |
|||
int32_t APPDM::module_clear_error(uint16_t id) { //
|
|||
ZLOGI(TAG, "module_clear_error %d", id); |
|||
DOCMD(DM::module_clear_error(id)); |
|||
} |
|||
|
|||
int32_t APPDM::module_set_inited_flag(uint16_t id, int32_t flag) { //
|
|||
ZLOGI(TAG, "module_set_inited_flag %d %d", id, flag); |
|||
DOCMD(DM::module_set_inited_flag(id, flag)); |
|||
} |
|||
int32_t APPDM::module_get_inited_flag(uint16_t id, int32_t *flag) { //
|
|||
DOCMD(DM::module_get_inited_flag(id, flag)); |
|||
} |
|||
|
|||
int32_t APPDM::module_factory_reset(uint16_t id) { //
|
|||
ZLOGI(TAG, "module_factory_reset %d", id); |
|||
DOCMD(DM::module_factory_reset(id)); |
|||
} |
|||
int32_t APPDM::module_flush_cfg(uint16_t id) { //
|
|||
ZLOGI(TAG, "module_flush_cfg %d", id); |
|||
DOCMD(DM::module_flush_cfg(id)); |
|||
} |
|||
int32_t APPDM::module_active_cfg(uint16_t id) { //
|
|||
ZLOGI(TAG, "module_active_cfg %d", id); |
|||
DOCMD(DM::module_active_cfg(id)); |
|||
} |
|||
|
|||
int32_t APPDM::module_set_state(uint16_t id, int32_t state_id, int32_t state_value) { //
|
|||
ZLOGI(TAG, "module_set_state %d %d %d", id, state_id, state_value); |
|||
DOCMD(DM::module_set_state(id, state_id, state_value)); |
|||
} |
|||
int32_t APPDM::module_get_state(uint16_t id, int32_t state_id, int32_t *state_value) { //
|
|||
DOCMD(DM::module_get_state(id, state_id, state_value)); |
|||
} |
|||
|
|||
/*******************************************************************************
|
|||
* ZIMotor * |
|||
*******************************************************************************/ |
|||
|
|||
int32_t APPDM::motor_enable(uint16_t id, int32_t enable) { //
|
|||
ZLOGI(TAG, "motor_enable %d %d", id, enable); |
|||
DOCMD(DM::motor_enable(id, enable)); |
|||
} |
|||
int32_t APPDM::motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc) { //
|
|||
ZLOGI(TAG, "motor_rotate %d %d %d %d", id, direction, motor_velocity, acc); |
|||
DOCMD(DM::motor_rotate(id, direction, motor_velocity, acc)); |
|||
} |
|||
int32_t APPDM::motor_move_by(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acc) { //
|
|||
ZLOGI(TAG, "motor_move_by %d %d %d %d", id, distance, motor_velocity, acc); |
|||
DOCMD(DM::motor_move_by(id, distance, motor_velocity, acc)); |
|||
} |
|||
int32_t APPDM::motor_move_to(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acc) { //
|
|||
ZLOGI(TAG, "motor_move_to %d %d %d %d", id, position, motor_velocity, acc); |
|||
DOCMD(DM::motor_move_to(id, position, motor_velocity, acc)); |
|||
} |
|||
int32_t APPDM::motor_rotate_acctime(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acctime) { //
|
|||
ZLOGI(TAG, "motor_rotate_acctime %d %d %d %d", id, direction, motor_velocity, acctime); |
|||
DOCMD(DM::motor_rotate_acctime(id, direction, motor_velocity, acctime)); |
|||
} |
|||
int32_t APPDM::motor_move_by_acctime(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acctime) { //
|
|||
ZLOGI(TAG, "motor_move_by_acctime %d %d %d %d", id, distance, motor_velocity, acctime); |
|||
DOCMD(DM::motor_move_by_acctime(id, distance, motor_velocity, acctime)); |
|||
} |
|||
int32_t APPDM::motor_move_to_acctime(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acctime) { //
|
|||
ZLOGI(TAG, "motor_move_to_acctime %d %d %d %d", id, position, motor_velocity, acctime); |
|||
DOCMD(DM::motor_move_to_acctime(id, position, motor_velocity, acctime)); |
|||
} |
|||
int32_t APPDM::motor_move_to_zero_forward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { //
|
|||
ZLOGI(TAG, "motor_move_to_zero_forward %d %d %d %d %d", id, findzerospeed, findzeroedge_speed, acc, overtime); |
|||
DOCMD(DM::motor_move_to_zero_forward(id, findzerospeed, findzeroedge_speed, acc, overtime)); |
|||
} |
|||
int32_t APPDM::motor_move_to_zero_backward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { //
|
|||
ZLOGI(TAG, "motor_move_to_zero_backward %d %d %d %d %d", id, findzerospeed, findzeroedge_speed, acc, overtime); |
|||
DOCMD(DM::motor_move_to_zero_backward(id, findzerospeed, findzeroedge_speed, acc, overtime)); |
|||
} |
|||
int32_t APPDM::motor_move_to_with_torque(uint16_t id, int32_t direction, int32_t torque) { //
|
|||
ZLOGI(TAG, "motor_move_to_with_torque %d %d %d", id, direction, torque); |
|||
DOCMD(DM::motor_move_to_with_torque(id, direction, torque)); |
|||
} |
|||
int32_t APPDM::motor_read_pos(uint16_t id, int32_t *pos) { //
|
|||
DOCMD(DM::motor_read_pos(id, pos)); |
|||
} |
|||
int32_t APPDM::motor_set_current_pos_by_change_shift(uint16_t id, int32_t pos) { //
|
|||
ZLOGI(TAG, "motor_set_current_pos_by_change_shift %d %d", id, pos); |
|||
DOCMD(DM::motor_set_current_pos_by_change_shift(id, pos)); |
|||
} |
|||
int32_t APPDM::motor_move_to_zero_forward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { //
|
|||
ZLOGI(TAG, "motor_move_to_zero_forward_and_calculated_shift %d %d %d %d %d", id, findzerospeed, findzeroedge_speed, acc, overtime); |
|||
DOCMD(DM::motor_move_to_zero_forward_and_calculated_shift(id, findzerospeed, findzeroedge_speed, acc, overtime)); |
|||
} |
|||
int32_t APPDM::motor_move_to_zero_backward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { //
|
|||
ZLOGI(TAG, "motor_move_to_zero_backward_and_calculated_shift %d %d %d %d %d", id, findzerospeed, findzeroedge_speed, acc, overtime); |
|||
DOCMD(DM::motor_move_to_zero_backward_and_calculated_shift(id, findzerospeed, findzeroedge_speed, acc, overtime)); |
|||
} |
|||
|
|||
/*******************************************************************************
|
|||
* ZIXYMotor * |
|||
*******************************************************************************/ |
|||
|
|||
int32_t APPDM::xymotor_enable(uint16_t id, int32_t enable) { //
|
|||
ZLOGI(TAG, "xymotor_enable %d %d", id, enable); |
|||
DOCMD(DM::xymotor_enable(id, enable)); |
|||
} |
|||
int32_t APPDM::xymotor_move_by(uint16_t id, int32_t dx, int32_t dy, int32_t motor_velocity) { //
|
|||
ZLOGI(TAG, "xymotor_move_by %d %d %d %d", id, dx, dy, motor_velocity); |
|||
DOCMD(DM::xymotor_move_by(id, dx, dy, motor_velocity)); |
|||
} |
|||
int32_t APPDM::xymotor_move_to(uint16_t id, int32_t x, int32_t y, int32_t motor_velocity) { //
|
|||
ZLOGI(TAG, "xymotor_move_to %d %d %d %d", id, x, y, motor_velocity); |
|||
DOCMD(DM::xymotor_move_to(id, x, y, motor_velocity)); |
|||
} |
|||
int32_t APPDM::xymotor_move_to_zero(uint16_t id) { //
|
|||
ZLOGI(TAG, "xymotor_move_to_zero %d", id); |
|||
DOCMD(DM::xymotor_move_to_zero(id)); |
|||
} |
|||
int32_t APPDM::xymotor_move_to_zero_and_calculated_shift(uint16_t id) { //
|
|||
ZLOGI(TAG, "xymotor_move_to_zero_and_calculated_shift %d", id); |
|||
DOCMD(DM::xymotor_move_to_zero_and_calculated_shift(id)); |
|||
} |
|||
int32_t APPDM::xymotor_read_pos(uint16_t id, int32_t *x, int32_t *y) { //
|
|||
DOCMD(DM::xymotor_read_pos(id, x, y)); |
|||
} |
|||
int32_t APPDM::xymotor_calculated_pos_by_move_to_zero(uint16_t id) { //
|
|||
ZLOGI(TAG, "xymotor_calculated_pos_by_move_to_zero %d", id); |
|||
DOCMD(DM::xymotor_calculated_pos_by_move_to_zero(id)); |
|||
} |
@ -0,0 +1,78 @@ |
|||
#pragma once
|
|||
#include <map>
|
|||
|
|||
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
|
|||
|
|||
namespace iflytop { |
|||
class APPDM : public ZModuleDeviceManager { |
|||
private: |
|||
|
|||
public: |
|||
void initialize(IZcanCmderMaster *m_cancmder); |
|||
void registerModule(ZIModule *module); |
|||
|
|||
/*******************************************************************************
|
|||
* ZIModule * |
|||
*******************************************************************************/ |
|||
virtual int32_t module_stop(uint16_t id) override; |
|||
virtual int32_t module_break(uint16_t id) override; |
|||
|
|||
virtual int32_t module_get_last_exec_status(uint16_t id, int32_t *status) override; |
|||
virtual int32_t module_get_status(uint16_t id, int32_t *status) override; |
|||
|
|||
virtual int32_t module_set_param(uint16_t id, int32_t param_id, int32_t param_value) override; |
|||
virtual int32_t module_get_param(uint16_t id, int32_t param_id, int32_t *param_value) override; |
|||
|
|||
virtual int32_t module_readio(uint16_t id, int32_t *io) override; |
|||
virtual int32_t module_writeio(uint16_t id, int32_t io) override; |
|||
|
|||
virtual int32_t module_read_adc(uint16_t id, int32_t adcindex, int32_t *adc) override; |
|||
|
|||
virtual int32_t module_get_error(uint16_t id, int32_t *iserror) override; |
|||
virtual int32_t module_clear_error(uint16_t id) override; |
|||
|
|||
virtual int32_t module_set_inited_flag(uint16_t id, int32_t flag) override; |
|||
virtual int32_t module_get_inited_flag(uint16_t id, int32_t *flag) override; |
|||
|
|||
virtual int32_t module_factory_reset(uint16_t id) override; |
|||
virtual int32_t module_flush_cfg(uint16_t id) override; |
|||
virtual int32_t module_active_cfg(uint16_t id) override; |
|||
|
|||
virtual int32_t module_set_state(uint16_t id, int32_t state_id, int32_t state_value) override; |
|||
virtual int32_t module_get_state(uint16_t id, int32_t state_id, int32_t *state_value) override; |
|||
|
|||
/*******************************************************************************
|
|||
* ZIMotor * |
|||
*******************************************************************************/ |
|||
|
|||
virtual int32_t motor_enable(uint16_t id, int32_t enable) override; |
|||
virtual int32_t motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc) override; |
|||
virtual int32_t motor_move_by(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acc) override; |
|||
virtual int32_t motor_move_to(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acc) override; |
|||
virtual int32_t motor_rotate_acctime(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acctime) override; |
|||
virtual int32_t motor_move_by_acctime(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acctime) override; |
|||
virtual int32_t motor_move_to_acctime(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acctime) override; |
|||
virtual int32_t motor_move_to_zero_forward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
virtual int32_t motor_move_to_zero_backward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
virtual int32_t motor_move_to_with_torque(uint16_t id, int32_t direction, int32_t torque) override; |
|||
virtual int32_t motor_read_pos(uint16_t id, int32_t *pos) override; |
|||
virtual int32_t motor_set_current_pos_by_change_shift(uint16_t id, int32_t pos) override; |
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(uint16_t id, 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(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
|
|||
/*******************************************************************************
|
|||
* ZIXYMotor * |
|||
*******************************************************************************/ |
|||
|
|||
virtual int32_t xymotor_enable(uint16_t id, int32_t enable) override; |
|||
virtual int32_t xymotor_move_by(uint16_t id, int32_t dx, int32_t dy, int32_t motor_velocity) override; |
|||
virtual int32_t xymotor_move_to(uint16_t id, int32_t x, int32_t y, int32_t motor_velocity) override; |
|||
virtual int32_t xymotor_move_to_zero(uint16_t id) override; |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift(uint16_t id) override; |
|||
virtual int32_t xymotor_read_pos(uint16_t id, int32_t *x, int32_t *y) override; |
|||
virtual int32_t xymotor_calculated_pos_by_move_to_zero(uint16_t id) override; |
|||
|
|||
private: |
|||
}; |
|||
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue