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

canon_pre.cc

Go to the documentation of this file.
00001 /* canon.cc
00002 
00003 This file contains two sets of functions:
00004 1. functions for the interpreter to call to tell the rest of the world to
00005    do something. These all return nothing.
00006 2. functions for the interpreter to call to get information from the rest
00007    of the world. These all return some type of information.
00008 These functions implement the interface between the RS274NGC interpreter
00009 and some external environment.
00010 
00011 This version of canon.cc also includes a third set of stuff: a dummy
00012 model of the external world. The dummy model is used by the second set
00013 of interface functions.
00014 
00015 */
00016 
00017 /************************************************************************/
00018 
00019 #include "canon.hh"
00020 #include <math.h>
00021 #include <stdio.h>
00022 #include <string.h>
00023 #define SET_TO =
00024 #define IS ==
00025 #define AND &&
00026 #define OR ||
00027 
00028 /* where to print */
00029 extern FILE * _outfile;
00030 
00031 /* Dummy world model */
00032 
00033 static CANON_PLANE       _active_plane = CANON_PLANE_XY;
00034 static int               _active_slot = 1;
00035 static double            _feed_rate = 0.0;
00036 static int               _flood = 0;
00037 static double            _length_unit_factor = 1; /* 1 for MM 25.4 for inch */
00038 static CANON_UNITS       _length_unit_type = CANON_UNITS_MM;
00039 static int               _line_number = 1;
00040 static int               _mist = 0;
00041 static CANON_MOTION_MODE _motion_mode = CANON_CONTINUOUS;
00042 char                     _parameter_file_name[PARAMETER_FILE_NAME_LENGTH];/*Not static.Driver writes*/
00043 #ifdef AA
00044 static double            _probe_position_a = 0; /*AA*/
00045 #endif
00046 #ifdef BB
00047 static double            _probe_position_b = 0; /*BB*/
00048 #endif
00049 #ifdef CC
00050 static double            _probe_position_c = 0; /*CC*/
00051 #endif
00052 static double            _probe_position_x = 0;
00053 static double            _probe_position_y = 0;
00054 static double            _probe_position_z = 0;
00055 #ifdef AA
00056 static double            _program_origin_a = 0; /*AA*/
00057 #endif
00058 #ifdef BB
00059 static double            _program_origin_b = 0; /*BB*/
00060 #endif
00061 #ifdef CC
00062 static double            _program_origin_c = 0; /*CC*/
00063 #endif
00064 static double            _program_origin_x = 0;
00065 static double            _program_origin_y = 0;
00066 static double            _program_origin_z = 0;
00067 #ifdef AA
00068 static double            _program_position_a = 0; /*AA*/
00069 #endif
00070 #ifdef BB
00071 static double            _program_position_b = 0; /*BB*/
00072 #endif
00073 #ifdef CC
00074 static double            _program_position_c = 0; /*CC*/
00075 #endif
00076 static double            _program_position_x = 0;
00077 static double            _program_position_y = 0;
00078 static double            _program_position_z = 0;
00079 static double            _spindle_speed;
00080 static CANON_DIRECTION   _spindle_turning;
00081 int                      _tool_max = 68;         /*Not static. Driver reads  */
00082 CANON_TOOL_TABLE         _tools[CANON_TOOL_MAX]; /*Not static. Driver writes */
00083 static double            _traverse_rate;
00084 FILE * _outfile=NULL;      /* where to print, set in main */
00085 
00086 /************************************************************************/
00087 
00088 /* Canonical "Do it" functions
00089 
00090 This is a set of dummy definitions for the canonical machining functions
00091 given in canon.hh. These functions just print themselves and, if necessary,
00092 update the dummy world model. On each output line is printed:
00093 1. an output line number (sequential, starting with 1).
00094 2. an input line number read from the input (or ... if not provided).
00095 3. a printed representation of the function call which was made.
00096 
00097 If an interpreter which makes these calls is compiled with this set of
00098 definitions, it can be used as a translator by redirecting output from
00099 stdout to a file.
00100 
00101 */
00102 
00103 extern void rs274ngc_line_text(char * line_text, int max_size);
00104 
00105 void print_nc_line_number()
00106 {
00107   char text[256];
00108   int k;
00109   int m;
00110 
00111   if(NULL == _outfile)
00112     {
00113       _outfile=stdout;
00114     }
00115 
00116   rs274ngc_line_text(text, 256);
00117   for (k SET_TO 0;
00118        ((k < 256) AND
00119         ((text[k] IS '\t') OR (text[k] IS ' ') OR (text[k] IS '/')));
00120        k++);
00121   if ((k < 256) AND ((text[k] IS 'n') OR (text[k] IS 'N')))
00122     {
00123       fputc('N', _outfile);
00124       for (k++, m SET_TO 0;
00125            ((k < 256) AND (text[k] >= '0') AND (text[k] <= '9'));
00126            k++, m++)
00127         fputc(text[k], _outfile);
00128       for (; m < 6; m++)
00129         fputc(' ', _outfile);
00130     }
00131   else if (k < 256)
00132     fprintf(_outfile, "N..... ");
00133 }
00134 
00135 
00136 #define PRINT0(control) if (1)                        \
00137           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++); \
00138            print_nc_line_number();                    \
00139            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control);                \
00140           } else
00141 #define PRINT1(control, arg1) if (1)                  \
00142           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++); \
00143            print_nc_line_number();                    \
00144            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control, arg1);          \
00145           } else
00146 #define PRINT2(control, arg1, arg2) if (1)            \
00147           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++); \
00148            print_nc_line_number();                    \
00149            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control, arg1, arg2);    \
00150           } else
00151 #define PRINT3(control, arg1, arg2, arg3) if (1)         \
00152           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++);    \
00153            print_nc_line_number();                       \
00154            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control, arg1, arg2, arg3); \
00155           } else
00156 #define PRINT4(control, arg1, arg2, arg3, arg4) if (1)         \
00157           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++);          \
00158            print_nc_line_number();                             \
00159            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control, arg1, arg2, arg3, arg4); \
00160           } else
00161 #define PRINT5(control, arg1, arg2, arg3, arg4, arg5) if (1)         \
00162           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++);                \
00163            print_nc_line_number();                                   \
00164            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control, arg1, arg2, arg3, arg4, arg5); \
00165           } else
00166 #define PRINT6(control, arg1, arg2, arg3, arg4, arg5, arg6) if (1)         \
00167           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++);                      \
00168            print_nc_line_number();                                         \
00169            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control, arg1, arg2, arg3, arg4, arg5, arg6); \
00170           } else
00171 #define PRINT7(control, arg1, arg2, arg3, arg4, arg5, arg6, arg7) if (1) \
00172           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++);                    \
00173            print_nc_line_number();                                       \
00174            {if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  control,                                    \
00175                            arg1, arg2, arg3, arg4, arg5, arg6, arg7);    \
00176           } else
00177 #define PRINT10(control,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
00178           if (1)                                                            \
00179           {{if(_outfile==NULL){_outfile=stdout;}} fprintf(_outfile,  "%5d ", _line_number++);                       \
00180            print_nc_line_number();                                          \
00181            fprintf(_outfile, control,                                       \
00182                    arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);     \
00183           } else
00184 
00185 /* Representation */
00186 
00187 void SET_ORIGIN_OFFSETS(
00188  double x, double y, double z
00189 #ifdef AA
00190  , double a  /*AA*/
00191 #endif
00192 #ifdef BB
00193  , double b  /*BB*/
00194 #endif
00195 #ifdef CC
00196  , double c  /*CC*/
00197 #endif
00198 )
00199 {
00200   fprintf(_outfile, "%5d ", _line_number++);
00201   print_nc_line_number();
00202   fprintf(_outfile, "SET_ORIGIN_OFFSETS(%.4f, %.4f, %.4f"
00203 #ifdef AA
00204          ", %.4f"  /*AA*/
00205 #endif
00206 #ifdef BB
00207          ", %.4f"  /*BB*/
00208 #endif
00209 #ifdef CC
00210          ", %.4f"  /*CC*/
00211 #endif
00212          ")\n", x, y, z
00213 #ifdef AA
00214          , a  /*AA*/
00215 #endif
00216 #ifdef BB
00217          , b  /*BB*/
00218 #endif
00219 #ifdef CC
00220          , c  /*CC*/
00221 #endif
00222          );
00223   _program_position_x SET_TO _program_position_x + _program_origin_x - x;
00224   _program_position_y SET_TO _program_position_y + _program_origin_y - y;
00225   _program_position_z SET_TO _program_position_z + _program_origin_z - z;
00226 #ifdef AA
00227   _program_position_a SET_TO _program_position_a + _program_origin_a - a;/*AA*/
00228 #endif
00229 #ifdef BB
00230   _program_position_b SET_TO _program_position_b + _program_origin_b - b;/*BB*/
00231 #endif
00232 #ifdef CC
00233   _program_position_c SET_TO _program_position_c + _program_origin_c - c;/*CC*/
00234 #endif
00235 
00236   _program_origin_x SET_TO x;
00237   _program_origin_y SET_TO y;
00238   _program_origin_z SET_TO z;
00239 #ifdef AA
00240   _program_origin_a SET_TO a;  /*AA*/
00241 #endif
00242 #ifdef BB
00243   _program_origin_b SET_TO b;  /*BB*/
00244 #endif
00245 #ifdef CC
00246   _program_origin_c SET_TO c;  /*CC*/
00247 #endif
00248 }
00249 
00250 void USE_LENGTH_UNITS(CANON_UNITS in_unit)
00251 {
00252   if (in_unit IS CANON_UNITS_INCHES)
00253     {
00254       PRINT0("USE_LENGTH_UNITS(CANON_UNITS_INCHES)\n");
00255       if (_length_unit_type IS CANON_UNITS_MM)
00256         {
00257           _length_unit_type SET_TO CANON_UNITS_INCHES;
00258           _length_unit_factor SET_TO 25.4;
00259           _program_origin_x SET_TO (_program_origin_x / 25.4);
00260           _program_origin_y SET_TO (_program_origin_y / 25.4);
00261           _program_origin_z SET_TO (_program_origin_z / 25.4);
00262           _program_position_x SET_TO (_program_position_x / 25.4);
00263           _program_position_y SET_TO (_program_position_y / 25.4);
00264           _program_position_z SET_TO (_program_position_z / 25.4);
00265         }
00266     }
00267   else if (in_unit IS CANON_UNITS_MM)
00268     {
00269       PRINT0("USE_LENGTH_UNITS(CANON_UNITS_MM)\n");
00270       if (_length_unit_type IS CANON_UNITS_INCHES)
00271         {
00272           _length_unit_type SET_TO CANON_UNITS_MM;
00273           _length_unit_factor SET_TO 1.0;
00274           _program_origin_x SET_TO (_program_origin_x * 25.4);
00275           _program_origin_y SET_TO (_program_origin_y * 25.4);
00276           _program_origin_z SET_TO (_program_origin_z * 25.4);
00277           _program_position_x SET_TO (_program_position_x * 25.4);
00278           _program_position_y SET_TO (_program_position_y * 25.4);
00279           _program_position_z SET_TO (_program_position_z * 25.4);
00280         }
00281     }
00282   else
00283     PRINT0("USE_LENGTH_UNITS(UNKNOWN)\n");
00284 }
00285 
00286 /* Free Space Motion */
00287 void SET_TRAVERSE_RATE(double rate)
00288 {
00289   PRINT1("SET_TRAVERSE_RATE(%.4f)\n", rate);
00290   _traverse_rate SET_TO rate;
00291 }
00292 
00293 void STRAIGHT_TRAVERSE(
00294  double x, double y, double z
00295 #ifdef AA
00296  , double a /*AA*/
00297 #endif
00298 #ifdef BB
00299  , double b /*BB*/
00300 #endif
00301 #ifdef CC
00302  , double c /*CC*/
00303 #endif
00304 )
00305 {
00306   fprintf(_outfile, "%5d ", _line_number++);
00307   print_nc_line_number();
00308   fprintf(_outfile, "STRAIGHT_TRAVERSE(%.4f, %.4f, %.4f"
00309 #ifdef AA
00310          ", %.4f" /*AA*/
00311 #endif
00312 #ifdef BB
00313          ", %.4f" /*BB*/
00314 #endif
00315 #ifdef CC
00316          ", %.4f" /*CC*/
00317 #endif
00318          ")\n", x, y, z
00319 #ifdef AA
00320          , a /*AA*/
00321 #endif
00322 #ifdef BB
00323          , b /*BB*/
00324 #endif
00325 #ifdef CC
00326          , c /*CC*/
00327 #endif
00328          );
00329   _program_position_x SET_TO x;
00330   _program_position_y SET_TO y;
00331   _program_position_z SET_TO z;
00332 #ifdef AA
00333   _program_position_a SET_TO a; /*AA*/
00334 #endif
00335 #ifdef BB
00336   _program_position_b SET_TO b; /*BB*/
00337 #endif
00338 #ifdef CC
00339   _program_position_c SET_TO c; /*CC*/
00340 #endif
00341 }
00342 
00343 /* Machining Attributes */
00344 void SET_FEED_RATE(double rate)
00345 {
00346   PRINT1("SET_FEED_RATE(%.4f)\n", rate);
00347   _feed_rate SET_TO rate;
00348 }
00349 
00350 void SET_FEED_REFERENCE(CANON_FEED_REFERENCE reference)
00351 {
00352   PRINT1("SET_FEED_REFERENCE(%s)\n",
00353          (reference IS CANON_WORKPIECE) ? "CANON_WORKPIECE" : "CANON_XYZ");
00354 }
00355 
00356 extern void SET_MOTION_CONTROL_MODE(CANON_MOTION_MODE mode)
00357 {
00358   if (mode IS CANON_EXACT_STOP)
00359     {
00360       PRINT0("SET_MOTION_CONTROL_MODE(CANON_EXACT_STOP)\n");
00361       _motion_mode SET_TO CANON_EXACT_STOP;
00362     }
00363   else if (mode IS CANON_EXACT_PATH)
00364     {
00365       PRINT0("SET_MOTION_CONTROL_MODE(CANON_EXACT_PATH)\n");
00366       _motion_mode SET_TO CANON_EXACT_PATH;
00367     }
00368   else if (mode IS CANON_CONTINUOUS)
00369     {
00370       PRINT0("SET_MOTION_CONTROL_MODE(CANON_CONTINUOUS)\n");
00371       _motion_mode SET_TO CANON_CONTINUOUS;
00372     }
00373   else
00374     PRINT0("SET_MOTION_CONTROL_MODE(UNKNOWN)\n");
00375 }
00376 
00377 void SELECT_PLANE(CANON_PLANE in_plane)
00378 {
00379   PRINT1("SELECT_PLANE(CANON_PLANE_%s)\n",
00380          ((in_plane IS CANON_PLANE_XY) ? "XY" :
00381           (in_plane IS CANON_PLANE_YZ) ? "YZ" :
00382           (in_plane IS CANON_PLANE_XZ) ? "XZ" : "UNKNOWN"));
00383   _active_plane SET_TO in_plane;
00384 }
00385 
00386 void SET_CUTTER_RADIUS_COMPENSATION(double radius)
00387 {PRINT1("SET_CUTTER_RADIUS_COMPENSATION(%.4f)\n", radius);}
00388 
00389 void START_CUTTER_RADIUS_COMPENSATION(int side)
00390 {PRINT1("START_CUTTER_RADIUS_COMPENSATION(%s)\n",
00391         (side IS CANON_SIDE_LEFT)  ? "LEFT"  :
00392         (side IS CANON_SIDE_RIGHT) ? "RIGHT" : "UNKNOWN");
00393 }
00394 
00395 void STOP_CUTTER_RADIUS_COMPENSATION()
00396 {PRINT0 ("STOP_CUTTER_RADIUS_COMPENSATION()\n");}
00397 
00398 void START_SPEED_FEED_SYNCH()
00399 {PRINT0 ("START_SPEED_FEED_SYNCH()\n");}
00400 
00401 void STOP_SPEED_FEED_SYNCH()
00402 {PRINT0 ("STOP_SPEED_FEED_SYNCH()\n");}
00403 
00404 /* Machining Functions */
00405 
00406 void ARC_FEED(
00407  double first_end, double second_end,
00408  double first_axis, double second_axis, int rotation, double axis_end_point
00409 #ifdef AA
00410  , double a /*AA*/
00411 #endif
00412 #ifdef BB
00413  , double b /*BB*/
00414 #endif
00415 #ifdef CC
00416  , double c /*CC*/
00417 #endif
00418 )
00419 {
00420   fprintf(_outfile, "%5d ", _line_number++);
00421   print_nc_line_number();
00422   fprintf(_outfile, "ARC_FEED(%.4f, %.4f, %.4f, %.4f, %d, %.4f"
00423 #ifdef AA
00424          ", %.4f" /*AA*/
00425 #endif
00426 #ifdef BB
00427          ", %.4f" /*BB*/
00428 #endif
00429 #ifdef CC
00430          ", %.4f" /*CC*/
00431 #endif
00432          ")\n", first_end, second_end, first_axis, second_axis,
00433          rotation, axis_end_point
00434 #ifdef AA
00435          , a /*AA*/
00436 #endif
00437 #ifdef BB
00438          , b /*BB*/
00439 #endif
00440 #ifdef CC
00441          , c /*CC*/
00442 #endif
00443          );
00444   if (_active_plane IS CANON_PLANE_XY)
00445     {
00446       _program_position_x SET_TO first_end;
00447       _program_position_y SET_TO second_end;
00448       _program_position_z SET_TO axis_end_point;
00449     }
00450   else if (_active_plane IS CANON_PLANE_YZ)
00451     {
00452       _program_position_x SET_TO axis_end_point;
00453       _program_position_y SET_TO first_end;
00454       _program_position_z SET_TO second_end;
00455     }
00456   else /* if (_active_plane IS CANON_PLANE_XZ) */
00457     {
00458       _program_position_x SET_TO second_end;
00459       _program_position_y SET_TO axis_end_point;
00460       _program_position_z SET_TO first_end;
00461     }
00462 #ifdef AA
00463   _program_position_a SET_TO a; /*AA*/
00464 #endif
00465 #ifdef BB
00466   _program_position_b SET_TO b; /*BB*/
00467 #endif
00468 #ifdef CC
00469   _program_position_c SET_TO c; /*CC*/
00470 #endif
00471 }
00472 
00473 void STRAIGHT_FEED(
00474  double x, double y, double z
00475 #ifdef AA
00476  , double a /*AA*/
00477 #endif
00478 #ifdef BB
00479  , double b /*BB*/
00480 #endif
00481 #ifdef CC
00482  , double c /*CC*/
00483 #endif
00484 )
00485 {
00486   fprintf(_outfile, "%5d ", _line_number++);
00487   print_nc_line_number();
00488   fprintf(_outfile, "STRAIGHT_FEED(%.4f, %.4f, %.4f"
00489 #ifdef AA
00490          ", %.4f" /*AA*/
00491 #endif
00492 #ifdef BB
00493          ", %.4f" /*BB*/
00494 #endif
00495 #ifdef CC
00496          ", %.4f" /*CC*/
00497 #endif
00498          ")\n", x, y, z
00499 #ifdef AA
00500          , a /*AA*/
00501 #endif
00502 #ifdef BB
00503          , b /*BB*/
00504 #endif
00505 #ifdef CC
00506          , c /*CC*/
00507 #endif
00508          );
00509   _program_position_x SET_TO x;
00510   _program_position_y SET_TO y;
00511   _program_position_z SET_TO z;
00512 #ifdef AA
00513   _program_position_a SET_TO a; /*AA*/
00514 #endif
00515 #ifdef BB
00516   _program_position_b SET_TO b; /*BB*/
00517 #endif
00518 #ifdef CC
00519   _program_position_c SET_TO c; /*CC*/
00520 #endif
00521 }
00522 
00523 
00524 /* This models backing the probe off 0.01 inch or 0.254 mm from the probe
00525 point towards the previous location after the probing, if the probe
00526 point is not the same as the previous point -- which it should not be. */
00527 
00528 void STRAIGHT_PROBE(
00529  double x, double y, double z
00530 #ifdef AA
00531  , double a /*AA*/
00532 #endif
00533 #ifdef BB
00534  , double b /*BB*/
00535 #endif
00536 #ifdef CC
00537  , double c /*CC*/
00538 #endif
00539 )
00540 {
00541   double distance;
00542   double dx, dy, dz;
00543   double backoff;
00544 
00545   dx SET_TO (_program_position_x - x);
00546   dy SET_TO (_program_position_y - y);
00547   dz SET_TO (_program_position_z - z);
00548   distance SET_TO sqrt((dx * dx) + (dy * dy) + (dz * dz));
00549 
00550   fprintf(_outfile, "%5d ", _line_number++);
00551   print_nc_line_number();
00552   fprintf(_outfile, "STRAIGHT_PROBE(%.4f, %.4f, %.4f"
00553 #ifdef AA
00554          ", %.4f" /*AA*/
00555 #endif
00556 #ifdef BB
00557          ", %.4f" /*BB*/
00558 #endif
00559 #ifdef CC
00560          ", %.4f" /*CC*/
00561 #endif
00562          ")\n", x, y, z
00563 #ifdef AA
00564          , a /*AA*/
00565 #endif
00566 #ifdef BB
00567          , b /*BB*/
00568 #endif
00569 #ifdef CC
00570          , c /*CC*/
00571 #endif
00572          );
00573   _probe_position_x SET_TO x;
00574   _probe_position_y SET_TO y;
00575   _probe_position_z SET_TO z;
00576 #ifdef AA
00577   _probe_position_a SET_TO a; /*AA*/
00578 #endif
00579 #ifdef BB
00580   _probe_position_b SET_TO b; /*BB*/
00581 #endif
00582 #ifdef CC
00583   _probe_position_c SET_TO c; /*CC*/
00584 #endif
00585   if (distance IS 0)
00586     {
00587       _program_position_x SET_TO _program_position_x;
00588       _program_position_y SET_TO _program_position_y;
00589       _program_position_z SET_TO _program_position_z;
00590     }
00591   else
00592     {
00593       backoff SET_TO ((_length_unit_type IS CANON_UNITS_MM) ? 0.254 : 0.01);
00594       _program_position_x SET_TO (x + (backoff * (dx / distance)));
00595       _program_position_y SET_TO (y + (backoff * (dy / distance)));
00596       _program_position_z SET_TO (z + (backoff * (dz / distance)));
00597     }
00598 #ifdef AA
00599   _program_position_a SET_TO a; /*AA*/
00600 #endif
00601 #ifdef BB
00602   _program_position_b SET_TO b; /*BB*/
00603 #endif
00604 #ifdef CC
00605   _program_position_c SET_TO c; /*CC*/
00606 #endif
00607 }
00608 
00609 /*
00610 void PARAMETRIC_2D_CURVE_FEED(FunctionPtr f1, FunctionPtr f2,
00611                               double start_parameter_value,
00612                               double end_parameter_value) {}
00613 
00614 void PARAMETRIC_3D_CURVE_FEED(FunctionPtr xfcn, FunctionPtr yfcn,
00615         FunctionPtr zfcn, double start_parameter_value,
00616                               double end_parameter_value) {}
00617 */
00618 
00619 void DWELL(double seconds)
00620 {PRINT1("DWELL(%.4f)\n", seconds);}
00621 
00622 /* Spindle Functions */
00623 void SPINDLE_RETRACT_TRAVERSE()
00624 {PRINT0("SPINDLE_RETRACT_TRAVERSE()\n");}
00625 
00626 void START_SPINDLE_CLOCKWISE()
00627 {
00628   PRINT0("START_SPINDLE_CLOCKWISE()\n");
00629   _spindle_turning SET_TO ((_spindle_speed IS 0) ? CANON_STOPPED :
00630                                                    CANON_CLOCKWISE);
00631 }
00632 
00633 void START_SPINDLE_COUNTERCLOCKWISE()
00634 {
00635   PRINT0("START_SPINDLE_COUNTERCLOCKWISE()\n");
00636   _spindle_turning SET_TO ((_spindle_speed IS 0) ? CANON_STOPPED :
00637                                                    CANON_COUNTERCLOCKWISE);
00638 }
00639 
00640 void SET_SPINDLE_SPEED(double rpm)
00641 {
00642   PRINT1("SET_SPINDLE_SPEED(%.4f)\n", rpm);
00643   _spindle_speed SET_TO rpm;
00644 }
00645 
00646 void STOP_SPINDLE_TURNING()
00647 {
00648   PRINT0("STOP_SPINDLE_TURNING()\n");
00649   _spindle_turning SET_TO CANON_STOPPED;
00650 }
00651 
00652 void SPINDLE_RETRACT()
00653 {PRINT0("SPINDLE_RETRACT()\n");}
00654 
00655 void ORIENT_SPINDLE(double orientation, CANON_DIRECTION direction)
00656 {PRINT2("ORIENT_SPINDLE(%.4f, %s)\n", orientation,
00657         (direction IS CANON_CLOCKWISE) ? "CANON_CLOCKWISE" :
00658                                          "CANON_COUNTERCLOCKWISE");
00659 }
00660 
00661 void USE_NO_SPINDLE_FORCE()
00662 {PRINT0("USE_NO_SPINDLE_FORCE()\n");}
00663 
00664 /* Tool Functions */
00665 
00666 void USE_TOOL_LENGTH_OFFSET(double length)
00667 {PRINT1("USE_TOOL_LENGTH_OFFSET(%.4f)\n", length);}
00668 
00669 void CHANGE_TOOL(int slot)
00670 {
00671   PRINT1("CHANGE_TOOL(%d)\n", slot);
00672   _active_slot SET_TO slot;
00673 }
00674 
00675 void SELECT_TOOL(int slot)
00676 {PRINT1("SELECT_TOOL(%d)\n", slot);}
00677 
00678 
00679 /* Misc Functions */
00680 
00681 void CLAMP_AXIS(CANON_AXIS axis)
00682 {PRINT1("CLAMP_AXIS(%s)\n",
00683         (axis IS CANON_AXIS_X) ? "CANON_AXIS_X" :
00684         (axis IS CANON_AXIS_Y) ? "CANON_AXIS_Y" :
00685         (axis IS CANON_AXIS_Z) ? "CANON_AXIS_Z" :
00686         (axis IS CANON_AXIS_A) ? "CANON_AXIS_A" :
00687         (axis IS CANON_AXIS_C) ? "CANON_AXIS_C" : "UNKNOWN");}
00688 
00689 void COMMENT(char *s)
00690 {PRINT1("COMMENT(\"%s\")\n", s);}
00691 
00692 void DISABLE_FEED_OVERRIDE()
00693 {PRINT0("DISABLE_FEED_OVERRIDE()\n");}
00694 
00695 void DISABLE_SPEED_OVERRIDE()
00696 {PRINT0("DISABLE_SPEED_OVERRIDE()\n");}
00697 
00698 void ENABLE_FEED_OVERRIDE()
00699 {PRINT0("ENABLE_FEED_OVERRIDE()\n");}
00700 
00701 void ENABLE_SPEED_OVERRIDE()
00702 {PRINT0("ENABLE_SPEED_OVERRIDE()\n");}
00703 
00704 void FLOOD_OFF()
00705 {
00706   PRINT0("FLOOD_OFF()\n");
00707   _flood SET_TO 0;
00708 }
00709 
00710 void FLOOD_ON()
00711 {
00712   PRINT0("FLOOD_ON()\n");
00713   _flood SET_TO 1;
00714 }
00715 
00716 void INIT_CANON()
00717 {
00718 }
00719 
00720 void MESSAGE(char *s)
00721 {PRINT1("MESSAGE(\"%s\")\n", s);}
00722 
00723 void MIST_OFF()
00724 {
00725   PRINT0("MIST_OFF()\n");
00726   _mist SET_TO 0;
00727 }
00728 
00729 void MIST_ON()
00730 {
00731   PRINT0("MIST_ON()\n");
00732   _mist SET_TO 1;
00733 }
00734 
00735 void PALLET_SHUTTLE()
00736 {PRINT0("PALLET_SHUTTLE()\n");}
00737 
00738 void TURN_PROBE_OFF()
00739 {PRINT0("TURN_PROBE_OFF()\n");}
00740 
00741 void TURN_PROBE_ON()
00742 {PRINT0("TURN_PROBE_ON()\n");}
00743 
00744 void UNCLAMP_AXIS(CANON_AXIS axis)
00745 {PRINT1("UNCLAMP_AXIS(%s)\n",
00746         (axis IS CANON_AXIS_X) ? "CANON_AXIS_X" :
00747         (axis IS CANON_AXIS_Y) ? "CANON_AXIS_Y" :
00748         (axis IS CANON_AXIS_Z) ? "CANON_AXIS_Z" :
00749         (axis IS CANON_AXIS_A) ? "CANON_AXIS_A" :
00750         (axis IS CANON_AXIS_B) ? "CANON_AXIS_B" :
00751         (axis IS CANON_AXIS_C) ? "CANON_AXIS_C" : "UNKNOWN");}
00752 
00753 /* Program Functions */
00754 
00755 void PROGRAM_STOP()
00756 {PRINT0("PROGRAM_STOP()\n");}
00757 
00758 void OPTIONAL_PROGRAM_STOP()
00759 {PRINT0("OPTIONAL_PROGRAM_STOP()\n");}
00760 
00761 void PROGRAM_END()
00762 {PRINT0("PROGRAM_END()\n");}
00763 
00764 
00765 /*************************************************************************/
00766 
00767 /* Canonical "Give me information" functions
00768 
00769 In general, returned values are valid only if any canonical do it commands
00770 that may have been called for have been executed to completion. If a function
00771 returns a valid value regardless of execution, that is noted in the comments
00772 below.
00773 
00774 */
00775 
00776 /* The interpreter is not using this function
00777 // Returns the system angular unit factor, in units / degree
00778 extern double GET_EXTERNAL_ANGLE_UNIT_FACTOR()
00779 {
00780   return 1;
00781 }
00782 */
00783 
00784 /* Returns the system feed rate */
00785 double GET_EXTERNAL_FEED_RATE()
00786 {
00787   return _feed_rate;
00788 }
00789 
00790 /* Returns the system flood coolant setting zero = off, non-zero = on */
00791 int GET_EXTERNAL_FLOOD()
00792 {
00793   return _flood;
00794 }
00795 
00796 /* Returns the system length unit factor, in units per mm */
00797 extern double GET_EXTERNAL_LENGTH_UNIT_FACTOR()
00798 {
00799   return 1/_length_unit_factor;
00800 }
00801 
00802 /* Returns the system length unit type */
00803 CANON_UNITS GET_EXTERNAL_LENGTH_UNIT_TYPE()
00804 {
00805   return _length_unit_type;
00806 }
00807 
00808 /* Returns the system mist coolant setting zero = off, non-zero = on */
00809 extern int GET_EXTERNAL_MIST()
00810 {
00811   return _mist;
00812 }
00813 
00814 // Returns the current motion control mode
00815 extern CANON_MOTION_MODE GET_EXTERNAL_MOTION_CONTROL_MODE()
00816 {
00817   return _motion_mode;
00818 }
00819 
00820 
00821 /* The interpreter is not using these six GET_EXTERNAL_ORIGIN functions
00822 
00823 #ifdef AA
00824 // returns the current a-axis origin offset
00825 double GET_EXTERNAL_ORIGIN_A()
00826 {
00827   return _program_origin_a;
00828 }
00829 #endif
00830 
00831 #ifdef BB
00832 // returns the current b-axis origin offset
00833 double GET_EXTERNAL_ORIGIN_B()
00834 {
00835   return _program_origin_b;
00836 }
00837 #endif
00838 
00839 #ifdef CC
00840 // returns the current c-axis origin offset
00841 double GET_EXTERNAL_ORIGIN_C()
00842 {
00843   return _program_origin_c;
00844 }
00845 #endif
00846 
00847 // returns the current x-axis origin offset
00848 double GET_EXTERNAL_ORIGIN_X()
00849 {
00850   return _program_origin_x;
00851 }
00852 
00853 // returns the current y-axis origin offset
00854 double GET_EXTERNAL_ORIGIN_Y()
00855 {
00856   return _program_origin_y;
00857 }
00858 
00859 // returns the current z-axis origin offset
00860 double GET_EXTERNAL_ORIGIN_Z()
00861 {
00862   return _program_origin_z;
00863 }
00864 
00865 */
00866 
00867 void GET_EXTERNAL_PARAMETER_FILE_NAME(
00868  char * file_name,       /* string: to copy file name into       */
00869  int max_size)           /* maximum number of characters to copy */
00870 {
00871   if (strlen(_parameter_file_name) < max_size)
00872     strcpy(file_name, _parameter_file_name);
00873   else
00874     file_name[0] SET_TO 0;
00875 }
00876 
00877 CANON_PLANE GET_EXTERNAL_PLANE()
00878 {
00879   return _active_plane;
00880 }
00881 
00882 #ifdef AA
00883 /* returns the current a-axis position */
00884 double GET_EXTERNAL_POSITION_A()
00885 {
00886   return _program_position_a;
00887 }
00888 #endif
00889 
00890 #ifdef BB
00891 /* returns the current b-axis position */
00892 double GET_EXTERNAL_POSITION_B()
00893 {
00894   return _program_position_b;
00895 }
00896 #endif
00897 
00898 #ifdef CC
00899 /* returns the current c-axis position */
00900 double GET_EXTERNAL_POSITION_C()
00901 {
00902   return _program_position_c;
00903 }
00904 #endif
00905 
00906 /* returns the current x-axis position */
00907 double GET_EXTERNAL_POSITION_X()
00908 {
00909   return _program_position_x;
00910 }
00911 
00912 /* returns the current y-axis position */
00913 double GET_EXTERNAL_POSITION_Y()
00914 {
00915   return _program_position_y;
00916 }
00917 
00918 /* returns the current z-axis position */
00919 double GET_EXTERNAL_POSITION_Z()
00920 {
00921   return _program_position_z;
00922 }
00923 
00924 #ifdef AA
00925 /* returns the a-axis position at the last probe trip. This is only valid
00926    once the probe command has executed to completion. */
00927 double GET_EXTERNAL_PROBE_POSITION_A()
00928 {
00929   return _probe_position_a;
00930 }
00931 #endif
00932 
00933 #ifdef BB
00934 /* returns the b-axis position at the last probe trip. This is only valid
00935    once the probe command has executed to completion. */
00936 double GET_EXTERNAL_PROBE_POSITION_B()
00937 {
00938   return _probe_position_b;
00939 }
00940 #endif
00941 
00942 #ifdef CC
00943 /* returns the c-axis position at the last probe trip. This is only valid
00944    once the probe command has executed to completion. */
00945 double GET_EXTERNAL_PROBE_POSITION_C()
00946 {
00947   return _probe_position_c;
00948 }
00949 #endif
00950 
00951 /* returns the x-axis position at the last probe trip. This is only valid
00952    once the probe command has executed to completion. */
00953 double GET_EXTERNAL_PROBE_POSITION_X()
00954 {
00955   return _probe_position_x;
00956 }
00957 
00958 /* returns the y-axis position at the last probe trip. This is only valid
00959    once the probe command has executed to completion. */
00960 double GET_EXTERNAL_PROBE_POSITION_Y()
00961 {
00962   return _probe_position_y;
00963 }
00964 
00965 /* returns the z-axis position at the last probe trip. This is only valid
00966    once the probe command has executed to completion. */
00967 double GET_EXTERNAL_PROBE_POSITION_Z()
00968 {
00969   return _probe_position_z;
00970 }
00971 
00972 /* Returns the value for any analog non-contact probing. */
00973 /* This is a dummy of a dummy, returning a useless value. */
00974 /* It is not expected this will ever be called. */
00975 extern double GET_EXTERNAL_PROBE_VALUE()
00976 {
00977   return 1.0;
00978 }
00979 
00980 /* Returns zero if queue is not empty, non-zero if the queue is empty */
00981 /* In the stand-alone interpreter, there is no queue, so it is always empty */
00982 extern int GET_EXTERNAL_QUEUE_EMPTY()
00983 {
00984   return 1;
00985 }
00986 
00987 /* Returns the system value for spindle speed in rpm */
00988 double GET_EXTERNAL_SPEED()
00989 {
00990   return _spindle_speed;
00991 }
00992 
00993 /* Returns the system value for direction of spindle turning */
00994 extern CANON_DIRECTION GET_EXTERNAL_SPINDLE()
00995 {
00996   return _spindle_turning;
00997 }
00998 
00999 /* Returns the system value for the carousel slot in which the tool
01000 currently in the spindle belongs. Return value zero means there is no
01001 tool in the spindle. */
01002 extern int GET_EXTERNAL_TOOL_SLOT()
01003 {
01004   return _active_slot;
01005 }
01006 
01007 /* Returns maximum number of tools */
01008 int GET_EXTERNAL_TOOL_MAX()
01009 {
01010   return _tool_max;
01011 }
01012 
01013 /* Returns the CANON_TOOL_TABLE structure associated with the tool
01014    in the given pocket */
01015 extern CANON_TOOL_TABLE GET_EXTERNAL_TOOL_TABLE(int pocket)
01016 {
01017   return _tools[pocket];
01018 }
01019 
01020 /* Returns the system traverse rate */
01021 double GET_EXTERNAL_TRAVERSE_RATE()
01022 {
01023   return _traverse_rate;
01024 }

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