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

canon_stand_alone.cc

Go to the documentation of this file.
00001 /*
00002 
00003 This is a set of dummy definitions for the canonical machining
00004 functions given in canon.hh. These functions just print. On each
00005 output line is printed:
00006 1. an output line number (sequential, starting with 1).
00007 2. an input line number read from the input (or ... if not provided).
00008 3. a printed representation of the function call which was made.
00009 
00010 If an interpreter which makes these calls is compiled with this set of
00011 definitions, it can be used as a translator by redirecting output from
00012 stdout to a file.
00013 
00014 */
00015 
00016 /*
00017   Modification history:
00018 
00019    1-Nov-2000 WPS added unused variables a,b,c to ARC_FEED,STRAIHT_FEED, etc.
00020   24-Feb-2000  FMP added CANON_UPDATE_POSITION()
00021 */
00022 
00023 #include <stdio.h>
00024 #include "rs274ngc.hh"
00025 
00026 extern block _interpreter_block;
00027 extern setup _interpreter_settings;
00028 void print_nc_line_number()
00029 {
00030   int line_number SET_TO _interpreter_block.line_number;
00031   if (line_number IS -1)
00032     printf(" N ... ");
00033   else if (line_number < 10)
00034     printf("    N%d ", line_number);
00035   else if (line_number < 100)
00036     printf("   N%d ", line_number);
00037   else if (line_number < 1000)
00038     printf("  N%d ", line_number);
00039   else if (line_number < 10000)
00040     printf(" N%d ", line_number);
00041   else
00042     printf("N%d ", line_number);
00043 }
00044 
00045 #define PRINT0(control) if (1)               \
00046           {printf("%5d ", line_number++);    \
00047            print_nc_line_number();           \
00048            printf(control);                  \
00049           } else
00050 #define PRINT1(control, arg1) if (1)         \
00051           {printf("%5d ", line_number++);    \
00052            print_nc_line_number();           \
00053            printf(control, arg1);            \
00054           } else
00055 #define PRINT2(control, arg1, arg2) if (1)   \
00056           {printf("%5d ", line_number++);    \
00057            print_nc_line_number();           \
00058            printf(control, arg1, arg2);      \
00059           } else
00060 #define PRINT3(control, arg1, arg2, arg3) if (1)         \
00061           {printf("%5d ", line_number++);                \
00062            print_nc_line_number();                       \
00063            printf(control, arg1, arg2, arg3);            \
00064           } else
00065 #define PRINT4(control, arg1, arg2, arg3, arg4) if (1)   \
00066           {printf("%5d ", line_number++);                \
00067            print_nc_line_number();                       \
00068            printf(control, arg1, arg2, arg3, arg4);      \
00069           } else
00070 #define PRINT6(control, arg1, arg2, arg3, arg4, arg5, arg6) if (1) \
00071           {printf("%5d ", line_number++);                          \
00072            print_nc_line_number();                                 \
00073            printf(control, arg1, arg2, arg3, arg4, arg5, arg6);    \
00074           } else
00075 static int line_number SET_TO 1;
00076 static CANON_VECTOR program_origin;
00077 static CANON_UNITS length_units = CANON_UNITS_MM;
00078 static CANON_PLANE active_plane = CANON_PLANE_XY;
00079 
00080 /* Representation */
00081 
00082 void SET_ORIGIN_OFFSETS(double x, double y, double z,
00083                         double a, double b, double c)
00084 {PRINT3("SET_ORIGIN_OFFSETS(%.4f, %.4f, %.4f)\n", x, y, z);
00085   program_origin.x SET_TO x;
00086   program_origin.y SET_TO y;
00087   program_origin.z SET_TO z;
00088 }
00089 
00090 void USE_LENGTH_UNITS(CANON_UNITS in_unit)
00091 {PRINT1("USE_LENGTH_UNITS(%s)\n",
00092         (in_unit IS CANON_UNITS_INCHES) ? "CANON_UNITS_INCHES" :
00093         (in_unit IS CANON_UNITS_MM)     ? "CANON_UNITS_MM" : "UNKNOWN");
00094 }
00095 
00096 /* Free Space Motion */
00097 void SET_TRAVERSE_RATE(double rate)
00098 {PRINT1("SET_TRAVERSE_RATE(%.4f)\n", rate);}
00099 
00100 void STRAIGHT_TRAVERSE (double x, double y, double z,
00101                         double a, double b , double c)
00102 {PRINT3("STRAIGHT_TRAVERSE(%.4f, %.4f, %.4f)\n", x, y, z);}
00103 
00104 /* Machining Attributes */
00105 void SET_FEED_RATE(double rate)
00106 {PRINT1("SET_FEED_RATE(%.4f)\n", rate);}
00107 
00108 void SET_FEED_REFERENCE(CANON_FEED_REFERENCE reference)
00109 {PRINT1("SET_FEED_REFERENCE(%s)\n",
00110         (reference IS CANON_WORKPIECE) ? "CANON_WORKPIECE" : "CANON_XYZ");}
00111 
00112 void SET_MOTION_CONTROL_MODE(CANON_MOTION_MODE mode)
00113 {PRINT1("SET_MOTION_CONTROL_MODE(%s)\n",
00114         (mode IS CANON_EXACT_PATH) ? "CANON_EXACT_PATH" :
00115         (mode IS CANON_EXACT_STOP) ? "CANON_EXACT_STOP" : "CANON_CONTINUOUS");}
00116 
00117 void SELECT_PLANE(CANON_PLANE in_plane)
00118 {PRINT1("SELECT_PLANE(%s)\n",
00119         (in_plane IS CANON_PLANE_XY) ? "CANON_PLANE_XY" :
00120         (in_plane IS CANON_PLANE_YZ) ? "CANON_PLANE_YZ" :
00121         (in_plane IS CANON_PLANE_XZ) ? "CANON_PLANE_XZ" : "UNKNOWN");
00122 }
00123 
00124 void SET_CUTTER_RADIUS_COMPENSATION(double radius)
00125 {PRINT1("SET_CUTTER_RADIUS_COMPENSATION(%.4f)\n", radius);}
00126 
00127 void START_CUTTER_RADIUS_COMPENSATION(int side)
00128 {PRINT1("START_CUTTER_RADIUS_COMPENSATION(%s)\n",
00129         (side IS LEFT)  ? "LEFT"  :
00130         (side IS RIGHT) ? "RIGHT" : "UNKNOWN");
00131 }
00132 
00133 void STOP_CUTTER_RADIUS_COMPENSATION()
00134 {PRINT0 ("STOP_CUTTER_RADIUS_COMPENSATION()\n");}
00135 
00136 void START_SPEED_FEED_SYNCH()
00137 {PRINT0 ("START_SPEED_FEED_SYNCH()\n");}
00138 
00139 void STOP_SPEED_FEED_SYNCH()
00140 {PRINT0 ("STOP_SPEED_FEED_SYNCH()\n");}
00141 
00142 void SELECT_MOTION_MODE(CANON_MOTION_MODE mode)
00143 {PRINT1("SELECT_MOTION_MODE(%s)\n",
00144         (mode IS CANON_EXACT_STOP) ? "CANON_EXACT_STOP" :
00145         (mode IS CANON_EXACT_PATH) ? "CANON_EXACT_PATH" :
00146         (mode IS CANON_CONTINUOUS) ? "CANON_CONTINUOUS" :
00147                                           "UNKNOWN");
00148 }
00149 
00150 /* Machining Functions */
00151 void ARC_FEED(double first_end, double second_end,
00152               double first_axis, double second_axis, int rotation,
00153               double axis_end_point,
00154               double a, double b, double c)
00155 {PRINT6("ARC_FEED(%.4f, %.4f, %.4f, %.4f, %d, %.4f)\n",
00156         first_end, second_end, first_axis, second_axis, rotation,
00157         axis_end_point);}
00158 
00159 void STRAIGHT_FEED (double x, double y, double z,
00160                     double a, double b, double c)
00161 {PRINT3("STRAIGHT_FEED(%.4f, %.4f, %.4f)\n", x, y, z);}
00162 
00163 void STRAIGHT_PROBE (double x, double y, double z,
00164                      double a, double b, double c)
00165 {PRINT3("STRAIGHT_PROBE(%.4f, %.4f, %.4f)\n", x, y, z);}
00166 
00167 
00168 /*
00169 void PARAMETRIC_2D_CURVE_FEED(FunctionPtr f1, FunctionPtr f2,
00170                               double start_parameter_value,
00171                               double end_parameter_value) {}
00172 
00173 void PARAMETRIC_3D_CURVE_FEED(FunctionPtr xfcn, FunctionPtr yfcn,
00174         FunctionPtr zfcn, double start_parameter_value,
00175                               double end_parameter_value) {}
00176 */
00177 
00178 void DWELL(double seconds)
00179 {PRINT1("DWELL(%.4f)\n", seconds);}
00180 
00181 /* Spindle Functions */
00182 void SPINDLE_RETRACT_TRAVERSE()
00183 {PRINT0("SPINDLE_RETRACT_TRAVERSE()\n");}
00184 
00185 void START_SPINDLE_CLOCKWISE()
00186 {PRINT0("START_SPINDLE_CLOCKWISE()\n");}
00187 
00188 void START_SPINDLE_COUNTERCLOCKWISE()
00189 {PRINT0("START_SPINDLE_COUNTERCLOCKWISE()\n");}
00190 
00191 void SET_SPINDLE_SPEED(double r)
00192 {PRINT1("SET_SPINDLE_SPEED(%.4f)\n", r);}
00193 
00194 void STOP_SPINDLE_TURNING()
00195 {PRINT0("STOP_SPINDLE_TURNING()\n");}
00196 
00197 void SPINDLE_RETRACT()
00198 {PRINT0("SPINDLE_RETRACT()\n");}
00199 
00200 void ORIENT_SPINDLE(double orientation, CANON_DIRECTION direction)
00201 {PRINT2("ORIENT_SPINDLE(%.4f, %s)\n", orientation,
00202         (direction IS CANON_CLOCKWISE) ? "CANON_CLOCKWISE" :
00203                                          "CANON_COUNTERCLOCKWISE");
00204 }
00205 
00206 void USE_NO_SPINDLE_FORCE()
00207 {PRINT0("USE_NO_SPINDLE_FORCE()\n");}
00208 
00209 /* Tool Functions */
00210 
00211 void USE_TOOL_LENGTH_OFFSET(double length)
00212 {PRINT1("USE_TOOL_LENGTH_OFFSET(%.4f)\n", length);}
00213 
00214 void CHANGE_TOOL(int slot)
00215 {PRINT1("CHANGE_TOOL(%d)\n", slot);}
00216 
00217 void SELECT_TOOL(int slot)
00218 {PRINT1("SELECT_TOOL(%d)\n", slot);}
00219 
00220 
00221 /* Misc Functions */
00222 
00223 void CLAMP_AXIS(CANON_AXIS axis)
00224 {PRINT1("CLAMP_AXIS(%s)\n",
00225         (axis IS CANON_AXIS_X) ? "CANON_AXIS_X" :
00226         (axis IS CANON_AXIS_Y) ? "CANON_AXIS_Y" :
00227         (axis IS CANON_AXIS_Z) ? "CANON_AXIS_Z" : "UNKNOWN");}
00228 
00229 void COMMENT(char *s)
00230 {PRINT1("COMMENT(\"%s\")\n", s);}
00231 
00232 void DISABLE_FEED_OVERRIDE()
00233 {PRINT0("DISABLE_FEED_OVERRIDE()\n");}
00234 
00235 void DISABLE_SPEED_OVERRIDE()
00236 {PRINT0("DISABLE_SPEED_OVERRIDE()\n");}
00237 
00238 void ENABLE_FEED_OVERRIDE()
00239 {PRINT0("ENABLE_FEED_OVERRIDE()\n");}
00240 
00241 void ENABLE_SPEED_OVERRIDE()
00242 {PRINT0("ENABLE_SPEED_OVERRIDE()\n");}
00243 
00244 void FLOOD_OFF()
00245 {PRINT0("FLOOD_OFF()\n");}
00246 
00247 void FLOOD_ON()
00248 {PRINT0("FLOOD_ON()\n");}
00249 
00250 void MESSAGE(char *s)
00251 {PRINT1("MESSAGE(\"%s\")\n", s);}
00252 
00253 void MIST_OFF()
00254 {PRINT0("MIST_OFF()\n");}
00255 
00256 void MIST_ON()
00257 {PRINT0("MIST_ON()\n");}
00258 
00259 void PALLET_SHUTTLE()
00260 {PRINT0("PALLET_SHUTTLE()\n");}
00261 
00262 void TURN_PROBE_OFF()
00263 {PRINT0("TURN_PROBE_OFF()\n");}
00264 
00265 void TURN_PROBE_ON()
00266 {PRINT0("TURN_PROBE_ON()\n");}
00267 
00268 void UNCLAMP_AXIS(CANON_AXIS axis)
00269 {PRINT1("UNCLAMP_AXIS(%s)\n",
00270         (axis IS CANON_AXIS_X) ? "CANON_AXIS_X" :
00271         (axis IS CANON_AXIS_Y) ? "CANON_AXIS_Y" :
00272         (axis IS CANON_AXIS_Z) ? "CANON_AXIS_Z" : "UNKNOWN");}
00273 
00274 /* Program Functions */
00275 
00276 void PROGRAM_STOP()
00277 {PRINT0("PROGRAM_STOP()\n");}
00278 
00279 void OPTIONAL_PROGRAM_STOP()
00280 {PRINT0("OPTIONAL_PROGRAM_STOP()\n");}
00281 
00282 void PROGRAM_END()
00283 {PRINT0("PROGRAM_END()\n");}
00284 
00285 /* returns the current x, y, z origin offsets */
00286 CANON_VECTOR GET_PROGRAM_ORIGIN()
00287 {
00288   return program_origin;
00289 }
00290 
00291 /* returns the current active units */
00292 CANON_UNITS GET_LENGTH_UNITS()
00293 {
00294   return length_units;
00295 }
00296 
00297 CANON_PLANE GET_PLANE()
00298 {
00299   return active_plane;
00300 }
00301 
00302 /*********************************************************************/
00303 
00304 /*
00305 
00306 The purpose of these GET_XXX (and other) functions is to provide for
00307 local emulation of the world modeling done by the EMC system.
00308 
00309 /*********************************************************************/
00310 
00311 /* GET_EXTERNAL_FEED_RATE
00312 
00313 called by: rs274ngc_synch
00314 
00315 This is a stub.
00316 
00317 */
00318 
00319 double GET_EXTERNAL_FEED_RATE()
00320 {
00321   return 15;
00322 }
00323 
00324 /*********************************************************************/
00325 
00326 int GET_EXTERNAL_FLOOD()
00327 {
00328   return OFF;
00329 }
00330 
00331 /*********************************************************************/
00332 
00333 int GET_EXTERNAL_MIST()
00334 {
00335   return OFF;
00336 }
00337 
00338 /*********************************************************************/
00339 
00340 int GET_EXTERNAL_POCKET()
00341 {
00342   return 1;
00343 }
00344 
00345 /*********************************************************************/
00346 
00347 CANON_POSITION GET_EXTERNAL_POSITION()
00348 {
00349   return CANON_POSITION(_interpreter_settings.current_x,
00350                         _interpreter_settings.current_y,
00351                         _interpreter_settings.current_z,
00352                         0.0,
00353                         0.0,
00354                         0.0);
00355 }
00356 
00357 /*********************************************************************/
00358 
00359 CANON_POSITION GET_EXTERNAL_PROBE_POSITION()
00360 {
00361   return CANON_POSITION(_interpreter_settings.current_x,
00362                         _interpreter_settings.current_y,
00363                         _interpreter_settings.current_z,
00364                         0.0,
00365                         0.0,
00366                         0.0);
00367 }
00368 
00369 /*********************************************************************/
00370 
00371 double GET_EXTERNAL_PROBE_VALUE()
00372 {
00373   return 1.0;
00374 }
00375 
00376 /*********************************************************************/
00377 
00378 double GET_EXTERNAL_SPEED()
00379 {
00380   // speed is in RPMs everywhere
00381   return 1000;
00382 }
00383 
00384 /*********************************************************************/
00385 
00386 CANON_DIRECTION GET_EXTERNAL_SPINDLE()
00387 {
00388   return CANON_STOPPED;
00389 }
00390 
00391 /*********************************************************************/
00392 
00393 int GET_EXTERNAL_TOOL()
00394 {
00395   return 1;
00396 }
00397 
00398 /*********************************************************************/
00399 
00400 int GET_EXTERNAL_TOOL_MAX()
00401 {
00402   return CANON_TOOL_MAX;
00403 }
00404 
00405 /*********************************************************************/
00406 
00407 CANON_TOOL_TABLE GET_EXTERNAL_TOOL_TABLE(int pocket)
00408 {
00409   CANON_TOOL_TABLE retval;
00410 
00411   if (pocket == 0)
00412     {
00413       retval.id = 1;
00414       retval.length = 2.0;
00415       retval.diameter = 1.0;
00416     }
00417   else if (pocket == 1)
00418     {
00419       retval.id = 1;
00420       retval.length = 2.0;
00421       retval.diameter = 1.0;
00422     }
00423   else if (pocket == 2)
00424     {
00425       retval.id = 2;
00426       retval.length = 1.0;
00427       retval.diameter = 2.0;
00428     }
00429   else
00430     {
00431       retval.id = 0;
00432       retval.length = 0.0;
00433       retval.diameter = 0.0;
00434     }
00435 
00436   return retval;
00437 }
00438 
00439 
00440 /*********************************************************************/
00441 
00442 double GET_EXTERNAL_TRAVERSE_RATE()
00443 {
00444   return 100.0;
00445 }
00446 
00447 /*********************************************************************/
00448 
00449 CANON_MOTION_MODE GET_MOTION_CONTROL_MODE()
00450 {
00451   return CANON_EXACT_PATH;
00452 }
00453 
00454 /*********************************************************************/
00455 
00456 /* INIT_CANON()
00457 
00458 called by: rs274ngc_init
00459 
00460 This is a stub.
00461 
00462 */
00463 
00464 void INIT_CANON()
00465 {}
00466 
00467 /*********************************************************************/
00468 
00469 /*
00470 
00471 IS_EXTERNAL_QUEUE_EMPTY emulates the EMC external to the
00472 interpreter. It just returns 1, meaning the queue is empty (any
00473 non-zero means the queue is empty).
00474 
00475 */
00476 
00477 int IS_EXTERNAL_QUEUE_EMPTY()
00478 {
00479   return 1;
00480 }
00481 
00482 /*********************************************************************/
00483 
00484 /*
00485 
00486 CANON_UPDATE_POSITION tells the canonical interface that it should
00487 update the end position it may have been saving, due to an abort other
00488 other external event that may have made the end position different.
00489 Here it does nothing since the standalone interpreter doesn't keep track
00490 of the end position.
00491 
00492 */
00493 
00494 void CANON_UPDATE_POSITION()
00495 {
00496   return;
00497 }
00498 
00499 /*********************************************************************/

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