#pragma once #include "sdk/os/zos.hpp" #include "sdk\components\zprotocols\zcancmder_v2\api\api.hpp" #include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp" // #include "app_zmodule_device_manager.hpp" #define ZMOTOR_ID 4 #define XYRobot_ID 3 #define XYRobot_HOOK_ID 21 namespace iflytop { using namespace std; class IntelligentWindingRobotCtrl { public: typedef struct { int32_t m2_zerooff; /** * @brief 机械臂夹线舵机 */ int32_t m11_arm_jiaxian_reset_pos; int32_t m11_arm_jiaxian_clamp_direction; int32_t m11_arm_jiaxian_clamp_torque; /** * @brief 线夹紧舵机 */ int32_t m12_jiaxian_reset_pos; int32_t m12_jiaxian_clamp_direction; int32_t m12_jiaxian_clamp_torque; /** * @brief 压线舵机 */ /** * 高度: * 1. 没有弹夹 1015 * 2. 有弹夹 1055 * 3. 弹夹有壳 1110 * */ int32_t m13_yaxian_forward_reset_pos; // 压死待机位 int32_t m13_yaxian_backward_reset_pos; // 反向待机位 int32_t m13_jiaxian_clamp_direction; // 压线方向 int32_t m13_jiaxian_clamp_torque; // 压线扭矩 /** * @brief 绕线探测舵机 */ int32_t m14_raoxiantance_reset_pos; int32_t m14_raoxiantance_tance_zero_pos; /** * @brief 排废舵机 */ int32_t m15_paifei_reset_pos; int32_t m15_paifei_press_direction; int32_t m15_paifei_press_torque; /** * @brief 线拉紧舵机 */ int32_t m16_xianlajin_reset_pos; int32_t m16_xianlajin_tight_line_pos; int32_t m16_xianlajin_winding_low_pos; int32_t m16_xianlajin_winding_high_pos; int32_t m16_xianlajin_line_entry_pos; int32_t m16_xianlajin_cook_line_end_ready_pos; int32_t m16_xianlajin_cook_line_end_high_pos; int32_t m16_xianlajin_cook_line_end_low_pos; /** * @brief 钩爪 */ int32_t m21_arm_hook_claws_half_pos; int32_t m21_arm_hook_claws_full_pos; /** * @brief 剪刀 */ // int32_t m22_scissors_cut_pos; /** * @brief 拉线 */ // int32_t m23_laxian_move_to_tight_pos; /** * @brief Z轴定位 */ int32_t z_axis_take_line_high; int32_t z_axis_take_clip_pos; int32_t z_axis_winding_hight; int32_t z_axis_transfer_line_high; int32_t z_axis_remove_line_high; // 2585 // 3377 int32_t z_axis_cook_bullet_pos; /** * @brief XY平台 */ int32_t xy_platform_cook_bullet_pos_x; // 绕线加工 int32_t xy_platform_cook_bullet_pos_y; // 绕线加工 int32_t xy_platform_remove_line_pos_x; // 移线位 int32_t xy_platform_remove_line_pos_y; // 移线位 int32_t xy_platform_takeline_pos_x; // 取线位置 int32_t xy_platform_takeline_pos_y; // 取线位置 int32_t xy_platform_enter_line_pos_x; // 入线位 int32_t xy_platform_enter_line_pos_y; // 入线位 // int32_t xy_platform_takeline_clip00_pos_x; // int32_t xy_platform_takeline_clip00_pos_y; int32_t xy_platform_takeline_clipXX_pos_x; int32_t xy_platform_takeline_clipXX_pos_y; int32_t clip_line; int32_t clip_each_line_num; } config_t; APPDM* m_dm; ICmdParser* m_cmdparse; config_t cfg; ZThread m_work_thread; ZThread m_detect_thread; typedef enum { kBulletBulletHolderPos = 0, kCookPos, } take_bullet_pos_type_t; typedef enum { kTakeBullet = 0, kTakeBackBullet, kTakeBulletCase, kTakeBackBulletCase, } take_bullet_acktion_t; typedef enum { kTakeLine = 0, kReleaseLine, kKeepLine, } take_bullet_line_acktion_t; bool m_iswinding = false; int32_t m_nowwinding_index = 0; int32_t m_exception_val = 0; typedef struct { int32_t index; } winding_event_t; public: int32_t initialize(APPDM* dm, ICmdParser* cmdparse); private: void start_probe_bullet_pos(); void start_probe_bullet_pos_forward(); void stop_probe_bullet_pos(); int32_t get_probe_bullet_pos(); bool is_hasbullet(); public: void wait_module_idle(int32_t moduleid); void wait_modules_idle(void* mark, ...); int32_t m11_arm_jiaxian_move_to_reset_pos(); int32_t m11_arm_jiaxian_move_to_clamp_pos(); int32_t m12_jiaxian_move_to_open_pos(); int32_t m12_jiaxian_move_to_clamp_pos(); int32_t m13_yaxian_move_to_reset_forward(); int32_t m13_yaxian_move_to_reset_backward(); int32_t m13_yaxian_press_clip(); int32_t m14_raoxiantance_move_to_reset(); int32_t m15_paifei_moveto_reset(); int32_t m15_paifei_moveto_press(); int32_t m16_xianlajin_move_to_reset(); int32_t m16_xianlajin_move_to_tight_line_pos(); int32_t m16_xianlajin_move_to_winding_low_pos(); int32_t m16_xianlajin_move_to_winding_up_pos(); int32_t m16_xianlajin_move_to_line_entry_pos(); int32_t m16_xianlajin_move_to_cook_lineend_high_pos(); int32_t m16_xianlajin_move_to_cook_lineend_low_pos(); int32_t m16_xianlajin_move_to_cook_lineend_ready_pos(); int32_t m21_arm_hook_claws_reset(); int32_t m21_arm_hook_claws_move_to_half_pos(); int32_t m21_arm_hook_claws_move_to_full_pos(); int32_t m22_scissors_move_reset_pos(); // int32_t m22_scissors_cut(); // int32_t m23_laxian_motor_move_to_reset_pos(); // int32_t m23_laxian_motor_move_to_tight_line_pos(); // int32_t m4_zreset(); int32_t m4_zmove_to(int32_t pos); int32_t device_reset(); int32_t disable_all_module(); int32_t enable_all_module(); int32_t substep_zaxis_do_bullet_action(take_bullet_pos_type_t zpos, // take_bullet_acktion_t take_bullet_acktion, // take_bullet_line_acktion_t take_bullet_line_acktion, // function bottomoperation = nullptr); int32_t step_take_bullet(int32_t bulletindex); int32_t step_take_back_bullet(int32_t bulletindex); int32_t step_take_bullet_case(int32_t bulletindex); int32_t step_take_back_bullet_case(int32_t bulletindex); int32_t step_prepare_remove_line(int32_t bulletindex, bool& hasbullet); int32_t step_remove_line(); int32_t step_winding_prepare(); int32_t step_winding(); // int32_t step_load_the_bullet_case(); int32_t step_winding_lineend_prepare(int bulletindex); // 绕线头准备 int32_t step_winding_lineend(); // 绕线头 int32_t step_winding_take_bullet_from_cooking_to_origin_pos(int bulletindex); // 绕线头 int32_t xy_get_point(int32_t clip_index, int32_t& x, int32_t& y); // 取弹夹 int32_t xy_run_to(int32_t x, int32_t y, int32_t zpos = 0, bool jiaxian_reset = true); // 取弹夹 int32_t xy_reset(); int32_t xymove_to(int32_t x, int32_t y); int32_t xymove_to_bullet_pos(int32_t bulletindex); void regcb(); int32_t initialize_device(); /** * @brief */ int32_t setcfg(const char* cfgname, int32_t cfgvalue); public: int32_t start_winding(); int32_t stop_winding(); int32_t dumpcfg(); int32_t do_winding(int32_t index); int32_t get_winding_index() { return m_nowwinding_index; } bool iswinding() { return m_iswinding; } int32_t get_exception_val() { return m_exception_val; } void processError(int32_t err); }; } // namespace iflytop