00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
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
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
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
00170
00171
00172
00173
00174
00175
00176
00177
00178 void DWELL(double seconds)
00179 {PRINT1("DWELL(%.4f)\n", seconds);}
00180
00181
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
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
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
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
00286 CANON_VECTOR GET_PROGRAM_ORIGIN()
00287 {
00288 return program_origin;
00289 }
00290
00291
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
00307
00308
00309
00310
00311
00312
00313
00314
00315
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
00457
00458
00459
00460
00461
00462
00463
00464 void INIT_CANON()
00465 {}
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 int IS_EXTERNAL_QUEUE_EMPTY()
00478 {
00479 return 1;
00480 }
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 void CANON_UPDATE_POSITION()
00495 {
00496 return;
00497 }
00498
00499