⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interp_convert.cc

📁 Source code for an Numeric Cmputer
💻 CC
📖 第 1 页 / 共 5 页
字号:
  } else    ERM(NCE_BUG_CODE_NOT_IN_G92_SERIES);  return INTERP_OK;}/****************************************************************************//*! convert_commentReturned Value: int (INTERP_OK)Side effects:   The message function is called if the string starts with "MSG,".   Otherwise, the comment function is called.Called by: execute_blockTo be a message, the first four characters of the comment after theopening left parenthesis must be "MSG,", ignoring the case of theletters and allowing spaces or tabs anywhere before the comma (to makethe treatment of case and white space consistent with how it ishandled elsewhere).Messages are not provided for in [NCMS]. They are implemented here as asubtype of comment. This is an extension to the rs274NGC language.*/int Interp::convert_comment(char *comment)       //!< string with comment{  enum  { LC_SIZE = 256 };            // 256 from comment[256] in rs274ngc.hh  char lc[LC_SIZE];  char MSG_STR[] = "msg,";  char SYSTEM_STR[] = "system,";  int m, n, start;  // step over leading white space in comment  m = 0;  while (isspace(comment[m]))    m++;  start = m;  // copy lowercase comment to lc[]  for (n = 0; n < LC_SIZE && comment[m] != 0; m++, n++) {    lc[n] = tolower(comment[m]);  }  lc[n] = 0;                    // null terminate  // compare with MSG, SYSTEM  if (!strncmp(lc, MSG_STR, strlen(MSG_STR))) {    MESSAGE(comment + start + strlen(MSG_STR));    return INTERP_OK;  } else if (!strncmp(lc, SYSTEM_STR, strlen(SYSTEM_STR))) {/*! \todo Implement SYSTEM commands in the task controller *//*! \todo Another #if 0 */#if 0/*! \todo FIX-ME Impliment these at a later stage... */    SYSTEM(comment + start + strlen(SYSTEM_STR));    return INTERP_EXECUTE_FINISH;     // inhibit read-ahead until this is done#endif  }  // else it's a real comment  COMMENT(comment + start);  return INTERP_OK;}/****************************************************************************//*! convert_control_modeReturned Value: int   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. g_code isn't G_61, G_61_1 or G_64: NCE_BUG_CODE_NOT_G61_G61_1_OR_G64Side effects: See belowCalled by: convert_g.The interpreter switches the machine settings to indicate thecontrol mode (CANON_EXACT_STOP, CANON_EXACT_PATH or CANON_CONTINUOUS).A call is made to SET_MOTION_CONTROL_MODE(CANON_XXX), where CANON_XXX isCANON_EXACT_PATH if g_code is G_61, CANON_EXACT_STOP if g_code is G_61_1,and CANON_CONTINUOUS if g_code is G_64.Setting the control mode to CANON_EXACT_STOP on G_61 would correspondmore closely to the meaning of G_61 as given in [NCMS, page 40], butCANON_EXACT_PATH has the advantage that the tool does not stop if itdoes not have to, and no evident disadvantage compared toCANON_EXACT_STOP, so it is being used for G_61. G_61_1 is not definedin [NCMS], so it is available and is used here for setting the controlmode to CANON_EXACT_STOP.It is OK to call SET_MOTION_CONTROL_MODE(CANON_XXX) when CANON_XXX isalready in force.*/int Interp::convert_control_mode(int g_code,     //!< g_code being executed (G_61, G61_1, || G_64)				double tolerance,    //tolerance for the path following in G64                                setup_pointer settings) //!< pointer to machine settings                 {  static char name[] = "convert_control_mode";  if (g_code == G_61) {    SET_MOTION_CONTROL_MODE(CANON_EXACT_PATH, 0);    settings->control_mode = CANON_EXACT_PATH;  } else if (g_code == G_61_1) {    SET_MOTION_CONTROL_MODE(CANON_EXACT_STOP, 0);    settings->control_mode = CANON_EXACT_STOP;  } else if (g_code == G_64) {	if (tolerance >= 0) {	    SET_MOTION_CONTROL_MODE(CANON_CONTINUOUS, tolerance);	} else {	    SET_MOTION_CONTROL_MODE(CANON_CONTINUOUS, 0);	}    settings->control_mode = CANON_CONTINUOUS;  } else    ERM(NCE_BUG_CODE_NOT_G61_G61_1_OR_G64);  return INTERP_OK;}/****************************************************************************//*! convert_coordinate_systemReturned Value: int   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. The value of the g_code argument is not 540, 550, 560, 570, 580, 590      591, 592, or 593:      NCE_BUG_CODE_NOT_IN_RANGE_G54_TO_G593Side effects:   If the coordinate system selected by the g_code is not already in   use, the canonical program coordinate system axis offset values are   reset and the coordinate values of the current point are reset.Called by: convert_g.COORDINATE SYSTEMS (involves g10, g53, g54 - g59.3, g92)The canonical machining functions view of coordinate systems is:1. There are two coordinate systems: absolute and program.2. All coordinate values are given in terms of the program coordinate system.3. The offsets of the program coordinate system may be reset.The RS274/NGC view of coordinate systems, as given in section 3.2of [NCMS] is:1. there are ten coordinate systems: absolute and 9 program. The   program coordinate systems are numbered 1 to 9.2. you can switch among the 9 but not to the absolute one. G54   selects coordinate system 1, G55 selects 2, and so on through   G56, G57, G58, G59, G59.1, G59.2, and G59.3.3. you can set the offsets of the 9 program coordinate systems   using G10 L2 Pn (n is the number of the coordinate system) with   values for the axes in terms of the absolute coordinate system.4. the first one of the 9 program coordinate systems is the default.5. data for coordinate systems is stored in parameters [NCMS, pages 59 - 60].6. g53 means to interpret coordinate values in terms of the absolute   coordinate system for the one block in which g53 appears.7. You can offset the current coordinate system using g92. This offset   will then apply to all nine program coordinate systems.The approach used in the interpreter mates the canonical and NGC viewsof coordinate systems as follows:During initialization, data from the parameters for the first NGCcoordinate system is used in a SET_ORIGIN_OFFSETS function call andorigin_index in the machine model is set to 1.If a g_code in the range g54 - g59.3 is encountered in an NC program,the data from the appropriate NGC coordinate system is copied into theorigin offsets used by the interpreter, a SET_ORIGIN_OFFSETS functioncall is made, and the current position is reset.If a g10 is encountered, the convert_setup function is called to resetthe offsets of the program coordinate system indicated by the P numbergiven in the same block.If a g53 is encountered, the axis values given in that block are usedto calculate what the coordinates are of that point in the currentcoordinate system, and a STRAIGHT_TRAVERSE or STRAIGHT_FEED functioncall to that point using the calculated values is made. No offsetvalues are changed.If a g92 is encountered, that is handled by the convert_axis_offsetsfunction. A g92 results in an axis offset for each axis being calculatedand stored in the machine model. The axis offsets are applied to allnine coordinate systems. Axis offsets are initialized to zero.*/int Interp::convert_coordinate_system(int g_code,        //!< g_code called (must be one listed above)                                          setup_pointer settings)    //!< pointer to machine settings                  {  static char name[] = "convert_coordinate_system";  int origin;  double x;  double y;  double z;  double a;  double b;  double c;  double *parameters;  parameters = settings->parameters;  switch (g_code) {  case 540:    origin = 1;    break;  case 550:    origin = 2;    break;  case 560:    origin = 3;    break;  case 570:    origin = 4;    break;  case 580:    origin = 5;    break;  case 590:    origin = 6;    break;  case 591:    origin = 7;    break;  case 592:    origin = 8;    break;  case 593:    origin = 9;    break;  default:    ERM(NCE_BUG_CODE_NOT_IN_RANGE_G54_TO_G593);  }  if (origin == settings->origin_index) {       /* already using this origin */#ifdef DEBUG_EMC    COMMENT("interpreter: continuing to use same coordinate system");#endif    return INTERP_OK;  }  settings->origin_index = origin;  parameters[5220] = (double) origin;/* axis offsets could be included in the two set of calculations for   current_x, current_y, etc., but do not need to be because the results   would be the same. They would be added in then subtracted out. */  settings->current_x = (settings->current_x + settings->origin_offset_x);  settings->current_y = (settings->current_y + settings->origin_offset_y);  settings->current_z = (settings->current_z + settings->origin_offset_z);  settings->AA_current = (settings->AA_current + settings->AA_origin_offset);  settings->BB_current = (settings->BB_current + settings->BB_origin_offset);  settings->CC_current = (settings->CC_current + settings->CC_origin_offset);  x = USER_TO_PROGRAM_LEN(parameters[5201 + (origin * 20)]);  y = USER_TO_PROGRAM_LEN(parameters[5202 + (origin * 20)]);  z = USER_TO_PROGRAM_LEN(parameters[5203 + (origin * 20)]);  a = USER_TO_PROGRAM_ANG(parameters[5204 + (origin * 20)]);  b = USER_TO_PROGRAM_ANG(parameters[5205 + (origin * 20)]);  c = USER_TO_PROGRAM_ANG(parameters[5206 + (origin * 20)]);  settings->origin_offset_x = x;  settings->origin_offset_y = y;  settings->origin_offset_z = z;  settings->AA_origin_offset = a;  settings->BB_origin_offset = b;  settings->CC_origin_offset = c;  settings->current_x = (settings->current_x - x);  settings->current_y = (settings->current_y - y);  settings->current_z = (settings->current_z - z);  settings->AA_current = (settings->AA_current - a);  settings->BB_current = (settings->BB_current - b);  settings->CC_current = (settings->CC_current - c);  SET_ORIGIN_OFFSETS(x + settings->axis_offset_x,                     y + settings->axis_offset_y, z + settings->axis_offset_z,                     a + settings->AA_axis_offset,                     b + settings->BB_axis_offset,                     c + settings->CC_axis_offset);  return INTERP_OK;}/****************************************************************************//*! convert_cutter_compensationReturned Value: int   If convert_cutter_compensation_on or convert_cutter_compensation_off      is called and returns an error code, this returns that code.   If any of the following errors occur, this returns the error shown.   Otherwise, it returns INTERP_OK.   1. g_code is not G_40, G_41, or G_42:      NCE_BUG_CODE_NOT_G40_G41_OR_G42Side effects:   The value of cutter_comp_side in the machine model mode is   set to RIGHT, LEFT, or OFF. The currently active tool table index in   the machine model (which is the index of the slot whose diameter   value is used in cutter radius compensation) is updated.Since cutter radius compensation is performed in the interpreter, nocall is made to any canonical function regarding cutter radius compensation.Called by: convert_g*/int Interp::convert_cutter_compensation(int g_code,      //!< must be G_40, G_41, or G_42                                                    block_pointer block,     //!< pointer to a block of RS274 instructions                                       setup_pointer settings)  //!< pointer to machine settings             {  static char name[] = "convert_cutter_compensation";  int status;  if (g_code == G_40) {    CHP(convert_cutter_compensation_off(settings));  } else if (g_code == G_41) {    CHP(convert_cutter_compensation_on(LEFT, block, settings));  } else if (g_code == G_42) {    CHP(convert_cutter_compensation_on(RIGHT, block, settings));  } else    ERM(NCE_BUG_CODE_NOT_G40_G41_OR_G42);  return INTERP_OK;}/****************************************************************************//*! convert_cutter_compensation_offReturned Value: int (INTERP_OK)Side effects:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -