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.

118 lines
3.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #pragma once
  2. #include <stdint.h>
  3. #include <functional>
  4. #include "basic_type.hpp"
  5. //
  6. namespace iflytop {
  7. using namespace std;
  8. class I_MiniServoModule {
  9. public:
  10. typedef enum { kNormalStop, kBreakStop } StopType_t;
  11. #pragma pack(1)
  12. #if 0
  13. typedef struct {
  14. s32 exec_status;
  15. s32 has_run_time;
  16. } rotate_cb_status_t;
  17. typedef struct {
  18. s32 exec_status;
  19. s32 pos;
  20. } move_to_cb_status_t;
  21. typedef struct {
  22. s32 exec_status;
  23. s32 dpos;
  24. } move_by_cb_status_t;
  25. typedef struct {
  26. s32 exec_status;
  27. s32 has_run_time;
  28. } run_with_torque_cb_status_t;
  29. typedef struct {
  30. s32 exec_status;
  31. s32 pos;
  32. } move_by_nolimit_cb_status_t;
  33. #endif
  34. /*******************************************************************************
  35. * READ *
  36. *******************************************************************************/
  37. typedef struct {
  38. int32_t version;
  39. } version_t;
  40. typedef struct {
  41. uint8_t status; // 0:normal 1:������ 2:offline 3:����
  42. uint8_t io_state; //
  43. int16_t torque; //
  44. int16_t speed; //
  45. int16_t pos; //
  46. } status_t;
  47. typedef struct {
  48. uint8_t status;
  49. uint8_t io_state;
  50. int16_t torque;
  51. int16_t speed;
  52. int16_t pos;
  53. int16_t voltage;
  54. int16_t current;
  55. int16_t temperature;
  56. int16_t error_flag;
  57. } detailed_status_t;
  58. /*******************************************************************************
  59. * CFG *
  60. *******************************************************************************/
  61. typedef struct {
  62. s16 pos_calibrate;
  63. } basic_param_t;
  64. typedef struct {
  65. s16 minlimit;
  66. s16 maxlimit;
  67. } run_param_t;
  68. typedef struct {
  69. s16 mintemp;
  70. s16 maxtemp;
  71. s16 minvoltage;
  72. s16 maxvoltage;
  73. s16 mincurrent;
  74. s16 maxcurrent;
  75. } warning_limit_param_t;
  76. #pragma pack()
  77. public:
  78. virtual int32_t enable(u8 enable) = 0;
  79. virtual int32_t stop(u8 stop_type) = 0;
  80. virtual int32_t position_calibrate(s32 calibrate_pos) = 0;
  81. virtual int32_t rotate(s32 speed, s32 torque, s32 run_time, action_cb_status_t status_cb) = 0;
  82. virtual int32_t move_to(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) = 0;
  83. virtual int32_t move_by(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) = 0;
  84. virtual int32_t run_with_torque(s32 torque, s32 run_time, action_cb_status_t status_cb) = 0;
  85. virtual int32_t move_by_nolimit(s32 pos, s32 speed, s32 torque, action_cb_status_t status_cb) = 0;
  86. virtual int32_t read_version(version_t& version) = 0;
  87. virtual int32_t read_status(status_t& status) = 0;
  88. virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0;
  89. virtual int32_t set_run_param(run_param_t& param) = 0;
  90. virtual int32_t set_basic_param(basic_param_t& param) = 0;
  91. virtual int32_t set_warning_limit_param(warning_limit_param_t& param) = 0;
  92. virtual int32_t get_run_param(run_param_t& param) = 0;
  93. virtual int32_t get_basic_param(basic_param_t& param) = 0;
  94. virtual int32_t get_warning_limit_param(warning_limit_param_t& param) = 0;
  95. virtual ~I_MiniServoModule() {}
  96. };
  97. } // namespace iflytop