Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

rs274ngc.cc File Reference

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include "canon.hh"
#include "rs274ngc.hh"
#include "inifile.h"

Include dependency graph for rs274ngc.cc:

Include dependency graph

Go to the source code of this file.

Defines

#define DEBUG_EMC
#define G83_RAPID_DELTA   0.010
#define CYCLE_MACRO(call)

Typedefs

typedef int(* _function_pointer )(char *, int *, block_pointer, double *)

Functions

int read_real_value (char *line, int *counter, double *double_ptr, double *parameters)
int read_real_expression (char *line, int *counter, double *hold2, double *parameters)
int utility_error_number (char *message, char *error_array[], int index)
int execute_binary1 (double *left, int operation, double *right)
int execute_binary2 (double *left, int operation, double *right)
int execute_unary (double *double_ptr, int operation)
int read_atan (char *line, int *counter, double *double_ptr, double *parameters)
int read_integer_value (char *line, int *counter, int *integer_ptr, double *parameters)
int read_operation (char *line, int *counter, int *operation)
int read_operation_unary (char *line, int *counter, int *operation)
double utility_find_turn (double x1, double y1, double center_x, double center_y, int turn, double x2, double y2)
int arc_data_comp_ijk (int move, int side, double tool_radius, double current_x, double current_y, double end_x, double end_y, double i_number, double j_number, double *center_x, double *center_y, int *turn, double tolerance)
int arc_data_comp_r (int move, int side, double tool_radius, double current_x, double current_y, double end_x, double end_y, double big_radius, double *center_x, double *center_y, int *turn)
int arc_data_ijk (int move, double current_x, double current_y, double end_x, double end_y, double i_number, double j_number, double *center_x, double *center_y, int *turn, double tolerance)
int arc_data_r (int move, double current_x, double current_y, double end_x, double end_y, double radius, double *center_x, double *center_y, int *turn)
int read_parameter (char *line, int *counter, double *double_ptr, double *parameters)
int read_real_number (char *line, int *counter, double *double_ptr)
int read_unary (char *line, int *counter, double *double_ptr, double *parameters)
double utility_find_arc_length (double x1, double y1, double z1, double center_x, double center_y, int turn, double x2, double y2, double z2)
double utility_find_straight_length (double x2, double y2, double z2, double x1, double y1, double z1)
int convert_arc_comp1 (int move, block_pointer block, setup_pointer settings, double end_x, double end_y, double end_z)
int convert_arc_comp2 (int move, block_pointer block, setup_pointer settings, double end_x, double end_y, double end_z)
int convert_arc_xy (int move, block_pointer block, setup_pointer settings, double end_x, double end_y, double end_z)
int convert_arc_yz (int move, block_pointer block, setup_pointer settings, double end_y, double end_z, double end_x)
int convert_arc_zx (int move, block_pointer block, setup_pointer settings, double end_z, double end_x, double end_y)
int convert_cycle_g81 (double x, double y, double clear_z, double bottom_z)
int convert_cycle_g82 (double x, double y, double clear_z, double bottom_z, double dwell)
int convert_cycle_g83 (double x, double y, double r, double clear_z, double bottom_z, double delta)
int convert_cycle_g84 (double x, double y, double clear_z, double bottom_z, CANON_DIRECTION direction, CANON_SPEED_FEED_MODE mode)
int convert_cycle_g85 (double x, double y, double clear_z, double bottom_z)
int convert_cycle_g86 (double x, double y, double clear_z, double bottom_z, double dwell, CANON_DIRECTION direction)
int convert_cycle_g87 (double x, double offset_x, double y, double offset_y, double r, double clear_z, double middle_z, double bottom_z, CANON_DIRECTION direction)
int convert_cycle_g88 (double x, double y, double bottom_z, double dwell, CANON_DIRECTION direction)
int convert_cycle_g89 (double x, double y, double clear_z, double bottom_z, double dwell)
int convert_straight_comp1 (setup_pointer settings, double px, double py, double end_z)
int convert_straight_comp2 (setup_pointer settings, double program_end_x, double program_end_y, double end_z)
int read_integer_unsigned (char *line, int *counter, int *integer_ptr)
int utility_find_ends (block_pointer block, setup_pointer settings, double *px, double *py, double *pz)
int convert_arc (int move, block_pointer block, setup_pointer settings)
int convert_axis_offsets (int g_code, block_pointer block, setup_pointer settings)
int convert_cutter_compensation_off (setup_pointer settings)
int convert_cutter_compensation_on (int side, block_pointer block, setup_pointer settings)
int convert_cycle (int motion, block_pointer block, setup_pointer settings)
int convert_probe (block_pointer block, setup_pointer settings)
int convert_setup (block_pointer block, setup_pointer settings)
int convert_straight (int move, block_pointer block, setup_pointer settings)
int read_comment (char *line, int *counter, block_pointer block, double *parameters)
int read_d (char *line, int *counter, block_pointer block, double *parameters)
int read_f (char *line, int *counter, block_pointer block, double *parameters)
int read_g (char *line, int *counter, block_pointer block, double *parameters)
int read_i (char *line, int *counter, block_pointer block, double *parameters)
int read_j (char *line, int *counter, block_pointer block, double *parameters)
int read_k (char *line, int *counter, block_pointer block, double *parameters)
int read_l (char *line, int *counter, block_pointer block, double *parameters)
int read_m (char *line, int *counter, block_pointer block, double *parameters)
int read_p (char *line, int *counter, block_pointer block, double *parameters)
int read_parameter_setting (char *line, int *counter, block_pointer block, double *parameters)
int read_q (char *line, int *counter, block_pointer block, double *parameters)
int read_r (char *line, int *counter, block_pointer block, double *parameters)
int read_spindle_speed (char *line, int *counter, block_pointer block, double *parameters)
int read_tool (char *line, int *counter, block_pointer block, double *parameters)
int read_tool_length_offset (char *line, int *counter, block_pointer block, double *parameters)
int read_x (char *line, int *counter, block_pointer block, double *parameters)
int read_y (char *line, int *counter, block_pointer block, double *parameters)
int read_z (char *line, int *counter, block_pointer block, double *parameters)
int check_g_codes (block_pointer block, setup_pointer settings)
int check_m_codes (block_pointer block, setup_pointer settings)
int check_other_codes (block_pointer block, setup_pointer settings)
int convert_control_mode (int g_code, block_pointer block, setup_pointer settings)
int convert_coordinate_system (int g_code, block_pointer block, setup_pointer settings)
int convert_cutter_compensation (int g_code, block_pointer block, setup_pointer settings)
int convert_distance_mode (int g_code, block_pointer block, setup_pointer settings)
int convert_dwell (double time)
int convert_length_units (int g_code, setup_pointer settings)
int convert_modal_0 (int code, block_pointer block, setup_pointer settings)
int convert_motion (int motion, block_pointer block, setup_pointer settings)
int convert_retract_mode (int g_code, block_pointer block, setup_pointer settings)
int convert_set_plane (int g_code, block_pointer block, setup_pointer settings)
int convert_tool_change (block_pointer block, setup_pointer settings)
int convert_tool_length_offset (int g_code, block_pointer block, setup_pointer settings)
int read_line_number (char *line, int *counter, block_pointer block)
int read_one_item (char *line, int *counter, block_pointer block, double *parameters)
int check_items (block_pointer block, setup_pointer settings)
int close_and_downcase (char *line)
int convert_comment (char *comment)
int convert_feed_mode (int g_code, block_pointer block, setup_pointer settings)
int convert_feed_rate (block_pointer block, setup_pointer settings)
int convert_g (block_pointer block, setup_pointer settings)
int convert_m (block_pointer block, setup_pointer settings)
int convert_speed (block_pointer block, setup_pointer settings)
int convert_stop (block_pointer block, setup_pointer settings)
int convert_tool_select (block_pointer block, setup_pointer settings)
int init_block (block_pointer block)
int read_items (block_pointer block, char *line, double *parameters)
int utility_enhance_block (block_pointer block, setup_pointer settings)
int write_g_codes (block_pointer block, setup_pointer settings, int line_number, int *gez)
int write_m_codes (block_pointer block, setup_pointer settings, int line_number, int *ems)
int write_settings (block_pointer block, setup_pointer settings, int line_number, double *vals)
int execute_block (block_pointer block, setup_pointer settings, int line_number)
int read_line (char *line, block_pointer block, setup_pointer settings)
int read_text (const char *command, FILE *inport, char *raw_line, char *line, int *length, ON_OFF block_delete)
int set_probe_data (setup_pointer settings)
int rs274ngc_reset ()
const char * rs274ngc_command ()
const char * rs274ngc_file ()
int rs274ngc_line ()
int rs274ngc_close ()
int rs274ngc_execute (const char *command)
int rs274ngc_exit ()
int rs274ngc_synch ()
int rs274ngc_init ()
int rs274ngc_open (const char *filename)
int rs274ngc_read ()
int rs274ngc_load_tool_table ()
int rs274ngc_restore_parameters (const char *filename, double parameters[])
 restore interpreter variables from file. More...

int rs274ngc_save_parameters (const char *filename, const double parameters[])
 save interpreter variables to file. More...

int rs274ngc_ini_load (const char *filename)
 load settings from INI file. More...

int rs274ngc_active_g_codes (int *codes)
int rs274ngc_active_m_codes (int *codes)
int rs274ngc_active_settings (double *settings)

Variables

char ident [] = "$Id: rs274ngc.cc,v 1.4 2000/10/27 20:34:44 terrylr Exp $"
setup _interpreter_settings
int _textline SET_TO
char _interpreter_filename [INTERP_TEXT_SIZE]
char _interpreter_linetext [INTERP_TEXT_SIZE]
char _interpreter_blocktext [INTERP_TEXT_SIZE]
FILE *_interpreter_fp SET_TO NULL
int _interpreter_active_g_codes [RS274NGC_ACTIVE_G_CODES]
int _interpreter_active_m_codes [RS274NGC_ACTIVE_M_CODES]
double _interpreter_active_settings [RS274NGC_ACTIVE_SETTINGS]
char RS274NGC_PARAMETER_FILE [INTERP_TEXT_SIZE]


Define Documentation

#define CYCLE_MACRO call   
 

Value:

for (repeat SET_TO block->l_number;             \
     repeat > 0;                                \
     repeat--)                                  \
{                                               \
  x SET_TO (x + x_increment);                   \
  y SET_TO (y + y_increment);                   \
  STRAIGHT_TRAVERSE(x, y, old_z);               \
  if (old_z ISNT r)                             \
    STRAIGHT_TRAVERSE(x, y, r);                 \
  if (call IS RS274NGC_ERROR)                   \
    ERROR_MACRO_PASS(name);                     \
  old_z SET_TO clear_z;                         \
}

Definition at line 3895 of file rs274ngc.cc.

#define DEBUG_EMC
 

Definition at line 110 of file rs274ngc.cc.

#define G83_RAPID_DELTA   0.010
 

Definition at line 2721 of file rs274ngc.cc.


Typedef Documentation

typedef int(* _function_pointer)(char *, int *, block_pointer, double *)
 

Definition at line 6632 of file rs274ngc.cc.


Function Documentation

int arc_data_comp_ijk int    move,
int    side,
double    tool_radius,
double    current_x,
double    current_y,
double    end_x,
double    end_y,
double    i_number,
double    j_number,
double *    center_x,
double *    center_y,
int *    turn,
double    tolerance
 

Definition at line 1218 of file rs274ngc.cc.

01232 {
01233   static char name[] SET_TO "arc_data_comp_ijk";
01234   double arc_radius;
01235   double radius2;
01236   *center_x SET_TO (current_x + i_number);
01237   *center_y SET_TO (current_y + j_number);
01238   arc_radius SET_TO hypot((*center_x - current_x), (*center_y - current_y));
01239   radius2 SET_TO hypot((*center_x - end_x), (*center_y - end_y));
01240   radius2 SET_TO
01241     (((side IS LEFT ) AND (move IS 30)) OR
01242      ((side IS RIGHT) AND (move IS 20))) ?
01243        (radius2 - tool_radius): (radius2 + tool_radius);
01244   if (fabs(arc_radius - radius2) > tolerance)
01245     ERROR_MACRO(_interpreter_linetext, name,
01246                 "Radius to end of arc differs from radius to start of arc");
01247     /* This catches an arc too small for the tool, also */
01248   if (move IS G_2)
01249     *turn SET_TO -1;
01250   else if (move IS G_3)
01251     *turn SET_TO 1;
01252   else
01253     BUG_MACRO(name, "Code is not G2 or G3 in arc_data_comp");
01254   return RS274NGC_OK;
01255 }

int arc_data_comp_r int    move,
int    side,
double    tool_radius,
double    current_x,
double    current_y,
double    end_x,
double    end_y,
double    big_radius,
double *    center_x,
double *    center_y,
int *    turn
 

Definition at line 1298 of file rs274ngc.cc.

01310 {
01311   static char name[] SET_TO "arc_data_comp_r";
01312   double abs_radius; /* absolute value of big_radius */
01313   double radius2;    /* distance from center to current point */
01314   double distance;   /* length of line L from current to end */
01315   double mid_length; /* length from current point to point P */
01316   double offset;     /* length of line from P to center */
01317   double alpha;      /* direction of line from current to end */
01318   double theta;      /* direction of line from P to center */
01319   double mid_x;      /* x-value of point P */
01320   double mid_y;      /* y-value of point P */
01321 
01322   if ((end_x IS current_x) AND (end_y IS current_y))
01323     ERROR_MACRO(_interpreter_linetext, name, "Current point same as end point of arc");
01324   abs_radius SET_TO fabs(big_radius);
01325   if ((abs_radius < tool_radius) AND (((side IS LEFT ) AND (move IS G_3)) OR
01326                                       ((side IS RIGHT) AND (move IS G_2))))
01327     ERROR_MACRO(_interpreter_linetext, name,
01328      "Tool radius not less than arc radius with cutter radius comp");
01329 
01330   distance SET_TO hypot((end_x - current_x), (end_y - current_y));
01331   alpha SET_TO atan2 ((end_y - current_y), (end_x - current_x));
01332   theta SET_TO (((move IS G_3) AND (big_radius > 0)) OR
01333                 ((move IS G_2) AND (big_radius < 0))) ?
01334                   (alpha + PI2) : (alpha - PI2);
01335   radius2 SET_TO (((side IS LEFT ) AND (move IS G_3)) OR
01336                   ((side IS RIGHT) AND (move IS G_2))) ?
01337                     (abs_radius - tool_radius) : (abs_radius + tool_radius);
01338   if (distance > (radius2 + abs_radius))
01339     ERROR_MACRO(_interpreter_linetext, name, "Radius too small to reach end point");
01340   mid_length SET_TO (((radius2 * radius2) + (distance * distance) -
01341                       (abs_radius * abs_radius)) / (2.0 * distance));
01342   mid_x SET_TO (current_x + (mid_length * cos(alpha)));
01343   mid_y SET_TO (current_y + (mid_length * sin(alpha)));
01344   offset SET_TO sqrt((radius2 * radius2) - (mid_length * mid_length));
01345   *center_x SET_TO mid_x + (offset * cos(theta));
01346   *center_y SET_TO mid_y + (offset * sin(theta));
01347   *turn SET_TO (move IS G_2) ? -1 : 1;
01348 
01349   return RS274NGC_OK;
01350 }

int arc_data_ijk int    move,
double    current_x,
double    current_y,
double    end_x,
double    end_y,
double    i_number,
double    j_number,
double *    center_x,
double *    center_y,
int *    turn,
double    tolerance
 

Definition at line 1380 of file rs274ngc.cc.

01392 {
01393   static char name[] SET_TO "arc_data_ijk";
01394   double radius;    /* radius to current point */
01395   double radius2;   /* radius to end point     */
01396   *center_x SET_TO (current_x + i_number);
01397   *center_y SET_TO (current_y + j_number);
01398   radius SET_TO hypot((*center_x - current_x), (*center_y - current_y));
01399   radius2 SET_TO hypot((*center_x - end_x), (*center_y - end_y));
01400   if (fabs(radius - radius2) > tolerance)
01401     ERROR_MACRO(_interpreter_linetext, name,
01402                 "Radius to end of arc differs from radius to start of arc");
01403   if (move IS G_2)
01404     *turn SET_TO -1;
01405   else if (move IS G_3)
01406     *turn SET_TO 1;
01407   else
01408     BUG_MACRO(name, "Code is not G2 or G3 in arc_data_ijk");
01409   return RS274NGC_OK;
01410 }

int arc_data_r int    move,
double    current_x,
double    current_y,
double    end_x,
double    end_y,
double    radius,
double *    center_x,
double *    center_y,
int *    turn
 

Definition at line 1447 of file rs274ngc.cc.

01457 {
01458   static char name[] SET_TO "arc_data_r";
01459   double abs_radius; /* absolute value of given radius */
01460   double half_length;
01461   double turn2;  /* absolute value of half of turn */
01462   double offset; /* distance from M to center */
01463   double theta;  /* angle of line from M to center */
01464   double mid_x;  /* first coordinate of M */
01465   double mid_y;  /* second coordinate of M */
01466 
01467   if ((end_x IS current_x) AND (end_y IS current_y))
01468     ERROR_MACRO(_interpreter_linetext, name, "Current point same as end point of arc");
01469   abs_radius SET_TO fabs(radius);
01470   mid_x SET_TO (end_x + current_x)/2.0;
01471   mid_y SET_TO (end_y + current_y)/2.0;
01472   half_length SET_TO hypot((mid_x - end_x), (mid_y - end_y));
01473   if ((half_length/abs_radius) > (1+TINY))
01474     ERROR_MACRO(_interpreter_linetext, name, "Arc radius too small to reach end point");
01475   else if ((half_length/abs_radius) > (1-TINY))
01476     half_length SET_TO abs_radius; /* allow a small error for semicircle */
01477                                    /* check needed before calling asin   */
01478   if (((move IS G_2) AND (radius > 0)) OR
01479       ((move IS G_3) AND (radius < 0)))
01480     theta SET_TO atan2((end_y - current_y), (end_x - current_x)) - PI2;
01481   else
01482     theta SET_TO atan2((end_y - current_y), (end_x - current_x)) + PI2;
01483 
01484   turn2 SET_TO asin (half_length/abs_radius);
01485   offset SET_TO abs_radius * cos(turn2);
01486   *center_x SET_TO mid_x + (offset * cos(theta));
01487   *center_y SET_TO mid_y + (offset * sin(theta));
01488   *turn SET_TO (move IS G_2) ? -1 : 1;
01489 
01490   return RS274NGC_OK;
01491 }

int check_g_codes block_pointer    block,
setup_pointer    settings
 

Definition at line 5541 of file rs274ngc.cc.

05544 {
05545   static char name[] SET_TO "check_g_codes";
05546   ON_OFF axis_flag;
05547   int explicit_motion;
05548   int mode0;
05549   int p_int;
05550 
05551   axis_flag SET_TO
05552     ((block->x_flag) OR (block->y_flag) OR (block->z_flag)) ? ON : OFF;
05553   explicit_motion SET_TO block->g_modes[1];
05554   mode0 SET_TO block->g_modes[0];
05555 
05556   if(block->g_count > MAX_GEES)
05557     ERROR_MACRO(_interpreter_linetext, name, "Too many G codes on line");
05558 
05559   if (mode0 IS -1)
05560     {
05561       if (block->g_modes[4] IS -1)
05562         {
05563           if ((block->motion_to_be IS G_80) AND (axis_flag IS ON))
05564             ERROR_MACRO(_interpreter_linetext, name,  "Cannot use axis commands with G80");
05565         }
05566       else if (block->g_modes[4] IS G_4)
05567         {
05568           if (((block->motion_to_be IS -1) OR
05569                (block->motion_to_be IS G_80)) AND
05570               (axis_flag IS ON))
05571             ERROR_MACRO(_interpreter_linetext, name, "Cannot use axis commands with G4");
05572           if(block->p_number IS -1.0)
05573             ERROR_MACRO(_interpreter_linetext, name, "Dwell time missing with G4");
05574         }
05575       else if (block->g_modes[4] IS G_53)
05576         {
05577           if ((block->motion_to_be ISNT G_0) AND
05578               (block->motion_to_be ISNT G_1))
05579             ERROR_MACRO(_interpreter_linetext, name, "Must use G0 or G1 with G53");
05580           if((block->g_modes[3] IS G_91) OR
05581              ((block->g_modes[3] ISNT G_90) AND
05582               (settings->distance_mode IS MODE_INCREMENTAL)))
05583             ERROR_MACRO(_interpreter_linetext, name, "Cannot use G53 in incremental distance mode");
05584         }
05585       else
05586         BUG_MACRO(name, "Bad setting of g_mode in check_g_codes");
05587     }
05588   else if (block->g_modes[4] ISNT -1)
05589     ERROR_MACRO(_interpreter_linetext, name, "Cannot use two G codes from group 0");
05590   else if (mode0 IS G_10)
05591     {
05592       p_int SET_TO (int)(block->p_number + 0.0001);
05593       if ((explicit_motion ISNT -1) AND (explicit_motion ISNT G_80))
05594         ERROR_MACRO(_interpreter_linetext, name, "Cannot use a G code for motion with G10");
05595       if (block->l_number ISNT 2)
05596         ERROR_MACRO(_interpreter_linetext, name, "Line with G10 does not have L2");
05597       if (((block->p_number + 0.0001) - p_int) > 0.0002)
05598         ERROR_MACRO(_interpreter_linetext, name, "P value not an integer with G10 L2");
05599       if ((p_int < 1) OR (p_int > 9))
05600         ERROR_MACRO(_interpreter_linetext, name, "P value out of range with G10 L2");
05601     }
05602   else if (mode0 IS G_92)
05603     {
05604       if ((explicit_motion ISNT -1) AND (explicit_motion ISNT G_80))
05605         ERROR_MACRO(_interpreter_linetext, name, "Cannot use a G motion with G92");
05606       if (axis_flag IS OFF)
05607         ERROR_MACRO(_interpreter_linetext, name, "All axes missing with G92");
05608     }
05609   else if (mode0 IS G_92_2)
05610     {}
05611   else
05612     BUG_MACRO(name, "Bad setting of g_mode in check_g_codes");
05613 
05614   return RS274NGC_OK;
05615 }

int check_items block_pointer    block,
setup_pointer    settings
 

Definition at line 6742 of file rs274ngc.cc.

06745 {
06746   static char name[] SET_TO "check_items";
06747   if (check_g_codes(block, settings) ISNT RS274NGC_OK)
06748     ERROR_MACRO_PASS(name);
06749   if (check_m_codes(block, settings) ISNT RS274NGC_OK)
06750     ERROR_MACRO_PASS(name);
06751   if (check_other_codes(block, settings) ISNT RS274NGC_OK)
06752     ERROR_MACRO_PASS(name);
06753   if ((block->m_modes[4] ISNT -1) AND (block->g_modes[1] IS G_38_2))
06754     ERROR_MACRO(_interpreter_linetext, name, "Cannot put an M code for stopping with G38.2");
06755   return RS274NGC_OK;
06756 }

int check_m_codes block_pointer    block,
setup_pointer    settings
 

Definition at line 5637 of file rs274ngc.cc.

05640 {
05641   static char name[] SET_TO "check_m_codes";
05642 
05643   if(block->m_count > MAX_EMS)
05644     ERROR_MACRO(_interpreter_linetext, name, "Too many M codes on line");
05645 
05646   return RS274NGC_OK;
05647 }

int check_other_codes block_pointer    block,
setup_pointer    settings
 

Definition at line 5678 of file rs274ngc.cc.

05681 {
05682   static char name[] SET_TO "check_other_codes";
05683   int motion;
05684 
05685   motion SET_TO block->motion_to_be;
05686   if (block->d_number ISNT -1)
05687     {
05688       if ((block->g_modes[7] ISNT G_41) AND (block->g_modes[7] ISNT G_42))
05689         ERROR_MACRO(_interpreter_linetext, name,
05690            "D word on line with no cutter comp on (G41 or G42) command");
05691     }
05692   if (block->h_number ISNT -1)
05693     {
05694       if (block->g_modes[8] ISNT G_43)
05695         ERROR_MACRO(_interpreter_linetext, name,
05696           "H word on line with no tool length comp (G43) command");
05697     }
05698 
05699   if (block->i_flag IS ON) /* could still be useless if yz_plane arc */
05700     {
05701       if (((motion ISNT G_2) AND (motion ISNT G_3)) AND (motion ISNT G_87))
05702         ERROR_MACRO(_interpreter_linetext, name,
05703           "I word on line with no G code (G2, G3, G87) that uses it");
05704     }
05705 
05706 
05707   if (block->j_flag IS ON) /* could still be useless if xz_plane arc */
05708     {
05709       if (((motion ISNT G_2) AND (motion ISNT G_3)) AND (motion ISNT G_87))
05710         ERROR_MACRO(_interpreter_linetext, name,
05711           "J word on line with no G code (G2, G3, G87) that uses it");
05712     }
05713 
05714   if (block->k_flag IS ON) /* could still be useless if xy_plane arc */
05715     {
05716       if (((motion ISNT G_2) AND (motion ISNT G_3)) AND (motion ISNT G_87))
05717         ERROR_MACRO(_interpreter_linetext, name,
05718           "K word on line with no G code (G2, G3, G87) that uses it");
05719     }
05720 
05721   if (block->l_number ISNT -1)
05722     {
05723       if (((motion < G_81) OR (motion > G_89)) AND
05724           (block->g_modes[0] ISNT G_10))
05725         ERROR_MACRO(_interpreter_linetext, name,
05726                     "L word on line with no canned cycle or G10 to use it");
05727     }
05728 
05729   if (block->p_number ISNT -1.0)
05730     {
05731       if (((block->g_modes[0] ISNT G_10) AND
05732            (block->g_modes[4] ISNT G_4)) AND
05733           (((motion ISNT G_82) AND (motion ISNT G_86)) AND
05734            ((motion ISNT G_88) AND (motion ISNT G_89))))
05735         ERROR_MACRO(_interpreter_linetext, name,
05736       "P word on line with no G code (G4 G10 G82 G86 G88 G89) that uses it");
05737     }
05738 
05739   if (block->q_number ISNT -1.0)
05740     {
05741       if (motion ISNT G_83)
05742         ERROR_MACRO(_interpreter_linetext, name, "Q word on line with no G83 cycle that uses it");
05743     }
05744 
05745   if (block->r_flag IS ON)
05746     {
05747       if (((motion ISNT G_2) AND (motion ISNT G_3)) AND
05748           ((motion < G_81) OR (motion > G_89)))
05749         ERROR_MACRO(_interpreter_linetext, name,
05750           "R word on line with no G code (arc or cycle) that uses it");
05751     }
05752 
05753   return RS274NGC_OK;
05754 }

int close_and_downcase char *    line
 

Definition at line 6800 of file rs274ngc.cc.

06801                                  : one line of NC code */
06802 {
06803   static char name[] SET_TO "close_and_downcase";
06804   int m;
06805   int n;
06806   int comment;
06807   char item;
06808   comment SET_TO 0;
06809   for (n SET_TO 0, m SET_TO 0; (item SET_TO line[m]) ISNT (char) NULL; m++)
06810     {
06811       if (comment)
06812         {
06813           line[n++] SET_TO item;
06814           if (item IS ')')
06815             {
06816               comment SET_TO 0;
06817             }
06818           else if (item IS '(')
06819             ERROR_MACRO(_interpreter_linetext, name, "Nested comment found");
06820         }
06821       else if ((item IS ' ') OR (item IS '\t') OR (item IS '\r'));
06822                                       /* don't copy blank or tab  or CR */
06823       else if (item IS '\n')          /* don't copy newline             */
06824         {                             /* but check null follows         */
06825           if (line[m+1] ISNT 0)
06826             ERROR_MACRO(_interpreter_linetext, name, "Null missing after newline");
06827         }
06828       else if ((64 < item) AND (item < 91)) /* downcase upper case letters */
06829         {
06830           line[n++] SET_TO (32 + item);
06831         }
06832       else if (item IS '(')   /* comment is starting */
06833         {
06834           comment SET_TO 1;
06835           line[n++] SET_TO item;
06836         }
06837       else
06838         {
06839           line[n++] SET_TO item; /* copy anything else */
06840         }
06841     }
06842   if (m IS (INTERP_TEXT_SIZE - 1)) /* line was too long */
06843     ERROR_MACRO(_interpreter_linetext, name, "Command too long");
06844   else if (comment)
06845     ERROR_MACRO(_interpreter_linetext, name, "Unclosed comment found");
06846   line[n] SET_TO 0;
06847   return RS274NGC_OK;
06848 }

int convert_arc int    move,
block_pointer    block,
setup_pointer    settings
 

Definition at line 3508 of file rs274ngc.cc.

03512 {
03513   static char name[] SET_TO "convert_arc";
03514   int status;
03515   DISTANCE_MODE mode;
03516   int first;
03517   int ijk_flag;
03518   double end_x;
03519   double end_y;
03520   double end_z;
03521 
03522   mode SET_TO settings->distance_mode;
03523   ijk_flag SET_TO
03524     ((block->i_flag OR block->j_flag) OR block->k_flag) ? ON : OFF;
03525   first SET_TO (settings->program_x IS UNKNOWN);
03526 
03527   if ((block->r_flag ISNT ON) AND (ijk_flag ISNT ON))
03528     ERROR_MACRO(_interpreter_linetext, name, "R, I, J, and K words all missing for arc");
03529   else if ((block->r_flag IS ON) AND (ijk_flag IS ON))
03530     ERROR_MACRO(_interpreter_linetext, name, "Mixed radius-ijk format for arc");
03531   else if (settings->feed_rate IS 0.0)
03532     ERROR_MACRO(_interpreter_linetext, name, "Cannot make arc with zero feed rate");
03533   else if (ijk_flag)
03534     {
03535       if (settings->plane IS CANON_PLANE_XY)
03536         {
03537           if (block->k_flag)
03538             ERROR_MACRO(_interpreter_linetext, name, "K word given for arc in XY-plane");
03539           else if (block->i_flag IS OFF) /* i or j flag on to get here */
03540               block->i_number SET_TO 0.0;
03541           else if (block->j_flag IS OFF)
03542             block->j_number SET_TO 0.0;
03543         }
03544       else if (settings->plane IS CANON_PLANE_YZ)
03545         {
03546           if (block->i_flag)
03547             ERROR_MACRO(_interpreter_linetext, name, "I word given for arc in YZ-plane");
03548           else if (block->j_flag IS OFF) /* j or k flag on to get here */
03549               block->j_number SET_TO 0.0;
03550           else if (block->k_flag IS OFF)
03551             block->k_number SET_TO 0.0;
03552         }
03553       else if (settings->plane IS CANON_PLANE_XZ)
03554         {
03555           if (block->j_flag)
03556             ERROR_MACRO(_interpreter_linetext, name, "J word given for arc in XZ-plane");
03557           else if (block->i_flag IS OFF) /* i or k flag on to get here */
03558               block->i_number SET_TO 0.0;
03559           else if (block->k_flag IS OFF)
03560             block->k_number SET_TO 0.0;
03561         }
03562       else
03563         BUG_MACRO(name, "Plane is not XY, YZ, or XZ in convert_arc");
03564     }
03565   else; /* r format arc; no other checks needed specific to this format */
03566 
03567   if (settings->plane IS CANON_PLANE_XY) /* checks for both formats */
03568     {
03569       if ((block->x_flag IS OFF) AND (block->y_flag IS OFF))
03570         ERROR_MACRO(_interpreter_linetext, name, "X and Y words missing for arc in XY-plane");
03571     }
03572   else if (settings->plane IS CANON_PLANE_YZ)
03573     {
03574       if ((block->y_flag IS OFF) AND (block->z_flag IS OFF))
03575         ERROR_MACRO(_interpreter_linetext, name, "Y and Z words missing for arc in YZ-plane");
03576     }
03577   else if (settings->plane IS CANON_PLANE_XZ)
03578     {
03579       if ((block->x_flag IS OFF) AND (block->z_flag IS OFF))
03580         ERROR_MACRO(_interpreter_linetext, name, "X and Z words missing for arc in XZ-plane");
03581     }
03582 
03583   utility_find_ends(block, settings, &end_x, &end_y, &end_z);
03584 
03585   settings->motion_mode SET_TO move;
03586 
03587   if (settings->plane IS CANON_PLANE_XY)
03588     {
03589       if (settings->cutter_radius_compensation IS OFF)
03590         status SET_TO convert_arc_xy(move, block, settings, end_x, end_y,
03591                                      end_z);
03592       else if (settings->feed_mode IS INVERSE_TIME)
03593         ERROR_MACRO(_interpreter_linetext, name,
03594                      "Cannot use inverse time feed with cutter radius comp");
03595       else if (first)
03596         status SET_TO convert_arc_comp1
03597           (move, block, settings, end_x, end_y, end_z);
03598       else
03599         status SET_TO convert_arc_comp2
03600           (move, block, settings, end_x, end_y, end_z);
03601     }
03602   else if (settings->plane IS CANON_PLANE_XZ)
03603     status SET_TO convert_arc_zx (move, block, settings, end_z, end_x, end_y);
03604   else if (settings->plane IS CANON_PLANE_YZ)
03605     status SET_TO convert_arc_yz (move, block, settings, end_y, end_z, end_x);
03606   else
03607    BUG_MACRO(name, "Plane is not XY, YZ, or XZ in convert_arc");
03608 
03609   if (status ISNT RS274NGC_OK)
03610     ERROR_MACRO_PASS(name);
03611   else
03612     return RS274NGC_OK;
03613 }

int convert_arc_comp1 int    move,
block_pointer    block,
setup_pointer    settings,
double    end_x,
double    end_y,
double    end_z
 

Definition at line 2198 of file rs274ngc.cc.

02205 {
02206   static char name[] SET_TO "convert_arc_comp1";
02207   double center_x;
02208   double center_y;
02209   int turn;     /* 1 for counterclockwise, -1 for clockwise */
02210   double gamma; /* direction of perpendicular to arc at end */
02211   double tolerance;
02212   double tool_radius;
02213   int side;
02214   int status;
02215 
02216   side SET_TO settings->cutter_radius_compensation;
02217   tool_radius SET_TO
02218     (settings->tool_table[settings->tool_table_index].diameter)/2.0;
02219   if (tool_radius <= 0.0)
02220     ERROR_MACRO(_interpreter_linetext, name, "Bad tool radius value with cutter radius comp");
02221   tolerance SET_TO (settings->length_units IS CANON_UNITS_INCHES) ?
02222     TOLERANCE_INCH : TOLERANCE_MM;
02223 
02224   if (block->r_flag)
02225     {
02226       status SET_TO
02227         arc_data_comp_r(move, side, tool_radius, settings->current_x,
02228                         settings->current_y, end_x, end_y, block->r_number,
02229                         &center_x, &center_y, &turn);
02230     }
02231   else
02232     {
02233       status SET_TO
02234         arc_data_comp_ijk(move, side, tool_radius, settings->current_x,
02235                           settings->current_y, end_x, end_y,
02236                           block->i_number, block->j_number,
02237                           &center_x, &center_y, &turn, tolerance);
02238     }
02239 
02240   if (status IS RS274NGC_ERROR)
02241    ERROR_MACRO_PASS(name);
02242 
02243   gamma SET_TO
02244     (((side IS LEFT) AND (move IS G_3)) OR
02245      ((side IS RIGHT) AND (move IS G_2))) ?
02246        atan2 ((center_y - end_y), (center_x - end_x)) :
02247        atan2 ((end_y - center_y), (end_x - center_x));
02248 
02249   settings->program_x SET_TO end_x;
02250   settings->program_y SET_TO end_y;
02251   end_x SET_TO (end_x + (tool_radius * cos(gamma)));
02252   end_y SET_TO (end_y + (tool_radius * sin(gamma)));
02253   ARC_FEED(end_x, end_y, center_x, center_y, turn, end_z);
02254   settings->current_x SET_TO end_x;
02255   settings->current_y SET_TO end_y;
02256   settings->current_z SET_TO end_z;
02257 
02258   return RS274NGC_OK;
02259 }

int convert_arc_comp2 int    move,
block_pointer    block,
setup_pointer    settings,
double    end_x,
double    end_y,
double    end_z
 

Definition at line 2292 of file rs274ngc.cc.

02299 {
02300   static char name[] SET_TO "convert_arc_comp2";
02301   double center_x; /* center of arc */
02302   double center_y;
02303   double start_x;
02304   double start_y;
02305   int turn;     /* number of full or partial circles CCW */
02306   double theta; /* direction of tangent to last cut */
02307   double delta; /* direction of radius from start of arc to center of arc */
02308   double alpha; /* direction of tangent to start of arc */
02309   double beta;  /* angle between two tangents above */
02310   double gamma; /* direction of perpendicular to arc at end */
02311   double arc_radius;
02312   double tool_radius;
02313   /* small angle in radians for testing corners */
02314   double small SET_TO TOLERANCE_CONCAVE_CORNER;
02315   int side;
02316   int status;
02317   double tolerance;
02318 
02319 /* find basic arc data: center_x, center_y, and turn */
02320 
02321   start_x SET_TO settings->program_x;
02322   start_y SET_TO settings->program_y;
02323   tolerance SET_TO (settings->length_units IS CANON_UNITS_INCHES) ?
02324     TOLERANCE_INCH : TOLERANCE_MM;
02325 
02326   if (block->r_flag)
02327     {
02328       status SET_TO arc_data_r(move, start_x, start_y, end_x, end_y,
02329                                block->r_number, &center_x, &center_y, &turn);
02330     }
02331   else
02332     {
02333       status SET_TO
02334         arc_data_ijk(move, start_x, start_y, end_x, end_y,
02335                      block->i_number, block->j_number,
02336                      &center_x, &center_y, &turn, tolerance);
02337     }
02338 
02339   if (status IS RS274NGC_ERROR)
02340     ERROR_MACRO_PASS(name);
02341 
02342 /* compute other data */
02343   side SET_TO settings->cutter_radius_compensation;
02344   tool_radius SET_TO
02345     (settings->tool_table[settings->tool_table_index].diameter)/2.0;
02346   if (tool_radius <= 0.0)
02347     ERROR_MACRO(_interpreter_linetext, name, "Bad tool radius value with cutter radius comp");
02348   arc_radius SET_TO hypot((center_x - end_x), (center_y - end_y));
02349   theta SET_TO
02350     atan2(settings->current_y - start_y, settings->current_x - start_x);
02351   theta SET_TO (side IS LEFT) ? (theta - PI2) : (theta + PI2);
02352   delta SET_TO atan2(center_y - start_y, center_x - start_x);
02353   alpha SET_TO (move IS G_3) ? (delta - PI2) : (delta + PI2);
02354   beta SET_TO (side IS LEFT) ? (theta - alpha) : (alpha - theta);
02355   beta SET_TO (beta > (1.5 * PI))  ? (beta - TWO_PI) :
02356               (beta < -PI2) ? (beta + TWO_PI) : beta;
02357 
02358   if (((side IS LEFT)  AND (move IS G_3)) OR
02359       ((side IS RIGHT) AND (move IS G_2)))
02360     {
02361       gamma SET_TO atan2 ((center_y - end_y), (center_x - end_x));
02362       if (arc_radius <= tool_radius)
02363         ERROR_MACRO(_interpreter_linetext, name,
02364            "Tool radius not less than arc radius with cutter radius comp");
02365     }
02366   else
02367     {
02368       gamma SET_TO atan2 ((end_y - center_y), (end_x - center_x));
02369       delta SET_TO (delta + PI);
02370     }
02371 
02372   settings->program_x SET_TO end_x;
02373   settings->program_y SET_TO end_y;
02374 
02375 /* check if extra arc needed and insert if so */
02376 
02377   if ((beta < -small) OR (beta > (PI + small)))
02378     ERROR_MACRO(_interpreter_linetext, name, "Concave corner with cutter radius comp");
02379   else if (beta > small) /* TWO ARCS NEEDED */
02380     ARC_FEED((start_x + (tool_radius * cos(delta))),
02381              (start_y + (tool_radius * sin(delta))),
02382              start_x, start_y, (side IS LEFT) ? -1 : 1,
02383              settings->current_z);
02384 
02385   end_x SET_TO (end_x + (tool_radius * cos(gamma))); /* end_x reset actual */
02386   end_y SET_TO (end_y + (tool_radius * sin(gamma))); /* end_y reset actual */
02387 
02388 /* insert main arc */
02389   ARC_FEED(end_x, end_y, center_x, center_y, turn, end_z);
02390 
02391   settings->current_x SET_TO end_x;
02392   settings->current_y SET_TO end_y;
02393   settings->current_z SET_TO end_z;
02394 
02395   return RS274NGC_OK;
02396 }

int convert_arc_xy int    move,
block_pointer    block,
setup_pointer    settings,
double    end_x,
double    end_y,
double    end_z
 

Definition at line 2418 of file rs274ngc.cc.

02425 {
02426   static char name[] SET_TO "convert_arc_xy";
02427   double center_x;
02428   double center_y;
02429   double length;
02430   double rate;
02431   int turn;
02432   int status;
02433   double tolerance;
02434 
02435   tolerance SET_TO (settings->length_units IS CANON_UNITS_INCHES) ?
02436     TOLERANCE_INCH : TOLERANCE_MM;
02437 
02438   if (block->r_flag)
02439     {
02440       status SET_TO
02441         arc_data_r(move, settings->current_x, settings->current_y, end_x,
02442                    end_y, block->r_number, &center_x, &center_y, &turn);
02443     }
02444   else
02445     {
02446       status SET_TO
02447         arc_data_ijk(move, settings->current_x, settings->current_y,
02448                      end_x, end_y, block->i_number, block->j_number,
02449                      &center_x, &center_y, &turn, tolerance);
02450     }
02451 
02452   if (status IS RS274NGC_ERROR)
02453     ERROR_MACRO_PASS(name);
02454 
02455   if (settings->feed_mode IS INVERSE_TIME)
02456     {
02457       length SET_TO utility_find_arc_length
02458         (settings->current_x, settings->current_y, settings->current_z,
02459          center_x, center_y, turn, end_x, end_y, end_z);
02460       rate SET_TO MAX(0.1, (length * block->f_number));
02461       SET_FEED_RATE (rate);
02462       settings->feed_rate SET_TO rate;
02463     }
02464 
02465   ARC_FEED(end_x, end_y, center_x, center_y, turn, end_z);
02466   settings->current_x SET_TO end_x;
02467   settings->current_y SET_TO end_y;
02468   settings->current_z SET_TO end_z;
02469   return RS274NGC_OK;
02470 }

int convert_arc_yz int    move,
block_pointer    block,
setup_pointer    settings,
double    end_y,
double    end_z,
double    end_x
 

Definition at line 2492 of file rs274ngc.cc.

02499 {
02500   static char name[] SET_TO "convert_arc_yz";
02501   double center_y;
02502   double center_z;
02503   double length;
02504   double rate;
02505   int turn;
02506   int status;
02507   double tolerance;
02508 
02509   tolerance SET_TO (settings->length_units IS CANON_UNITS_INCHES) ?
02510     TOLERANCE_INCH : TOLERANCE_MM;
02511 
02512   if (block->r_flag)
02513     {
02514       status SET_TO
02515         arc_data_r(move, settings->current_y, settings->current_z, end_y,
02516                    end_z, block->r_number, &center_y, &center_z, &turn);
02517     }
02518   else
02519     {
02520       status SET_TO
02521         arc_data_ijk(move, settings->current_y, settings->current_z,
02522                      end_y, end_z, block->j_number, block->k_number,
02523                      &center_y, &center_z, &turn, tolerance);
02524     }
02525 
02526   if (status IS RS274NGC_ERROR)
02527     ERROR_MACRO_PASS(name);
02528 
02529   if (settings->feed_mode IS INVERSE_TIME)
02530     {
02531       length SET_TO utility_find_arc_length
02532         (settings->current_y, settings->current_z, settings->current_x,
02533          center_y, center_z, turn, end_y, end_z, end_x);
02534       rate SET_TO MAX(0.1, (length * block->f_number));
02535       SET_FEED_RATE (rate);
02536       settings->feed_rate SET_TO rate;
02537     }
02538 
02539   ARC_FEED(end_y, end_z, center_y, center_z, turn, end_x);
02540   settings->current_y SET_TO end_y;
02541   settings->current_z SET_TO end_z;
02542   settings->current_x SET_TO end_x;
02543 
02544   return RS274NGC_OK;
02545 }

int convert_arc_zx int    move,
block_pointer    block,
setup_pointer    settings,
double    end_z,
double    end_x,
double    end_y
 

Definition at line 2567 of file rs274ngc.cc.

02574 {
02575   static char name[] SET_TO "convert_arc_zx";
02576   double center_z;
02577   double center_x;
02578   double length;
02579   double rate;
02580   int turn;
02581   int status;
02582   double tolerance;
02583 
02584   tolerance SET_TO (settings->length_units IS CANON_UNITS_INCHES) ?
02585     TOLERANCE_INCH : TOLERANCE_MM;
02586 
02587   if (block->r_flag)
02588     {
02589       status SET_TO
02590         arc_data_r(move, settings->current_z, settings->current_x, end_z,
02591                    end_x, block->r_number, &center_z, &center_x, &turn);
02592     }
02593   else
02594     {
02595       status SET_TO
02596         arc_data_ijk(move, settings->current_z, settings->current_x,
02597                      end_z, end_x, block->k_number, block->i_number,
02598                      &center_z, &center_x, &turn, tolerance);
02599     }
02600 
02601   if (status IS RS274NGC_ERROR)
02602     ERROR_MACRO_PASS(name);
02603 
02604   if (settings->feed_mode IS INVERSE_TIME)
02605     {
02606       length SET_TO utility_find_arc_length
02607         (settings->current_z, settings->current_x, settings->current_y,
02608          center_z, center_x, turn, end_z, end_x, end_y);
02609       rate SET_TO MAX(0.1, (length * block->f_number));
02610       SET_FEED_RATE (rate);
02611       settings->feed_rate SET_TO rate;
02612     }
02613 
02614   ARC_FEED(end_z, end_x, center_z, center_x, turn, end_y);
02615   settings->current_z SET_TO end_z;
02616   settings->current_x SET_TO end_x;
02617   settings->current_y SET_TO end_y;
02618 
02619   return RS274NGC_OK;
02620 }

int convert_axis_offsets int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 3663 of file rs274ngc.cc.

03667 {
03668   static char name[] SET_TO "convert_axis_offsets";
03669 
03670   if (settings->cutter_radius_compensation ISNT OFF) /* not "IS ON" */
03671     ERROR_MACRO(_interpreter_linetext, name, "Cannot change axis offsets with cutter radius comp");
03672   else if (g_code IS G_92)
03673     {
03674       if (block->x_flag IS ON)
03675         {
03676           settings->axis_offset_x SET_TO
03677             (settings->current_x + settings->axis_offset_x - block->x_number);
03678           settings->current_x SET_TO block->x_number;
03679         }
03680 
03681       if (block->y_flag IS ON)
03682         {
03683           settings->axis_offset_y SET_TO
03684             (settings->current_y + settings->axis_offset_y - block->y_number);
03685           settings->current_y SET_TO block->y_number;
03686         }
03687 
03688       if (block->z_flag IS ON)
03689         {
03690           settings->axis_offset_z SET_TO
03691             (settings->current_z + settings->axis_offset_z - block->z_number);
03692           settings->current_z SET_TO block->z_number;
03693         }
03694 
03695       SET_ORIGIN_OFFSETS(settings->origin_offset_x + settings->axis_offset_x,
03696                          settings->origin_offset_y + settings->axis_offset_y,
03697                          settings->origin_offset_z + settings->axis_offset_z);
03698 
03699       settings->parameters[5211] SET_TO settings->axis_offset_x;
03700       settings->parameters[5212] SET_TO settings->axis_offset_y;
03701       settings->parameters[5213] SET_TO settings->axis_offset_z;
03702     }
03703   else if (g_code IS G_92_2)
03704     {
03705       settings->current_x SET_TO
03706         settings->current_x + settings->axis_offset_x;
03707       settings->current_y SET_TO
03708         settings->current_y + settings->axis_offset_y;
03709       settings->current_z SET_TO
03710         settings->current_z + settings->axis_offset_z;
03711       SET_ORIGIN_OFFSETS(settings->origin_offset_x,
03712                          settings->origin_offset_y,
03713                          settings->origin_offset_z);
03714       settings->axis_offset_x SET_TO 0.0;
03715       settings->axis_offset_y SET_TO 0.0;
03716       settings->axis_offset_z SET_TO 0.0;
03717 
03718       settings->parameters[5211] SET_TO 0.0;
03719       settings->parameters[5212] SET_TO 0.0;
03720       settings->parameters[5213] SET_TO 0.0;
03721     }
03722   else
03723     BUG_MACRO(name, "Code is not G92 or G92.2 in convert_axis_offsets");
03724 
03725   return RS274NGC_OK;
03726 }

int convert_comment char *    comment
 

Definition at line 6873 of file rs274ngc.cc.

06875 {
06876   int m;
06877   int item;
06878 
06879   for (m SET_TO 0; ((item SET_TO comment[m]) IS ' ') OR (item IS '\t') ; m++);
06880   if ((item ISNT 'M') AND (item ISNT 'm'))
06881     {
06882       COMMENT(comment);
06883       return RS274NGC_OK;
06884     }
06885   for (m++; ((item SET_TO comment[m]) IS ' ') OR (item IS '\t') ; m++);
06886   if ((item ISNT 'S') AND (item ISNT 's'))
06887     {
06888       COMMENT(comment);
06889       return RS274NGC_OK;
06890     }
06891   for (m++; ((item SET_TO comment[m]) IS ' ') OR (item IS '\t') ; m++);
06892   if ((item ISNT 'G') AND (item ISNT 'g'))
06893     {
06894       COMMENT(comment);
06895       return RS274NGC_OK;
06896     }
06897   for (m++; ((item SET_TO comment[m]) IS ' ') OR (item IS '\t') ; m++);
06898   if (item ISNT ',')
06899     {
06900       COMMENT(comment);
06901       return RS274NGC_OK;
06902     }
06903   MESSAGE(comment + m + 1);
06904   return RS274NGC_OK;
06905 }

int convert_control_mode int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 5785 of file rs274ngc.cc.

05789 {
05790   static char name[] SET_TO "convert_control_mode";
05791   if (g_code IS G_61)
05792     {
05793       SET_MOTION_CONTROL_MODE(CANON_EXACT_PATH);
05794       settings->control_mode SET_TO CANON_EXACT_PATH;
05795     }
05796   else if (g_code IS G_64)
05797     {
05798       SET_MOTION_CONTROL_MODE(CANON_CONTINUOUS);
05799       settings->control_mode SET_TO CANON_CONTINUOUS;
05800     }
05801   else
05802     BUG_MACRO(name, "Code is not G61 or G64 in convert_control_mode");
05803   return RS274NGC_OK;
05804 }

int convert_coordinate_system int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 5877 of file rs274ngc.cc.

05881 {
05882   static char name[] SET_TO "convert_coordinate_system";
05883   int origin;
05884   double x;
05885   double y;
05886   double z;
05887   double * parameters;
05888 
05889   parameters SET_TO settings->parameters;
05890   switch(g_code)
05891     {
05892     case 540:
05893       origin SET_TO 1;
05894       break;
05895     case 550:
05896       origin SET_TO 2;
05897       break;
05898     case 560:
05899       origin SET_TO 3;
05900       break;
05901     case 570:
05902       origin SET_TO 4;
05903       break;
05904     case 580:
05905       origin SET_TO 5;
05906       break;
05907     case 590:
05908       origin SET_TO 6;
05909       break;
05910     case 591:
05911       origin SET_TO 7;
05912       break;
05913     case 592:
05914       origin SET_TO 8;
05915       break;
05916     case 593:
05917       origin SET_TO 9;
05918       break;
05919     default:
05920       BUG_MACRO(name, "Code is not G54 to G59.3 in convert_coordinate_system");
05921     }
05922 
05923   if (origin IS settings->origin_ngc) /* already using this origin */
05924     {
05925 #ifdef DEBUG_EMC
05926       COMMENT("interpreter: continuing to use same coordinate system");
05927 #endif
05928       return RS274NGC_OK;
05929     }
05930 
05931 /* axis offsets could be included in the following calculcations
05932 but do not need to be because they would not change the result. */
05933   settings->current_x SET_TO
05934     (settings->current_x + settings->origin_offset_x);
05935   settings->current_y SET_TO
05936     (settings->current_y + settings->origin_offset_y);
05937   settings->current_z SET_TO
05938     (settings->current_z + settings->origin_offset_z);
05939 
05940   x SET_TO parameters[5201 + (origin * 20)];
05941   y SET_TO parameters[5202 + (origin * 20)];
05942   z SET_TO parameters[5203 + (origin * 20)];
05943 
05944   settings->origin_offset_x SET_TO x;
05945   settings->origin_offset_y SET_TO y;
05946   settings->origin_offset_z SET_TO z;
05947 
05948   settings->current_x SET_TO (settings->current_x - x);
05949   settings->current_y SET_TO (settings->current_y - y);
05950   settings->current_z SET_TO (settings->current_z - z);
05951   settings->origin_ngc SET_TO origin;
05952 
05953   SET_ORIGIN_OFFSETS(x + settings->axis_offset_x,
05954                      y + settings->axis_offset_y,
05955                      z + settings->axis_offset_z);
05956 
05957   return RS274NGC_OK;
05958 }

int convert_cutter_compensation int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 5983 of file rs274ngc.cc.

05987 {
05988   static char name[] SET_TO "convert_cutter_compensation";
05989   if (g_code IS G_40)
05990     {
05991       if (convert_cutter_compensation_off(settings) IS RS274NGC_ERROR)
05992         ERROR_MACRO_PASS(name);
05993     }
05994   else if (g_code IS G_41)
05995     {
05996       if (convert_cutter_compensation_on(LEFT, block, settings)
05997           IS RS274NGC_ERROR)
05998         ERROR_MACRO_PASS(name);
05999     }
06000   else if (g_code IS G_42)
06001     {
06002       if (convert_cutter_compensation_on(RIGHT, block, settings)
06003           IS RS274NGC_ERROR)
06004         ERROR_MACRO_PASS(name);
06005     }
06006   else
06007     BUG_MACRO(name,
06008               "Code is not G40, G41, or G42 in convert_cutter_compensation");
06009 
06010   return RS274NGC_OK;
06011 }

int convert_cutter_compensation_off setup_pointer    settings
 

Definition at line 3745 of file rs274ngc.cc.

03747 {
03748 #ifdef DEBUG_EMC
03749   COMMENT("interpreter: cutter radius compensation off");
03750 #endif
03751   settings->cutter_radius_compensation SET_TO OFF;
03752   settings->program_x SET_TO UNKNOWN;
03753   return RS274NGC_OK;
03754 }

int convert_cutter_compensation_on int    side,
block_pointer    block,
setup_pointer    settings
 

Definition at line 3785 of file rs274ngc.cc.

03789 {
03790   static char name[] SET_TO "convert_cutter_compensation_on";
03791 
03792   if (settings->plane ISNT CANON_PLANE_XY)
03793     ERROR_MACRO(_interpreter_linetext, name, "Cannot turn cutter radius comp on out of XY-plane");
03794   if (block->d_number IS -1)
03795     ERROR_MACRO(_interpreter_linetext, name, "D word missing with cutter radius comp on");
03796   if (settings->cutter_radius_compensation ISNT OFF)
03797     ERROR_MACRO(_interpreter_linetext, name, "Cannot turn cutter radius comp on when already on");
03798 
03799 #ifdef DEBUG_EMC
03800   if (side IS RIGHT)
03801     COMMENT("interpreter: cutter radius compensation on right");
03802   else
03803     COMMENT("interpreter: cutter radius compensation on left");
03804 #endif
03805 
03806   /* radius is (settings->tool_table[block->d_number].diameter)/2.0) */
03807   settings->tool_table_index SET_TO block->d_number;
03808   settings->cutter_radius_compensation SET_TO side;
03809   return RS274NGC_OK;
03810 }

int convert_cycle int    motion,
block_pointer    block,
setup_pointer    settings
 

Definition at line 3910 of file rs274ngc.cc.

03914 {
03915   static char name[] SET_TO "convert_cycle";
03916   double x_increment;
03917   double y_increment;
03918   double i;
03919   double j;
03920   double k;
03921   double x;
03922   double y;
03923   double clear_z;
03924   double old_z;
03925   double z;
03926   double r;
03927   int repeat;
03928   CANON_MOTION_MODE save_mode;
03929 
03930   if (settings->motion_mode ISNT motion)
03931     {
03932       if (block->r_flag IS OFF)
03933         ERROR_MACRO(_interpreter_linetext, name, "R clearance plane unspecified in canned cycle");
03934       if (block->z_flag IS OFF)
03935         ERROR_MACRO(_interpreter_linetext, name, "Z value unspecified in canned cycle");
03936     }
03937 
03938   block->r_number SET_TO
03939     block->r_flag IS ON ? block->r_number : settings->cycle_r;
03940   block->z_number SET_TO
03941     block->z_flag IS ON ? block->z_number : settings->cycle_z;
03942   old_z SET_TO settings->current_z;
03943 
03944   if (settings->distance_mode IS MODE_ABSOLUTE)
03945     {
03946       x_increment SET_TO 0.0;
03947       y_increment SET_TO 0.0;
03948       r SET_TO block->r_number;
03949       z SET_TO block->z_number;
03950       x SET_TO block->x_flag IS ON ? block->x_number : settings->current_x;
03951       y SET_TO block->y_flag IS ON ? block->y_number : settings->current_y;
03952     }
03953   else if (settings->distance_mode IS MODE_INCREMENTAL)
03954     {
03955       x_increment SET_TO block->x_number;
03956       y_increment SET_TO block->y_number;
03957       r SET_TO (block->r_number + old_z);
03958       z SET_TO (r + block->z_number); /* [NCMS, page 98] */
03959       x SET_TO settings->current_x;
03960       y SET_TO settings->current_y;
03961     }
03962   else
03963     BUG_MACRO(name,
03964         "Distance mode is neither absolute nor incremental in convert_cycle");
03965 
03966   if (r < z)
03967     ERROR_MACRO(_interpreter_linetext, name, "R value less than Z value in canned cycle");
03968 
03969   if (block->l_number IS -1)
03970     block->l_number SET_TO 1;
03971   else if (block->l_number IS 0)
03972     ERROR_MACRO(_interpreter_linetext, name, "Cannot do zero repeats of cycle");
03973 
03974   if (old_z < r)
03975     {
03976       STRAIGHT_TRAVERSE(settings->current_x, settings->current_y, r);
03977       old_z SET_TO r;
03978     }
03979   clear_z SET_TO (settings->retract_mode IS R_PLANE) ? r : old_z;
03980 
03981   save_mode = GET_MOTION_CONTROL_MODE();
03982   if (save_mode ISNT CANON_EXACT_PATH)
03983     SET_MOTION_CONTROL_MODE(CANON_EXACT_PATH);
03984 
03985   switch(motion)
03986     {
03987     case G_81:
03988       CYCLE_MACRO(convert_cycle_g81(x, y, clear_z, z))
03989       break;
03990     case G_82:
03991       if ((settings->motion_mode ISNT G_82) AND (block->p_number IS -1.0))
03992         ERROR_MACRO(_interpreter_linetext, name, "P word (dwell time) missing with G82");
03993       block->p_number SET_TO
03994         block->p_number IS -1.0 ? settings->cycle_p : block->p_number;
03995       CYCLE_MACRO(convert_cycle_g82 (x, y, clear_z, z, block->p_number))
03996       settings->cycle_p SET_TO block->p_number;
03997       break;
03998     case G_83:
03999       if ((settings->motion_mode ISNT G_83) AND (block->q_number IS -1.0))
04000         ERROR_MACRO(_interpreter_linetext, name, "Q word (depth increment) missing with G83");
04001       block->q_number SET_TO
04002         block->q_number IS -1.0 ? settings->cycle_q : block->q_number;
04003       CYCLE_MACRO(convert_cycle_g83 (x, y, r, clear_z, z, block->q_number))
04004       settings->cycle_q SET_TO block->q_number;
04005       break;
04006     case G_84:
04007       CYCLE_MACRO(convert_cycle_g84 (x, y, clear_z, z,
04008                       settings->spindle_turning, settings->speed_feed_mode))
04009       break;
04010     case G_85:
04011       CYCLE_MACRO(convert_cycle_g85 (x, y, clear_z, z))
04012       break;
04013     case G_86:
04014       if ((settings->motion_mode ISNT G_86) AND (block->p_number IS -1.0))
04015         ERROR_MACRO(_interpreter_linetext, name, "P word (dwell time) missing with G86");
04016       block->p_number SET_TO
04017         block->p_number IS -1.0 ? settings->cycle_p : block->p_number;
04018       CYCLE_MACRO(convert_cycle_g86 (x, y, clear_z, z, block->p_number,
04019                                  settings->spindle_turning))
04020       settings->cycle_p SET_TO block->p_number;
04021       break;
04022     case G_87:
04023       if (settings->motion_mode ISNT G_87)
04024         {
04025           if (block->i_flag IS OFF)
04026             ERROR_MACRO(_interpreter_linetext, name, "I word missing with G87");
04027           if (block->j_flag IS OFF)
04028             ERROR_MACRO(_interpreter_linetext, name, "J word missing with G87");
04029           if (block->k_flag IS OFF)
04030             ERROR_MACRO(_interpreter_linetext, name, "K word missing with G87");
04031         }
04032       i SET_TO block->i_flag IS ON ? block->i_number : settings->cycle_i;
04033       j SET_TO block->j_flag IS ON ? block->j_number : settings->cycle_j;
04034       k SET_TO block->k_flag IS ON ? block->k_number : settings->cycle_k;
04035       settings->cycle_i SET_TO i;
04036       settings->cycle_j SET_TO j;
04037       settings->cycle_k SET_TO k;
04038       if (settings->distance_mode IS MODE_INCREMENTAL)
04039         {
04040           k SET_TO (z + k); /* k always absolute in function call below */
04041         }
04042       CYCLE_MACRO(convert_cycle_g87 (x, (x + i), y, (y + j), r, clear_z, k,
04043                                  z, settings->spindle_turning))
04044       break;
04045     case G_88:
04046       if ((settings->motion_mode ISNT G_88) AND (block->p_number IS -1.0))
04047         ERROR_MACRO(_interpreter_linetext, name, "P word (dwell time) missing with G88");
04048       block->p_number SET_TO
04049         block->p_number IS -1.0 ? settings->cycle_p : block->p_number;
04050       CYCLE_MACRO(convert_cycle_g88 (x, y, z, block->p_number,
04051                                  settings->spindle_turning))
04052       settings->cycle_p SET_TO block->p_number;
04053       break;
04054     case G_89:
04055       if ((settings->motion_mode ISNT G_89) AND (block->p_number IS -1.0))
04056         ERROR_MACRO(_interpreter_linetext, name, "P word (dwell time) missing with G89");
04057       block->p_number SET_TO
04058         block->p_number IS -1.0 ? settings->cycle_p : block->p_number;
04059       CYCLE_MACRO(convert_cycle_g89 (x, y, clear_z, z, block->p_number))
04060       settings->cycle_p SET_TO block->p_number;
04061       break;
04062     default:
04063       BUG_MACRO(name, "Convert_cycle should not have been called");
04064     }
04065   settings->current_x SET_TO x;
04066   settings->current_y SET_TO y;
04067   settings->current_z SET_TO clear_z;
04068   settings->cycle_l SET_TO block->l_number;
04069   settings->cycle_r SET_TO block->r_number;
04070   settings->cycle_z SET_TO block->z_number;
04071   settings->motion_mode SET_TO motion;
04072 
04073   if (save_mode ISNT CANON_EXACT_PATH)
04074     SET_MOTION_CONTROL_MODE(save_mode);
04075 
04076   return RS274NGC_OK;
04077 }

int convert_cycle_g81 double    x,
double    y,
double    clear_z,
double    bottom_z
 

Definition at line 2643 of file rs274ngc.cc.

02648 {
02649   static char name[] SET_TO "convert_cycle_g81";
02650 
02651   STRAIGHT_FEED(x, y, bottom_z);
02652   STRAIGHT_TRAVERSE(x, y, clear_z);
02653 
02654   return RS274NGC_OK;
02655 }

int convert_cycle_g82 double    x,
double    y,
double    clear_z,
double    bottom_z,
double    dwell
 

Definition at line 2677 of file rs274ngc.cc.

02683 {
02684   static char name[] SET_TO "convert_cycle_g82";
02685 
02686   STRAIGHT_FEED(x, y, bottom_z);
02687   DWELL(dwell);
02688   STRAIGHT_TRAVERSE(x, y, clear_z);
02689 
02690   return RS274NGC_OK;
02691 }

int convert_cycle_g83 double    x,
double    y,
double    r,
double    clear_z,
double    bottom_z,
double    delta
 

Definition at line 2723 of file rs274ngc.cc.

02730 {
02731   static char name[] SET_TO "convert_cycle_g83";
02732   double current_depth;
02733   double rapid_delta;
02734 
02735   rapid_delta SET_TO G83_RAPID_DELTA;
02736   if (_interpreter_settings.length_units IS CANON_UNITS_MM)
02737     rapid_delta *= 25.4;
02738 
02739   for (current_depth SET_TO (r - delta);
02740        current_depth > bottom_z;
02741        current_depth SET_TO (current_depth - delta))
02742     {
02743       STRAIGHT_FEED(x, y, current_depth);
02744       DWELL(0.25);
02745       STRAIGHT_TRAVERSE(x, y, clear_z);
02746       STRAIGHT_TRAVERSE(x, y, current_depth + rapid_delta);
02747     }
02748   STRAIGHT_FEED(x, y, bottom_z);
02749   DWELL(0.25);
02750   STRAIGHT_TRAVERSE(x, y, clear_z);
02751 
02752   return RS274NGC_OK;
02753 }

int convert_cycle_g84 double    x,
double    y,
double    clear_z,
double    bottom_z,
CANON_DIRECTION    direction,
CANON_SPEED_FEED_MODE    mode
 

Definition at line 2784 of file rs274ngc.cc.

02791 {
02792   static char name[] SET_TO "convert_cycle_g84";
02793 
02794   if (direction ISNT CANON_CLOCKWISE)
02795     ERROR_MACRO(_interpreter_linetext, name, "Spindle not turning clockwise in G84 canned cycle");
02796   START_SPEED_FEED_SYNCH();
02797   STRAIGHT_FEED(x, y, bottom_z);
02798   STOP_SPINDLE_TURNING();
02799   START_SPINDLE_COUNTERCLOCKWISE();
02800   STRAIGHT_FEED(x, y, clear_z);
02801   if (mode ISNT CANON_SYNCHED)
02802     STOP_SPEED_FEED_SYNCH();
02803   STOP_SPINDLE_TURNING();
02804   START_SPINDLE_CLOCKWISE();
02805 
02806   return RS274NGC_OK;
02807 }

int convert_cycle_g85 double    x,
double    y,
double    clear_z,
double    bottom_z
 

Definition at line 2828 of file rs274ngc.cc.

02833 {
02834   static char name[] SET_TO "convert_cycle_g85";
02835 
02836   STRAIGHT_FEED(x, y, bottom_z);
02837   STRAIGHT_FEED(x, y, clear_z);
02838 
02839   return RS274NGC_OK;
02840 }

int convert_cycle_g86 double    x,
double    y,
double    clear_z,
double    bottom_z,
double    dwell,
CANON_DIRECTION    direction
 

Definition at line 2867 of file rs274ngc.cc.

02874 {
02875   static char name[] SET_TO "convert_cycle_g86";
02876 
02877   if ((direction ISNT CANON_CLOCKWISE) AND
02878       (direction ISNT CANON_COUNTERCLOCKWISE))
02879     ERROR_MACRO(_interpreter_linetext, name, "Spindle not turning in G86 canned cycle");
02880 
02881   STRAIGHT_FEED(x, y, bottom_z);
02882   DWELL(dwell);
02883   STOP_SPINDLE_TURNING();
02884   STRAIGHT_TRAVERSE(x, y, clear_z);
02885   if (direction IS CANON_CLOCKWISE)
02886     START_SPINDLE_CLOCKWISE();
02887   else
02888     START_SPINDLE_COUNTERCLOCKWISE();
02889 
02890   return RS274NGC_OK;
02891 }

int convert_cycle_g87 double    x,
double    offset_x,
double    y,
double    offset_y,
double    r,
double    clear_z,
double    middle_z,
double    bottom_z,
CANON_DIRECTION    direction
 

Definition at line 2942 of file rs274ngc.cc.

02952 {
02953   static char name[] SET_TO "convert_cycle_g87";
02954 
02955   if ((direction ISNT CANON_CLOCKWISE) AND
02956       (direction ISNT CANON_COUNTERCLOCKWISE))
02957     ERROR_MACRO(_interpreter_linetext, name, "Spindle not turning in G87 canned cycle");
02958 
02959   STRAIGHT_TRAVERSE(offset_x, offset_y, r);
02960   STOP_SPINDLE_TURNING();
02961   ORIENT_SPINDLE(0.0, direction);
02962   STRAIGHT_TRAVERSE(offset_x, offset_y, bottom_z);
02963   STRAIGHT_TRAVERSE(x, y, bottom_z);
02964   if (direction IS CANON_CLOCKWISE)
02965     START_SPINDLE_CLOCKWISE();
02966   else
02967     START_SPINDLE_COUNTERCLOCKWISE();
02968   STRAIGHT_FEED(x, y, middle_z);
02969   STRAIGHT_FEED(x, y, bottom_z);
02970   STOP_SPINDLE_TURNING();
02971   ORIENT_SPINDLE(0.0, direction);
02972   STRAIGHT_TRAVERSE(offset_x, offset_y, bottom_z);
02973   STRAIGHT_TRAVERSE(offset_x, offset_y, clear_z);
02974   STRAIGHT_TRAVERSE(x, y, clear_z);
02975   if (direction IS CANON_CLOCKWISE)
02976     START_SPINDLE_CLOCKWISE();
02977   else
02978     START_SPINDLE_COUNTERCLOCKWISE();
02979 
02980   return RS274NGC_OK;
02981 }

int convert_cycle_g88 double    x,
double    y,
double    bottom_z,
double    dwell,
CANON_DIRECTION    direction
 

Definition at line 3008 of file rs274ngc.cc.

03014 {
03015   static char name[] SET_TO "convert_cycle_g88";
03016 
03017   if ((direction ISNT CANON_CLOCKWISE) AND
03018       (direction ISNT CANON_COUNTERCLOCKWISE))
03019     ERROR_MACRO(_interpreter_linetext, name, "Spindle not turning in G88 canned cycle");
03020 
03021   STRAIGHT_FEED(x, y, bottom_z);
03022   DWELL(dwell);
03023   STOP_SPINDLE_TURNING();
03024   PROGRAM_STOP(); /* operator retracts the spindle here */
03025   if (direction IS CANON_CLOCKWISE)
03026     START_SPINDLE_CLOCKWISE();
03027   else
03028     START_SPINDLE_COUNTERCLOCKWISE();
03029 
03030   return RS274NGC_OK;
03031 }

int convert_cycle_g89 double    x,
double    y,
double    clear_z,
double    bottom_z,
double    dwell
 

Definition at line 3051 of file rs274ngc.cc.

03057 {
03058   static char name[] SET_TO "convert_cycle_g89";
03059 
03060   STRAIGHT_FEED(x, y, bottom_z);
03061   DWELL(dwell);
03062   STRAIGHT_FEED(x, y, clear_z);
03063 
03064   return RS274NGC_OK;
03065 }

int convert_distance_mode int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 6032 of file rs274ngc.cc.

06036 {
06037   static char name[] SET_TO "convert_distance_mode";
06038   if (g_code IS G_90)
06039     {
06040       if (settings->distance_mode ISNT MODE_ABSOLUTE)
06041         {
06042 #ifdef DEBUG_EMC
06043           COMMENT("interpreter: distance mode changed to absolute");
06044 #endif
06045           settings->distance_mode SET_TO MODE_ABSOLUTE;
06046         }
06047     }
06048   else if (g_code IS G_91)
06049     {
06050       if (settings->distance_mode ISNT MODE_INCREMENTAL)
06051         {
06052 #ifdef DEBUG_EMC
06053           COMMENT("interpreter: distance mode changed to incremental");
06054 #endif
06055           settings->distance_mode SET_TO MODE_INCREMENTAL;
06056         }
06057     }
06058   else
06059     BUG_MACRO(name, "Code is not G90 or G91 in convert_distance_mode");
06060   return RS274NGC_OK;
06061 }

int convert_dwell double    time
 

Definition at line 6076 of file rs274ngc.cc.

06078 {
06079   DWELL(time);
06080   return RS274NGC_OK;
06081 }

int convert_feed_mode int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 6928 of file rs274ngc.cc.

06932 {
06933   static char name[] SET_TO "convert_feed_mode";
06934   if (g_code IS G_93)
06935     {
06936 #ifdef DEBUG_EMC
06937       COMMENT("interpreter: feed mode set to inverse time");
06938 #endif
06939       settings->feed_mode SET_TO INVERSE_TIME;
06940     }
06941   else if (g_code IS G_94)
06942     {
06943 #ifdef DEBUG_EMC
06944       COMMENT("interpreter: feed mode set to units per minute");
06945 #endif
06946       settings->feed_mode SET_TO UNITS_PER_MINUTE;
06947     }
06948   else
06949     BUG_MACRO(name, "Code is not G93 or G94 in convert_feed_mode");
06950   return RS274NGC_OK;
06951 }

int convert_feed_rate block_pointer    block,
setup_pointer    settings
 

Definition at line 6968 of file rs274ngc.cc.

06971 {
06972   SET_FEED_RATE(block->f_number);
06973   settings->feed_rate SET_TO block->f_number;
06974   return RS274NGC_OK;
06975 }

int convert_g block_pointer    block,
setup_pointer    settings
 

Definition at line 7039 of file rs274ngc.cc.

07042 {
07043   static char name[] SET_TO "convert_g";
07044 
07045   if (block->g_modes[4] IS G_4)
07046     {
07047       if (convert_dwell(block->p_number) IS RS274NGC_ERROR)
07048         ERROR_MACRO_PASS(name);
07049     }
07050 
07051   if (block->g_modes[2] ISNT -1)
07052     {
07053       if (convert_set_plane(block->g_modes[2], block, settings)
07054           IS RS274NGC_ERROR)
07055         ERROR_MACRO_PASS(name);
07056     }
07057 
07058   if (block->g_modes[6] ISNT -1)
07059     {
07060       if (convert_length_units(block->g_modes[6], settings) IS RS274NGC_ERROR)
07061         ERROR_MACRO_PASS(name);
07062     }
07063 
07064   if (block->g_modes[7] ISNT -1)
07065     {
07066       if (convert_cutter_compensation(block->g_modes[7], block, settings)
07067           IS RS274NGC_ERROR)
07068         ERROR_MACRO_PASS(name);
07069     }
07070 
07071   if (block->g_modes[8] ISNT -1)
07072     {
07073       if (convert_tool_length_offset(block->g_modes[8], block, settings)
07074           IS RS274NGC_ERROR)
07075         ERROR_MACRO_PASS(name);
07076     }
07077 
07078   if (block->g_modes[12] ISNT -1)
07079     {
07080       if (convert_coordinate_system (block->g_modes[12], block, settings)
07081           IS RS274NGC_ERROR)
07082         ERROR_MACRO_PASS(name);
07083     }
07084 
07085   if (block->g_modes[13] ISNT -1)
07086     {
07087       if (convert_control_mode (block->g_modes[13], block, settings)
07088           IS RS274NGC_ERROR)
07089         ERROR_MACRO_PASS(name);
07090     }
07091 
07092   if (block->g_modes[3] ISNT -1)
07093     {
07094       if (convert_distance_mode(block->g_modes[3], block, settings)
07095           IS RS274NGC_ERROR)
07096         ERROR_MACRO_PASS(name);
07097     }
07098 
07099   if (block->g_modes[10] ISNT -1)
07100     {
07101       if (convert_retract_mode(block->g_modes[10], block, settings)
07102           IS RS274NGC_ERROR)
07103         ERROR_MACRO_PASS(name);
07104     }
07105 
07106   if (block->g_modes[0] ISNT -1)
07107     {
07108       if (convert_modal_0(block->g_modes[0], block, settings)
07109           IS RS274NGC_ERROR)
07110         ERROR_MACRO_PASS(name);
07111     }
07112 
07113   if (block->motion_to_be ISNT -1)
07114     {
07115       if (convert_motion(block->motion_to_be, block, settings)
07116           IS RS274NGC_ERROR)
07117         ERROR_MACRO_PASS(name);
07118     }
07119   return RS274NGC_OK;
07120 }

int convert_length_units int    g_code,
setup_pointer    settings
 

Definition at line 6124 of file rs274ngc.cc.

06127 {
06128   static char name[] SET_TO "convert_length_units";
06129   if (settings->cutter_radius_compensation ISNT OFF)
06130     ERROR_MACRO(_interpreter_linetext, name, "Cannot change units with cutter radius comp");
06131   else if (g_code IS G_20)
06132     {
06133       USE_LENGTH_UNITS(CANON_UNITS_INCHES);
06134       if (settings->length_units ISNT CANON_UNITS_INCHES)
06135         {
06136           settings->length_units SET_TO CANON_UNITS_INCHES;
06137           settings->current_x SET_TO (settings->current_x * INCH_PER_MM);
06138           settings->current_y SET_TO (settings->current_y * INCH_PER_MM);
06139           settings->current_z SET_TO (settings->current_z * INCH_PER_MM);
06140           settings->axis_offset_x SET_TO
06141             (settings->axis_offset_x * INCH_PER_MM);
06142           settings->axis_offset_y SET_TO
06143             (settings->axis_offset_y * INCH_PER_MM);
06144           settings->axis_offset_z SET_TO
06145             (settings->axis_offset_z * INCH_PER_MM);
06146           settings->origin_offset_x SET_TO
06147             (settings->origin_offset_x * INCH_PER_MM);
06148           settings->origin_offset_y SET_TO
06149             (settings->origin_offset_y * INCH_PER_MM);
06150           settings->origin_offset_z SET_TO
06151             (settings->origin_offset_z * INCH_PER_MM);
06152         }
06153     }
06154   else if (g_code IS G_21)
06155     {
06156       USE_LENGTH_UNITS(CANON_UNITS_MM);
06157       if (settings->length_units ISNT CANON_UNITS_MM)
06158         {
06159           settings->length_units SET_TO CANON_UNITS_MM;
06160           settings->current_x SET_TO (settings->current_x * MM_PER_INCH);
06161           settings->current_y SET_TO (settings->current_y * MM_PER_INCH);
06162           settings->current_z SET_TO (settings->current_z * MM_PER_INCH);
06163           settings->axis_offset_x SET_TO
06164             (settings->axis_offset_x * MM_PER_INCH);
06165           settings->axis_offset_y SET_TO
06166             (settings->axis_offset_y * MM_PER_INCH);
06167           settings->axis_offset_z SET_TO
06168             (settings->axis_offset_z * MM_PER_INCH);
06169           settings->origin_offset_x SET_TO
06170             (settings->origin_offset_x * MM_PER_INCH);
06171           settings->origin_offset_y SET_TO
06172             (settings->origin_offset_y * MM_PER_INCH);
06173           settings->origin_offset_z SET_TO
06174             (settings->origin_offset_z * MM_PER_INCH);
06175         }
06176     }
06177   else
06178     BUG_MACRO(name, "Code is not G20 or G21 in convert_length_units");
06179   return RS274NGC_OK;
06180 }

int convert_m block_pointer    block,
setup_pointer    settings
 

Definition at line 7149 of file rs274ngc.cc.

07152 {
07153   static char name[] SET_TO "convert_m";
07154   if (block->m_modes[6] ISNT -1)
07155     if (convert_tool_change(block, settings) IS RS274NGC_ERROR)
07156       ERROR_MACRO_PASS(name);
07157 
07158   if (block->m_modes[7] IS 3)
07159     {
07160       START_SPINDLE_CLOCKWISE();
07161       settings->spindle_turning SET_TO CANON_CLOCKWISE;
07162     }
07163   else if (block->m_modes[7] IS 4)
07164     {
07165       START_SPINDLE_COUNTERCLOCKWISE();
07166       settings->spindle_turning SET_TO CANON_COUNTERCLOCKWISE;
07167     }
07168   else if (block->m_modes[7] IS 5)
07169     {
07170       STOP_SPINDLE_TURNING();
07171       settings->spindle_turning SET_TO CANON_STOPPED;
07172     }
07173 
07174   if (block->m_modes[8] IS 7)
07175     {
07176       MIST_ON();
07177       settings->mist SET_TO ON;
07178     }
07179   else if (block->m_modes[8] IS 8)
07180     {
07181       FLOOD_ON();
07182       settings->flood SET_TO ON;
07183     }
07184   else if (block->m_modes[8] IS 9)
07185     {
07186       MIST_OFF();
07187       settings->mist SET_TO OFF;
07188       FLOOD_OFF();
07189       settings->flood SET_TO OFF;
07190     }
07191 
07192   if (block->m_modes[9] IS 48)
07193     {
07194       ENABLE_FEED_OVERRIDE();
07195       ENABLE_SPEED_OVERRIDE();
07196       settings->feed_override SET_TO ON;
07197       settings->speed_override SET_TO ON;
07198     }
07199   else if (block->m_modes[9] IS 49)
07200     {
07201       DISABLE_FEED_OVERRIDE();
07202       DISABLE_SPEED_OVERRIDE();
07203       settings->feed_override SET_TO OFF;
07204       settings->speed_override SET_TO OFF;
07205     }
07206   return RS274NGC_OK;
07207 }

int convert_modal_0 int    code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 6201 of file rs274ngc.cc.

06205 {
06206   static char name[] SET_TO "convert_modal_0";
06207 
06208   if (code IS G_10)
06209     {
06210       if (convert_setup(block, settings) IS RS274NGC_ERROR)
06211         ERROR_MACRO_PASS(name);
06212     }
06213   else if ((code IS G_92) OR (code IS G_92_2))
06214     {
06215       if (convert_axis_offsets(code, block, settings) IS RS274NGC_ERROR)
06216         ERROR_MACRO_PASS(name);
06217     }
06218   else
06219     BUG_MACRO(name, "Code is not G10, G92, or G92.2 in convert_modal_0");
06220   return RS274NGC_OK;
06221 }

int convert_motion int    motion,
block_pointer    block,
setup_pointer    settings
 

Definition at line 6252 of file rs274ngc.cc.

06256 {
06257   static char name[] SET_TO "convert_motion";
06258 
06259   if ((motion IS G_0) OR (motion IS G_1))
06260     {
06261       if (convert_straight (motion, block, settings) IS RS274NGC_ERROR)
06262         ERROR_MACRO_PASS(name);
06263     }
06264   else if ((motion IS G_3) OR (motion IS G_2))
06265     {
06266       if ((settings->feed_mode IS INVERSE_TIME) AND
06267           (block->f_number IS -1.0))
06268         ERROR_MACRO(_interpreter_linetext, name, "F word missing with inverse time arc move");
06269       if (convert_arc (motion, block, settings) IS RS274NGC_ERROR)
06270         ERROR_MACRO_PASS(name);
06271     }
06272   else if (motion IS G_38_2)
06273     {
06274       if (settings->feed_mode IS INVERSE_TIME)
06275         ERROR_MACRO(_interpreter_linetext, name, "Cannot probe in inverse time feed mode");
06276       if (settings->cutter_radius_compensation ISNT OFF) /* NOT "IS ON"! */
06277         ERROR_MACRO(_interpreter_linetext, name, "Cannot probe with cutter radius compensation on");
06278       if (settings->feed_rate IS 0.0)
06279         ERROR_MACRO(_interpreter_linetext, name, "Cannot probe with zero feed rate");
06280       if (convert_probe (block, settings) IS RS274NGC_ERROR)
06281         ERROR_MACRO_PASS(name);
06282     }
06283   else if (motion IS G_80)
06284     {
06285       if((block->x_flag) OR (block->y_flag) OR (block->z_flag))
06286         ERROR_MACRO(_interpreter_linetext, name, "Coordinate setting given with G80");
06287       else
06288         {
06289 #ifdef DEBUG_EMC
06290           COMMENT("interpreter: motion mode set to none");
06291 #endif
06292           settings->motion_mode SET_TO G_80;
06293         }
06294     }
06295   else if ((motion > G_80) AND (motion < G_90))
06296     {
06297      if (convert_cycle(motion, block, settings) IS RS274NGC_ERROR)
06298         ERROR_MACRO_PASS(name);
06299     }
06300   else
06301     BUG_MACRO(name, "Code is not G0 to G3 or G80 to G89 in convert_motion");
06302 
06303   return RS274NGC_OK;
06304 }

int convert_probe block_pointer    block,
setup_pointer    settings
 

Definition at line 4111 of file rs274ngc.cc.

04114 {
04115   static char name[] SET_TO "convert_probe";
04116   double end_x;
04117   double end_y;
04118   double end_z;
04119 
04120   if (((block->x_flag IS OFF) AND (block->y_flag IS OFF)) AND
04121       (block->z_flag IS OFF))
04122     ERROR_MACRO(_interpreter_linetext, name, "X, Y, and Z words all missing with G38.2");
04123   utility_find_ends(block, settings, &end_x, &end_y, &end_z);
04124   TURN_PROBE_ON();
04125   STRAIGHT_PROBE (end_x, end_y, end_z);
04126   TURN_PROBE_OFF();
04127   settings->motion_mode SET_TO G_38_2;
04128   settings->probe_flag SET_TO ON;
04129 #ifdef STAND_ALONE_INTERP
04130   settings->current_x SET_TO ((0.9 * end_x) + (0.1 * settings->current_x));
04131   settings->current_y SET_TO ((0.9 * end_y) + (0.1 * settings->current_y));
04132   settings->current_z SET_TO ((0.9 * end_z) + (0.1 * settings->current_z));
04133 #endif
04134   return RS274NGC_OK;
04135 }

int convert_retract_mode int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 6327 of file rs274ngc.cc.

06331 {
06332   static char name[] SET_TO "convert_retract_mode";
06333   if (g_code IS G_98)
06334     {
06335 #ifdef DEBUG_EMC
06336       COMMENT("interpreter: retract mode set to old_z");
06337 #endif
06338       settings->retract_mode SET_TO OLD_Z;
06339     }
06340   else if (g_code IS G_99)
06341     {
06342 #ifdef DEBUG_EMC
06343       COMMENT("interpreter: retract mode set to r_plane");
06344 #endif
06345       settings->retract_mode SET_TO R_PLANE;
06346     }
06347   else
06348     BUG_MACRO(name, "Code is not G98 or G99 in convert_retract_mode");
06349   return RS274NGC_OK;
06350 }

int convert_set_plane int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 6369 of file rs274ngc.cc.

06373 {
06374   static char name[] SET_TO "convert_set_plane";
06375   if (g_code IS G_17)
06376     {
06377       SELECT_PLANE(CANON_PLANE_XY);
06378       settings->plane SET_TO CANON_PLANE_XY;
06379     }
06380   else if (g_code IS G_18)
06381     {
06382       if (settings->cutter_radius_compensation ISNT OFF)
06383         ERROR_MACRO(_interpreter_linetext, name, "Cannot use XZ plane with cutter radius comp");
06384       SELECT_PLANE(CANON_PLANE_XZ);
06385       settings->plane SET_TO CANON_PLANE_XZ;
06386     }
06387   else if (g_code IS G_19)
06388     {
06389       if (settings->cutter_radius_compensation ISNT OFF)
06390         ERROR_MACRO(_interpreter_linetext, name, "Cannot use YZ plane with cutter radius comp");
06391       SELECT_PLANE(CANON_PLANE_YZ);
06392       settings->plane SET_TO CANON_PLANE_YZ;
06393     }
06394   else
06395     BUG_MACRO(name, "Code is not G17, G18, or G19 in convert_set_plane");
06396   return RS274NGC_OK;
06397 }

int convert_setup block_pointer    block,
setup_pointer    settings
 

Definition at line 4163 of file rs274ngc.cc.

04166 {
04167   static char name[] SET_TO "convert_setup";
04168   double x;
04169   double y;
04170   double z;
04171   double * parameters;
04172   int p_int;
04173 
04174   parameters SET_TO settings->parameters;
04175   p_int SET_TO (int)(block->p_number + 0.0001); /* p_number is a double */
04176 
04177   if (block->x_flag IS ON)
04178     {
04179       x SET_TO block->x_number;
04180       parameters[5201 + (p_int * 20)] SET_TO x;
04181     }
04182   else
04183     x SET_TO parameters[5201 + (p_int * 20)];
04184 
04185   if (block->y_flag IS ON)
04186     {
04187       y SET_TO block->y_number;
04188       parameters[5202 + (p_int * 20)] SET_TO y;
04189     }
04190   else
04191     y SET_TO parameters[5202 + (p_int * 20)];
04192 
04193   if (block->z_flag IS ON)
04194     {
04195       z SET_TO block->z_number;
04196       parameters[5203 + (p_int * 20)] SET_TO z;
04197     }
04198   else
04199    z SET_TO parameters[5203 + (p_int * 20)];
04200 
04201 /* axis offsets could be included in the following calculations but
04202    do not need to be because the results do not change */
04203   if (p_int IS settings->origin_ngc) /* system is currently used */
04204     {
04205       settings->current_x SET_TO
04206         (settings->current_x + settings->origin_offset_x);
04207       settings->current_y SET_TO
04208         (settings->current_y + settings->origin_offset_y);
04209       settings->current_z SET_TO
04210         (settings->current_z + settings->origin_offset_z);
04211 
04212       settings->origin_offset_x SET_TO x;
04213       settings->origin_offset_y SET_TO y;
04214       settings->origin_offset_z SET_TO z;
04215 
04216       SET_ORIGIN_OFFSETS(x + settings->axis_offset_x,
04217                          y + settings->axis_offset_y,
04218                          z + settings->axis_offset_z);
04219       settings->current_x SET_TO (settings->current_x - x);
04220       settings->current_y SET_TO (settings->current_y - y);
04221       settings->current_z SET_TO (settings->current_z - z);
04222     }
04223 #ifdef DEBUG_EMC
04224   else
04225     COMMENT("interpreter: setting coordinate system origin");
04226 #endif
04227   return RS274NGC_OK;
04228 }

int convert_speed block_pointer    block,
setup_pointer    settings
 

Definition at line 7224 of file rs274ngc.cc.

07227 {
07228   SET_SPINDLE_SPEED(block->s_number);
07229   settings->speed SET_TO block->s_number;
07230   return RS274NGC_OK;
07231 }

int convert_stop block_pointer    block,
setup_pointer    settings
 

Definition at line 7297 of file rs274ngc.cc.

07300 {
07301   static char name[] SET_TO "convert_stop";
07302 
07303   if (block->m_modes[4] IS 0)
07304     {
07305       PROGRAM_STOP();
07306     }
07307   else if (block->m_modes[4] IS 60)
07308     {
07309       PALLET_SHUTTLE();
07310       PROGRAM_STOP();
07311     }
07312   else if (block->m_modes[4] IS 1)
07313     {
07314       OPTIONAL_PROGRAM_STOP();
07315     }
07316   else if ((block->m_modes[4] IS 2) OR (block->m_modes[4] IS 30))
07317     { /* reset stuff here */
07318 /*1*/
07319       settings->current_x SET_TO settings->current_x
07320         + settings->origin_offset_x;
07321       settings->current_y SET_TO settings->current_y
07322         + settings->origin_offset_y;
07323       settings->current_z SET_TO settings->current_z
07324         + settings->origin_offset_z;
07325       settings->origin_offset_x SET_TO settings->parameters[5221];
07326       settings->origin_offset_y SET_TO settings->parameters[5222];
07327       settings->origin_offset_z SET_TO settings->parameters[5223];
07328       settings->current_x SET_TO settings->current_x -
07329         settings->origin_offset_x;
07330       settings->current_y SET_TO settings->current_y -
07331         settings->origin_offset_y;
07332       settings->current_z SET_TO settings->current_z -
07333         settings->origin_offset_z;
07334       SET_ORIGIN_OFFSETS(settings->origin_offset_x + settings->axis_offset_x,
07335                          settings->origin_offset_y + settings->axis_offset_y,
07336                          settings->origin_offset_z + settings->axis_offset_z);
07337 
07338 /*2*/ if (settings->plane ISNT CANON_PLANE_XY)
07339         {
07340           SELECT_PLANE(CANON_PLANE_XY);
07341           settings->plane SET_TO CANON_PLANE_XY;
07342         }
07343 
07344 /*3*/ settings->distance_mode SET_TO MODE_ABSOLUTE;
07345 
07346 /*4*/ settings->feed_mode SET_TO UNITS_PER_MINUTE;
07347 
07348 /*5*/ if (settings->feed_override ISNT ON)
07349         {
07350           ENABLE_FEED_OVERRIDE();
07351           settings->feed_override SET_TO ON;
07352         }
07353       if (settings->speed_override ISNT ON)
07354         {
07355           ENABLE_SPEED_OVERRIDE();
07356           settings->speed_override SET_TO ON;
07357         }
07358 
07359 /*6*/ settings->cutter_radius_compensation SET_TO OFF;
07360       settings->program_x SET_TO UNKNOWN;
07361 
07362 /*7*/ STOP_SPINDLE_TURNING();
07363       settings->spindle_turning SET_TO CANON_STOPPED;
07364 
07365 /*8*/ settings->motion_mode SET_TO G_1;
07366 
07367 /*9*/ if (settings->mist IS ON)
07368         {
07369           MIST_OFF();
07370           settings->mist SET_TO OFF;
07371         }
07372       if (settings->flood IS ON)
07373         {
07374           FLOOD_OFF();
07375           settings->flood SET_TO OFF;
07376         }
07377 
07378       if (block->m_modes[4] IS 30)
07379         PALLET_SHUTTLE();
07380       PROGRAM_END();
07381       return RS274NGC_EXIT;
07382     }
07383   else
07384     BUG_MACRO(name, "Code is not M0, M1, M2, M30 or M60 in convert_stop");
07385   return RS274NGC_OK;
07386 }

int convert_straight int    move,
block_pointer    block,
setup_pointer    settings
 

Definition at line 4264 of file rs274ngc.cc.

04268 {
04269   static char name[] SET_TO "convert_straight";
04270   double end_x = 0.0;
04271   double end_y = 0.0;
04272   double end_z = 0.0;
04273   double length;
04274   double rate;
04275 
04276   if (((block->x_flag IS OFF) AND (block->y_flag IS OFF)) AND
04277       (block->z_flag IS OFF))
04278     ERROR_MACRO(_interpreter_linetext, name, "X, Y, and Z words all missing with G0 or G1");
04279 
04280   settings->motion_mode SET_TO move;
04281   utility_find_ends(block, settings, &end_x, &end_y, &end_z);
04282 
04283   if (move IS G_0)
04284     {
04285       if (settings->cutter_radius_compensation ISNT OFF)
04286         ERROR_MACRO(_interpreter_linetext, name, "Cannot use G0 with cutter radius comp");
04287       STRAIGHT_TRAVERSE(end_x, end_y, end_z);
04288       settings->current_x SET_TO end_x;
04289       settings->current_y SET_TO end_y;
04290     }
04291   else if (move IS G_1)
04292     {
04293       if (settings->cutter_radius_compensation ISNT OFF) /* NOT "IS ON"! */
04294         {
04295           if (settings->feed_mode IS INVERSE_TIME)
04296             ERROR_MACRO(_interpreter_linetext, name,
04297                 "Cannot use inverse time feed with cutter radius comp");
04298           else if (block->g_modes[4] IS G_53)
04299             ERROR_MACRO(_interpreter_linetext, name, "Cannot use G53 with cutter radius comp");
04300           else if (settings->feed_rate IS 0.0)
04301             ERROR_MACRO(_interpreter_linetext, name, "Cannot do G1 with zero feed rate");
04302           else if (settings->program_x IS UNKNOWN)
04303             {
04304               if (convert_straight_comp1(settings, end_x, end_y, end_z)
04305                   IS RS274NGC_ERROR)
04306                 ERROR_MACRO_PASS(name);
04307             }
04308           else
04309             {
04310               if (convert_straight_comp2(settings, end_x, end_y, end_z)
04311                   IS RS274NGC_ERROR)
04312                 ERROR_MACRO_PASS(name);
04313             }
04314         }
04315       else
04316         {
04317           if (settings->feed_mode IS INVERSE_TIME)
04318             {
04319               if (block->f_number IS -1.0)
04320                 ERROR_MACRO(_interpreter_linetext, name,
04321                             "F word missing with inverse time G1 move");
04322               else
04323                 {
04324                   length SET_TO utility_find_straight_length
04325                     (end_x, end_y, end_z,
04326                      settings->current_x, settings->current_y,
04327                      settings->current_z);
04328                   rate SET_TO MAX(0.1, (length * block->f_number));
04329                   SET_FEED_RATE (rate);
04330                   settings->feed_rate SET_TO rate;
04331                 }
04332             }
04333           else if (settings->feed_rate IS 0.0)
04334             ERROR_MACRO(_interpreter_linetext, name, "Cannot do G1 with zero feed rate");
04335           STRAIGHT_FEED(end_x, end_y, end_z);
04336           settings->current_x SET_TO end_x;
04337           settings->current_y SET_TO end_y;
04338         }
04339     }
04340   else
04341     BUG_MACRO(name, "Code is not G0 or G1 in convert_straight");
04342 
04343   settings->current_z SET_TO end_z;
04344   return RS274NGC_OK;
04345 }

int convert_straight_comp1 setup_pointer    settings,
double    px,
double    py,
double    end_z
 

Definition at line 3099 of file rs274ngc.cc.

03104 {
03105   static char name[] SET_TO "convert_straight_comp1";
03106   double radius;
03107   double cx, cy;
03108   double distance;
03109   double theta;
03110   double alpha;
03111   int side;
03112 
03113   side SET_TO settings->cutter_radius_compensation;
03114   cx SET_TO settings->current_x;
03115   cy SET_TO settings->current_y;
03116 
03117   radius SET_TO
03118     (settings->tool_table[settings->tool_table_index].diameter)/2.0;
03119   if (radius <= 0.0)
03120     ERROR_MACRO(_interpreter_linetext, name, "Bad tool radius value with cutter radius comp");
03121   distance SET_TO hypot((px - cx), (py -cy));
03122 
03123   if ((side ISNT LEFT) AND (side ISNT RIGHT))
03124     BUG_MACRO(name,
03125               "Side fails to be right or left in convert_straight_comp1");
03126   else if (distance <= radius)
03127     ERROR_MACRO(_interpreter_linetext, name, "Cutter gouging with cutter radius comp");
03128 
03129   theta SET_TO acos(radius/distance);
03130   alpha SET_TO (side IS LEFT) ? (atan2((cy - py), (cx - px)) - theta) :
03131                                 (atan2((cy - py), (cx - px)) + theta);
03132   cx SET_TO (px + (radius * cos(alpha))); /* reset to end location */
03133   cy SET_TO (py + (radius * sin(alpha)));
03134   STRAIGHT_FEED (cx, cy, end_z);
03135   settings->current_x SET_TO cx;
03136   settings->current_y SET_TO cy;
03137   settings->program_x SET_TO px;
03138   settings->program_y SET_TO py;
03139   return RS274NGC_OK;
03140 }

int convert_straight_comp2 setup_pointer    settings,
double    program_end_x,
double    program_end_y,
double    end_z
 

Definition at line 3193 of file rs274ngc.cc.

03198 {
03199   static char name[] SET_TO "convert_straight_comp2";
03200   double radius;
03201   double cx, cy; /* actual end point */
03202   double dx, dy; /* end of added arc, if needed */
03203   double start_x, start_y; /* programmed beginning point */
03204   double theta;
03205   double alpha;
03206   double beta;
03207   double gamma;
03208   /* small angle in radians for testing corners */
03209   double small SET_TO TOLERANCE_CONCAVE_CORNER;
03210   int side;
03211 
03212   side SET_TO settings->cutter_radius_compensation;
03213   start_x SET_TO settings->program_x;
03214   start_y SET_TO settings->program_y;
03215   if ((start_x IS program_end_x) AND (start_y IS program_end_y))
03216     {
03217       STRAIGHT_FEED(settings->current_x, settings->current_y, end_z);
03218       return RS274NGC_OK;
03219     }
03220   radius SET_TO
03221     (settings->tool_table[settings->tool_table_index].diameter)/2.0;
03222   if (radius <= 0.0)
03223     ERROR_MACRO(_interpreter_linetext, name, "Bad tool radius value with cutter radius comp");
03224   theta SET_TO atan2(settings->current_y - start_y,
03225                      settings->current_x - start_x);
03226   alpha SET_TO
03227     atan2(program_end_y - start_y, program_end_x - start_x);
03228 
03229   if (side IS LEFT)
03230     {
03231       if (theta < alpha)
03232         theta SET_TO (theta + TWO_PI);
03233       beta SET_TO ((theta - alpha) - PI2);
03234       gamma SET_TO PI2;
03235     }
03236   else if (side IS RIGHT)
03237     {
03238       if (alpha < theta)
03239         alpha SET_TO (alpha + TWO_PI);
03240       beta SET_TO ((alpha - theta) - PI2);
03241       gamma SET_TO -PI2;
03242     }
03243   else
03244     BUG_MACRO(name,
03245               "Side fails to be right or left in convert_straight_comp2");
03246   cx SET_TO (program_end_x + (radius * cos(alpha + gamma)));
03247   cy SET_TO (program_end_y + (radius * sin(alpha + gamma)));
03248   dx SET_TO (start_x + (radius * cos(alpha + gamma)));
03249   dy SET_TO (start_y + (radius * sin(alpha + gamma)));
03250 
03251   if ((beta < -small) OR (beta > (PI + small)))
03252     ERROR_MACRO(_interpreter_linetext, name, "Cannot have concave corner with cutter radius comp");
03253   else if (beta > small) /* ARC NEEDED */
03254     {
03255       ARC_FEED(dx, dy, start_x, start_y, (side IS LEFT) ? -1 : 1, end_z);
03256       STRAIGHT_FEED (cx, cy, end_z);
03257     }
03258   else STRAIGHT_FEED (cx, cy, end_z);
03259 
03260   settings->current_x SET_TO cx;
03261   settings->current_y SET_TO cy;
03262   settings->program_x SET_TO program_end_x;
03263   settings->program_y SET_TO program_end_y;
03264   return RS274NGC_OK;
03265 }

int convert_tool_change block_pointer    block,
setup_pointer    settings
 

Definition at line 6458 of file rs274ngc.cc.

06461 {
06462   static char name[] SET_TO "convert_tool_change";
06463 
06464   CHANGE_TOOL(settings->selected_tool_slot);
06465   settings->current_slot SET_TO settings->selected_tool_slot;
06466   settings->spindle_turning SET_TO CANON_STOPPED;
06467 
06468   return RS274NGC_OK;
06469 }

int convert_tool_length_offset int    g_code,
block_pointer    block,
setup_pointer    settings
 

Definition at line 6503 of file rs274ngc.cc.

06507 {
06508   static char name[] SET_TO "convert_tool_length_offset";
06509   int index;
06510   double offset;
06511 
06512   if (g_code IS G_49)
06513     {
06514       USE_TOOL_LENGTH_OFFSET(0.0);
06515       settings->current_z SET_TO (settings->current_z +
06516                                   settings->tool_length_offset);
06517       settings->tool_length_offset SET_TO 0.0;
06518       settings->length_offset_index SET_TO 0;
06519     }
06520   else if (g_code IS G_43)
06521     {
06522       index SET_TO block->h_number;
06523       if (index IS -1)
06524         ERROR_MACRO(_interpreter_linetext, name, "Offset index missing");
06525       else if (index > GET_EXTERNAL_TOOL_MAX())
06526         ERROR_MACRO(_interpreter_linetext, name, "Tool index out of bounds");
06527       else
06528         {
06529           offset SET_TO settings->tool_table[index].length;
06530           USE_TOOL_LENGTH_OFFSET(offset);
06531           settings->current_z SET_TO
06532             (settings->current_z + settings->tool_length_offset - offset);
06533           settings->tool_length_offset SET_TO offset;
06534           settings->length_offset_index SET_TO index;
06535         }
06536     }
06537   else
06538     BUG_MACRO(name, "Code is not G43 or G49 in convert_tool_length_offset");
06539   return RS274NGC_OK;
06540 }

int convert_tool_select block_pointer    block,
setup_pointer    settings
 

Definition at line 7406 of file rs274ngc.cc.

07409 {
07410   static char name[] SET_TO "convert_tool_select";
07411 
07412   if (block->t_number > GET_EXTERNAL_TOOL_MAX())
07413     ERROR_MACRO(_interpreter_linetext, name, "Selected tool slot number too large");
07414 
07415   SELECT_TOOL(block->t_number);
07416   settings->selected_tool_slot SET_TO block->t_number;
07417   return RS274NGC_OK;
07418 }

int execute_binary1 double *    left,
int    operation,
double *    right
 

Definition at line 607 of file rs274ngc.cc.

00611 {
00612   static char name[] SET_TO "execute_binary1";
00613   switch (operation)
00614     {
00615     case DIVIDED_BY:
00616       if (*right IS 0.0)
00617         ERROR_MACRO(_interpreter_linetext, name, "Attempt to divide by zero");
00618       else
00619         {
00620           *left SET_TO (*left / *right);
00621           return RS274NGC_OK;
00622         }
00623     case MODULO: /* always calculates a positive answer */
00624       *left SET_TO fmod(*left, *right);
00625       if (*left < 0.0)
00626         {
00627           *left SET_TO (*left + fabs(*right));
00628         }
00629       return RS274NGC_OK;
00630     case POWER:
00631       if ((*left < 0.0) AND (floor(*right) ISNT *right))
00632         ERROR_MACRO(_interpreter_linetext, name, "Cannot raise negative number to non-integer power");
00633       *left SET_TO pow(*left, *right);
00634       return RS274NGC_OK;
00635     case TIMES:
00636       *left SET_TO (*left * *right);
00637       return RS274NGC_OK;
00638     default:
00639       BUG_MACRO(name, "Unknown operation in execute_binary1");
00640     }
00641 }

int execute_binary2 double *    left,
int    operation,
double *    right
 

Definition at line 666 of file rs274ngc.cc.

00670 {
00671   static char name[] SET_TO "execute_binary2";
00672   switch (operation)
00673     {
00674     case AND2:
00675       *left SET_TO ((*left IS 0.0) OR (*right IS 0.0)) ? 0.0 : 1.0;
00676       return RS274NGC_OK;
00677     case EXCLUSIVE_OR:
00678       *left SET_TO (((*left IS 0.0) AND (*right ISNT 0.0)) OR
00679                     ((*left ISNT 0.0) AND (*right IS 0.0))) ? 1.0 : 0.0;
00680       return RS274NGC_OK;
00681     case MINUS:
00682       *left SET_TO (*left - *right);
00683       return RS274NGC_OK;
00684     case NON_EXCLUSIVE_OR:
00685       *left SET_TO ((*left ISNT 0.0) OR (*right ISNT 0.0)) ? 1.0 : 0.0;
00686       return RS274NGC_OK;
00687     case PLUS:
00688       *left SET_TO (*left + *right);
00689       return RS274NGC_OK;
00690     default:
00691       BUG_MACRO(name, "Unknown operation in execute_binary2");
00692     }
00693 }

int execute_block block_pointer    block,
setup_pointer    settings,
int    line_number
 

Definition at line 7743 of file rs274ngc.cc.

07747 {
07748   static char name[] SET_TO "execute_block";
07749   if (block->comment[0] ISNT 0)
07750     {
07751       if (convert_comment(block->comment) IS RS274NGC_ERROR)
07752         ERROR_MACRO_PASS(name);
07753     }
07754   if (block->g_modes[5] ISNT -1)
07755     {
07756       if (convert_feed_mode(block->g_modes[5], block, settings)
07757           IS RS274NGC_ERROR)
07758         ERROR_MACRO_PASS(name);
07759     }
07760   if (block->f_number > -1.0)
07761     {
07762       if (settings->feed_mode IS INVERSE_TIME); /* handle elsewhere */
07763       else if (convert_feed_rate(block, settings) IS RS274NGC_ERROR)
07764         ERROR_MACRO_PASS(name);
07765     }
07766   if (block->s_number > -1.0)
07767     {
07768       if (convert_speed(block, settings) IS RS274NGC_ERROR)
07769         ERROR_MACRO_PASS(name);
07770     }
07771   if (block->t_number ISNT -1)
07772     {
07773       if (convert_tool_select(block, settings) IS RS274NGC_ERROR)
07774         ERROR_MACRO_PASS(name);
07775     }
07776   if (convert_m(block, settings) IS RS274NGC_ERROR)
07777         ERROR_MACRO_PASS(name);
07778   if (convert_g(block, settings) IS RS274NGC_ERROR)
07779     ERROR_MACRO_PASS(name);
07780   if (block->m_modes[4] ISNT -1) /* converts m0, m1, m2, m30, or m60 */
07781     {
07782       if (convert_stop(block, settings) IS RS274NGC_EXIT)
07783         return RS274NGC_EXIT;
07784     }
07785   if (settings->probe_flag IS ON)
07786     return RS274NGC_EXECUTE_FINISH;
07787   else
07788     return RS274NGC_OK;
07789 }

int execute_unary double *    double_ptr,
int    operation
 

Definition at line 720 of file rs274ngc.cc.

00723 {
00724   static char name[] SET_TO "execute_unary";
00725   switch (operation)
00726     {
00727     case ABS:
00728       if (*double_ptr < 0.0)
00729           *double_ptr SET_TO (-1.0 * *double_ptr);
00730       return RS274NGC_OK;
00731     case ACOS:
00732       if ((*double_ptr < -1.0) OR (*double_ptr > 1.0))
00733         ERROR_MACRO(_interpreter_linetext, name, "Argument to acos out of range");
00734       else
00735         {
00736           *double_ptr SET_TO acos(*double_ptr);
00737           *double_ptr SET_TO ((*double_ptr * 180.0)/ PI);
00738           return RS274NGC_OK;
00739         }
00740     case ASIN:
00741       if ((*double_ptr < -1.0) OR (*double_ptr > 1.0))
00742         ERROR_MACRO(_interpreter_linetext, name, "Argument to asin out of range");
00743       else
00744         {
00745           *double_ptr SET_TO asin(*double_ptr);
00746           *double_ptr SET_TO ((*double_ptr * 180.0)/ PI);
00747           return RS274NGC_OK;
00748         }
00749     case COS:
00750       *double_ptr SET_TO cos((*double_ptr * PI)/180.0);
00751       return RS274NGC_OK;
00752     case EXP:
00753       *double_ptr SET_TO exp(*double_ptr);
00754       return RS274NGC_OK;
00755     case FIX:
00756       *double_ptr SET_TO floor(*double_ptr);
00757       return RS274NGC_OK;
00758     case FUP:
00759       *double_ptr SET_TO ceil(*double_ptr);
00760       return RS274NGC_OK;
00761     case LN:
00762       if (*double_ptr <= 0.0)
00763         ERROR_MACRO(_interpreter_linetext, name, "Zero or negative argument to ln");
00764       else
00765         {
00766           *double_ptr SET_TO log(*double_ptr);
00767           return RS274NGC_OK;
00768         }
00769     case ROUND:
00770       *double_ptr SET_TO (double)
00771         ((int) (*double_ptr + ((*double_ptr < 0.0) ? -0.5 : 0.5)));
00772       return RS274NGC_OK;
00773     case SIN:
00774       *double_ptr SET_TO sin((*double_ptr * PI)/180.0);
00775       return RS274NGC_OK;
00776     case SQRT:
00777       if (*double_ptr < 0.0)
00778         ERROR_MACRO(_interpreter_linetext, name, "Negative argument to sqrt");
00779       else
00780         {
00781           *double_ptr SET_TO sqrt(*double_ptr);
00782           return RS274NGC_OK;
00783         }
00784     case TAN:
00785       *double_ptr SET_TO tan((*double_ptr * PI)/180.0);
00786       return RS274NGC_OK;
00787     default:
00788       BUG_MACRO(name, "Unknown operation in execute_unary");
00789     }
00790 }

int init_block block_pointer    block
 

Definition at line 7458 of file rs274ngc.cc.

07460 {
07461   int n;
07462   block->comment[0] SET_TO 0;
07463   block->d_number SET_TO -1;
07464   block->f_number SET_TO -1.0;
07465   block->g_count SET_TO 0;
07466   for (n SET_TO 0; n < 14; n++)
07467     {
07468       block->g_modes[n] SET_TO -1;
07469     }
07470   block->h_number SET_TO -1;
07471   block->i_flag SET_TO OFF;
07472   block->j_flag SET_TO OFF;
07473   block->k_flag SET_TO OFF;
07474   block->l_number SET_TO -1;
07475   block->line_number SET_TO -1;
07476   block->motion_to_be SET_TO -1;
07477   block->m_count SET_TO 0;
07478   for (n SET_TO 0; n < 10; n++)
07479     {
07480       block->m_modes[n] SET_TO -1;
07481     }
07482   block->p_number SET_TO -1.0;
07483   block->q_number SET_TO -1.0;
07484   block->r_flag SET_TO OFF;
07485   block->s_number SET_TO -1.0;
07486   block->t_number SET_TO -1;
07487   block->x_flag SET_TO OFF;
07488   block->y_flag SET_TO OFF;
07489   block->z_flag SET_TO OFF;
07490 
07491   return RS274NGC_OK;
07492 }

int read_atan char *    line,
int *    counter,
double *    double_ptr,
double *    parameters
 

Definition at line 826 of file rs274ngc.cc.

00827                                : line of RS274/NGC code being processed */
00828  int * counter,       /* pointer to a counter for position on line      */
00829  double * double_ptr, /* pointer to double to be read                   */
00830  double * parameters) /* array of system parameters                     */
00831 {
00832   static char name[] SET_TO "read_atan";
00833   double argument2;
00834 
00835   if (line [*counter] ISNT '/')
00836     ERROR_MACRO(_interpreter_linetext, name, "Slash missing");
00837 
00838   *counter SET_TO (*counter + 1);
00839 
00840   if(line[*counter] ISNT '[')
00841     ERROR_MACRO(_interpreter_linetext, name, "Left bracket missing after slash with atan operator");
00842 
00843   if (read_real_expression (line, counter, &argument2, parameters)
00844       IS RS274NGC_ERROR)
00845     ERROR_MACRO_PASS(name);
00846 
00847   *double_ptr SET_TO atan2(*double_ptr, argument2); /* value in radians */
00848   *double_ptr SET_TO ((*double_ptr * 180.0)/PI);    /* convert to degrees */
00849   return RS274NGC_OK;
00850 }

int read_comment char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4379 of file rs274ngc.cc.

04380                                : line of RS274 code being processed    */
04381  int * counter,       /* pointer to a counter for position on the line */
04382  block_pointer block, /* pointer to a block being filled from the line */
04383  double * parameters) /* array of system parameters                    */
04384 {
04385   static char name[] SET_TO "read_comment";
04386   int n;
04387 
04388   if (line[*counter] ISNT '(')
04389     BUG_MACRO(name, "Read_comment should not have been called");
04390 
04391   (*counter)++;
04392   for (n SET_TO 0; line[*counter] ISNT ')' ; (*counter)++, n++)
04393     {
04394       block->comment[n] SET_TO line[*counter];
04395     }
04396   block->comment[n] SET_TO 0;
04397   (*counter)++;
04398   return RS274NGC_OK;
04399 }

int read_d char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4429 of file rs274ngc.cc.

04430                                : line of RS274 code being processed    */
04431  int * counter,       /* pointer to a counter for position on the line */
04432  block_pointer block, /* pointer to a block being filled from the line */
04433  double * parameters) /* array of system parameters                    */
04434 {
04435   static char name[] SET_TO "read_d";
04436   int value;
04437 
04438   if (line[*counter] ISNT 'd')
04439     BUG_MACRO(name, "Read_d should not have been called");
04440 
04441   *counter SET_TO (*counter + 1);
04442 
04443   if (block->d_number > -1)
04444     ERROR_MACRO(_interpreter_linetext, name, "Multiple D words on one line");
04445   else if (read_integer_value(line, counter, &value, parameters)
04446            IS RS274NGC_ERROR)
04447     ERROR_MACRO_PASS(name);
04448   else if (value < 0)
04449     ERROR_MACRO(_interpreter_linetext, name, "Negative D code used");
04450   else
04451     {
04452       block->d_number SET_TO value;
04453       return RS274NGC_OK;
04454     }
04455 }

int read_f char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4487 of file rs274ngc.cc.

04488                                : line of RS274 code being processed    */
04489  int * counter,       /* pointer to a counter for position on the line */
04490  block_pointer block, /* pointer to a block being filled from the line */
04491  double * parameters) /* array of system parameters                    */
04492 {
04493   static char name[] SET_TO "read_f";
04494   double value;
04495 
04496   if (line[*counter] ISNT 'f')
04497     BUG_MACRO(name, "Read_f should not have been called");
04498 
04499   *counter SET_TO (*counter + 1);
04500 
04501   if (block->f_number > -1.0)
04502     ERROR_MACRO(_interpreter_linetext, name, "Multiple F words on one line");
04503   else if (read_real_value(line, counter, &value, parameters)
04504            IS RS274NGC_ERROR)
04505     ERROR_MACRO_PASS(name);
04506   else if (value < 0.0)
04507     ERROR_MACRO(_interpreter_linetext, name, "Negative F word found");
04508   else
04509     {
04510       block->f_number SET_TO value;
04511       return RS274NGC_OK;
04512     }
04513 }

int read_g char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4563 of file rs274ngc.cc.

04564                                : line of RS274/NGC code being processed */
04565  int * counter,       /* pointer to a counter for position on the line  */
04566  block_pointer block, /* pointer to a block being filled from the line  */
04567  double * parameters) /* array of system parameters                     */
04568 {
04569   static char name[] SET_TO "read_g";
04570   double value_read;
04571   int value;
04572   int mode;
04573 
04574   if (line[*counter] ISNT 'g')
04575     BUG_MACRO(name, "Read_g should not have been called");
04576 
04577   *counter SET_TO (*counter + 1);
04578   if (read_real_value(line, counter, &value_read, parameters)
04579       IS RS274NGC_ERROR)
04580     ERROR_MACRO_PASS(name);
04581   value_read SET_TO (10.0 * value_read);
04582   value SET_TO (int)floor(value_read);
04583 
04584   if ((value_read - value) > 0.999)
04585     value SET_TO (int)ceil(value_read);
04586   else if ((value_read - value) > 0.001)
04587     ERROR_MACRO(_interpreter_linetext, name,"G code out of range");
04588 
04589   if (value > 999)
04590     ERROR_MACRO(_interpreter_linetext, name, "G code out of range");
04591   else if (value < 0)
04592     ERROR_MACRO(_interpreter_linetext, name, "Negative G code used");
04593 
04594   mode SET_TO gees[value];
04595 
04596   if (mode IS -1)
04597     ERROR_MACRO(_interpreter_linetext, name, "Unknown G code used");
04598   else if (block->g_modes[mode] ISNT -1)
04599     ERROR_MACRO(_interpreter_linetext, name, "Two G codes used from same modal group");
04600   else
04601     {
04602       block->g_modes[mode] SET_TO value;
04603       block->g_count++;
04604       return RS274NGC_OK;
04605     }
04606 }

int read_i char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4639 of file rs274ngc.cc.

04640                                : line of RS274 code being processed     */
04641  int * counter,       /* pointer to a counter for position on the line  */
04642  block_pointer block, /* pointer to a block being filled from the line  */
04643  double * parameters) /* array of system parameters                     */
04644 {
04645   static char name[] SET_TO "read_i";
04646   double value;
04647 
04648   if (line[*counter] ISNT 'i')
04649     BUG_MACRO(name, "Read_i should not have been called");
04650 
04651   *counter SET_TO (*counter + 1);
04652 
04653   if (block->i_flag ISNT OFF)
04654     ERROR_MACRO(_interpreter_linetext, name, "Multiple I words on one line");
04655   else if (read_real_value(line, counter, &value, parameters)
04656            IS RS274NGC_ERROR)
04657     ERROR_MACRO_PASS(name);
04658   else
04659     {
04660       block->i_flag SET_TO ON;
04661       block->i_number SET_TO value;
04662       return RS274NGC_OK;
04663     }
04664 }

int read_integer_unsigned char *    line,
int *    counter,
int *    integer_ptr
 

Definition at line 3291 of file rs274ngc.cc.

03292                                : line of RS274 code being processed    */
03293  int * counter,       /* pointer to a counter for position on the line */
03294  int * integer_ptr)   /* pointer to the value being read               */
03295 {
03296   static char name[] SET_TO "read_integer_unsigned";
03297   int n;
03298   char c;
03299 
03300   for (n SET_TO *counter; ; n++)
03301     {
03302       c SET_TO line[n];
03303       if ((c < 48) OR (c > 57))
03304         break;
03305     }
03306   if (n IS *counter)
03307     ERROR_MACRO(_interpreter_linetext, name, "Bad format unsigned integer");
03308   if (sscanf(line + *counter, "%d", integer_ptr) IS 0)
03309     BUG_MACRO(name, "Sscanf failure in read_integer_unsigned");
03310   else
03311     {
03312       *counter SET_TO n;
03313       return RS274NGC_OK;
03314     }
03315 }

int read_integer_value char *    line,
int *    counter,
int *    integer_ptr,
double *    parameters
 

Definition at line 884 of file rs274ngc.cc.

00885                                    : line of RS274/NGC code being processed */
00886  int * counter,           /* pointer to a counter for position on the line  */
00887  int * integer_ptr,       /* pointer to the value being read                */
00888  double * parameters)     /* array of system parameters                     */
00889 {
00890   static char name[] SET_TO "read_integer_value";
00891   double float_value;
00892 
00893   if (read_real_value(line, counter, &float_value, parameters)
00894       IS RS274NGC_ERROR)
00895     ERROR_MACRO_PASS(name);
00896   *integer_ptr SET_TO (int)floor(float_value);
00897   if ((float_value - *integer_ptr) > 0.9999)
00898     {
00899       *integer_ptr SET_TO (int)ceil(float_value);
00900     }
00901   else if ((float_value - *integer_ptr) > 0.0001)
00902     ERROR_MACRO(_interpreter_linetext, name, "Non-integer value for integer");
00903   return RS274NGC_OK;
00904 }

int read_items block_pointer    block,
char *    line,
double *    parameters
 

Definition at line 7511 of file rs274ngc.cc.

07513                                : line of RS274/NGC code being processed */
07514  double * parameters) /* array of system parameters                     */
07515 {
07516   static char name[] SET_TO "read_items";
07517   int counter;
07518   int length;
07519 
07520   length SET_TO strlen(line);
07521   counter SET_TO 0;
07522 
07523   if (line[counter] IS '/')
07524     counter++;
07525   if (line[counter] IS 'n')
07526     {
07527       if (read_line_number(line, &counter, block) IS RS274NGC_ERROR)
07528         ERROR_MACRO_PASS(name);
07529     }
07530   for ( ; counter < length; )
07531     {
07532       if (read_one_item (line, &counter, block, parameters) IS RS274NGC_ERROR)
07533         ERROR_MACRO_PASS(name);
07534     }
07535   return RS274NGC_OK;
07536 }

int read_j char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4697 of file rs274ngc.cc.

04698                                : line of RS274 code being processed     */
04699  int * counter,       /* pointer to a counter for position on the line  */
04700  block_pointer block, /* pointer to a block being filled from the line  */
04701  double * parameters) /* array of system parameters                     */
04702 {
04703   static char name[] SET_TO "read_j";
04704   double value;
04705 
04706   if (line[*counter] ISNT 'j')
04707     BUG_MACRO(name, "Read_j should not have been called");
04708 
04709   *counter SET_TO (*counter + 1);
04710 
04711   if (block->j_flag ISNT OFF)
04712     ERROR_MACRO(_interpreter_linetext, name, "Multiple J words on one line");
04713   else if (read_real_value(line, counter, &value, parameters)
04714            IS RS274NGC_ERROR)
04715     ERROR_MACRO_PASS(name);
04716   else
04717     {
04718       block->j_flag SET_TO ON;
04719       block->j_number SET_TO value;
04720       return RS274NGC_OK;
04721     }
04722 }

int read_k char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4755 of file rs274ngc.cc.

04756                                : line of RS274 code being processed     */
04757  int * counter,       /* pointer to a counter for position on the line  */
04758  block_pointer block, /* pointer to a block being filled from the line  */
04759  double * parameters) /* array of system parameters                     */
04760 {
04761   static char name[] SET_TO "read_k";
04762   double value;
04763 
04764   if (line[*counter] ISNT 'k')
04765     BUG_MACRO(name, "Read_k should not have been called");
04766 
04767   *counter SET_TO (*counter + 1);
04768 
04769   if (block->k_flag ISNT OFF)
04770     ERROR_MACRO(_interpreter_linetext, name, "Multiple K words on one line");
04771   else if (read_real_value(line, counter, &value, parameters)
04772            IS RS274NGC_ERROR)
04773     ERROR_MACRO_PASS(name);
04774   else
04775     {
04776       block->k_flag SET_TO ON;
04777       block->k_number SET_TO value;
04778       return RS274NGC_OK;
04779     }
04780 }

int read_l char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4811 of file rs274ngc.cc.

04812                                : line of RS274/NGC code being processed */
04813  int * counter,       /* pointer to a counter for position on the line  */
04814  block_pointer block, /* pointer to a block being filled from the line  */
04815  double * parameters) /* array of system parameters                     */
04816 {
04817   static char name[] SET_TO "read_l";
04818   int value;
04819 
04820   if (line[*counter] ISNT 'l')
04821     BUG_MACRO(name, "Read_l should not have been called");
04822 
04823   *counter SET_TO (*counter + 1);
04824 
04825   if (block->l_number > -1)
04826     ERROR_MACRO(_interpreter_linetext, name, "Multiple L words on one line");
04827   else if (read_integer_value(line, counter, &value, parameters)
04828            IS RS274NGC_ERROR)
04829     ERROR_MACRO_PASS(name);
04830   else if (value < 0)
04831     ERROR_MACRO(_interpreter_linetext, name, "Negative L word used");
04832   else
04833     {
04834       block->l_number SET_TO value;
04835       return RS274NGC_OK;
04836     }
04837 }

int read_line char *    line,
block_pointer    block,
setup_pointer    settings
 

Definition at line 7810 of file rs274ngc.cc.

Referenced by rs274ngc_read().

07814 {
07815   static char name[] SET_TO "read_line";
07816   if (init_block (block) IS RS274NGC_ERROR)
07817     ERROR_MACRO_PASS(name);
07818   if (read_items(block, line, settings->parameters) IS RS274NGC_ERROR)
07819     ERROR_MACRO_PASS(name);
07820   if (utility_enhance_block(block, settings) IS RS274NGC_ERROR)
07821     ERROR_MACRO_PASS(name);
07822   if (check_items (block, settings) IS RS274NGC_ERROR)
07823     ERROR_MACRO_PASS(name);
07824   return RS274NGC_OK;
07825 }

int read_line_number char *    line,
int *    counter,
block_pointer    block
 

Definition at line 6569 of file rs274ngc.cc.

06570                                : line of RS274    code being processed  */
06571  int * counter,       /* pointer to a counter for position on the line  */
06572  block_pointer block) /* pointer to a block being filled from the line  */
06573 {
06574   static char name[] SET_TO "read_line_number";
06575   int value;
06576 
06577   if (line[*counter] ISNT 'n')
06578     BUG_MACRO(name, "Read_line_number should not have been called");
06579 
06580   *counter SET_TO (*counter + 1);
06581   if (read_integer_unsigned(line, counter, &value) IS RS274NGC_ERROR)
06582     ERROR_MACRO_PASS(name);
06583   else if (value > 99999)
06584     ERROR_MACRO(_interpreter_linetext, name, "Line number greater than 99999");
06585   else
06586     {
06587       block->line_number SET_TO value;
06588       return RS274NGC_OK;
06589     }
06590 }

int read_m char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4871 of file rs274ngc.cc.

04872                                : line of RS274 code being processed    */
04873  int * counter,       /* pointer to a counter for position on the line */
04874  block_pointer block, /* pointer to a block being filled from the line */
04875  double * parameters) /* array of system parameters                    */
04876 {
04877   static char name[] SET_TO "read_m";
04878   int value;
04879   int mode;
04880 
04881   if (line[*counter] ISNT 'm')
04882     BUG_MACRO(name, "Read_m should not have been called");
04883 
04884   *counter SET_TO (*counter + 1);
04885 
04886   if (read_integer_value(line, counter, &value, parameters) IS RS274NGC_ERROR)
04887     ERROR_MACRO_PASS(name);
04888   else if (value < 0)
04889     ERROR_MACRO(_interpreter_linetext, name, "Negative M code used");
04890   else if (value > 99)
04891     ERROR_MACRO(_interpreter_linetext, name, "M code greater than 99");
04892 
04893   mode SET_TO ems[value];
04894 
04895   if (mode IS -1)
04896     ERROR_MACRO(_interpreter_linetext, name, "Unknown M code used");
04897   else if (block->m_modes[mode] ISNT -1)
04898     ERROR_MACRO(_interpreter_linetext, name, "Two M codes used from same modal group");
04899   else
04900     {
04901       block->m_modes[mode] SET_TO value;
04902       block->m_count++;
04903       return RS274NGC_OK;
04904     }
04905 }

int read_one_item char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 6634 of file rs274ngc.cc.

06635                                : line of RS274/NGC code being processed */
06636  int * counter,       /* pointer to a counter for position on the line  */
06637  block_pointer block, /* pointer to a block being filled from the line  */
06638  double * parameters) /* array of system parameters                     */
06639 {
06640   static char name[] SET_TO "read_one_item";
06641   _function_pointer function_pointer;
06642 
06643   switch (line[*counter])
06644     {
06645     case 'd':
06646       function_pointer SET_TO read_d;
06647       break;
06648     case 'f':
06649       function_pointer SET_TO read_f;
06650       break;
06651     case 'g':
06652       function_pointer SET_TO read_g;
06653       break;
06654     case 'h':
06655       function_pointer SET_TO read_tool_length_offset;
06656       break;
06657     case 'i':
06658       function_pointer SET_TO read_i;
06659       break;
06660     case 'j':
06661       function_pointer SET_TO read_j;
06662       break;
06663     case 'k':
06664       function_pointer SET_TO read_k;
06665       break;
06666     case 'l':
06667       function_pointer SET_TO read_l;
06668       break;
06669     case 'm':
06670       function_pointer SET_TO read_m;
06671       break;
06672     case 'p':
06673       function_pointer SET_TO read_p;
06674       break;
06675     case 'q':
06676       function_pointer SET_TO read_q;
06677       break;
06678     case 'r':
06679       function_pointer SET_TO read_r;
06680       break;
06681     case 's':
06682       function_pointer SET_TO read_spindle_speed;
06683       break;
06684     case 't':
06685       function_pointer SET_TO read_tool;
06686       break;
06687     case 'x':
06688       function_pointer SET_TO read_x;
06689       break;
06690     case 'y':
06691       function_pointer SET_TO read_y;
06692       break;
06693     case 'z':
06694       function_pointer SET_TO read_z;
06695       break;
06696     case '(':
06697       function_pointer SET_TO read_comment;
06698       break;
06699     case '#':
06700       function_pointer SET_TO read_parameter_setting;
06701       break;
06702     default:
06703       ERROR_MACRO(_interpreter_linetext, name, "Bad character used");
06704     }
06705   if (function_pointer (line, counter, block, parameters) IS RS274NGC_ERROR)
06706     ERROR_MACRO_PASS(name);
06707   return RS274NGC_OK;
06708 }

int read_operation char *    line,
int *    counter,
int *    operation
 

Definition at line 922 of file rs274ngc.cc.

00923                                : line of RS274/NGC code being processed */
00924  int * counter,       /* pointer to a counter for position on the line  */
00925  int * operation)     /* pointer to operation to be read                */
00926 {
00927   static char name[] SET_TO "read_operation";
00928   char c;
00929 
00930   c SET_TO line[*counter];
00931   *counter SET_TO (*counter + 1);
00932   switch(c)
00933     {
00934     case '+':
00935       *operation SET_TO PLUS;
00936       return RS274NGC_OK;
00937     case '-':
00938       *operation SET_TO MINUS;
00939       return RS274NGC_OK;
00940     case '/':
00941       *operation SET_TO DIVIDED_BY;
00942       return RS274NGC_OK;
00943     case '*':
00944       if(strncmp((line + *counter), "*", 1) IS 0)
00945         {
00946           *operation SET_TO POWER;
00947           *counter SET_TO (*counter + 1);
00948           return RS274NGC_OK;
00949         }
00950       else
00951         {
00952           *operation SET_TO TIMES;
00953           return RS274NGC_OK;
00954         }
00955     case ']':
00956       *operation SET_TO RIGHT_BRACKET;
00957       return RS274NGC_OK;
00958     case 'a':
00959       if(strncmp((line + *counter), "nd", 2) IS 0)
00960         {
00961           *operation SET_TO AND2;
00962           *counter SET_TO (*counter + 2);
00963           return RS274NGC_OK;
00964         }
00965       else
00966         ERROR_MACRO(_interpreter_linetext, name, "Unknown operation name starting with A");
00967     case 'm':
00968       if(strncmp((line + *counter), "od", 2) IS 0)
00969         {
00970           *operation SET_TO MODULO;
00971           *counter SET_TO (*counter + 2);
00972           return RS274NGC_OK;
00973         }
00974       else
00975         ERROR_MACRO(_interpreter_linetext, name, "Unknown operation name starting with M");
00976     case 'o':
00977       if(strncmp((line + *counter), "r", 1) IS 0)
00978         {
00979           *operation SET_TO NON_EXCLUSIVE_OR;
00980           *counter SET_TO (*counter + 1);
00981           return RS274NGC_OK;
00982         }
00983       else
00984         ERROR_MACRO(_interpreter_linetext, name, "Unknown operation name starting with O");
00985     case 'x':
00986       if(strncmp((line + *counter), "or", 2) IS 0)
00987         {
00988           *operation SET_TO EXCLUSIVE_OR;
00989           *counter SET_TO (*counter + 2);
00990           return RS274NGC_OK;
00991         }
00992       else
00993         ERROR_MACRO(_interpreter_linetext, name, "Unknown operation name starting with X");
00994     case 0:
00995       ERROR_MACRO(_interpreter_linetext, name, "Unclosed expression");
00996     default:
00997       ERROR_MACRO(_interpreter_linetext, name, "Unknown operation");
00998     }
00999 }

int read_operation_unary char *    line,
int *    counter,
int *    operation
 

Definition at line 1023 of file rs274ngc.cc.

01024                                    : line of RS274/NGC code being processed */
01025  int * counter,           /* pointer to a counter for position on the line  */
01026  int * operation)         /* pointer to operation to be read                */
01027 {
01028   static char name[] SET_TO "read_operation_unary";
01029   char c;
01030 
01031   c SET_TO line[*counter];
01032   *counter SET_TO (*counter + 1);
01033   switch (c)
01034     {
01035     case 'a':
01036       if(strncmp((line + *counter), "bs", 2) IS 0)
01037         {
01038           *operation SET_TO ABS;
01039           *counter SET_TO (*counter + 2);
01040           return RS274NGC_OK;
01041         }
01042       else if(strncmp((line + *counter), "cos", 3) IS 0)
01043         {
01044           *operation SET_TO ACOS;
01045           *counter SET_TO (*counter + 3);
01046           return RS274NGC_OK;
01047         }
01048       else if(strncmp((line + *counter), "sin", 3) IS 0)
01049         {
01050           *operation SET_TO ASIN;
01051           *counter SET_TO (*counter + 3);
01052           return RS274NGC_OK;
01053         }
01054       else if(strncmp((line + *counter), "tan", 3) IS 0)
01055         {
01056           *operation SET_TO ATAN;
01057           *counter SET_TO (*counter + 3);
01058           return RS274NGC_OK;
01059         }
01060       else
01061         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with A");
01062     case 'c':
01063       if(strncmp((line + *counter), "os", 2) IS 0)
01064         {
01065           *operation SET_TO COS;
01066           *counter SET_TO (*counter + 2);
01067           return RS274NGC_OK;
01068         }
01069       else
01070         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with C");
01071     case 'e':
01072       if(strncmp((line + *counter), "xp", 2) IS 0)
01073         {
01074           *operation SET_TO EXP;
01075           *counter SET_TO (*counter + 2);
01076           return RS274NGC_OK;
01077         }
01078       else
01079         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with E");
01080     case 'f':
01081       if(strncmp((line + *counter), "ix", 2) IS 0)
01082         {
01083           *operation SET_TO FIX;
01084           *counter SET_TO (*counter + 2);
01085           return RS274NGC_OK;
01086         }
01087       else if(strncmp((line + *counter), "up", 2) IS 0)
01088         {
01089           *operation SET_TO FUP;
01090           *counter SET_TO (*counter + 2);
01091           return RS274NGC_OK;
01092         }
01093       else
01094         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with F");
01095     case 'l':
01096       if(strncmp((line + *counter), "n", 1) IS 0)
01097         {
01098           *operation SET_TO LN;
01099           *counter SET_TO (*counter + 1);
01100           return RS274NGC_OK;
01101         }
01102       else
01103         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with L");
01104     case 'r':
01105       if(strncmp((line + *counter), "ound", 4) IS 0)
01106         {
01107           *operation SET_TO ROUND;
01108           *counter SET_TO (*counter + 4);
01109           return RS274NGC_OK;
01110         }
01111       else
01112         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with R");
01113     case 's':
01114       if(strncmp((line + *counter), "in", 2) IS 0)
01115         {
01116           *operation SET_TO SIN;
01117           *counter SET_TO (*counter + 2);
01118           return RS274NGC_OK;
01119         }
01120       else if(strncmp((line + *counter), "qrt", 3) IS 0)
01121         {
01122           *operation SET_TO SQRT;
01123           *counter SET_TO (*counter + 3);
01124           return RS274NGC_OK;
01125         }
01126       else
01127         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with S");
01128     case 't':
01129       if(strncmp((line + *counter), "an", 2) IS 0)
01130         {
01131           *operation SET_TO TAN;
01132           *counter SET_TO (*counter + 2);
01133           return RS274NGC_OK;
01134         }
01135       else
01136         ERROR_MACRO(_interpreter_linetext, name, "Unknown word starting with T");
01137     default:
01138       ERROR_MACRO(_interpreter_linetext, name, "Unknown word where unary operation could be");
01139     }
01140 }

int read_p char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 4938 of file rs274ngc.cc.

04939                                : line of RS274/NGC code being processed */
04940  int * counter,       /* pointer to a counter for position on the line  */
04941  block_pointer block, /* pointer to a block being filled from the line  */
04942  double * parameters) /* array of system parameters                     */
04943 {
04944   static char name[] SET_TO "read_p";
04945   double value;
04946 
04947   if (line[*counter] ISNT 'p')
04948     BUG_MACRO(name, "Read_p should not have been called");
04949 
04950   *counter SET_TO (*counter + 1);
04951   if (block->p_number > -1.0)
04952     ERROR_MACRO(_interpreter_linetext, name, "Multiple P words on one line");
04953   else if (read_real_value(line, counter, &value, parameters)
04954            IS RS274NGC_ERROR)
04955     ERROR_MACRO_PASS(name);
04956   else if (value < 0.0)
04957     ERROR_MACRO(_interpreter_linetext, name, "Negative P value used");
04958   else
04959     {
04960       block->p_number SET_TO value;
04961       return RS274NGC_OK;
04962     }
04963 }

int read_parameter char *    line,
int *    counter,
double *    double_ptr,
double *    parameters
 

Definition at line 1523 of file rs274ngc.cc.

01524                                : line of RS274/NGC code being processed */
01525  int * counter,       /* pointer to a counter for position on the line  */
01526  double * double_ptr, /* pointer to double to be read                   */
01527  double * parameters) /* array of system parameters                     */
01528 {
01529   static char name[] SET_TO "read_parameter";
01530   int index;
01531 
01532   if (line[*counter] ISNT '#')
01533     BUG_MACRO(name, "Read_parameter should not have been called");
01534   *counter SET_TO (*counter + 1);
01535   if (read_integer_value(line, counter, &index, parameters) IS RS274NGC_ERROR)
01536     ERROR_MACRO_PASS(name);
01537   else if ((index < 1) OR (index >= RS274NGC_MAX_PARAMETERS))
01538     ERROR_MACRO(_interpreter_linetext, name, "Parameter number out of range");
01539   else
01540     {
01541       *double_ptr SET_TO parameters[index];
01542       return RS274NGC_OK;
01543     }
01544 }

int read_parameter_setting char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5015 of file rs274ngc.cc.

05016                                : line of RS274/NGC code being processed */
05017  int * counter,       /* pointer to a counter for position on the line  */
05018  block_pointer block, /* pointer to a block being filled from the line  */
05019  double * parameters) /* array of system parameters                     */
05020 {
05021   static char name[] SET_TO "read_parameter_setting";
05022   int index;
05023   double value;
05024 
05025   if (line[*counter] ISNT '#')
05026     BUG_MACRO(name, "Read_parameter_setting should not have been called");
05027   *counter SET_TO (*counter + 1);
05028   if (read_integer_value(line, counter, &index, parameters) IS RS274NGC_ERROR)
05029     ERROR_MACRO_PASS(name);
05030   else if ((index < 1) OR (index >= RS274NGC_MAX_PARAMETERS))
05031     ERROR_MACRO(_interpreter_linetext, name, "Parameter number out of range");
05032   else if (line[*counter] ISNT '=')
05033     ERROR_MACRO(_interpreter_linetext, name, "Equal sign missing in parameter setting");
05034   *counter SET_TO (*counter + 1);
05035   if (read_real_value(line, counter, &value, parameters) IS RS274NGC_ERROR)
05036     ERROR_MACRO_PASS(name);
05037   else
05038     {
05039       parameters[index] SET_TO value;
05040       return RS274NGC_OK;
05041     }
05042 }

int read_q char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5072 of file rs274ngc.cc.

05073                                : line of RS274/NGC code being processed */
05074  int * counter,       /* pointer to a counter for position on the line  */
05075  block_pointer block, /* pointer to a block being filled from the line  */
05076  double * parameters) /* array of system parameters                     */
05077 {
05078   static char name[] SET_TO "read_q";
05079   double value;
05080 
05081   if (line[*counter] ISNT 'q')
05082     BUG_MACRO(name, "Read_q should not have been called");
05083 
05084   *counter SET_TO (*counter + 1);
05085   if (block->q_number > -1.0)
05086     ERROR_MACRO(_interpreter_linetext, name, "Multiple Q words on one line");
05087   else if (read_real_value(line, counter, &value, parameters)
05088            IS RS274NGC_ERROR)
05089     ERROR_MACRO_PASS(name);
05090   else if (value < 0.0)
05091     ERROR_MACRO(_interpreter_linetext, name, "Negative Q value used");
05092   else
05093     {
05094       block->q_number SET_TO value;
05095       return RS274NGC_OK;
05096     }
05097 }

int read_r char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5130 of file rs274ngc.cc.

05131                                : line of RS274 code being processed    */
05132  int * counter,       /* pointer to a counter for position on the line */
05133  block_pointer block, /* pointer to a block being filled from the line */
05134  double * parameters) /* array of system parameters                    */
05135 {
05136   static char name[] SET_TO "read_r";
05137   double value;
05138 
05139   if (line[*counter] ISNT 'r')
05140     BUG_MACRO(name, "Read_r should not have been called");
05141 
05142   *counter SET_TO (*counter + 1);
05143 
05144   if (block->r_flag ISNT OFF)
05145     ERROR_MACRO(_interpreter_linetext, name, "Multiple R words on one line");
05146   else if (read_real_value(line, counter, &value, parameters)
05147            IS RS274NGC_ERROR)
05148     ERROR_MACRO_PASS(name);
05149   else
05150     {
05151       block->r_flag SET_TO ON;
05152       block->r_number SET_TO value;
05153       return RS274NGC_OK;
05154     }
05155 }

int read_real_expression char *    line,
int *    counter,
double *    value,
double *    parameters
 

Definition at line 1853 of file rs274ngc.cc.

01854                                    : line of RS274/NGC code being processed */
01855  int * counter,           /* pointer to a counter for position on the line  */
01856  double * hold2,          /* pointer to double to be read                   */
01857  double * parameters)     /* array of system parameters                     */
01858 {
01859   static char name[] SET_TO "read_real_expression";
01860   double value;
01861   double hold1;
01862   int waiting_operation;  /* always a bop2 */
01863   int last_operation;
01864   int next_operation;
01865 
01866   if (line[*counter] ISNT '[')
01867     BUG_MACRO(name, "Read_real_expression should not have been called");
01868   *counter SET_TO (*counter + 1);
01869   waiting_operation SET_TO PLUS;
01870   *hold2 SET_TO 0.0;
01871   last_operation SET_TO PLUS;
01872 
01873   for (;;)
01874     {
01875       if (read_real_value(line, counter, &value, parameters) ISNT RS274NGC_OK)
01876         ERROR_MACRO_PASS(name);
01877       if (read_operation(line, counter, &next_operation) ISNT RS274NGC_OK)
01878         ERROR_MACRO_PASS(name);
01879       if (next_operation IS RIGHT_BRACKET)
01880         {
01881           if (last_operation < AND2)
01882             {
01883               if (execute_binary1(&hold1,last_operation, &value)
01884                   ISNT RS274NGC_OK)
01885                 ERROR_MACRO_PASS(name);
01886               if (execute_binary2(hold2, waiting_operation, &hold1)
01887                   ISNT RS274NGC_OK)
01888                 ERROR_MACRO_PASS(name);
01889             }
01890           else if (execute_binary2(hold2, waiting_operation, &value)
01891                    ISNT RS274NGC_OK)
01892             ERROR_MACRO_PASS(name);
01893           else {}
01894           return RS274NGC_OK;
01895         }
01896       else if (next_operation < AND2)  /* next operation is a bop1 */
01897         {
01898           if (last_operation >= AND2)
01899             {
01900               hold1 SET_TO value;
01901             }
01902           else if (execute_binary1(&hold1, last_operation, &value)
01903                    ISNT RS274NGC_OK)
01904             ERROR_MACRO_PASS(name);
01905         }
01906       else                            /* next operation is a bop2 */
01907         {
01908           if (last_operation < AND2)
01909             {
01910               if (execute_binary1(&hold1, last_operation, &value)
01911                   ISNT RS274NGC_OK)
01912                 ERROR_MACRO_PASS(name);
01913               if (execute_binary2(hold2, waiting_operation, &hold1)
01914                   ISNT RS274NGC_OK)
01915                 ERROR_MACRO_PASS(name);
01916             }
01917           else
01918             {
01919               if (execute_binary2(hold2, waiting_operation, &value)
01920                   ISNT RS274NGC_OK)
01921                 ERROR_MACRO_PASS(name);
01922             }
01923           waiting_operation SET_TO next_operation;
01924         }
01925       last_operation SET_TO next_operation;
01926     }
01927 }

int read_real_number char *    line,
int *    counter,
double *    double_ptr
 

Definition at line 1965 of file rs274ngc.cc.

01966                                : line of RS274/NGC code being processed */
01967  int * counter,       /* pointer to a counter for position on the line  */
01968  double * double_ptr) /* pointer to double to be read                   */
01969 {
01970   static char name[] SET_TO "read_real_number";
01971   int n;
01972   char c;
01973   int flag_point;  /* set to ON if decimal point found */
01974   int flag_digit; /* set to ON if digit found */
01975 
01976   n SET_TO *counter;
01977   flag_point SET_TO OFF;
01978   flag_digit SET_TO OFF;
01979 
01980 /* check first character */
01981   c SET_TO line[n];
01982   if (c IS '+')
01983     {
01984       *counter SET_TO (*counter + 1); /* skip plus sign */
01985       n++;
01986     }
01987   else if (c IS '-')
01988     {
01989       n++;
01990     }
01991   else if ((c ISNT '.') AND ((c < 48) OR (c > 57)))
01992     ERROR_MACRO(_interpreter_linetext, name, "Bad number format");
01993 
01994 /* check out rest of characters (must be digit or decimal point) */
01995   for (; (c SET_TO line[n]) ISNT (char) NULL; n++)
01996     {
01997       if (( 47 < c) AND ( c < 58))
01998         {
01999           flag_digit SET_TO ON;
02000         }
02001       else if (c IS '.')
02002         {
02003           if (flag_point IS OFF)
02004             {
02005               flag_point SET_TO ON;
02006             }
02007           else
02008             break;
02009         }
02010       else
02011         break;
02012     }
02013 
02014   if (flag_digit IS OFF)
02015     ERROR_MACRO(_interpreter_linetext, name, "No digits found where real number should be");
02016 
02017   line[n] SET_TO (char) NULL; /* temporary string termination for sscanf */
02018   if (sscanf(line + *counter, "%lf", double_ptr) IS 0)
02019     {
02020       line[n] SET_TO c;
02021       BUG_MACRO(name, "Sscanf failure in read_real_number");
02022     }
02023   else
02024     {
02025       line[n] SET_TO c;
02026       *counter SET_TO n;
02027       return RS274NGC_OK;
02028     }
02029 }

int read_real_value char *    line,
int *    counter,
double *    double_ptr,
double *    parameters
 

Definition at line 3357 of file rs274ngc.cc.

03358                                : line of RS274/NGC code being processed */
03359  int * counter,       /* pointer to a counter for position on the line  */
03360  double * double_ptr, /* pointer to double to be read                   */
03361  double * parameters) /* array of system parameters                     */
03362 {
03363   static char name[] SET_TO "read_real_value";
03364   char c;
03365 
03366   c SET_TO line[*counter];
03367   if (c IS 0)
03368     ERROR_MACRO(_interpreter_linetext, name, "No characters found in reading real value");
03369   else if (c IS '[')
03370     return read_real_expression (line, counter, double_ptr, parameters);
03371   else if (c IS '#')
03372     return read_parameter(line, counter, double_ptr, parameters);
03373   else if ((c >= 'a') AND (c <= 'z'))
03374     return read_unary(line, counter, double_ptr, parameters);
03375   else
03376     return read_real_number(line, counter, double_ptr);
03377 }

int read_spindle_speed char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5186 of file rs274ngc.cc.

05187                                  : line of RS274 code being processed    */
05188  int * counter,         /* pointer to a counter for position on the line */
05189  block_pointer block,   /* pointer to a block being filled from the line */
05190  double * parameters)   /* array of system parameters                    */
05191 {
05192   static char name[] SET_TO "read_spindle_speed";
05193   double speed;
05194 
05195   if (line[*counter] ISNT 's')
05196     BUG_MACRO(name, "Read_spindle_speed should not have been called");
05197 
05198   *counter SET_TO (*counter + 1);
05199 
05200   if (block->s_number > -1.0)
05201     ERROR_MACRO(_interpreter_linetext, name, "Multiple S word spindle speed settings on one line");
05202   else if (read_real_value(line, counter, &speed, parameters)
05203            IS RS274NGC_ERROR)
05204     ERROR_MACRO_PASS(name);
05205   else if (speed < 0.0)
05206     ERROR_MACRO(_interpreter_linetext, name, "Negative spindle speed found");
05207   else
05208     {
05209       block->s_number SET_TO speed;
05210       return RS274NGC_OK;
05211     }
05212 }

int read_text const char *    command,
FILE *    inport,
char *    raw_line,
char *    line,
int *    length,
ON_OFF    block_delete
 

Definition at line 7879 of file rs274ngc.cc.

07886 {
07887   static char name[] SET_TO "read_text";
07888   char * returned_value;
07889   int len;
07890 
07891   if (command IS NULL)
07892     {
07893       returned_value SET_TO fgets(raw_line, INTERP_TEXT_SIZE, inport);
07894       // knock off CR, LF
07895       len = strlen(raw_line) - 1; // set len to index of last char
07896       while (len >= 0)
07897         {
07898           if (isspace(raw_line[len]))
07899             {
07900               raw_line[len] = 0;
07901               len--;
07902             }
07903           else
07904             {
07905               break;
07906             }
07907         }
07908       if (returned_value IS NULL)
07909         return RS274NGC_ENDFILE;
07910       else
07911         strcpy(line, raw_line);
07912     }
07913   else
07914     {
07915       strcpy(raw_line, command);
07916       strcpy(line, command);
07917     }
07918 
07919   if (close_and_downcase(line) IS RS274NGC_ERROR)
07920     ERROR_MACRO_PASS(name);
07921 
07922   if (((line[0] IS '/') AND ((block_delete IS ON) OR (line[1] IS 0))) OR
07923       (line[0] IS 0))
07924     *length SET_TO 0;
07925   else
07926     *length SET_TO strlen(line);
07927 
07928   return RS274NGC_OK;
07929 }

int read_tool char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5239 of file rs274ngc.cc.

05240                                : line of RS274/NGC code being processed */
05241  int * counter,       /* pointer to a counter for position on the line  */
05242  block_pointer block, /* pointer to a block being filled from the line  */
05243  double * parameters) /* array of system parameters                     */
05244 {
05245   static char name[] SET_TO "read_tool";
05246   int value;
05247 
05248   if (line[*counter] ISNT 't')
05249     BUG_MACRO(name, "Read_tool should not have been called");
05250 
05251   *counter SET_TO (*counter + 1);
05252   if (block->t_number > -1)
05253     ERROR_MACRO(_interpreter_linetext, name, "Multiple T words (tool ids) on one line");
05254   if (read_integer_value(line, counter, &value, parameters) IS RS274NGC_ERROR)
05255     ERROR_MACRO_PASS(name);
05256   else if (value < 0)
05257     ERROR_MACRO(_interpreter_linetext, name, "Negative tool id used");
05258   else
05259     {
05260       block->t_number SET_TO value;
05261       return RS274NGC_OK;
05262     }
05263 }

int read_tool_length_offset char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5292 of file rs274ngc.cc.

05293                                : line of RS274/NGC code being processed */
05294  int * counter,       /* pointer to a counter for position on the line  */
05295  block_pointer block, /* pointer to a block being filled from the line  */
05296  double * parameters) /* array of system parameters                     */
05297 {
05298   static char name[] SET_TO "read_tool_length_offset";
05299   int value;
05300 
05301   if (line[*counter] ISNT 'h')
05302     BUG_MACRO(name, "Read_tool_length_offset should not have been called");
05303 
05304   *counter SET_TO (*counter + 1);
05305   if (block->h_number > -1)
05306     ERROR_MACRO(_interpreter_linetext, name, "Multiple tool length offsets on one line");
05307   if (read_integer_value(line, counter, &value, parameters) IS RS274NGC_ERROR)
05308     ERROR_MACRO_PASS(name);
05309   else if (value < 0)
05310     ERROR_MACRO(_interpreter_linetext, name, "Negative tool length offset used");
05311   else
05312     {
05313       block->h_number SET_TO value;
05314       return RS274NGC_OK;
05315     }
05316 }

int read_unary char *    line,
int *    counter,
double *    double_ptr,
double *    parameters
 

Definition at line 2057 of file rs274ngc.cc.

02058                                : line of RS274/NGC code being processed */
02059  int * counter,       /* pointer to a counter for position on the line  */
02060  double * double_ptr, /* pointer to double to be read                   */
02061  double * parameters) /* array of system parameters                     */
02062 {
02063   static char name[] SET_TO "read_unary";
02064   int operation;
02065 
02066   if (read_operation_unary (line, counter, &operation) IS RS274NGC_ERROR)
02067     ERROR_MACRO_PASS(name);
02068   if (line[*counter] ISNT '[')
02069     ERROR_MACRO(_interpreter_linetext, name, "Left bracket missing after unary operation name");
02070   if (read_real_expression (line, counter, double_ptr, parameters)
02071       IS RS274NGC_ERROR)
02072     ERROR_MACRO_PASS(name);
02073 
02074   if (operation IS ATAN)
02075     return read_atan(line, counter, double_ptr, parameters);
02076   else
02077     return execute_unary (double_ptr, operation);
02078 }

int read_x char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5349 of file rs274ngc.cc.

05350                                : line of RS274 code being processed     */
05351  int * counter,       /* pointer to a counter for position on the line  */
05352  block_pointer block, /* pointer to a block being filled from the line  */
05353  double * parameters) /* array of system parameters                     */
05354 {
05355   static char name[] SET_TO "read_x";
05356   double value;
05357 
05358   if (line[*counter] ISNT 'x')
05359     BUG_MACRO(name, "Read_x should not have been called");
05360 
05361   *counter SET_TO (*counter + 1);
05362 
05363   if (block->x_flag ISNT OFF)
05364     ERROR_MACRO(_interpreter_linetext, name, "Multiple X words on one line");
05365   else if (read_real_value(line, counter, &value, parameters)
05366            IS RS274NGC_ERROR)
05367     ERROR_MACRO_PASS(name);
05368   else
05369     {
05370       block->x_flag SET_TO ON;
05371       block->x_number SET_TO value;
05372       return RS274NGC_OK;
05373     }
05374 }

int read_y char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5407 of file rs274ngc.cc.

05408                                : line of RS274 code being processed     */
05409  int * counter,       /* pointer to a counter for position on the line  */
05410  block_pointer block, /* pointer to a block being filled from the line  */
05411  double * parameters) /* array of system parameters                     */
05412 {
05413   static char name[] SET_TO "read_y";
05414   double value;
05415 
05416   if (line[*counter] ISNT 'y')
05417     BUG_MACRO(name, "Read_y should not have been called");
05418 
05419   *counter SET_TO (*counter + 1);
05420 
05421   if (block->y_flag ISNT OFF)
05422     ERROR_MACRO(_interpreter_linetext, name, "Multiple Y words on one line");
05423   else if (read_real_value(line, counter, &value, parameters)
05424            IS RS274NGC_ERROR)
05425     ERROR_MACRO_PASS(name);
05426   else
05427     {
05428       block->y_flag SET_TO ON;
05429       block->y_number SET_TO value;
05430       return RS274NGC_OK;
05431     }
05432 }

int read_z char *    line,
int *    counter,
block_pointer    block,
double *    parameters
 

Definition at line 5465 of file rs274ngc.cc.

05466                                : line of RS274 code being processed     */
05467  int * counter,       /* pointer to a counter for position on the line  */
05468  block_pointer block, /* pointer to a block being filled from the line  */
05469  double * parameters) /* array of system parameters                     */
05470 {
05471   static char name[] SET_TO "read_z";
05472   double value;
05473 
05474   if (line[*counter] ISNT 'z')
05475     BUG_MACRO(name, "Read_z should not have been called");
05476 
05477   *counter SET_TO (*counter + 1);
05478 
05479   if (block->z_flag ISNT OFF)
05480     ERROR_MACRO(_interpreter_linetext, name, "Multiple Z words on one line");
05481   else if (read_real_value(line, counter, &value, parameters)
05482            IS RS274NGC_ERROR)
05483     ERROR_MACRO_PASS(name);
05484   else
05485     {
05486       block->z_flag SET_TO ON;
05487       block->z_number SET_TO value;
05488       return RS274NGC_OK;
05489     }
05490 }

int rs274ngc_active_g_codes int *    codes
 

Definition at line 8832 of file rs274ngc.cc.

08833 {
08834   int t;
08835 
08836   for (t = 0; t < RS274NGC_ACTIVE_G_CODES; t++)
08837     {
08838       codes[t] = _interpreter_active_g_codes[t];
08839     }
08840 
08841   return RS274NGC_OK;
08842 }

int rs274ngc_active_m_codes int *    codes
 

Definition at line 8856 of file rs274ngc.cc.

08857 {
08858   int t;
08859 
08860   for (t = 0; t < RS274NGC_ACTIVE_M_CODES; t++)
08861     {
08862       codes[t] = _interpreter_active_m_codes[t];
08863     }
08864 
08865   return RS274NGC_OK;
08866 }

int rs274ngc_active_settings double *    settings
 

Definition at line 8880 of file rs274ngc.cc.

08881 {
08882   int t;
08883 
08884   for (t = 0; t < RS274NGC_ACTIVE_SETTINGS; t++)
08885     {
08886       settings[t] = _interpreter_active_settings[t];
08887     }
08888 
08889   return RS274NGC_OK;
08890 }

int rs274ngc_close  
 

Definition at line 8096 of file rs274ngc.cc.

Referenced by emcTaskPlanClose(), and main().

08097 {
08098   if (_interpreter_fp ISNT NULL)
08099   {
08100     fclose(_interpreter_fp);
08101     _interpreter_fp SET_TO NULL;
08102   }
08103 
08104   _interpreter_filename[0] SET_TO 0;
08105 
08106   rs274ngc_reset();
08107 
08108   return RS274NGC_OK;
08109 }

const char* rs274ngc_command  
 

Definition at line 8029 of file rs274ngc.cc.

Referenced by emcTaskPlanCommand().

08030 {
08031   return _interpreter_linetext;
08032 }

int rs274ngc_execute const char *    command = 0
 

Definition at line 8150 of file rs274ngc.cc.

08151                                  : line of NC code to execute (may be null) */
08152 {
08153   static char name[] SET_TO "rs274ngc_execute";
08154 
08155   if (_interpreter_settings.probe_flag IS ON)
08156     {
08157       if (IS_EXTERNAL_QUEUE_EMPTY() IS 0)
08158         {
08159           /* rs274ngc_reset(); */
08160           ERR_MACRO(_interpreter_linetext, name, "Queue is not empty after probing");
08161         }
08162       set_probe_data(&_interpreter_settings);
08163       _interpreter_settings.probe_flag SET_TO OFF;
08164     }
08165 
08166   if (command ISNT NULL)
08167     {
08168       if(strlen(command) > (INTERP_TEXT_SIZE -1))
08169         ERR_MACRO(_interpreter_linetext, name, "Command too long");
08170       else if (read_text (command, NULL, _interpreter_linetext,
08171                           _interpreter_blocktext, &_interpreter_length,
08172                           _interpreter_settings.block_delete) ISNT RS274NGC_OK)
08173         ERR_MACRO_PASS(name);
08174       else if (_interpreter_length IS 0) /* blank or block-deleted command */
08175         return RS274NGC_OK;
08176       else if (read_line(_interpreter_blocktext, &_interpreter_block,
08177                          &_interpreter_settings) IS RS274NGC_ERROR)
08178         ERR_MACRO_PASS(name);
08179       _textline++;
08180     }
08181 
08182   if (_interpreter_length IS 0) /* blank or block deleted line from file */
08183     {
08184       write_g_codes((block *) NULL, &_interpreter_settings, _textline,
08185                     &_interpreter_active_g_codes[0]);
08186       write_m_codes((block *) NULL, &_interpreter_settings, _textline,
08187                     &_interpreter_active_m_codes[0]);
08188       write_settings((block *) NULL, &_interpreter_settings, _textline,
08189                     &_interpreter_active_settings[0]);
08190 
08191       return RS274NGC_OK;
08192     }
08193 
08194   _interpreter_status SET_TO
08195     execute_block (&_interpreter_block, &_interpreter_settings, _textline);
08196 
08197   // write most recent G codes
08198   write_g_codes(&_interpreter_block, &_interpreter_settings, _textline,
08199                 &_interpreter_active_g_codes[0]);
08200   write_m_codes(&_interpreter_block, &_interpreter_settings, _textline,
08201                 &_interpreter_active_m_codes[0]);
08202   write_settings(&_interpreter_block, &_interpreter_settings, _textline,
08203                  &_interpreter_active_settings[0]);
08204 
08205   if (_interpreter_status IS RS274NGC_EXIT) /* program over */
08206     {
08207       if (_interpreter_fp ISNT NULL)
08208         {
08209           fclose(_interpreter_fp);
08210           _interpreter_fp SET_TO NULL;
08211           _textline SET_TO 0;
08212           _interpreter_linetext[0] SET_TO 0;
08213         }
08214       return RS274NGC_EXIT;
08215     }
08216   else if (_interpreter_status IS RS274NGC_ERROR)
08217     ERR_MACRO_PASS(name);
08218   else if (_interpreter_status IS RS274NGC_EXECUTE_FINISH)
08219     return RS274NGC_EXECUTE_FINISH;
08220   else /* satisfactory execution of a line */
08221     return RS274NGC_OK;
08222 }

int rs274ngc_exit  
 

Definition at line 8240 of file rs274ngc.cc.

Referenced by emcTaskPlanExit(), and main().

08241 {
08242   rs274ngc_save_parameters(RS274NGC_PARAMETER_FILE,
08243                            _interpreter_settings.parameters);
08244 
08245   rs274ngc_reset();
08246 
08247   return RS274NGC_OK;
08248 }

const char* rs274ngc_file  
 

Definition at line 8049 of file rs274ngc.cc.

08050 {
08051   return _interpreter_filename;
08052 }

int rs274ngc_ini_load const char *    filename
 

load settings from INI file.

Definition at line 8791 of file rs274ngc.cc.

08792 {
08793   INIFILE inifile;
08794   const char *inistring;
08795 
08796   // open it
08797   if (-1 == inifile.open(filename))
08798     {
08799       return -1;
08800     }
08801 
08802   if (NULL != (inistring = inifile.find("PARAMETER_FILE", "RS274NGC")))
08803     {
08804       // found it
08805       strcpy(RS274NGC_PARAMETER_FILE, inistring);
08806     }
08807   else
08808     {
08809       // not found, leave RS274NGC_PARAMETER_FILE alone
08810     }
08811 
08812   // close it
08813   inifile.close();
08814 
08815   return RS274NGC_OK;
08816 }

int rs274ngc_init  
 

calling interface

Definition at line 8332 of file rs274ngc.cc.

Referenced by emcTaskPlanInit(), and main().

08333 {
08334   CANON_VECTOR axis_offset;
08335   CANON_VECTOR origin_point;
08336   int k;
08337 
08338   rs274ngc_reset();
08339 
08340   INIT_CANON();
08341 
08342   _interpreter_settings.length_units SET_TO CANON_UNITS_INCHES;
08343   USE_LENGTH_UNITS(_interpreter_settings.length_units);
08344 
08345   for (k SET_TO 5161; k < 5387; k++)
08346     {
08347       _interpreter_settings.parameters[k] SET_TO 0.0;
08348     }
08349   rs274ngc_restore_parameters(
08350 #ifdef STAND_ALONE_INTERP
08351 DEFAULT_RS274NGC_PARAMETER_FILE,
08352 #else
08353 RS274NGC_PARAMETER_FILE,
08354 #endif
08355                               _interpreter_settings.parameters);
08356 
08357   // Get axis offsets from parameters
08358   axis_offset.x SET_TO _interpreter_settings.parameters[5211];
08359   axis_offset.y SET_TO _interpreter_settings.parameters[5212];
08360   axis_offset.z SET_TO _interpreter_settings.parameters[5213];
08361 
08362   // Get origin from parameters for G54 default coordinate system
08363   origin_point.x SET_TO _interpreter_settings.parameters[5221];
08364   origin_point.y SET_TO _interpreter_settings.parameters[5222];
08365   origin_point.z SET_TO _interpreter_settings.parameters[5223];
08366 
08367   // Set the origin offsets
08368   SET_ORIGIN_OFFSETS(origin_point.x + axis_offset.x,
08369                      origin_point.y + axis_offset.y,
08370                      origin_point.z + axis_offset.z);
08371 
08372   SET_FEED_REFERENCE(CANON_XYZ);
08373 
08374   _textline SET_TO 0;
08375   _interpreter_settings.axis_offset_x SET_TO 0.0;
08376   _interpreter_settings.axis_offset_y SET_TO 0.0;
08377   _interpreter_settings.axis_offset_z SET_TO 0.0;
08378   _interpreter_settings.block_delete SET_TO OFF;
08379 /*_interpreter_settings.control_mode set in rs274ngc_synch */
08380 /*_interpreter_settings.current_slot set in rs274ngc_synch */
08381   _interpreter_settings.current_x SET_TO 0.0; /* reset by rs274ngc_synch */
08382   _interpreter_settings.current_y SET_TO 0.0; /* reset by rs274ngc_synch */
08383   _interpreter_settings.current_z SET_TO 0.0; /* reset by rs274ngc_synch */
08384   _interpreter_settings.cutter_radius_compensation SET_TO OFF;
08385 /* cycle values do not need initialization */
08386   _interpreter_settings.distance_mode SET_TO MODE_ABSOLUTE;
08387   _interpreter_settings.feed_mode SET_TO UNITS_PER_MINUTE;
08388   _interpreter_settings.feed_override SET_TO ON;
08389 /*_interpreter_settings.feed_rate set in rs274ngc_synch */
08390 /*_interpreter_settings.flood set in rs274ngc_synch */
08391   _interpreter_settings.length_offset_index SET_TO 1;
08392 /*_interpreter_settings.length_units set above */
08393 /*_interpreter_settings.mist set in rs274ngc_synch */
08394   _interpreter_settings.motion_mode SET_TO G_1;
08395   _interpreter_settings.origin_ngc SET_TO 1;
08396   _interpreter_settings.axis_offset_x SET_TO axis_offset.x;
08397   _interpreter_settings.axis_offset_y SET_TO axis_offset.y;
08398   _interpreter_settings.axis_offset_z SET_TO axis_offset.z;
08399   _interpreter_settings.origin_offset_x SET_TO origin_point.x;
08400   _interpreter_settings.origin_offset_y SET_TO origin_point.y;
08401   _interpreter_settings.origin_offset_z SET_TO origin_point.z;
08402 /*_interpreter_settings.parameters set above */
08403   _interpreter_settings.plane SET_TO CANON_PLANE_XY;
08404   SELECT_PLANE(_interpreter_settings.plane);
08405   _interpreter_settings.probe_flag SET_TO OFF;
08406   _interpreter_settings.program_x SET_TO UNKNOWN; /* for cutter comp */
08407   _interpreter_settings.program_y SET_TO UNKNOWN; /* for cutter comp */
08408   _interpreter_settings.retract_mode SET_TO R_PLANE;
08409 /*_interpreter_settings.selected_tool_slot set in rs274ngc_synch */
08410 /*_interpreter_settings.speed set in rs274ngc_synch */
08411   _interpreter_settings.speed_feed_mode SET_TO CANON_INDEPENDENT;
08412   _interpreter_settings.speed_override SET_TO ON;
08413   _interpreter_settings.tool_length_offset SET_TO 0.0;
08414 /*_interpreter_settings.tool_table set in rs274ngc_synch */
08415   _interpreter_settings.tool_table_index SET_TO 1;
08416 /*_interpreter_settings.traverse_rate set in rs274ngc_synch */
08417 
08418   write_g_codes((block_pointer)NULL, &_interpreter_settings,
08419                 _textline, &_interpreter_active_g_codes[0]);
08420   write_m_codes((block_pointer)NULL, &_interpreter_settings,
08421                 _textline, &_interpreter_active_m_codes[0]);
08422   write_settings((block_pointer)NULL, &_interpreter_settings,
08423                 _textline, &_interpreter_active_settings[0]);
08424 
08425   // Synch rest of settings to external world
08426   rs274ngc_synch();
08427 
08428   return RS274NGC_OK;
08429 }

int rs274ngc_line  
 

Definition at line 8075 of file rs274ngc.cc.

Referenced by emcTaskPlanLine().

08076 {
08077   return _textline;
08078 }

int rs274ngc_load_tool_table  
 

Definition at line 8599 of file rs274ngc.cc.

Referenced by rs274ngc_synch().

08600 {
08601   int t;
08602 
08603   for (t SET_TO 0; t <= CANON_TOOL_MAX; t++)
08604     {
08605       _interpreter_settings.tool_table[t] SET_TO GET_EXTERNAL_TOOL_TABLE(t);
08606     }
08607 
08608   return 0;
08609 }

int rs274ngc_open const char *    filename
 

Definition at line 8457 of file rs274ngc.cc.

08458                                 : the name of the input NC-program file */
08459 {
08460   static char name[] SET_TO "rs274ngc_open";
08461 
08462   _interpreter_fp SET_TO fopen(filename, "r");
08463   if (_interpreter_fp IS NULL)
08464     ERR_MACRO(_interpreter_linetext, name, "Unable to open file");
08465 
08466   _textline SET_TO 0;
08467 
08468   strcpy(_interpreter_filename, filename);
08469 
08470   return RS274NGC_OK;
08471 }

int rs274ngc_read  
 

Definition at line 8518 of file rs274ngc.cc.

Referenced by emcTaskPlanRead(), interpret_from_file(), interpret_from_keyboard(), and rs274ngc_execute().

08519 {
08520   static char name[] SET_TO "rs274ngc_read";
08521   int status;
08522 
08523   if (_interpreter_settings.probe_flag IS ON)
08524     {
08525       if (IS_EXTERNAL_QUEUE_EMPTY() IS 0)
08526         {
08527           /* rs274ngc_reset(); */
08528           ERR_MACRO(_interpreter_linetext, name, "Queue is not empty after probing");
08529         }
08530       set_probe_data(&_interpreter_settings);
08531       _interpreter_settings.probe_flag SET_TO OFF;
08532     }
08533 
08534   if (_interpreter_fp IS NULL)
08535     {
08536       if (_interpreter_status IS RS274NGC_EXIT)
08537         {   /* set in call to rs274ngc_execute */
08538           /* rs274ngc_reset(); */
08539           return RS274NGC_EXIT;
08540         }
08541       else
08542         {
08543           /* rs274ngc_reset(); */
08544           ERR_MACRO_PASS(name);
08545         }
08546     }
08547 
08548   /* read the line */
08549   _textline++;
08550   status SET_TO read_text (NULL, _interpreter_fp, _interpreter_linetext,
08551                            _interpreter_blocktext, &_interpreter_length,
08552                            _interpreter_settings.block_delete);
08553   if ((status IS RS274NGC_ENDFILE) AND (_interpreter_block.m_modes[4] IS 1))
08554     return RS274NGC_ENDFILE;  /* m1 appeared on the preceding line */
08555   else if (status IS RS274NGC_ENDFILE)
08556     {
08557       fclose(_interpreter_fp);
08558       _interpreter_fp SET_TO NULL;
08559       /* rs274ngc_reset(); */
08560       ERR_MACRO(_interpreter_linetext, name, "File ended with no stopping command given");
08561     }
08562   else if (status IS RS274NGC_ERROR)
08563     {
08564       /* rs274ngc_reset(); */
08565       ERR_MACRO_PASS(name);
08566     }
08567   if (_interpreter_length IS 0)
08568     return RS274NGC_OK;
08569 
08570   /* parse the block */
08571   else if (read_line(_interpreter_blocktext, &_interpreter_block,
08572                      &_interpreter_settings) IS RS274NGC_ERROR)
08573     {
08574       /* rs274ngc_reset(); */
08575       ERR_MACRO_PASS(name);
08576     }
08577   else
08578     return RS274NGC_OK;
08579 }

int rs274ngc_reset  
 

Definition at line 8001 of file rs274ngc.cc.

Referenced by rs274ngc_close(), rs274ngc_exit(), and rs274ngc_init().

08002 {
08003   _textline SET_TO 0;
08004   _interpreter_filename[0] SET_TO 0;
08005   _interpreter_linetext[0] SET_TO 0;
08006   _interpreter_blocktext[0] SET_TO 0;
08007   _interpreter_fp SET_TO NULL;
08008   _interpreter_status SET_TO 0;
08009   _interpreter_length SET_TO 0;
08010 
08011   return 0;
08012 }

int rs274ngc_restore_parameters const char *    filename,
double    parameters[]
 

restore interpreter variables from file.

Definition at line 8633 of file rs274ngc.cc.

08634 {
08635   static char name[] SET_TO "rs274ngc_restore_parameters";
08636   FILE *infp = NULL;
08637   char line[256];
08638   int variable;
08639   double value;
08640 
08641   // open original for reading
08642   if (NULL == (infp = fopen(filename, "r")))
08643     {
08644       ERR_MACRO(_interpreter_linetext, name, "Cannot open file");
08645       return -1;
08646     }
08647 
08648   while (!feof(infp))
08649     {
08650       if (NULL == fgets(line, 256, infp))
08651         {
08652           break;
08653         }
08654 
08655       // try for a variable-value match
08656       if (2 == sscanf(line, "%d %lf", &variable, &value))
08657         {
08658           // write it into variable array
08659           if (variable <= 0 || variable >= RS274NGC_MAX_PARAMETERS)
08660             {
08661               ERR_MACRO(_interpreter_linetext, name, "Parameter number out of range");
08662             }
08663           else
08664             {
08665               parameters[variable] = value;
08666             }
08667         }
08668     }
08669 
08670   fclose(infp);
08671 
08672   return 0;
08673 }

int rs274ngc_save_parameters const char *    filename,
const double    parameters[]
 

save interpreter variables to file.

Definition at line 8697 of file rs274ngc.cc.

08698 {
08699   static char name[] SET_TO "rs274ngc_save_parameters";
08700   FILE *infp = NULL;
08701   FILE *outfp = NULL;
08702   char line[256];
08703   int variable;
08704   double value;
08705 
08706   // rename as .bak
08707   strcpy(line, filename);
08708   strcat(line, RS274NGC_PARAMETER_FILE_BACKUP_SUFFIX);
08709   if (0 != rename(filename, line))
08710     {
08711       ERR_MACRO(_interpreter_linetext, name, "Cannot create backup file");
08712       return -1;
08713     }
08714 
08715   // open backup for reading
08716   if (NULL == (infp = fopen(line, "r")))
08717     {
08718       ERR_MACRO(_interpreter_linetext, name, "Cannot open backup file");
08719       return -1;
08720     }
08721 
08722   // open original for writing
08723   if (NULL == (outfp = fopen(filename, "w")))
08724     {
08725       ERR_MACRO(_interpreter_linetext, name, "Cannot open variable file");
08726       return -1;
08727     }
08728 
08729   while (!feof(infp))
08730     {
08731       if (NULL == fgets(line, 256, infp))
08732         {
08733           break;
08734         }
08735 
08736       // try for a variable-value match
08737       if (2 == sscanf(line, "%d %f", &variable, &value))
08738         {
08739           // overwrite with internal variable
08740           if (variable <= 0 || variable >= RS274NGC_MAX_PARAMETERS)
08741             {
08742               ERR_MACRO(_interpreter_linetext, name, "Parameter number out of range");
08743             }
08744           else
08745             {
08746               sprintf(line, "%d\t%f\n", variable, parameters[variable]);
08747             }
08748         }
08749 
08750       // write it out
08751       fputs(line, outfp);
08752     }
08753 
08754   fclose(infp);
08755   fclose(outfp);
08756 
08757   return 0;
08758 }

int rs274ngc_synch  
 

Definition at line 8267 of file rs274ngc.cc.

Referenced by emcTaskPlanExecute(), emcTaskPlanSynch(), and rs274ngc_init().

08268 {
08269   CANON_POSITION current_point;
08270 
08271   _interpreter_settings.current_slot SET_TO GET_EXTERNAL_TOOL();
08272 
08273   rs274ngc_load_tool_table();
08274 
08275   _interpreter_settings.control_mode SET_TO GET_MOTION_CONTROL_MODE();
08276   current_point SET_TO GET_EXTERNAL_POSITION();
08277   _interpreter_settings.current_x SET_TO current_point.x;
08278   _interpreter_settings.current_y SET_TO current_point.y;
08279   _interpreter_settings.current_z SET_TO current_point.z;
08280 
08281   _interpreter_settings.feed_rate SET_TO GET_EXTERNAL_FEED_RATE();
08282 
08283   _interpreter_settings.flood SET_TO (GET_EXTERNAL_FLOOD() ISNT 0) ? ON : OFF;
08284 
08285   _interpreter_settings.mist SET_TO (GET_EXTERNAL_MIST() ISNT 0) ? ON : OFF;
08286 
08287   _interpreter_settings.selected_tool_slot SET_TO GET_EXTERNAL_POCKET();
08288 
08289   _interpreter_settings.speed SET_TO GET_EXTERNAL_SPEED();
08290 
08291   _interpreter_settings.spindle_turning SET_TO GET_EXTERNAL_SPINDLE();
08292 
08293   _interpreter_settings.traverse_rate SET_TO GET_EXTERNAL_TRAVERSE_RATE();
08294 
08295   return RS274NGC_OK;
08296 }

int set_probe_data setup_pointer    settings
 

Definition at line 7946 of file rs274ngc.cc.

07948 {
07949   static char name[] SET_TO "set_probe_data";
07950   CANON_POSITION position;
07951   CANON_POSITION probe_position;
07952 
07953   position SET_TO GET_EXTERNAL_POSITION();
07954   settings->current_x SET_TO position.x;
07955   settings->current_y SET_TO position.y;
07956   settings->current_z SET_TO position.z;
07957   probe_position SET_TO GET_EXTERNAL_PROBE_POSITION();
07958   settings->parameters[5061] SET_TO probe_position.x;
07959   settings->parameters[5062] SET_TO probe_position.y;
07960   settings->parameters[5063] SET_TO probe_position.z;
07961   settings->parameters[5067] SET_TO GET_EXTERNAL_PROBE_VALUE();
07962   return RS274NGC_OK;
07963 }

int utility_enhance_block block_pointer    block,
setup_pointer    settings
 

Definition at line 7557 of file rs274ngc.cc.

07560 {
07561   static char name[] SET_TO "utility_enhance_block";
07562   if (block->g_modes[1] ISNT -1)
07563     block->motion_to_be SET_TO block->g_modes[1];
07564   else if ((((block->x_flag IS ON) OR (block->y_flag IS ON)) OR
07565             (block->z_flag IS ON)) AND
07566            (block->g_modes[0] IS -1))
07567     block->motion_to_be SET_TO settings->motion_mode;
07568   return RS274NGC_OK;
07569 }

int utility_error_number char *    message,
char *    error_array[],
int    index
 

Definition at line 574 of file rs274ngc.cc.

00575                                   : the message text  */
00576  char * error_array[],   /* array of error messages   */
00577  int index)              /* index to start at         */
00578 {
00579   for (;error_array[index][0] ISNT 0; index++)
00580     {
00581       if (strcmp(message, error_array[index]) IS 0)
00582         return index;
00583     }
00584   return 0;
00585 }

double utility_find_arc_length double    x1,
double    y1,
double    z1,
double    center_x,
double    center_y,
int    turn,
double    x2,
double    y2,
double    z2
 

Definition at line 2111 of file rs274ngc.cc.

02121 {
02122   double radius;
02123   double theta;  /* amount of turn of arc */
02124 
02125   if (turn IS 0)
02126     return 0.0;
02127   radius SET_TO hypot((center_x - x1), (center_y - y1));
02128   theta SET_TO utility_find_turn(x1, y1, center_x, center_y, turn, x2, y2);
02129   if (z2 IS z1)
02130     return (radius * fabs(theta));
02131   else
02132     return hypot((radius * theta), (z2 - z1));
02133 }

int utility_find_ends block_pointer    block,
setup_pointer    settings,
double *    px,
double *    py,
double *    pz
 

Definition at line 3396 of file rs274ngc.cc.

03402 {
03403   int mode;
03404   int middle;
03405   int comp;
03406 
03407   mode SET_TO settings->distance_mode;
03408   middle SET_TO (settings->program_x ISNT UNKNOWN);
03409   comp SET_TO (settings->cutter_radius_compensation ISNT OFF);
03410 
03411   if (block->g_modes[4] IS G_53) /* mode is absolute in this case */
03412     {
03413 #ifdef DEBUG_EMC
03414       COMMENT("interpreter: offsets temporarily suspended");
03415 #endif
03416       *px SET_TO (block->x_flag IS ON) ? (block->x_number -
03417                    (settings->origin_offset_x + settings->axis_offset_x)) :
03418                      settings->current_x;
03419       *py SET_TO (block->y_flag IS ON) ? (block->y_number -
03420                    (settings->origin_offset_y + settings->axis_offset_y)) :
03421                      settings->current_y;
03422       *pz SET_TO (block->z_flag IS ON) ? (block->z_number -
03423                    (settings->tool_length_offset + settings->origin_offset_z
03424                     + settings->axis_offset_z)) : settings->current_z;
03425     }
03426   else if (mode IS MODE_ABSOLUTE)
03427     {
03428       *px SET_TO (block->x_flag IS ON) ? block->x_number     :
03429                  (comp AND middle)     ? settings->program_x :
03430                                          settings->current_x ;
03431 
03432       *py SET_TO (block->y_flag IS ON) ? block->y_number     :
03433                  (comp AND middle)     ? settings->program_y :
03434                                          settings->current_y ;
03435 
03436       *pz SET_TO (block->z_flag IS ON) ? block->z_number     :
03437                                          settings->current_z ;
03438     }
03439   else
03440     {
03441       *px SET_TO (block->x_flag IS ON)
03442         ? ((comp AND middle) ? (block->x_number + settings->program_x)
03443                              : (block->x_number + settings->current_x))
03444         : ((comp AND middle) ? settings->program_x
03445                              : settings->current_x);
03446 
03447       *py SET_TO (block->y_flag IS ON)
03448         ? ((comp AND middle) ? (block->y_number + settings->program_y)
03449                              : (block->y_number + settings->current_y))
03450         : ((comp AND middle) ? settings->program_y
03451                              : settings->current_y);
03452 
03453       *pz SET_TO (block->z_flag IS ON)
03454         ? (settings->current_z + block->z_number)
03455         : settings->current_z;
03456     }
03457 
03458   return RS274NGC_OK;
03459 }

double utility_find_straight_length double    x2,
double    y2,
double    z2,
double    x1,
double    y1,
double    z1
 

Definition at line 2158 of file rs274ngc.cc.

02165 {
02166     return sqrt(pow((x2 - x1),2) + pow((y2 - y1),2) + pow((z2 - z1),2));
02167 }

double utility_find_turn double    x1,
double    y1,
double    center_x,
double    center_y,
int    turn,
double    x2,
double    y2
 

Definition at line 1160 of file rs274ngc.cc.

01168 {
01169   double alpha;
01170   double beta;
01171   double theta;  /* amount of turn of arc CCW - negative if CW */
01172 
01173   if (turn IS 0)
01174     return 0.0;
01175   alpha SET_TO atan2((y1 - center_y), (x1 - center_x));
01176   beta SET_TO atan2((y2 - center_y), (x2 - center_x));
01177   if (turn > 0)
01178     {
01179       if (beta <= alpha)
01180         beta SET_TO (beta + TWO_PI);
01181       theta SET_TO ((beta - alpha) + ((turn - 1) * TWO_PI));
01182     }
01183   else /* turn < 0 */
01184     {
01185       if (alpha <= beta)
01186         alpha SET_TO (alpha + TWO_PI);
01187       theta SET_TO ((beta - alpha) + ((turn + 1) * TWO_PI));
01188     }
01189   return (theta);
01190 }

int write_g_codes block_pointer    block,
setup_pointer    settings,
int    line_number,
int *    gez
 

Definition at line 7596 of file rs274ngc.cc.

07601 {
07602   gez[0] SET_TO line_number;            /* 0 line number     */
07603   gez[1] SET_TO settings->motion_mode;  /* 1 motion mode     */
07604   gez[2] SET_TO
07605     (block IS NULL)             ? -1                :
07606     (block->g_modes[0] ISNT -1) ? block->g_modes[0] :  /* 2 g10,g92         */
07607                                   block->g_modes[4] ;  /* 2 g4, g53         */
07608   gez[3] SET_TO
07609     (settings->plane IS CANON_PLANE_XY) ? G_17 :       /* 3 active plane    */
07610     (settings->plane IS CANON_PLANE_XZ) ? G_18 : G_19;
07611   gez[4] SET_TO                         /* 4 cut radius comp */
07612     (settings->cutter_radius_compensation IS RIGHT) ? G_42 :
07613     (settings->cutter_radius_compensation IS LEFT) ? G_41 : G_40;
07614   gez[5] SET_TO                         /* 5 length units    */
07615     (settings->length_units IS CANON_UNITS_INCHES) ? G_20 : G_21;
07616   gez[6] SET_TO                         /* 6 distance mode   */
07617     (settings->distance_mode IS MODE_ABSOLUTE) ? G_90 : G_91;
07618   gez[7] SET_TO                         /* 7 feed mode       */
07619     (settings->feed_mode IS INVERSE_TIME) ? G_93 : G_94;
07620   gez[8] SET_TO                         /* 8 coord system    */
07621     (settings->origin_ngc < 7) ? (530 + (10 * settings->origin_ngc)) :
07622                                  (584 + settings->origin_ngc);
07623   gez[9] SET_TO                         /* 9 tool len offset */
07624     (settings->tool_length_offset IS 0.0) ? G_49 : G_43;
07625   gez[10] SET_TO                        /* 10 retract mode   */
07626     (settings->retract_mode IS OLD_Z) ? G_98 : G_99;
07627   gez[11] SET_TO                        /* 11 control mode   */
07628     (settings->control_mode IS CANON_CONTINUOUS) ? G_64 : G_61;
07629 
07630   return RS274NGC_OK;
07631 }

int write_m_codes block_pointer    block,
setup_pointer    settings,
int    line_number,
int *    ems
 

Definition at line 7651 of file rs274ngc.cc.

07656 {
07657   ems[0] SET_TO line_number;                           /* 0 line number */
07658   ems[1] SET_TO
07659     (block IS NULL) ? -1 : block->m_modes[4];          /* 1 stopping    */
07660   ems[2] SET_TO
07661     (settings->spindle_turning IS CANON_STOPPED) ? 5 : /* 2 spindle     */
07662     (settings->spindle_turning IS CANON_CLOCKWISE) ? 3 : 4;
07663   ems[3] SET_TO                                        /* 3 tool change */
07664     (block IS NULL) ? -1 : block->m_modes[6];
07665   ems[4] SET_TO                                        /* 4 mist        */
07666     (settings->mist IS ON) ? 7 :
07667     (settings->flood IS ON) ? -1 : 9;
07668   ems[5] SET_TO                                        /* 5 flood       */
07669     (settings->flood IS ON) ? 8 : -1;
07670   ems[6] SET_TO                                        /* 6 overrides   */
07671     (settings->feed_override IS ON) ? 48 : 49;         /* both overrides*/
07672 
07673   return RS274NGC_OK;
07674 }

int write_settings block_pointer    block,
setup_pointer    settings,
int    line_number,
double *    vals
 

Definition at line 7690 of file rs274ngc.cc.

07695 {
07696   vals[0] SET_TO line_number;   /* 0 line number */
07697   vals[1] SET_TO settings->feed_rate; /* 1 feed rate */
07698   vals[2] SET_TO settings->speed; /* 2 spindle speed */
07699 
07700   return RS274NGC_OK;
07701 }


Variable Documentation

FILE* _interpreter_fp SET_TO NULL [static]
 

Definition at line 533 of file rs274ngc.cc.

char RS274NGC_PARAMETER_FILE[INTERP_TEXT_SIZE]
 

Initial value:

Definition at line 544 of file rs274ngc.cc.

int _interpreter_length SET_TO [static]
 

Definition at line 538 of file rs274ngc.cc.

int _interpreter_active_g_codes[RS274NGC_ACTIVE_G_CODES] [static]
 

Definition at line 539 of file rs274ngc.cc.

int _interpreter_active_m_codes[RS274NGC_ACTIVE_M_CODES] [static]
 

Definition at line 540 of file rs274ngc.cc.

double _interpreter_active_settings[RS274NGC_ACTIVE_SETTINGS] [static]
 

Definition at line 541 of file rs274ngc.cc.

char _interpreter_blocktext[INTERP_TEXT_SIZE] [static]
 

Definition at line 531 of file rs274ngc.cc.

char _interpreter_filename[INTERP_TEXT_SIZE] [static]
 

Definition at line 529 of file rs274ngc.cc.

char _interpreter_linetext[INTERP_TEXT_SIZE] [static]
 

Definition at line 530 of file rs274ngc.cc.

setup _interpreter_settings
 

Definition at line 111 of file rs274ngc.cc.

char ident[] = "$Id: rs274ngc.cc,v 1.4 2000/10/27 20:34:44 terrylr Exp $" [static]
 

Definition at line 99 of file rs274ngc.cc.


Generated on Sun Dec 2 15:28:16 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001