Код: Выделить всё
int Interp::convert_cycle_zx(int motion, //!< a g-code between G_81 and G_89, a canned cycle
block_pointer block, //!< pointer to a block of RS274 instructions
setup_pointer settings) //!< pointer to machine settings
{
double aa;
double aa_increment=0.;
double bb;
double bb_increment=0.;
double cc;
double clear_cc;
double i;
double j;
double k;
double old_cc;
double radius_increment = 0.;
double theta_increment = 0.;
CANON_PLANE plane;
double r;
int repeat;
CANON_MOTION_MODE save_mode;
double save_tolerance; //save current path-following tolerance, to restore it lateron
double current_cc = settings->current_y;
plane = CANON_PLANE_XZ;
if (settings->motion_mode != motion) {
CHKS((!block->y_flag),
_readers[(int)'y']? NCE_Y_VALUE_UNSPECIFIED_IN_XZ_PLANE_CANNED_CYCLE: _("G18 canned cycle is not possible on a machine without Y axis"));
}
block->y_number =
block->y_flag ? block->y_number : settings->cycle_cc;
if(settings->cycle_il_flag) {
old_cc = settings->cycle_il;
} else {
old_cc = settings->cycle_il = current_cc;
settings->cycle_il_flag = true;
}
if (settings->distance_mode == MODE_ABSOLUTE) {
aa_increment = 0.0;
bb_increment = 0.0;
r = block->r_number;
cc = block->y_number;
aa = block->z_flag ? block->z_number : settings->current_z;
bb = block->x_flag ? block->x_number : settings->current_x;
} else if (settings->distance_mode == MODE_INCREMENTAL) {
if (block->z_flag) aa_increment = block->z_number;
if (block->x_flag) bb_increment = block->x_number;
r = (block->r_number + old_cc);
cc = (r + block->y_number); /* [NCMS, page 98] */
aa = settings->current_z;
bb = settings->current_x;
} else
ERS(NCE_BUG_DISTANCE_MODE_NOT_G90_OR_G91);
CHKS((r < cc), NCE_R_LESS_THAN_Y_IN_CYCLE_IN_XZ_PLANE);
if (old_cc < r) {
STRAIGHT_TRAVERSE(block->line_number, settings->current_x, r, settings->current_z,
settings->AA_current, settings->BB_current, settings->CC_current,
settings->u_current, settings->v_current, settings->w_current);
old_cc = r;
current_cc = old_cc;
}
clear_cc = (settings->retract_mode == R_PLANE) ? r : old_cc;
save_mode = GET_EXTERNAL_MOTION_CONTROL_MODE();
save_tolerance = GET_EXTERNAL_MOTION_CONTROL_TOLERANCE();
if (save_mode != CANON_EXACT_PATH)
SET_MOTION_CONTROL_MODE(CANON_EXACT_PATH, 0);
switch (motion) {
case G_81:
CYCLE_MACRO(convert_cycle_g81(block, CANON_PLANE_XZ, aa, bb, clear_cc, cc))
break;
case G_82:
CHKS(((settings->motion_mode != G_82) && (block->p_number == -1.0)),
NCE_DWELL_TIME_P_WORD_MISSING_WITH_G82);
block->p_number =
block->p_number == -1.0 ? settings->cycle_p : block->p_number;
CYCLE_MACRO(convert_cycle_g82(block, CANON_PLANE_XZ, aa, bb, clear_cc, cc,
block->p_number))
settings->cycle_p = block->p_number;
break;
case G_73:
CHKS(((settings->motion_mode != G_73) && (block->q_number == -1.0)),
NCE_Q_WORD_MISSING_WITH_G73);
block->q_number =
block->q_number == -1.0 ? settings->cycle_q : block->q_number;
CYCLE_MACRO(convert_cycle_g73(block, CANON_PLANE_XZ, aa, bb, r, clear_cc, cc,
block->q_number))
settings->cycle_q = block->q_number;
break;
case G_83:
CHKS(((settings->motion_mode != G_83) && (block->q_number == -1.0)),
NCE_Q_WORD_MISSING_WITH_G83);
block->q_number =
block->q_number == -1.0 ? settings->cycle_q : block->q_number;
CYCLE_MACRO(convert_cycle_g83(block, CANON_PLANE_XZ, aa, bb, r, clear_cc, cc,
block->q_number))
settings->cycle_q = block->q_number;
break;
case G_84:
CYCLE_MACRO(convert_cycle_g84(block, CANON_PLANE_XZ, aa, bb, clear_cc, cc,
settings->spindle_turning,
settings->speed_feed_mode)) break;
case G_85:
CYCLE_MACRO(convert_cycle_g85(block, CANON_PLANE_XZ, aa, bb, r, clear_cc, cc))
break;
case G_86:
CHKS(((settings->motion_mode != G_86) && (block->p_number == -1.0)),
NCE_DWELL_TIME_P_WORD_MISSING_WITH_G86);
block->p_number =
block->p_number == -1.0 ? settings->cycle_p : block->p_number;
CYCLE_MACRO(convert_cycle_g86(block, CANON_PLANE_XZ, aa, bb, clear_cc, cc,
block->p_number,
settings->spindle_turning)) settings->
cycle_p = block->p_number;
break;
case G_87:
if (settings->motion_mode != G_87) {
CHKS((!block->i_flag), NCE_I_WORD_MISSING_WITH_G87);
CHKS((!block->j_flag), NCE_J_WORD_MISSING_WITH_G87);
CHKS((!block->k_flag), NCE_K_WORD_MISSING_WITH_G87);
}
i = block->i_flag ? block->i_number : settings->cycle_i;
j = block->j_flag ? block->j_number : settings->cycle_j;
k = block->k_flag ? block->k_number : settings->cycle_k;
settings->cycle_i = i;
settings->cycle_j = j;
settings->cycle_k = k;
if (settings->distance_mode == MODE_INCREMENTAL) {
j = (cc + j); /* j always absolute in function call below */
}
CYCLE_MACRO(convert_cycle_g87(block, CANON_PLANE_XZ, aa, (aa + k), bb,
(bb + i), r, clear_cc, j, cc,
settings->spindle_turning)) break;
case G_88:
CHKS(((settings->motion_mode != G_88) && (block->p_number == -1.0)),
NCE_DWELL_TIME_P_WORD_MISSING_WITH_G88);
block->p_number =
block->p_number == -1.0 ? settings->cycle_p : block->p_number;
CYCLE_MACRO(convert_cycle_g88(block, CANON_PLANE_XZ, aa, bb, cc,
block->p_number,
settings->spindle_turning)) settings->
cycle_p = block->p_number;
break;
case G_89:
CHKS(((settings->motion_mode != G_89) && (block->p_number == -1.0)),
NCE_DWELL_TIME_P_WORD_MISSING_WITH_G89);
block->p_number =
block->p_number == -1.0 ? settings->cycle_p : block->p_number;
CYCLE_MACRO(convert_cycle_g89(block, CANON_PLANE_XZ, aa, bb, clear_cc, cc,
block->p_number))
settings->cycle_p = block->p_number;
break;
default:
ERS(NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);
}
settings->current_z = aa; /* CYCLE_MACRO updates aa and bb */
settings->current_x = bb;
settings->current_y = clear_cc;
settings->cycle_cc = block->y_number;
if (save_mode != CANON_EXACT_PATH)
SET_MOTION_CONTROL_MODE(save_mode, save_tolerance);
return INTERP_OK;
}