📄 interp_array.cc
字号:
/********************************************************************* Description: interp_array.cc** This file just allocates space for the static arrays used by the* interpreter.** Author:* License: GPL Version 2* System: Linux* * Copyright (c) 2004 All rights reserved.** Last change:* $Revision: 1.5 $* $Author: paul_c $* $Date: 2005/06/12 21:46:26 $********************************************************************/#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <ctype.h>#include <sys/types.h>#include <sys/stat.h>#include "rs274ngc.hh"#include "rs274ngc_return.hh"/* Interpreter global arrays for g_codes and m_codes. The nth entryin each array is the modal group number corresponding to the nthcode. Entries which are -1 represent illegal codes. Remember g_codesin this interpreter are multiplied by 10.The modal g groups and group numbers defined in [NCMS, pages 71 - 73](see also [Fanuc, pages 43 - 45]) are used here, except the cannedcycles (g80 - g89), which comprise modal g group 9 in [Fanuc], aretreated here as being in the same modal group (group 1) with thestraight moves and arcs (g0, g1, g2,g3). [Fanuc, page 45] says onlyone g_code from any one group may appear on a line, and we arefollowing that rule. The straight_probe move, g38.2, is in group 1; itis not defined in [NCMS].Some g_codes are non-modal (g4, g10, g28, g30, g53, g92, g92.1, g92.2,and g92.3 here - many more in [NCMS]). [Fanuc] and [NCMS] put allthese in the same group 0, so we do also. Logically, there are twosubgroups, those which require coordinate values (g10, g28, g30, andg92) and those which do not (g4, g53, g92.1, g92.2, and g92.3).The subgroups are identified by itemization when necessary.Those in group 0 which require coordinate values may not be on thesame line as those in group 1 (except g80) because they would becompeting for the coordinate values. Others in group 0 may be used onthe same line as those in group 1.A total of 52 G-codes are implemented.The groups are:group 0 = {g4,g10,g28,g30,g53,g92,g92.1,g92.2,g92.3} - NON-MODAL dwell, setup, return to ref1, return to ref2, motion in machine coordinates, set and unset axis offsetsgroup 1 = {g0,g1,g2,g3,g33,g38.2,g80,g81,g82,g83,g84,g85,g86,g87,g88,g89} - motiongroup 2 = {g17,g18,g19} - plane selectiongroup 3 = {g90,g91} - distance modegroup 5 = {g93,g94} - feed rate modegroup 6 = {g20,g21} - unitsgroup 7 = {g40,g41,g42} - cutter diameter compensationgroup 8 = {g43,g49} - tool length offsetgroup 10 = {g98,g99} - return mode in canned cyclesgroup 12 = {g54,g55,g56,g57,g58,g59,g59.1,g59.2,g59.3} - coordinate systemgroup 13 = {g61,g61.1,g64} - control mode*/// This stops indent from reformatting the following code.// *INDENT-OFF*const int Interp::_gees[] = {/* 0 */ 1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 20 */ 1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 40 */ 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 60 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 80 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 100 */ 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 120 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 140 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 160 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 180 */ 2,-1,-1,-1,-1,-1,-1,-1,-1,-1, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 200 */ 6,-1,-1,-1,-1,-1,-1,-1,-1,-1, 6,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 220 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 240 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-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1,-1,-1,-1,-1,-1,-1, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 880 */ 1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 900 */ 3,-1,-1,-1,-1,-1,-1,-1,-1,-1, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 920 */ 0, 0, 0, 0,-1,-1,-1,-1,-1,-1, 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 940 */ 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 960 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,/* 980 */ 10,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,-1,-1,-1,-1,-1,-1,-1,-1,-1};/*Modal groups and modal group numbers for M codes are not described in[Fanuc]. We have used the groups from [NCMS] and added M60, as anextension of the language for pallet shuttle and stop. This version hasno codes related to axis clamping.The groups are:group 4 = {m0,m1,m2,m30,m60} - stoppinggroup 5 = {m62,m63,m64,m65} - turn I/O point on/offgroup 6 = {m6} - tool changegroup 7 = {m3,m4,m5} - spindle turninggroup 8 = {m7,m8,m9} - coolantgroup 9 = {m48,m49} - feed and speed override switch bypassgroup 100+ = {m100..m199} - user-defined*/const int Interp::_ems[] = { 4, 4, 4, 7, 7, 7, 6, 8, 8, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, 5, 5, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199};/*This is an array of the index numbers of system parameters that mustbe included in a file used with the Interp::restore_parametersfunction. The array is used by that function and by theInterp::save_parameters function.*/const int Interp::_required_parameters[] = { 5161, 5162, 5163, /* G28 home */ 5164, 5165, 5166, /* A, B, & C */ 5181, 5182, 5183, /* G30 home */ 5184, 5185, 5186, /*A, B, & C */ 5211, 5212, 5213, /* G92 offsets */ 5214, 5215, 5216, /*A, B. & C */ 5220, /* selected coordinate */ 5221, 5222, 5223, /* coordinate system 1 */ 5224, 5225, 5226, /* A, B, & C */ 5241, 5242, 5243, /* coordinate system 2 */ 5244, 5245, 5246, /* A, B, & C */ 5261, 5262, 5263, /* coordinate system 3 */ 5264, 5265, 5266, /* A, B, & C */ 5281, 5282, 5283, /* coordinate system 4 */ 5284, 5285, 5286, /* A, B, & C */ 5301, 5302, 5303, /* coordinate system 5 */ 5304, 5305, 5306, /* A, B, & C */ 5321, 5322, 5323, /* coordinate system 6 */ 5324, 5325, 5326, /* A, B, & C */ 5341, 5342, 5343, /* coordinate system 7 */ 5344, 5345, 5346, /* A, B, & C */ 5361, 5362, 5363, /* coordinate system 8 */ 5364, 5365, 5366, /* A, B, & C */ 5381, 5382, 5383, /* coordinate system 9 */ 5384, 5385, 5386, /* A, B, & C */ RS274NGC_MAX_PARAMETERS};/* _readers is an array of pointers to functions that read. It is used by read_one_item. Each read function is placed in the array according to the ASCII character it corresponds to. Whilst a switch statement could have been used in read_one_item, using an array of function pointers allows a new read_foo to be added quickly in this one table. At some point, it may be advantageous to add a read_$ or read_n for perhaps macro or jump labels.. */const read_function_pointer Interp::_readers[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&Interp::read_parameter_setting, // reads # or ASCII 0x230, 0, 0, 0,&Interp::read_comment, // reads ( or ASCII 0x280, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&Interp::read_a, // reads a or ASCII 0x61&Interp::read_b, // reads b or ASCII 0x62&Interp::read_c, // reads c or ASCII 0x63&Interp::read_d, // reads d or ASCII 0x640,&Interp::read_f, // reads f or ASCII 0x66&Interp::read_g, // reads g or ASCII 0x67&Interp::read_h, // reads h or ASCII 0x68&Interp::read_i, // reads i or ASCII 0x69&Interp::read_j, // reads j or ASCII 0x6A&Interp::read_k, // reads k or ASCII 0x6B&Interp::read_l, // reads l or ASCII 0x6C&Interp::read_m, // reads m or ASCII 0x6D0, 0,&Interp::read_p, // reads p or ASCII 0x70&Interp::read_q, // reads q or ASCII 0x71&Interp::read_r, // reads r or ASCII 0x72&Interp::read_s, // reads s or ASCII 0x73&Interp::read_t, // reads t or ASCII 0x740, 0, 0,&Interp::read_x, // reads x or ASCII 0x78&Interp::read_y, // reads y or ASCII 0x79&Interp::read_z}; // reads z or ASCII 0x7A// *INDENT-ON*// And now indent can continue./****************************************************************************//* There are four global variables*. The first three are _gees, _ems,and _readers. The last one, declared here, is for interpreter settings */setup Interp::_setup;/* The notion of "global variables" is a misnomer - These last four should only be accessable by the interpreter and not exported to the rest of emc */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -