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.
39 lines
3.8 KiB
39 lines
3.8 KiB
#include "zmodule_device_manager.hpp"
|
|
using namespace iflytop;
|
|
using namespace std;
|
|
|
|
#define PROXY_IMPL(type, functionName, ...) \
|
|
type *module = nullptr; \
|
|
int32_t ecode = findModule<type>(id, &module); \
|
|
if (ecode != 0) { \
|
|
return ecode; \
|
|
} \
|
|
return module->functionName(__VA_ARGS__);
|
|
/*******************************************************************************
|
|
* ZIModule *
|
|
*******************************************************************************/
|
|
int32_t ZModuleDeviceManager::module_stop(uint16_t id) { PROXY_IMPL(ZIModule, module_stop); }
|
|
int32_t ZModuleDeviceManager::module_break(uint16_t id) { PROXY_IMPL(ZIModule, module_break); }
|
|
int32_t ZModuleDeviceManager::module_get_last_exec_status(uint16_t id, int32_t *ack0) { PROXY_IMPL(ZIModule, module_get_last_exec_status, ack0); }
|
|
int32_t ZModuleDeviceManager::module_get_status(uint16_t id, int32_t *status) { PROXY_IMPL(ZIModule, module_get_status, status); }
|
|
int32_t ZModuleDeviceManager::module_set_param(uint16_t id, int32_t param_id, int32_t param_value) { PROXY_IMPL(ZIModule, module_set_param, param_id, param_value); }
|
|
int32_t ZModuleDeviceManager::module_get_param(uint16_t id, int32_t param_id, int32_t *param_value) { PROXY_IMPL(ZIModule, module_get_param, param_id, param_value); }
|
|
int32_t ZModuleDeviceManager::module_readio(uint16_t id, int32_t *io) { PROXY_IMPL(ZIModule, module_readio, io); }
|
|
int32_t ZModuleDeviceManager::module_writeio(uint16_t id, int32_t io) { PROXY_IMPL(ZIModule, module_writeio, io); }
|
|
int32_t ZModuleDeviceManager::module_read_adc(uint16_t id, int32_t adcindex, int32_t *adc) { PROXY_IMPL(ZIModule, module_read_adc, adcindex, adc); }
|
|
int32_t ZModuleDeviceManager::module_get_error(uint16_t id, int32_t *iserror) { PROXY_IMPL(ZIModule, module_get_error, iserror); }
|
|
int32_t ZModuleDeviceManager::module_clear_error(uint16_t id) { PROXY_IMPL(ZIModule, module_clear_error); }
|
|
/*******************************************************************************
|
|
* ZIMotor *
|
|
*******************************************************************************/
|
|
int32_t ZModuleDeviceManager::motor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIMotor, motor_enable, enable); }
|
|
int32_t ZModuleDeviceManager::motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc) { PROXY_IMPL(ZIMotor, motor_rotate, direction, motor_velocity, acc); }
|
|
int32_t ZModuleDeviceManager::motor_move_by(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acc) { PROXY_IMPL(ZIMotor, motor_move_by, distance, motor_velocity, acc); }
|
|
int32_t ZModuleDeviceManager::motor_move_to(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acc) { PROXY_IMPL(ZIMotor, motor_move_to, position, motor_velocity, acc); }
|
|
int32_t ZModuleDeviceManager::motor_move_to_with_torque(uint16_t id, int32_t pos, int32_t torque) { PROXY_IMPL(ZIMotor, motor_move_to_with_torque, pos, torque); }
|
|
/*******************************************************************************
|
|
* ZIXYMotor *
|
|
*******************************************************************************/
|
|
int32_t ZModuleDeviceManager::xymotor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIXYMotor, xymotor_enable, enable); }
|
|
int32_t ZModuleDeviceManager::xymotor_move_by(uint16_t id, int32_t dx, int32_t dy, int32_t motor_velocity) { PROXY_IMPL(ZIXYMotor, xymotor_move_by, dx, dy, motor_velocity); }
|
|
int32_t ZModuleDeviceManager::xymotor_move_to(uint16_t id, int32_t x, int32_t y, int32_t motor_velocity) { PROXY_IMPL(ZIXYMotor, xymotor_move_to, x, y, motor_velocity); }
|