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

📄 rs274ngc.hh

📁 数控系统中的解释器源代码
💻 HH
📖 第 1 页 / 共 2 页
字号:
} 
FilePosition;typedef struct{	double x,y,z,A,B,C;}  Point;typedef struct{	       unsigned char head;           /* flag count for mutex detect */	int		UsrVarInt[NUMS_USERVAR_INT];		//0001--0100	double		UsrVarDouble[NUMS_USERVAR_DOUBLE];      //0101--0200	unsigned short	MCode[NUMS_MCODE];		//1000--1099	double		RefG28[6];		//2001--2006	double		RefG30[6];		//2011--2016	double		RefG92[6];		//2021--2026	double 		ProbeDate[7];	//2031--2037	int		DefOrigin;		//2500	Point		Origin[NUMS_USER_COORD];	//25n1--25n6(n=0--8)	/*unsigned char	XCompNum;		//3000 (0--199)	CompPoint	XComp[NUMS_COMP_POINT];			//3001--3298	unsigned char	YCompNum;		//3300	CompPoint	YComp[NUMS_COMP_POINT];			//3301--3598	unsigned char	ZCompNum;		//3000	CompPoint	ZComp[NUMS_COMP_POINT];			//3601--3898*/	unsigned char	UAS;			//4001	1: axis lock	unsigned char	RAP;			//4002	prof mode 1:traj 0:axis	unsigned char	USO;			//4003	1:optial stop	unsigned char	USB;			//4004  1:optial del  	double JOGIncr;				//1205	double ShapeError;			//1206	 unsigned char tail;		/* flag count for mutex detect */}SysParmeter;#ifdef LATHE_FLAGtypedef struct	{	BYTE 		ProfExistFlag;	long     	       DpfFPB;    	long 		DpfNumber;//	BYTE 		DpfReserved[6];	long      	       EfpFPB;  	long 		EfpNumber;//	BYTE		EfpReserved[6];//	char          	FileName[10];   }	ProfStruc; typedef struct	{	BYTE     	ProfNum;       	ProfStruc       ProfInf[10];   }	Profile_List;typedef struct	{	double 		Element[3];}	AGL;/*typedef struct	{	double          PosX;                    	double          PosY;                    }	PointVar; */   //move to  file agl.hhtypedef struct	{	BYTE            MoveType;	AGL             CurveExpression;	PointVar        Point;	int 			sequence_number;               // sequence number of line last read}	ProfBlockStruc; typedef struct	{	AGL             CurveExpression;	//PointVar        Point;	double 			CurrentOffset;}	AGLLine; typedef struct{  BYTE   		WorkStepNo;  double          Abs_UserStartValue;     double          Ord_UserStartValue;   double          ThreadAngle;  double          ThreadDeepth;   double          MinDeepth;  double 			FristDeepth;	  BYTE   		   RepeatNum;   double 		   ThreadPitch;  double 			UOV;  double 			PullOutValue;  AGLLine            LineAB;  AGLLine            LineAC;  AGLLine            LineCD;  AGLLine            LineDE;  AGLLine            LineEF;}G76Struct;typedef struct	{	BYTE   		WorkStep;             	BYTE   		ProfNo;               	BYTE   		ParaAxisFlag; 	BYTE		motion_mode;	//	BYTE   		AbsAxisNo;            //	BYTE   		OrdAxisNo;            //	double          AbsUserValue2;        //	double          OrdUserValue2;        	double          AbsMachineValue2;	double          OrdMachineValue2; 	double          AbsStartValue;	double          OrdStartValue; 	double 	      current_profile_x;	double 	      current_profile_z;	double          AbsMove;              	double          OrdMove;              	double          AbsUOV;               	double          OrdUOV;               	double          AbsCutStep;           	double          OrdCutStep;           	BYTE   		CutStepNum;           	BYTE   		CutNum;               	long               RetFPB;  	long			RetNumber;	double    retDistance;	long               G70_RetFPB;	long			G70_RetNumber;	long 		curFPB;//	BYTE   		Reserved1[4];               	AGL              Pos;	double          CutStep;              	double          AbsAdd;               	double          OrdAdd;               	BYTE   		ProfDirection;        	BYTE   		CaviceExistFlag;      	BYTE   		ErrorFlag;            	double          AbsValue;	double          OrdValue;//	char            Reserved2[0x8];	BYTE   		SPFFlag;//	char            Reserved3[0x79];      	BYTE   		BlockMaxNum;          	BYTE  		BlockNum;             	ProfBlockStruc  Block[40];    	double end_x;	double end_z;	double heart_x;	double heart_z;	double radius;	BYTE ContinuedFlag;} Special_Cycle; #endiftypedef struct setup_struct {#ifdef AA  double AA_axis_offset;             // A-axis g92 offset  double AA_current;                 // current A-axis position  double AA_origin_offset;           // A-axis origin offset#endif#ifdef BB  double BB_axis_offset;             // B-axis g92offset  double BB_current;                 // current B-axis position  double BB_origin_offset;           // B-axis origin offset#endif#ifdef CC  double CC_axis_offset;             // C-axis g92offset  double CC_current;                 // current C-axis position  double CC_origin_offset;           // C-axis origin offset#endif  int active_g_codes      [RS274NGC_ACTIVE_G_CODES];     // array of active G codes  int active_m_codes      [RS274NGC_ACTIVE_M_CODES];     // array of active M codes  double active_settings      [RS274NGC_ACTIVE_SETTINGS];    // array of feed, speed, etc.  double axis_offset_x;              // X-axis g92 offset  double axis_offset_y;              // Y-axis g92 offset  double axis_offset_z;              // Z-axis g92 offset  block block1;                      // parsed next block  char blocktext[RS274NGC_TEXT_SIZE];// linetext downcased, white space gone  CANON_MOTION_MODE control_mode;    // exact path or cutting mode  int current_slot;                  // carousel slot number of current tool  double current_x;                  // current X-axis position  double current_y;                  // current Y-axis position  double current_z;                  // current Z-axis position  double cutter_comp_radius;         // current cutter compensation radius#ifdef LATHE_FLAG	int tool_orientation;					 // current cutter compensation orientation  //lathe tool radius#endif    //double comp_radius_x;  //double comp_radius_y;  int cutter_comp_side;              // current cutter compensation side  double cycle_cc;                   // cc-value (normal) for canned cycles  double cycle_i;                    // i-value for canned cycles  double cycle_j;                    // j-value for canned cycles  double cycle_k;                    // k-value for canned cycles  int cycle_l;                       // l-value for canned cycles  double cycle_p;                    // p-value (dwell) for canned cycles  double cycle_q;                    // q-value for canned cycles  double cycle_r;                    // r-value for canned cycles  DISTANCE_MODE distance_mode;       // absolute or incremental    int feed_mode;                     // G_93 (inverse time) or G_94 units/min  ON_OFF feed_override;              // whether feed override is enabled  double feed_rate;                  // feed rate in current units/min  char filename[RS274NGC_TEXT_SIZE]; // name of currently open NC code file  FILE * file_pointer;               // file pointer for open NC code file  ON_OFF flood;                      // whether flood coolant is on  int length_offset_index;           // for use with tool length offsets  CANON_UNITS length_units;          // millimeters or inches  int line_length;                   // length of line last read  char linetext[RS274NGC_TEXT_SIZE]; // text of most recent line read  ON_OFF mist;                       // whether mist coolant is on  int motion_mode;                   // active G-code for motion  int origin_index;                  // active origin (1=G54 to 9=G59.3)  double origin_offset_x;            // origin offset x  double origin_offset_y;            // origin offset y  double origin_offset_z;            // origin offset z  SysParmeter parameters;  //double parameters[RS274NGC_MAX_PARAMETERS];     // system parameters  int parameter_occurrence;          // parameter buffer index  int parameter_numbers[200];         // parameter number buffer  double parameter_values[200];       // parameter value buffer  ON_OFF percent_flag;               // ON means first line was percent sign  CANON_PLANE plane;                 // active plane, XY-, YZ-, or XZ-plane  ON_OFF probe_flag;                 // flag indicating probing done  double program_x;                  // program x, used when cutter comp on  double program_y;                  // program y, used when cutter comp on  double program_z;  RETRACT_MODE retract_mode;         // for cycles, old_z or r_plane  double cycle_old_c;  double cycle_old_c_flag;  int selected_tool_slot;            // tool slot selected but not active  int sequence_number;               // sequence number of line last read   //int line_number;               // sequence number of line last read  double speed;                      // current spindle speed in rpm  CANON_SPEED_FEED_MODE speed_feed_mode;   // independent or synched  CANON_SPEED_MODE speed_mode;   // rpm or constant vel  ON_OFF speed_override;             // whether speed override is enabled  CANON_DIRECTION spindle_turning;   // direction spindle is turning  char stack[50][80];                // stack of calls for error reporting  int stack_index;                   // index into the stack  double tool_length_offset;         // current tool length offset#ifdef LATHE_FLAG    double tool_zOffset;             //lathe tool z Offset#endif    int tool_max;                      // highest number tool slot in carousel  CANON_TOOL_TABLE tool_table       [CANON_TOOL_MAX + 1];         // index is slot number  int tool_table_index;              // tool index used with cutter comp  double traverse_rate;              // rate for traverse motions  //added by jqfeng   double mirror_x;                      // mirror for x_axis,0 for none mirror,1 for mirror  double mirror_y;  double mirror_z;  double sacle_base_x;  double sacle_base_y;  double sacle_base_z;  int scale_mode;  int rotation_mode;    double rotation_base_abs;  double rotation_base_ord;    ON_OFF x_radius_flag;  ON_OFF y_radius_flag;  ON_OFF z_radius_flag;   int display_sequence_number;  int block_size;    int cycle_level;  FilePosition begin_sequence_number[3];         //sequence number for begin line,not the N number  FilePosition end_sequence_number[3];  FilePosition return_sequence_number[3]; //add by wp  int loop_max[3];  int loop_counter[3];                  //loop counter,0 for no loop,anyway like a flag when is 0  char  cycle_file_name[3][256];  int n_number_caller;               //loop instrument's N number,only one loop instrument affect at one time   double angle;  double read_x;  double read_y;  double read_z;  // add by wp  ON_OFF main_percent_flag;               // ON means first line was percent sign  ON_OFF sub_percent_flag;               // ON means first line was percent sign  FILE *fpmain;  FILE *fpsub1;  FILE *fpsub2;  int  level;    //0-main ,1-sub1,2-sub2  int sn_main;  int sn_sub1;  int sn_sub2;  char mainfilename[RS274NGC_TEXT_SIZE];  char subfilename[RS274NGC_TEXT_SIZE];  char subfilename2[RS274NGC_TEXT_SIZE];  long lastFilePos;  char compensation_end_flag;  //ON_OFF  optionalStop;  //ON_OFF optionalDel;#ifdef LATHE_FLAG  int  lastProfNo;  Profile_List      Prof;	  Special_Cycle  SpeCycle;     BYTE	SpeCycleState;  double LatheAbs;  double LatheOrd;  int cycle_sequence_number[50];  int cycle_num;  int cycle_index;  double prof_abs_offset;  double prof_ord_offset; G76Struct  G76Buffer; 	    #endif   /* stuff for subroutines and control structures */  int defining_sub;                  // true if in a subroutine defn  int doing_continue;                // true if doing a continue  //int doing_break;                 // true if doing a break  int executed_if;                   // true if executed in current if  int skipping_o;                    // o_number we are skipping for (or zero)  double test_value;                 // value for "if", "while", "elseif"  int call_level;                    // current subroutine level  context sub_context[RS274NGC_SUB_ROUTINE_LEVELS];  int oword_labels;  offset oword_offset[RS274NGC_OWORD_LABELS];  int compensation_flag;  int temp_queue_state;} setup;typedef setup * setup_pointer;// pointer to function that readstypedef int (*read_function_pointer) (char *, int *, block_pointer, SysParmeter *); int find_ends(block_pointer block, setup_pointer settings, double * px,  double * py, double * pz#ifdef AA, double * AA_p#endif#ifdef BB, double * BB_p#endif#ifdef CC, double * CC_p#endif);/*************************************************************************//*Interface functions to call to tell the interpreter what to do.Return values indicate status of execution.These functions may change the state of the interpreter.*/class NML_INTERP_LIST;extern setup _setup;extern NML_INTERP_LIST temp_list; // close the currently open NC code fileextern int rs274ngc_close();// execute a line of NC code#ifndef NOT_OLD_EMC_INTERP_COMPATIBLEextern int rs274ngc_execute(const char *command=0);#elseextern int rs274ngc_execute();#endif// stop runningextern int rs274ngc_exit();// get ready to runextern int rs274ngc_init();// load a tool tableextern int rs274ngc_load_tool_table();// open a file of NC codeextern int rs274ngc_open(const char *filename);// read the mdi or the next line of the open NC code fileextern int rs274ngc_read(const char * mdi = 0);// reset yourselfextern int rs274ngc_reset();// restore interpreter variables from a fileextern int rs274ngc_restore_parameters(const char * filename);// save interpreter variables to fileextern int rs274ngc_save_parameters(const char * filename,                                    SysParmeter * parameters);// synchronize your internal model with the external worldextern int rs274ngc_synch();/*************************************************************************//*Interface functions to call to get information from the interpreter.If a function has a return value, the return value contains the information.If a function returns nothing, information is copied into one of thearguments to the function. These functions do not change the state ofthe interpreter.*/// copy active G codes into array [0]..[11]extern void rs274ngc_active_g_codes(int * codes,int motionline);// copy active M codes into array [0]..[6]extern void rs274ngc_active_m_codes(int * codes,int motionline); //add  by wp;// copy active F, S settings into array [0]..[2]extern void rs274ngc_active_settings(double * settings,int motionline);  //add by wp;// copy active G codes into array [0]..[11]extern void rs274ngc_active_g_codes(int * codes);// copy active M codes into array [0]..[6]extern void rs274ngc_active_m_codes(int * codes);// copy active F, S settings into array [0]..[2]extern void rs274ngc_active_settings(double * settings);//extern void rs274ngc_active_comp(double * comp_x,double * comp_y ,int motionline);  //add by wp;//extern void rs274ngc_active_comp(double * comp_x,double * comp_y );  //add by wp;// copy the text of the error message whose number is error_code into the// error_text array, but stop at max_size if the text is longer.extern void rs274ngc_error_text(int error_code, char * error_text,                                int max_size);// copy the name of the currently open file into the file_name array,// but stop at max_size if the name is longerextern void rs274ngc_file_name(char * file_name, int max_size);// return the length of the most recently read lineextern int rs274ngc_line_length();// copy the text of the most recently read line into the line_text array,// but stop at max_size if the text is longerextern void rs274ngc_line_text(char * line_text, int max_size);// return the current sequence number (how many lines read)extern int rs274ngc_sequence_number();extern int rs274ngc_file_line_number();extern int rs274ngc_paramter_alter(int index,double value);// copy the function name from the stack_index'th position of the// function call stack at the time of the most recent error into// the function name string, but stop at max_size if the name is longerextern void rs274ngc_stack_name(int stack_index, char * function_name,                                int max_size);extern void rs274ngc_level_filename(char * file_name,int levle);  //add by wp for level file nameextern int rs274ngc_optional_stop(int flag);extern int rs274ngc_optional_delete(int flag);#ifndef NOT_OLD_EMC_INTERP_COMPATABLE// Get the parameter file name from the ini file.extern int rs274ngc_ini_load(const char *filename);static inline int rs274ngc_line() {return rs274ngc_sequence_number();}static inline const char *rs274ngc_command() { static char buf[100]; rs274ngc_line_text(buf,100); return buf;}static inline const char *rs274ngc_file() { static char buf[100]; rs274ngc_file_name(buf,100); return buf;}static inline int rs274ngc_file_line() {return rs274ngc_file_line_number();}#endif#ifdef LATHE_FLAGextern int rs274ngc_preprocess();#define _DEBUG_INTERPstatic inline void DEBUG_PRINT(const char *fmt, ...){#ifdef _DEBUG_INTERP char  error_msg[256];  va_list ap;  if(NULL == fmt)    {      return ;    }  if(0 == *fmt)    {      return ;    }  error_msg[0] = 0;   va_start(ap, fmt);  vsprintf(&error_msg[strlen(error_msg)], fmt, ap);  va_end(ap);  error_msg[255] = 0;  // write it  printf("%s\n",error_msg);    return;  #endif}#endif#endif

⌨️ 快捷键说明

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