|
@ -64,8 +64,9 @@ class WidthDetector { |
|
|
|
|
|
|
|
|
void wait_module_idle(int32_t moduleid, int32_t timeout_ms) { |
|
|
void wait_module_idle(int32_t moduleid, int32_t timeout_ms) { |
|
|
zos_delay(100); |
|
|
zos_delay(100); |
|
|
int i = 0; |
|
|
|
|
|
int32_t enterticket = zos_get_tick(); |
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
|
|
int32_t enterticket = zos_get_tick(); |
|
|
|
|
|
ThisThread thisThread; |
|
|
while (true) { |
|
|
while (true) { |
|
|
int32_t status = 0; |
|
|
int32_t status = 0; |
|
|
int32_t ecode = m_dm->module_get_status(moduleid, &status); |
|
|
int32_t ecode = m_dm->module_get_status(moduleid, &status); |
|
@ -86,15 +87,18 @@ class WidthDetector { |
|
|
throw (int32_t)err::kcatch_exception; |
|
|
throw (int32_t)err::kcatch_exception; |
|
|
break; |
|
|
break; |
|
|
}; |
|
|
}; |
|
|
if (i % 30 == 0) { |
|
|
|
|
|
|
|
|
if (i % 1000 == 0) { |
|
|
ZLOGI(TAG, "wait_module_idle %d %d....", moduleid, status); |
|
|
ZLOGI(TAG, "wait_module_idle %d %d....", moduleid, status); |
|
|
} |
|
|
} |
|
|
i++; |
|
|
i++; |
|
|
zos_delay(10); |
|
|
zos_delay(10); |
|
|
|
|
|
if (thisThread.getExitFlag()) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void m14_raoxiantance_move_to_reset() { m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 330, 0); } |
|
|
|
|
|
|
|
|
void m14_raoxiantance_move_to_reset() { m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 500, 0); } |
|
|
void start_run_back() { |
|
|
void start_run_back() { |
|
|
m_dm->motor_move_to(14, cfg->m14_raoxiantance_reset_pos, 30, 0); |
|
|
m_dm->motor_move_to(14, cfg->m14_raoxiantance_reset_pos, 30, 0); |
|
|
g_isrunning = true; |
|
|
g_isrunning = true; |
|
@ -104,7 +108,7 @@ class WidthDetector { |
|
|
g_isrunning = true; |
|
|
g_isrunning = true; |
|
|
} |
|
|
} |
|
|
void start_run_forward() { |
|
|
void start_run_forward() { |
|
|
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos + 100, 330, 0); |
|
|
|
|
|
|
|
|
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos + 100, 500, 0); |
|
|
g_isrunning = true; |
|
|
g_isrunning = true; |
|
|
} |
|
|
} |
|
|
void stop_run() { |
|
|
void stop_run() { |
|
@ -184,7 +188,7 @@ class WidthDetector { |
|
|
void stopDetect() { |
|
|
void stopDetect() { |
|
|
m_detect_thread.stop(); |
|
|
m_detect_thread.stop(); |
|
|
|
|
|
|
|
|
m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 330, 0); |
|
|
|
|
|
|
|
|
m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 500, 0); |
|
|
wait_module_idle(14, 0); |
|
|
wait_module_idle(14, 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -202,6 +206,14 @@ class WidthDetector { |
|
|
|
|
|
|
|
|
WidthDetector g_widthDetector; |
|
|
WidthDetector g_widthDetector; |
|
|
|
|
|
|
|
|
|
|
|
static void prv_sleep(int32_t ms) { |
|
|
|
|
|
ThisThread thisThread; |
|
|
|
|
|
thisThread.sleep(ms); |
|
|
|
|
|
|
|
|
|
|
|
if (thisThread.getExitFlag()) { |
|
|
|
|
|
throw (int32_t)0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
int32_t IntelligentWindingRobotCtrl::initialize(APPDM* dm, ICmdParser* cmdparse) { |
|
|
int32_t IntelligentWindingRobotCtrl::initialize(APPDM* dm, ICmdParser* cmdparse) { |
|
|
m_dm = dm; |
|
|
m_dm = dm; |
|
|
m_cmdparse = cmdparse; |
|
|
m_cmdparse = cmdparse; |
|
@ -277,63 +289,8 @@ int32_t IntelligentWindingRobotCtrl::initialize_device() { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void IntelligentWindingRobotCtrl::regcb() { |
|
|
|
|
|
// device_reset
|
|
|
|
|
|
m_cmdparse->regCMD("device_reset", "()", 0, [this](PARAM) { device_reset(); }); |
|
|
|
|
|
m_cmdparse->regCMD("enable_all_module", "()", 0, [this](PARAM) { enable_all_module(); }); |
|
|
|
|
|
m_cmdparse->regCMD("disable_all_module", "()", 0, [this](PARAM) { disable_all_module(); }); |
|
|
|
|
|
// m_cmdparse->regCMD("xy_run_to_clip_pos_test", "()", 1, [this](PARAM) { return xy_run_to_clip_pos_test(atoi(paraV[0])); });
|
|
|
|
|
|
m_cmdparse->regCMD("step_take_bullet", "()", 1, [this](PARAM) { return step_take_bullet(atoi(paraV[0])); }); |
|
|
|
|
|
m_cmdparse->regCMD("step_take_back_bullet", "()", 1, [this](PARAM) { return step_take_back_bullet(atoi(paraV[0])); }); |
|
|
|
|
|
m_cmdparse->regCMD("step_prepare_remove_line", "()", 1, [this](PARAM) { |
|
|
|
|
|
bool hasbullet = false; |
|
|
|
|
|
return step_prepare_remove_line(atoi(paraV[0]), hasbullet); |
|
|
|
|
|
}); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_prepare", "()", 0, [this](PARAM) { return step_winding_prepare(); }); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding", "()", 0, [this](PARAM) { return step_winding(); }); |
|
|
|
|
|
m_cmdparse->regCMD("step_remove_line", "()", 0, [this](PARAM) { return step_remove_line(); }); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_lineend", "()", 0, [this](PARAM) { return step_winding_lineend(); }); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_lineend_prepare", "()", 1, [this](PARAM) { return step_winding_lineend_prepare(atoi(paraV[0])); }); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_take_bullet_from_cooking_to_origin_pos", "()", 1, [this](PARAM) { return step_winding_take_bullet_from_cooking_to_origin_pos(atoi(paraV[0])); }); |
|
|
|
|
|
m_cmdparse->regCMD("start_winding", "()", 0, [this](PARAM) { return start_winding(); }); |
|
|
|
|
|
m_cmdparse->regCMD("stop_winding", "()", 0, [this](PARAM) { return stop_winding(); }); |
|
|
|
|
|
m_cmdparse->regCMD("start_remove_line", "()", 0, [this](PARAM) { return start_remove_line(); }); |
|
|
|
|
|
|
|
|
|
|
|
// m_cmdparse->regCMD("disable_all_motor", "()", 0, [this](PARAM) { return disable_all_motor(); });
|
|
|
|
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("m11_arm_jiaxian_move_to_reset_pos", "()", 0, [this](PARAM) { return m11_arm_jiaxian_move_to_reset_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m11_arm_jiaxian_move_to_clamp_pos", "()", 0, [this](PARAM) { return m11_arm_jiaxian_move_to_clamp_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m12_jiaxian_move_to_open_pos", "()", 0, [this](PARAM) { return m12_jiaxian_move_to_open_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m12_jiaxian_move_to_clamp_pos", "()", 0, [this](PARAM) { return m12_jiaxian_move_to_clamp_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m13_yaxian_move_to_reset_forward", "()", 0, [this](PARAM) { return m13_yaxian_move_to_reset_forward(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m13_yaxian_move_to_reset_backward", "()", 0, [this](PARAM) { return m13_yaxian_move_to_reset_backward(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m13_yaxian_press_clip", "()", 0, [this](PARAM) { return m13_yaxian_press_clip(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m14_raoxiantance_move_to_reset", "()", 0, [this](PARAM) { return m14_raoxiantance_move_to_reset(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m15_paifei_moveto_reset", "()", 0, [this](PARAM) { return m15_paifei_moveto_reset(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m15_paifei_moveto_press", "()", 0, [this](PARAM) { return m15_paifei_moveto_press(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_reset", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_reset(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_tight_line_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_tight_line_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_winding_low_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_winding_low_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_winding_up_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_winding_up_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_line_entry_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_line_entry_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_high_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_cook_lineend_high_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_low_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_cook_lineend_low_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_ready_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_cook_lineend_ready_pos(); }); |
|
|
|
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("m21_arm_hook_claws_reset", "()", 0, [this](PARAM) { return m21_arm_hook_claws_reset(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m21_arm_hook_claws_move_to_half_pos", "()", 0, [this](PARAM) { return m21_arm_hook_claws_move_to_half_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m21_arm_hook_claws_move_to_full_pos", "()", 0, [this](PARAM) { return m21_arm_hook_claws_move_to_full_pos(); }); |
|
|
|
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("m22_scissors_move_reset_pos", "()", 0, [this](PARAM) { return m22_scissors_move_reset_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m22_scissors_cut", "()", 0, [this](PARAM) { return m22_scissors_cut(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m23_laxian_motor_move_to_reset_pos", "()", 0, [this](PARAM) { return m23_laxian_motor_move_to_reset_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("m23_laxian_motor_move_to_tight_line_pos", "()", 0, [this](PARAM) { return m23_laxian_motor_move_to_tight_line_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("start_probe_bullet_pos", "()", 0, [this](PARAM) { return start_probe_bullet_pos(); }); |
|
|
|
|
|
m_cmdparse->regCMD("start_probe_bullet_pos_forward", "()", 0, [this](PARAM) { return start_probe_bullet_pos_forward(); }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void IntelligentWindingRobotCtrl::wait_module_idle(int32_t moduleid, int32_t timeout_ms) { |
|
|
void IntelligentWindingRobotCtrl::wait_module_idle(int32_t moduleid, int32_t timeout_ms) { |
|
|
zos_delay(100); |
|
|
|
|
|
|
|
|
prv_sleep(100); |
|
|
int i = 0; |
|
|
int i = 0; |
|
|
int32_t enterticket = zos_get_tick(); |
|
|
int32_t enterticket = zos_get_tick(); |
|
|
while (true) { |
|
|
while (true) { |
|
@ -356,11 +313,11 @@ void IntelligentWindingRobotCtrl::wait_module_idle(int32_t moduleid, int32_t tim |
|
|
throw (int32_t)err::kcatch_exception; |
|
|
throw (int32_t)err::kcatch_exception; |
|
|
break; |
|
|
break; |
|
|
}; |
|
|
}; |
|
|
if (i % 30 == 0) { |
|
|
|
|
|
|
|
|
if (i % 1000 == 0) { |
|
|
ZLOGI(TAG, "wait_module_idle %d %d....", moduleid, status); |
|
|
ZLOGI(TAG, "wait_module_idle %d %d....", moduleid, status); |
|
|
} |
|
|
} |
|
|
i++; |
|
|
i++; |
|
|
zos_delay(10); |
|
|
|
|
|
|
|
|
prv_sleep(10); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -392,6 +349,7 @@ int32_t IntelligentWindingRobotCtrl::stop_all_module() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::disable_all_module() { |
|
|
int32_t IntelligentWindingRobotCtrl::disable_all_module() { |
|
|
|
|
|
ZLOGI(TAG, "m_dm->motor_enable(2, 0)"); |
|
|
m_dm->motor_enable(2, 0); |
|
|
m_dm->motor_enable(2, 0); |
|
|
m_dm->xymotor_enable(3, 0); |
|
|
m_dm->xymotor_enable(3, 0); |
|
|
m_dm->motor_enable(4, 0); |
|
|
m_dm->motor_enable(4, 0); |
|
@ -655,6 +613,7 @@ int32_t IntelligentWindingRobotCtrl::step_prepare_remove_line(int32_t bulletinde |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
if (is_hasbullet()) { |
|
|
if (is_hasbullet()) { |
|
|
|
|
|
stop_probe_bullet_pos(); |
|
|
xymove_to(cfg.xy_platform_cook_bullet_pos_x, cfg.xy_platform_cook_bullet_pos_y - 3623); |
|
|
xymove_to(cfg.xy_platform_cook_bullet_pos_x, cfg.xy_platform_cook_bullet_pos_y - 3623); |
|
|
xymove_to(cfg.xy_platform_remove_line_pos_x, cfg.xy_platform_cook_bullet_pos_y - 3623); |
|
|
xymove_to(cfg.xy_platform_remove_line_pos_x, cfg.xy_platform_cook_bullet_pos_y - 3623); |
|
|
xymove_to(cfg.xy_platform_remove_line_pos_x, cfg.xy_platform_remove_line_pos_y); |
|
|
xymove_to(cfg.xy_platform_remove_line_pos_x, cfg.xy_platform_remove_line_pos_y); |
|
@ -687,12 +646,13 @@ int32_t IntelligentWindingRobotCtrl::step_prepare_remove_line(int32_t bulletinde |
|
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::step_remove_line() { |
|
|
int32_t IntelligentWindingRobotCtrl::step_remove_line() { |
|
|
ZLOGI(TAG, "step_remove_line"); |
|
|
ZLOGI(TAG, "step_remove_line"); |
|
|
start_probe_bullet_pos_forward(); |
|
|
|
|
|
m15_paifei_moveto_press(); |
|
|
m15_paifei_moveto_press(); |
|
|
WAIT_MODULES_IDLE(15); |
|
|
WAIT_MODULES_IDLE(15); |
|
|
|
|
|
|
|
|
m_dm->motor_rotate_acctime(2, -1, 1000, 1000); |
|
|
m_dm->motor_rotate_acctime(2, -1, 1000, 1000); |
|
|
int overtime = 90; |
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
int overtime = 30; |
|
|
|
|
|
|
|
|
for (int i = 0; i < overtime; i++) { |
|
|
for (int i = 0; i < overtime; i++) { |
|
|
osDelay(1000); |
|
|
osDelay(1000); |
|
|
if (g_widthDetector.isRemoveLineEnd()) { |
|
|
if (g_widthDetector.isRemoveLineEnd()) { |
|
@ -707,8 +667,15 @@ int32_t IntelligentWindingRobotCtrl::step_remove_line() { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
osDelay(10 * 1000); |
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
prv_sleep(30 * 1000); |
|
|
m_dm->module_stop(2); |
|
|
m_dm->module_stop(2); |
|
|
|
|
|
start_probe_bullet_pos_forward(); |
|
|
|
|
|
if (!g_widthDetector.isRemoveLineEnd()) { |
|
|
|
|
|
throw (int32_t)0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// m15_paifei_moveto_reset();
|
|
|
// m15_paifei_moveto_reset();
|
|
|
m15_paifei_moveto_reset(); |
|
|
m15_paifei_moveto_reset(); |
|
|
stop_probe_bullet_pos(); |
|
|
stop_probe_bullet_pos(); |
|
@ -783,7 +750,8 @@ int32_t IntelligentWindingRobotCtrl::step_winding() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (g_widthDetector.distanceIsStopChange()) { |
|
|
if (g_widthDetector.distanceIsStopChange()) { |
|
|
ZLOGI(TAG, "distanceIsStopChange......"); |
|
|
|
|
|
|
|
|
ZLOGW(TAG, "distanceIsStopChange......"); |
|
|
|
|
|
throw 0; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1009,46 +977,10 @@ int32_t IntelligentWindingRobotCtrl::setcfg(const char* cfgname, int32_t cfgvalu |
|
|
int32_t IntelligentWindingRobotCtrl::dumpcfg() { return 0; } |
|
|
int32_t IntelligentWindingRobotCtrl::dumpcfg() { return 0; } |
|
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::start_winding() { //
|
|
|
int32_t IntelligentWindingRobotCtrl::start_winding() { //
|
|
|
|
|
|
#if 0
|
|
|
m_work_thread.start([this]() { |
|
|
m_work_thread.start([this]() { |
|
|
try { |
|
|
try { |
|
|
ZLOGI(TAG, "start_winding"); |
|
|
|
|
|
m_iswinding = true; |
|
|
|
|
|
m_nowwinding_index = 0; |
|
|
|
|
|
device_reset(); |
|
|
|
|
|
bool hasbullet = false; |
|
|
|
|
|
for (size_t i = 0; i < 5 * 12; i++) { |
|
|
|
|
|
if (m_work_thread.getExitFlag()) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (!(i / 5 == 0 || i / 5 == 6 || i / 5 == 11)) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_nowwinding_index = i + 1; |
|
|
|
|
|
step_take_bullet(i); |
|
|
|
|
|
step_prepare_remove_line(i, hasbullet); |
|
|
|
|
|
if (!hasbullet) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
step_remove_line(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_prepare(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_lineend_prepare(i); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_lineend(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_take_bullet_from_cooking_to_origin_pos(i); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m4_zmove_to(0); |
|
|
|
|
|
wait_module_idle(4); |
|
|
|
|
|
xymove_to(0, 0); |
|
|
|
|
|
wait_module_idle(3); |
|
|
|
|
|
stop_all_module(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (int32_t ecode) { |
|
|
} catch (int32_t ecode) { |
|
|
ZLOGE(TAG, "work thread catch exception %d", ecode); |
|
|
ZLOGE(TAG, "work thread catch exception %d", ecode); |
|
@ -1059,59 +991,184 @@ int32_t IntelligentWindingRobotCtrl::start_winding() { // |
|
|
} |
|
|
} |
|
|
m_iswinding = false; |
|
|
m_iswinding = false; |
|
|
}); |
|
|
}); |
|
|
|
|
|
#endif
|
|
|
|
|
|
ZLOGI(TAG, "start_winding"); |
|
|
|
|
|
m_iswinding = true; |
|
|
|
|
|
m_nowwinding_index = 0; |
|
|
|
|
|
device_reset(); |
|
|
|
|
|
bool hasbullet = false; |
|
|
|
|
|
for (size_t i = 0; i < 5 * 12; i++) { |
|
|
|
|
|
if (m_work_thread.getExitFlag()) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (!(i / 5 == 0 || i / 5 == 6 || i / 5 == 11)) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_nowwinding_index = i + 1; |
|
|
|
|
|
step_take_bullet(i); |
|
|
|
|
|
step_prepare_remove_line(i, hasbullet); |
|
|
|
|
|
if (!hasbullet) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
step_remove_line(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_prepare(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_lineend_prepare(i); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_lineend(); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
step_winding_take_bullet_from_cooking_to_origin_pos(i); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m4_zmove_to(0); |
|
|
|
|
|
wait_module_idle(4); |
|
|
|
|
|
xymove_to(0, 0); |
|
|
|
|
|
wait_module_idle(3); |
|
|
|
|
|
stop_all_module(); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
int32_t IntelligentWindingRobotCtrl::start_remove_line() { |
|
|
int32_t IntelligentWindingRobotCtrl::start_remove_line() { |
|
|
//
|
|
|
//
|
|
|
m_work_thread.start([this]() { |
|
|
|
|
|
try { |
|
|
|
|
|
ZLOGI(TAG, "start_winding"); |
|
|
|
|
|
m_iswinding = true; |
|
|
|
|
|
m_nowwinding_index = 0; |
|
|
|
|
|
device_reset(); |
|
|
|
|
|
bool hasbullet = false; |
|
|
|
|
|
for (size_t i = 0; i < 5 * 12; i++) { |
|
|
|
|
|
if (m_work_thread.getExitFlag()) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (!(i / 5 == 0 || i / 5 == 6 || i / 5 == 11)) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
ZLOGI(TAG, "start_winding"); |
|
|
|
|
|
m_iswinding = true; |
|
|
|
|
|
m_nowwinding_index = 0; |
|
|
|
|
|
device_reset(); |
|
|
|
|
|
bool hasbullet = false; |
|
|
|
|
|
for (size_t i = 0; i < 5 * 12; i++) { |
|
|
|
|
|
if (m_work_thread.getExitFlag()) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (!(i / 5 == 0 || i / 5 == 6 || i / 5 == 11)) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
m_nowwinding_index = i + 1; |
|
|
|
|
|
step_take_bullet(i); |
|
|
|
|
|
step_prepare_remove_line(i, hasbullet); |
|
|
|
|
|
if (!hasbullet) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
step_remove_line(); |
|
|
|
|
|
stop_probe_bullet_pos(); |
|
|
|
|
|
substep_zaxis_do_bullet_action(kCookPos, kTakeBullet, kKeepLine, NULL); |
|
|
|
|
|
xymove_to_bullet_pos(i); |
|
|
|
|
|
substep_zaxis_do_bullet_action(kBulletBulletHolderPos, kTakeBackBullet, kReleaseLine, NULL); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
|
|
|
m_nowwinding_index = i + 1; |
|
|
|
|
|
step_take_bullet(i); |
|
|
|
|
|
step_prepare_remove_line(i, hasbullet); |
|
|
|
|
|
if (!hasbullet) { |
|
|
|
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
step_remove_line(); |
|
|
|
|
|
stop_probe_bullet_pos(); |
|
|
|
|
|
substep_zaxis_do_bullet_action(kCookPos, kTakeBullet, kKeepLine, NULL); |
|
|
|
|
|
xymove_to_bullet_pos(i); |
|
|
|
|
|
substep_zaxis_do_bullet_action(kBulletBulletHolderPos, kTakeBackBullet, kReleaseLine, NULL); |
|
|
|
|
|
if (m_work_thread.getExitFlag()) break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m4_zmove_to(0); |
|
|
|
|
|
wait_module_idle(4); |
|
|
|
|
|
xymove_to(0, 0); |
|
|
|
|
|
wait_module_idle(3); |
|
|
|
|
|
stop_all_module(); |
|
|
|
|
|
|
|
|
|
|
|
} catch (int32_t ecode) { |
|
|
|
|
|
ZLOGE(TAG, "work thread catch exception %d", ecode); |
|
|
|
|
|
disable_all_module(); // todo : 完成一个无异常版本
|
|
|
|
|
|
} catch (...) { |
|
|
|
|
|
ZLOGE(TAG, "work thread catch unkown exception"); |
|
|
|
|
|
disable_all_module(); // todo : 完成一个无异常版本
|
|
|
|
|
|
} |
|
|
|
|
|
m_iswinding = false; |
|
|
|
|
|
// m_work_thread.start([this]() {
|
|
|
|
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
// return 0;
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
m4_zmove_to(0); |
|
|
|
|
|
wait_module_idle(4); |
|
|
|
|
|
xymove_to(0, 0); |
|
|
|
|
|
wait_module_idle(3); |
|
|
|
|
|
stop_all_module(); |
|
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::stop_winding() { |
|
|
|
|
|
m_work_thread.stop(); |
|
|
|
|
|
m_iswinding = false; |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::doaction(function<void()> action) { |
|
|
|
|
|
m_work_thread.stop(); |
|
|
|
|
|
m_work_thread.start([this, action]() { |
|
|
|
|
|
try { |
|
|
|
|
|
enable_all_module(); |
|
|
|
|
|
action(); |
|
|
} catch (int32_t ecode) { |
|
|
} catch (int32_t ecode) { |
|
|
ZLOGE(TAG, "work thread catch exception %d", ecode); |
|
|
ZLOGE(TAG, "work thread catch exception %d", ecode); |
|
|
disable_all_module(); // todo : 完成一个无异常版本
|
|
|
|
|
|
|
|
|
stop_all_module(); // todo : 完成一个无异常版本
|
|
|
} catch (...) { |
|
|
} catch (...) { |
|
|
ZLOGE(TAG, "work thread catch unkown exception"); |
|
|
ZLOGE(TAG, "work thread catch unkown exception"); |
|
|
disable_all_module(); // todo : 完成一个无异常版本
|
|
|
|
|
|
|
|
|
stop_all_module(); // todo : 完成一个无异常版本
|
|
|
} |
|
|
} |
|
|
m_iswinding = false; |
|
|
m_iswinding = false; |
|
|
}); |
|
|
}); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::stop_winding() { |
|
|
|
|
|
m_work_thread.stop(); |
|
|
|
|
|
m_iswinding = false; |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#define REG_FUNC(dowhat) \
|
|
|
|
|
|
[this](PARAM) { \ |
|
|
|
|
|
int32_t param0 = 0; \ |
|
|
|
|
|
int32_t param1 = 0; \ |
|
|
|
|
|
int32_t param2 = 0; \ |
|
|
|
|
|
if (paramN >= 1) param0 = atoi(paraV[0]); \ |
|
|
|
|
|
if (paramN >= 2) param1 = atoi(paraV[1]); \ |
|
|
|
|
|
if (paramN >= 3) param2 = atoi(paraV[2]); \ |
|
|
|
|
|
doaction([this, param0, param1, param2]() { dowhat; }); \ |
|
|
|
|
|
return 0; \ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void IntelligentWindingRobotCtrl::regcb() { |
|
|
|
|
|
#if 0
|
|
|
|
|
|
m_cmdparse->regCMD("step_prepare_remove_line", "()", 1, [this](PARAM) { |
|
|
|
|
|
bool hasbullet = false; |
|
|
|
|
|
return step_prepare_remove_line(atoi(paraV[0]), hasbullet); |
|
|
|
|
|
}); |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("device_reset", "()", 0, REG_FUNC(device_reset())); |
|
|
|
|
|
m_cmdparse->regCMD("enable_all_module", "()", 0, REG_FUNC(enable_all_module())); |
|
|
|
|
|
m_cmdparse->regCMD("disable_all_module", "()", 0, REG_FUNC(disable_all_module())); |
|
|
|
|
|
m_cmdparse->regCMD("step_take_bullet", "()", 1, REG_FUNC(step_take_bullet(param0))); |
|
|
|
|
|
m_cmdparse->regCMD("m4_zmove_to", "()", 1, REG_FUNC(m4_zmove_to(param0))); |
|
|
|
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("step_take_back_bullet", "()", 1, REG_FUNC(step_take_back_bullet(param0))); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_prepare", "()", 0, REG_FUNC(step_winding_prepare())); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding", "()", 0, REG_FUNC(step_winding())); |
|
|
|
|
|
m_cmdparse->regCMD("step_remove_line", "()", 0, REG_FUNC(step_remove_line())); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_lineend", "()", 0, REG_FUNC(step_winding_lineend())); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_lineend_prepare", "()", 1, REG_FUNC(step_winding_lineend_prepare(param0))); |
|
|
|
|
|
m_cmdparse->regCMD("step_winding_take_bullet_from_cooking_to_origin_pos", "()", 1, REG_FUNC(step_winding_take_bullet_from_cooking_to_origin_pos(param0))); |
|
|
|
|
|
m_cmdparse->regCMD("start_winding", "()", 0, REG_FUNC(start_winding())); |
|
|
|
|
|
m_cmdparse->regCMD("stop_winding", "()", 0, [this](PARAM) { stop_winding(); }); |
|
|
|
|
|
m_cmdparse->regCMD("start_remove_line", "()", 0, REG_FUNC(start_remove_line())); |
|
|
|
|
|
m_cmdparse->regCMD("m11_arm_jiaxian_move_to_reset_pos", "()", 0, REG_FUNC(m11_arm_jiaxian_move_to_reset_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m11_arm_jiaxian_move_to_clamp_pos", "()", 0, REG_FUNC(m11_arm_jiaxian_move_to_clamp_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m12_jiaxian_move_to_open_pos", "()", 0, REG_FUNC(m12_jiaxian_move_to_open_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m12_jiaxian_move_to_clamp_pos", "()", 0, REG_FUNC(m12_jiaxian_move_to_clamp_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m13_yaxian_move_to_reset_forward", "()", 0, REG_FUNC(m13_yaxian_move_to_reset_forward())); |
|
|
|
|
|
m_cmdparse->regCMD("m13_yaxian_move_to_reset_backward", "()", 0, REG_FUNC(m13_yaxian_move_to_reset_backward())); |
|
|
|
|
|
m_cmdparse->regCMD("m13_yaxian_press_clip", "()", 0, REG_FUNC(m13_yaxian_press_clip())); |
|
|
|
|
|
m_cmdparse->regCMD("m14_raoxiantance_move_to_reset", "()", 0, REG_FUNC(m14_raoxiantance_move_to_reset())); |
|
|
|
|
|
m_cmdparse->regCMD("m15_paifei_moveto_reset", "()", 0, REG_FUNC(m15_paifei_moveto_reset())); |
|
|
|
|
|
m_cmdparse->regCMD("m15_paifei_moveto_press", "()", 0, REG_FUNC(m15_paifei_moveto_press())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_reset", "()", 0, REG_FUNC(m16_xianlajin_move_to_reset())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_tight_line_pos", "()", 0, REG_FUNC(m16_xianlajin_move_to_tight_line_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_winding_low_pos", "()", 0, REG_FUNC(m16_xianlajin_move_to_winding_low_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_winding_up_pos", "()", 0, REG_FUNC(m16_xianlajin_move_to_winding_up_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_line_entry_pos", "()", 0, REG_FUNC(m16_xianlajin_move_to_line_entry_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_high_pos", "()", 0, REG_FUNC(m16_xianlajin_move_to_cook_lineend_high_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_low_pos", "()", 0, REG_FUNC(m16_xianlajin_move_to_cook_lineend_low_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_ready_pos", "()", 0, REG_FUNC(m16_xianlajin_move_to_cook_lineend_ready_pos())); |
|
|
|
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("m21_arm_hook_claws_reset", "()", 0, REG_FUNC(m21_arm_hook_claws_reset())); |
|
|
|
|
|
m_cmdparse->regCMD("m21_arm_hook_claws_move_to_half_pos", "()", 0, REG_FUNC(m21_arm_hook_claws_move_to_half_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m21_arm_hook_claws_move_to_full_pos", "()", 0, REG_FUNC(m21_arm_hook_claws_move_to_full_pos())); |
|
|
|
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("m22_scissors_move_reset_pos", "()", 0, REG_FUNC(m22_scissors_move_reset_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m22_scissors_cut", "()", 0, REG_FUNC(m22_scissors_cut())); |
|
|
|
|
|
m_cmdparse->regCMD("m23_laxian_motor_move_to_reset_pos", "()", 0, REG_FUNC(m23_laxian_motor_move_to_reset_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("m23_laxian_motor_move_to_tight_line_pos", "()", 0, REG_FUNC(m23_laxian_motor_move_to_tight_line_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("start_probe_bullet_pos", "()", 0, REG_FUNC(start_probe_bullet_pos())); |
|
|
|
|
|
m_cmdparse->regCMD("start_probe_bullet_pos_forward", "()", 0, REG_FUNC(start_probe_bullet_pos_forward())); |
|
|
|
|
|
} |