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.

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