正点原子开发板 alientek_develop_board cancmder
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.

257 lines
7.2 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
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
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
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 "sdk/os/zos.hpp"
  3. #include "sdk\components\zprotocols\zcancmder_v2\api\api.hpp"
  4. #include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
  5. //
  6. #include "app_zmodule_device_manager.hpp"
  7. #define ZMOTOR_ID 4
  8. #define XYRobot_ID 3
  9. #define XYRobot_HOOK_ID 21
  10. namespace iflytop {
  11. using namespace std;
  12. class IntelligentWindingRobotCtrl {
  13. public:
  14. typedef struct {
  15. int32_t m2_zerooff;
  16. /**
  17. * @brief еۼ߶
  18. */
  19. int32_t m11_arm_jiaxian_reset_pos;
  20. int32_t m11_arm_jiaxian_clamp_direction;
  21. int32_t m11_arm_jiaxian_clamp_torque;
  22. /**
  23. * @brief ߼н
  24. */
  25. int32_t m12_jiaxian_reset_pos;
  26. int32_t m12_jiaxian_clamp_direction;
  27. int32_t m12_jiaxian_clamp_torque;
  28. /**
  29. * @brief ѹ߶
  30. */
  31. /**
  32. * ߶:
  33. * 1. ûе 1015
  34. * 2. е 1055
  35. * 3. п 1110
  36. *
  37. */
  38. int32_t m13_yaxian_forward_reset_pos; // ѹ������λ
  39. int32_t m13_yaxian_backward_reset_pos; // ��������λ
  40. int32_t m13_jiaxian_clamp_direction; // ѹ�߷���
  41. int32_t m13_jiaxian_clamp_torque; // ѹ��Ť��
  42. /**
  43. * @brief ̽
  44. */
  45. int32_t m14_raoxiantance_reset_pos;
  46. int32_t m14_raoxiantance_tance_zero_pos;
  47. /**
  48. * @brief ŷ϶
  49. */
  50. int32_t m15_paifei_reset_pos;
  51. int32_t m15_paifei_press_direction;
  52. int32_t m15_paifei_press_torque;
  53. /**
  54. * @brief
  55. */
  56. int32_t m16_xianlajin_reset_pos;
  57. int32_t m16_xianlajin_tight_line_pos;
  58. int32_t m16_xianlajin_winding_low_pos;
  59. int32_t m16_xianlajin_winding_high_pos;
  60. int32_t m16_xianlajin_line_entry_pos;
  61. int32_t m16_xianlajin_cook_line_end_ready_pos;
  62. int32_t m16_xianlajin_cook_line_end_high_pos;
  63. int32_t m16_xianlajin_cook_line_end_low_pos;
  64. /**
  65. * @brief צ
  66. */
  67. int32_t m21_arm_hook_claws_half_pos;
  68. int32_t m21_arm_hook_claws_full_pos;
  69. /**
  70. * @brief
  71. */
  72. // int32_t m22_scissors_cut_pos;
  73. /**
  74. * @brief
  75. */
  76. // int32_t m23_laxian_move_to_tight_pos;
  77. /**
  78. * @brief Zλ
  79. */
  80. int32_t z_axis_take_line_high;
  81. int32_t z_axis_take_clip_pos;
  82. int32_t z_axis_winding_hight;
  83. int32_t z_axis_transfer_line_high;
  84. int32_t z_axis_remove_line_high;
  85. // 2585
  86. // 3377
  87. int32_t z_axis_cook_bullet_pos;
  88. /**
  89. * @brief XYƽ̨
  90. */
  91. int32_t xy_platform_cook_bullet_pos_x; // ���߼ӹ�
  92. int32_t xy_platform_cook_bullet_pos_y; // ���߼ӹ�
  93. int32_t xy_platform_remove_line_pos_x; // ����λ
  94. int32_t xy_platform_remove_line_pos_y; // ����λ
  95. int32_t xy_platform_takeline_pos_x; // ȡ��λ��
  96. int32_t xy_platform_takeline_pos_y; // ȡ��λ��
  97. int32_t xy_platform_enter_line_pos_x; // ����λ
  98. int32_t xy_platform_enter_line_pos_y; // ����λ
  99. //
  100. int32_t xy_platform_takeline_clip00_pos_x; //
  101. int32_t xy_platform_takeline_clip00_pos_y;
  102. int32_t xy_platform_takeline_clipXX_pos_x;
  103. int32_t xy_platform_takeline_clipXX_pos_y;
  104. int32_t clip_line;
  105. int32_t clip_each_line_num;
  106. } config_t;
  107. APPDM* m_dm;
  108. ICmdParser* m_cmdparse;
  109. config_t cfg;
  110. ZThread m_work_thread;
  111. ZThread m_detect_thread;
  112. typedef enum {
  113. kBulletBulletHolderPos = 0,
  114. kCookPos,
  115. } take_bullet_pos_type_t;
  116. typedef enum {
  117. kTakeBullet = 0,
  118. kTakeBackBullet,
  119. kTakeBulletCase,
  120. kTakeBackBulletCase,
  121. } take_bullet_acktion_t;
  122. typedef enum {
  123. kTakeLine = 0,
  124. kReleaseLine,
  125. kKeepLine,
  126. } take_bullet_line_acktion_t;
  127. bool m_iswinding = false;
  128. int32_t m_nowwinding_index = 0;
  129. int32_t m_exception_val = 0;
  130. typedef struct {
  131. int32_t index;
  132. } winding_event_t;
  133. public:
  134. int32_t initialize(APPDM* dm, ICmdParser* cmdparse);
  135. private:
  136. void start_probe_bullet_pos();
  137. void start_probe_bullet_pos_forward();
  138. void stop_probe_bullet_pos();
  139. int32_t get_probe_bullet_pos();
  140. bool is_hasbullet();
  141. public:
  142. void wait_module_idle(int32_t moduleid);
  143. void wait_modules_idle(void* mark, ...);
  144. int32_t m11_arm_jiaxian_move_to_reset_pos();
  145. int32_t m11_arm_jiaxian_move_to_clamp_pos();
  146. int32_t m12_jiaxian_move_to_open_pos();
  147. int32_t m12_jiaxian_move_to_clamp_pos();
  148. int32_t m13_yaxian_move_to_reset_forward();
  149. int32_t m13_yaxian_move_to_reset_backward();
  150. int32_t m13_yaxian_press_clip();
  151. int32_t m14_raoxiantance_move_to_reset();
  152. int32_t m15_paifei_moveto_reset();
  153. int32_t m15_paifei_moveto_press();
  154. int32_t m16_xianlajin_move_to_reset();
  155. int32_t m16_xianlajin_move_to_tight_line_pos();
  156. int32_t m16_xianlajin_move_to_winding_low_pos();
  157. int32_t m16_xianlajin_move_to_winding_up_pos();
  158. int32_t m16_xianlajin_move_to_line_entry_pos();
  159. int32_t m16_xianlajin_move_to_cook_lineend_high_pos();
  160. int32_t m16_xianlajin_move_to_cook_lineend_low_pos();
  161. int32_t m16_xianlajin_move_to_cook_lineend_ready_pos();
  162. int32_t m21_arm_hook_claws_reset();
  163. int32_t m21_arm_hook_claws_move_to_half_pos();
  164. int32_t m21_arm_hook_claws_move_to_full_pos();
  165. int32_t m22_scissors_move_reset_pos(); //
  166. int32_t m22_scissors_cut(); //
  167. int32_t m23_laxian_motor_move_to_reset_pos(); //
  168. int32_t m23_laxian_motor_move_to_tight_line_pos(); //
  169. int32_t m4_zreset();
  170. int32_t m4_zmove_to(int32_t pos);
  171. int32_t device_reset();
  172. int32_t disable_all_module();
  173. int32_t enable_all_module();
  174. int32_t substep_zaxis_do_bullet_action(take_bullet_pos_type_t zpos, //
  175. take_bullet_acktion_t take_bullet_acktion, //
  176. take_bullet_line_acktion_t take_bullet_line_acktion, //
  177. function<void()> bottomoperation = nullptr);
  178. int32_t step_take_bullet(int32_t bulletindex);
  179. int32_t step_take_back_bullet(int32_t bulletindex);
  180. int32_t step_take_bullet_case(int32_t bulletindex);
  181. int32_t step_take_back_bullet_case(int32_t bulletindex);
  182. int32_t step_prepare_remove_line(int32_t bulletindex, bool& hasbullet);
  183. int32_t step_remove_line();
  184. int32_t step_winding_prepare();
  185. int32_t step_winding();
  186. // int32_t step_load_the_bullet_case();
  187. int32_t step_winding_lineend_prepare(int bulletindex); // ����ͷ׼��
  188. int32_t step_winding_lineend(); // ����ͷ
  189. int32_t step_winding_take_bullet_from_cooking_to_origin_pos(int bulletindex); // ����ͷ
  190. int32_t xy_get_point(int32_t clip_index, int32_t& x, int32_t& y); // ȡ����
  191. int32_t xy_run_to(int32_t x, int32_t y, int32_t zpos = 0, bool jiaxian_reset = true); // ȡ����
  192. int32_t xy_reset();
  193. int32_t xymove_to(int32_t x, int32_t y);
  194. int32_t xymove_to_bullet_pos(int32_t bulletindex);
  195. void regcb();
  196. int32_t initialize_device();
  197. /**
  198. * @brief
  199. */
  200. int32_t setcfg(const char* cfgname, int32_t cfgvalue);
  201. public:
  202. int32_t start_winding();
  203. int32_t stop_winding();
  204. int32_t dumpcfg();
  205. int32_t do_winding(int32_t index);
  206. int32_t get_winding_index() { return m_nowwinding_index; }
  207. bool iswinding() { return m_iswinding; }
  208. int32_t get_exception_val() { return m_exception_val; }
  209. void processError(int32_t err);
  210. };
  211. } // namespace iflytop