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.

36 lines
3.4 KiB

2 years ago
  1. #include "zmodule_device_manager.hpp"
  2. using namespace iflytop;
  3. using namespace std;
  4. #define PROXY_IMPL(type, functionName, ...) \
  5. type *module = nullptr; \
  6. int32_t ecode = findModule<type>(id, &module); \
  7. if (ecode != 0) { \
  8. return ecode; \
  9. } \
  10. return module->functionName(__VA_ARGS__);
  11. /*******************************************************************************
  12. * ZIModule *
  13. *******************************************************************************/
  14. int32_t ZModuleDeviceManager::stop(uint16_t id) { PROXY_IMPL(ZIModule, stop); }
  15. int32_t ZModuleDeviceManager::brake(uint16_t id) { PROXY_IMPL(ZIModule, brake); }
  16. int32_t ZModuleDeviceManager::get_last_exec_status(uint16_t id, int32_t *ack0) { PROXY_IMPL(ZIModule, get_last_exec_status, ack0); }
  17. int32_t ZModuleDeviceManager::get_status(uint16_t id, int32_t *status) { PROXY_IMPL(ZIModule, get_status, status); }
  18. int32_t ZModuleDeviceManager::set_param(uint16_t id, int32_t param_id, int32_t param_value) { PROXY_IMPL(ZIModule, set_param, param_id, param_value); }
  19. int32_t ZModuleDeviceManager::get_param(uint16_t id, int32_t param_id, int32_t *param_value) { PROXY_IMPL(ZIModule, get_param, param_id, param_value); }
  20. int32_t ZModuleDeviceManager::readio(uint16_t id, int32_t *io) { PROXY_IMPL(ZIModule, readio, io); }
  21. int32_t ZModuleDeviceManager::writeio(uint16_t id, int32_t io) { PROXY_IMPL(ZIModule, writeio, io); }
  22. int32_t ZModuleDeviceManager::read_adc(uint16_t id, int adcindex, int32_t *adc) { PROXY_IMPL(ZIModule, read_adc, adcindex, adc); }
  23. /*******************************************************************************
  24. * ZIMotor *
  25. *******************************************************************************/
  26. int32_t ZModuleDeviceManager::motor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIMotor, motor_enable, enable); }
  27. int32_t ZModuleDeviceManager::motor_rotate(uint16_t id, int32_t direction, int32_t velocitylevel) { PROXY_IMPL(ZIMotor, motor_rotate, direction, velocitylevel); }
  28. int32_t ZModuleDeviceManager::motor_move_by(uint16_t id, int32_t distance, int32_t velocitylevel) { PROXY_IMPL(ZIMotor, motor_move_by, distance, velocitylevel); }
  29. int32_t ZModuleDeviceManager::motor_move_to(uint16_t id, int32_t position, int32_t velocitylevel) { PROXY_IMPL(ZIMotor, motor_move_to, position, velocitylevel); }
  30. 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); }
  31. /*******************************************************************************
  32. * ZIXYMotor *
  33. *******************************************************************************/
  34. int32_t ZModuleDeviceManager::xymotor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIXYMotor, xymotor_enable, enable); }
  35. int32_t ZModuleDeviceManager::xymotor_move_by(uint16_t id, int32_t dx, int32_t dy, int32_t velocitylevel) { PROXY_IMPL(ZIXYMotor, xymotor_move_by, dx, dy, velocitylevel); }
  36. int32_t ZModuleDeviceManager::xymotor_move_to(uint16_t id, int32_t x, int32_t y, int32_t velocitylevel) { PROXY_IMPL(ZIXYMotor, xymotor_move_to, x, y, velocitylevel); }