-
Notifications
You must be signed in to change notification settings - Fork 0
/
canon_pre.c
1102 lines (932 loc) · 28.3 KB
/
canon_pre.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/************************************************************************
Copyright 2008 Mark Pictor
This file is part of RS274NGC.
RS274NGC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RS274NGC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RS274NGC. If not, see <http://www.gnu.org/licenses/>.
This software is based on software that was produced by the National
Institute of Standards and Technology (NIST).
************************************************************************/
/* canon.cc
This file contains two sets of functions:
1. functions for the interpreter to call to tell the rest of the world to
do something. These all return nothing.
2. functions for the interpreter to call to get information from the rest
of the world. These all return some type of information.
These functions implement the interface between the RS274NGC interpreter
and some external environment.
This version of canon.cc also includes a third set of stuff: a dummy
model of the external world. The dummy model is used by the second set
of interface functions.
*/
/************************************************************************/
#include "canon.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#define SET_TO =
#define IS ==
#define AND &&
#define OR ||
/* where to print */
extern FILE * _outfile;
/* Dummy world model */
static CANON_PLANE _active_plane = CANON_PLANE_XY;
static int _active_slot = 1;
static double _feed_rate = 0.0;
static int _flood = 0;
static double _length_unit_factor = 1; /* 1 for MM 25.4 for inch */
static CANON_UNITS _length_unit_type = CANON_UNITS_MM;
static int _line_number = 1;
static int _mist = 0;
static CANON_MOTION_MODE _motion_mode = CANON_CONTINUOUS;
/*Not static.Driver writes*/
char _parameter_file_name[100];
#ifdef AA
static double _probe_position_a = 0; /*AA*/
#endif
#ifdef BB
static double _probe_position_b = 0; /*BB*/
#endif
#ifdef CC
static double _probe_position_c = 0; /*CC*/
#endif
static double _probe_position_x = 0;
static double _probe_position_y = 0;
static double _probe_position_z = 0;
#ifdef AA
static double _program_origin_a = 0; /*AA*/
#endif
#ifdef BB
static double _program_origin_b = 0; /*BB*/
#endif
#ifdef CC
static double _program_origin_c = 0; /*CC*/
#endif
static double _program_origin_x = 0;
static double _program_origin_y = 0;
static double _program_origin_z = 0;
#ifdef AA
static double _program_position_a = 0; /*AA*/
#endif
#ifdef BB
static double _program_position_b = 0; /*BB*/
#endif
#ifdef CC
static double _program_position_c = 0; /*CC*/
#endif
static double _program_position_x = 0;
static double _program_position_y = 0;
static double _program_position_z = 0;
static double _spindle_speed;
static CANON_DIRECTION _spindle_turning;
int _tool_max = 68; /*Not static. Driver reads */
CANON_TOOL_TABLE _tools[CANON_TOOL_MAX]; /*Not static. Driver writes */
static double _traverse_rate;
/************************************************************************/
/* Canonical "Do it" functions
This is a set of dummy definitions for the canonical machining functions
given in canon.hh. These functions just print themselves and, if necessary,
update the dummy world model. On each output line is printed:
1. an output line number (sequential, starting with 1).
2. an input line number read from the input (or ... if not provided).
3. a printed representation of the function call which was made.
If an interpreter which makes these calls is compiled with this set of
definitions, it can be used as a translator by redirecting output from
stdout to a file.
*/
extern void rs274ngc_line_text(char * line_text, int max_size);
void print_nc_line_number()
{
char text[256];
int k;
int m;
rs274ngc_line_text(text, 256);
for (k SET_TO 0;
((k < 256) AND
((text[k] IS '\t') OR (text[k] IS ' ') OR (text[k] IS '/')));
k++);
if ((k < 256) AND ((text[k] IS 'n') OR (text[k] IS 'N')))
{
fputc('N', _outfile);
for (k++, m SET_TO 0;
((k < 256) AND (text[k] >= '0') AND (text[k] <= '9'));
k++, m++)
fputc(text[k], _outfile);
for (; m < 6; m++)
fputc(' ', _outfile);
}
else if (k < 256)
fprintf(_outfile, "N..... ");
}
#define PRINT0(control) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control); \
} else
#define PRINT1(control, arg1) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, arg1); \
} else
#define PRINT2(control, arg1, arg2) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, arg1, arg2); \
} else
#define PRINT3(control, arg1, arg2, arg3) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, arg1, arg2, arg3); \
} else
#define PRINT4(control, arg1, arg2, arg3, arg4) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, arg1, arg2, arg3, arg4); \
} else
#define PRINT5(control, arg1, arg2, arg3, arg4, arg5) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, arg1, arg2, arg3, arg4, arg5); \
} else
#define PRINT6(control, arg1, arg2, arg3, arg4, arg5, arg6) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, arg1, arg2, arg3, arg4, arg5, arg6); \
} else
#define PRINT7(control, arg1, arg2, arg3, arg4, arg5, arg6, arg7) if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, \
arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
} else
#define PRINT10(control,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) \
if (1) \
{ \
fprintf(_outfile, "%5d ", _line_number++); \
print_nc_line_number(); \
fprintf(_outfile, control, \
arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); \
} else
/* Representation */
void SET_ORIGIN_OFFSETS(
double x, double y, double z
#ifdef AA
, double a /*AA*/
#endif
#ifdef BB
, double b /*BB*/
#endif
#ifdef CC
, double c /*CC*/
#endif
)
{
fprintf(_outfile, "%5d ", _line_number++);
print_nc_line_number();
fprintf(_outfile, "SET_ORIGIN_OFFSETS(%.4f, %.4f, %.4f"
#ifdef AA
", %.4f" /*AA*/
#endif
#ifdef BB
", %.4f" /*BB*/
#endif
#ifdef CC
", %.4f" /*CC*/
#endif
")\r\n", x, y, z
#ifdef AA
, a /*AA*/
#endif
#ifdef BB
, b /*BB*/
#endif
#ifdef CC
, c /*CC*/
#endif
);
_program_position_x SET_TO _program_position_x + _program_origin_x - x;
_program_position_y SET_TO _program_position_y + _program_origin_y - y;
_program_position_z SET_TO _program_position_z + _program_origin_z - z;
#ifdef AA
/*AA*/
_program_position_a SET_TO _program_position_a + _program_origin_a - a;
#endif
#ifdef BB
/*BB*/
_program_position_b SET_TO _program_position_b + _program_origin_b - b;
#endif
#ifdef CC
/*CC*/
_program_position_c SET_TO _program_position_c + _program_origin_c - c;
#endif
_program_origin_x SET_TO x;
_program_origin_y SET_TO y;
_program_origin_z SET_TO z;
#ifdef AA
_program_origin_a SET_TO a; /*AA*/
#endif
#ifdef BB
_program_origin_b SET_TO b; /*BB*/
#endif
#ifdef CC
_program_origin_c SET_TO c; /*CC*/
#endif
}
void USE_LENGTH_UNITS(CANON_UNITS in_unit)
{
if (in_unit IS CANON_UNITS_INCHES)
{
PRINT0("USE_LENGTH_UNITS(CANON_UNITS_INCHES)\r\n");
if (_length_unit_type IS CANON_UNITS_MM)
{
_length_unit_type SET_TO CANON_UNITS_INCHES;
_length_unit_factor SET_TO 25.4;
_program_origin_x SET_TO (_program_origin_x / 25.4);
_program_origin_y SET_TO (_program_origin_y / 25.4);
_program_origin_z SET_TO (_program_origin_z / 25.4);
_program_position_x SET_TO (_program_position_x / 25.4);
_program_position_y SET_TO (_program_position_y / 25.4);
_program_position_z SET_TO (_program_position_z / 25.4);
}
}
else if (in_unit IS CANON_UNITS_MM)
{
PRINT0("USE_LENGTH_UNITS(CANON_UNITS_MM)\r\n");
if (_length_unit_type IS CANON_UNITS_INCHES)
{
_length_unit_type SET_TO CANON_UNITS_MM;
_length_unit_factor SET_TO 1.0;
_program_origin_x SET_TO (_program_origin_x * 25.4);
_program_origin_y SET_TO (_program_origin_y * 25.4);
_program_origin_z SET_TO (_program_origin_z * 25.4);
_program_position_x SET_TO (_program_position_x * 25.4);
_program_position_y SET_TO (_program_position_y * 25.4);
_program_position_z SET_TO (_program_position_z * 25.4);
}
}
else
PRINT0("USE_LENGTH_UNITS(UNKNOWN)\r\n");
}
/* Free Space Motion */
void SET_TRAVERSE_RATE(double rate)
{
PRINT1("SET_TRAVERSE_RATE(%.4f)\r\n", rate);
_traverse_rate SET_TO rate;
}
void STRAIGHT_TRAVERSE(
double x, double y, double z
#ifdef AA
, double a /*AA*/
#endif
#ifdef BB
, double b /*BB*/
#endif
#ifdef CC
, double c /*CC*/
#endif
)
{
fprintf(_outfile, "%5d ", _line_number++);
print_nc_line_number();
fprintf(_outfile, "STRAIGHT_TRAVERSE(%.4f, %.4f, %.4f"
#ifdef AA
", %.4f" /*AA*/
#endif
#ifdef BB
", %.4f" /*BB*/
#endif
#ifdef CC
", %.4f" /*CC*/
#endif
")\r\n", x, y, z
#ifdef AA
, a /*AA*/
#endif
#ifdef BB
, b /*BB*/
#endif
#ifdef CC
, c /*CC*/
#endif
);
_program_position_x SET_TO x;
_program_position_y SET_TO y;
_program_position_z SET_TO z;
#ifdef AA
_program_position_a SET_TO a; /*AA*/
#endif
#ifdef BB
_program_position_b SET_TO b; /*BB*/
#endif
#ifdef CC
_program_position_c SET_TO c; /*CC*/
#endif
}
/* Machining Attributes */
void SET_FEED_RATE(double rate)
{
PRINT1("SET_FEED_RATE(%.4f)\r\n", rate);
_feed_rate SET_TO rate;
}
void SET_FEED_REFERENCE(CANON_FEED_REFERENCE reference)
{
PRINT1("SET_FEED_REFERENCE(%s)\r\n",
(reference IS CANON_WORKPIECE) ? "CANON_WORKPIECE" : "CANON_XYZ");
}
extern void SET_MOTION_CONTROL_MODE(CANON_MOTION_MODE mode)
{
if (mode IS CANON_EXACT_STOP)
{
PRINT0("SET_MOTION_CONTROL_MODE(CANON_EXACT_STOP)\r\n");
_motion_mode SET_TO CANON_EXACT_STOP;
}
else if (mode IS CANON_EXACT_PATH)
{
PRINT0("SET_MOTION_CONTROL_MODE(CANON_EXACT_PATH)\r\n");
_motion_mode SET_TO CANON_EXACT_PATH;
}
else if (mode IS CANON_CONTINUOUS)
{
PRINT0("SET_MOTION_CONTROL_MODE(CANON_CONTINUOUS)\r\n");
_motion_mode SET_TO CANON_CONTINUOUS;
}
else
PRINT0("SET_MOTION_CONTROL_MODE(UNKNOWN)\r\n");
}
void SELECT_PLANE(CANON_PLANE in_plane)
{
PRINT1("SELECT_PLANE(CANON_PLANE_%s)\r\n",
((in_plane IS CANON_PLANE_XY) ? "XY" :
(in_plane IS CANON_PLANE_YZ) ? "YZ" :
(in_plane IS CANON_PLANE_XZ) ? "XZ" : "UNKNOWN"));
_active_plane SET_TO in_plane;
}
void SET_CUTTER_RADIUS_COMPENSATION(double radius)
{PRINT1("SET_CUTTER_RADIUS_COMPENSATION(%.4f)\r\n", radius);}
void START_CUTTER_RADIUS_COMPENSATION(int side)
{
PRINT1("START_CUTTER_RADIUS_COMPENSATION(%s)\r\n",
(side IS CANON_SIDE_LEFT) ? "LEFT" :
(side IS CANON_SIDE_RIGHT) ? "RIGHT" : "UNKNOWN");
}
void STOP_CUTTER_RADIUS_COMPENSATION()
{PRINT0 ("STOP_CUTTER_RADIUS_COMPENSATION()\r\n");}
void START_SPEED_FEED_SYNCH()
{PRINT0 ("START_SPEED_FEED_SYNCH()\r\n");}
void STOP_SPEED_FEED_SYNCH()
{PRINT0 ("STOP_SPEED_FEED_SYNCH()\r\n");}
/* Machining Functions */
void ARC_FEED(
double first_end, double second_end,
double first_axis, double second_axis, int rotation, double axis_end_point
#ifdef AA
, double a /*AA*/
#endif
#ifdef BB
, double b /*BB*/
#endif
#ifdef CC
, double c /*CC*/
#endif
)
{
fprintf(_outfile, "%5d ", _line_number++);
print_nc_line_number();
fprintf(_outfile, "ARC_FEED(%.4f, %.4f, %.4f, %.4f, %d, %.4f"
#ifdef AA
", %.4f" /*AA*/
#endif
#ifdef BB
", %.4f" /*BB*/
#endif
#ifdef CC
", %.4f" /*CC*/
#endif
")\r\n", first_end, second_end, first_axis, second_axis,
rotation, axis_end_point
#ifdef AA
, a /*AA*/
#endif
#ifdef BB
, b /*BB*/
#endif
#ifdef CC
, c /*CC*/
#endif
);
if (_active_plane IS CANON_PLANE_XY)
{
_program_position_x SET_TO first_end;
_program_position_y SET_TO second_end;
_program_position_z SET_TO axis_end_point;
}
else if (_active_plane IS CANON_PLANE_YZ)
{
_program_position_x SET_TO axis_end_point;
_program_position_y SET_TO first_end;
_program_position_z SET_TO second_end;
}
else /* if (_active_plane IS CANON_PLANE_XZ) */
{
_program_position_x SET_TO second_end;
_program_position_y SET_TO axis_end_point;
_program_position_z SET_TO first_end;
}
#ifdef AA
_program_position_a SET_TO a; /*AA*/
#endif
#ifdef BB
_program_position_b SET_TO b; /*BB*/
#endif
#ifdef CC
_program_position_c SET_TO c; /*CC*/
#endif
}
void STRAIGHT_FEED(
double x, double y, double z
#ifdef AA
, double a /*AA*/
#endif
#ifdef BB
, double b /*BB*/
#endif
#ifdef CC
, double c /*CC*/
#endif
)
{
fprintf(_outfile, "%5d ", _line_number++);
print_nc_line_number();
fprintf(_outfile, "STRAIGHT_FEED(%.4f, %.4f, %.4f"
#ifdef AA
", %.4f" /*AA*/
#endif
#ifdef BB
", %.4f" /*BB*/
#endif
#ifdef CC
", %.4f" /*CC*/
#endif
")\r\n", x, y, z
#ifdef AA
, a /*AA*/
#endif
#ifdef BB
, b /*BB*/
#endif
#ifdef CC
, c /*CC*/
#endif
);
_program_position_x SET_TO x;
_program_position_y SET_TO y;
_program_position_z SET_TO z;
#ifdef AA
_program_position_a SET_TO a; /*AA*/
#endif
#ifdef BB
_program_position_b SET_TO b; /*BB*/
#endif
#ifdef CC
_program_position_c SET_TO c; /*CC*/
#endif
}
/* This models backing the probe off 0.01 inch or 0.254 mm from the probe
point towards the previous location after the probing, if the probe
point is not the same as the previous point -- which it should not be. */
void STRAIGHT_PROBE(
double x, double y, double z
#ifdef AA
, double a /*AA*/
#endif
#ifdef BB
, double b /*BB*/
#endif
#ifdef CC
, double c /*CC*/
#endif
)
{
double distance;
double dx, dy, dz;
double backoff;
dx SET_TO (_program_position_x - x);
dy SET_TO (_program_position_y - y);
dz SET_TO (_program_position_z - z);
distance SET_TO sqrt((dx * dx) + (dy * dy) + (dz * dz));
fprintf(_outfile, "%5d ", _line_number++);
print_nc_line_number();
fprintf(_outfile, "STRAIGHT_PROBE(%.4f, %.4f, %.4f"
#ifdef AA
", %.4f" /*AA*/
#endif
#ifdef BB
", %.4f" /*BB*/
#endif
#ifdef CC
", %.4f" /*CC*/
#endif
")\r\n", x, y, z
#ifdef AA
, a /*AA*/
#endif
#ifdef BB
, b /*BB*/
#endif
#ifdef CC
, c /*CC*/
#endif
);
_probe_position_x SET_TO x;
_probe_position_y SET_TO y;
_probe_position_z SET_TO z;
#ifdef AA
_probe_position_a SET_TO a; /*AA*/
#endif
#ifdef BB
_probe_position_b SET_TO b; /*BB*/
#endif
#ifdef CC
_probe_position_c SET_TO c; /*CC*/
#endif
if (distance IS 0)
{
_program_position_x SET_TO _program_position_x;
_program_position_y SET_TO _program_position_y;
_program_position_z SET_TO _program_position_z;
}
else
{
backoff SET_TO ((_length_unit_type IS CANON_UNITS_MM) ? 0.254 : 0.01);
_program_position_x SET_TO (x + (backoff * (dx / distance)));
_program_position_y SET_TO (y + (backoff * (dy / distance)));
_program_position_z SET_TO (z + (backoff * (dz / distance)));
}
#ifdef AA
_program_position_a SET_TO a; /*AA*/
#endif
#ifdef BB
_program_position_b SET_TO b; /*BB*/
#endif
#ifdef CC
_program_position_c SET_TO c; /*CC*/
#endif
}
/*
void PARAMETRIC_2D_CURVE_FEED(FunctionPtr f1, FunctionPtr f2,
double start_parameter_value,
double end_parameter_value) {}
void PARAMETRIC_3D_CURVE_FEED(FunctionPtr xfcn, FunctionPtr yfcn,
FunctionPtr zfcn, double start_parameter_value,
double end_parameter_value) {}
*/
void DWELL(double seconds)
{PRINT1("DWELL(%.4f)\r\n", seconds);}
/* Spindle Functions */
void SPINDLE_RETRACT_TRAVERSE()
{PRINT0("SPINDLE_RETRACT_TRAVERSE()\r\n");}
void START_SPINDLE_CLOCKWISE()
{
PRINT0("START_SPINDLE_CLOCKWISE()\r\n");
_spindle_turning SET_TO ((_spindle_speed IS 0) ? CANON_STOPPED :
CANON_CLOCKWISE);
}
void START_SPINDLE_COUNTERCLOCKWISE()
{
PRINT0("START_SPINDLE_COUNTERCLOCKWISE()\r\n");
_spindle_turning SET_TO ((_spindle_speed IS 0) ? CANON_STOPPED :
CANON_COUNTERCLOCKWISE);
}
void SET_SPINDLE_SPEED(double rpm)
{
PRINT1("SET_SPINDLE_SPEED(%.4f)\r\n", rpm);
_spindle_speed SET_TO rpm;
}
void STOP_SPINDLE_TURNING()
{
PRINT0("STOP_SPINDLE_TURNING()\r\n");
_spindle_turning SET_TO CANON_STOPPED;
}
void SPINDLE_RETRACT()
{PRINT0("SPINDLE_RETRACT()\r\n");}
void ORIENT_SPINDLE(double orientation, CANON_DIRECTION direction)
{
PRINT2("ORIENT_SPINDLE(%.4f, %s)\r\n", orientation,
(direction IS CANON_CLOCKWISE) ? "CANON_CLOCKWISE" :
"CANON_COUNTERCLOCKWISE");
}
void USE_NO_SPINDLE_FORCE()
{PRINT0("USE_NO_SPINDLE_FORCE()\r\n");}
/* Tool Functions */
void USE_TOOL_LENGTH_OFFSET(double length)
{PRINT1("USE_TOOL_LENGTH_OFFSET(%.4f)\r\n", length);}
void CHANGE_TOOL(int slot)
{
PRINT1("CHANGE_TOOL(%d)\r\n", slot);
_active_slot SET_TO slot;
}
void SELECT_TOOL(int slot)
{PRINT1("SELECT_TOOL(%d)\r\n", slot);}
/* Misc Functions */
void CLAMP_AXIS(CANON_AXIS axis)
{
PRINT1("CLAMP_AXIS(%s)\r\n",
(axis IS CANON_AXIS_X) ? "CANON_AXIS_X" :
(axis IS CANON_AXIS_Y) ? "CANON_AXIS_Y" :
(axis IS CANON_AXIS_Z) ? "CANON_AXIS_Z" :
(axis IS CANON_AXIS_A) ? "CANON_AXIS_A" :
(axis IS CANON_AXIS_C) ? "CANON_AXIS_C" : "UNKNOWN");
}
void COMMENT(char *s)
{PRINT1("COMMENT(\"%s\")\r\n", s);}
void DISABLE_FEED_OVERRIDE()
{PRINT0("DISABLE_FEED_OVERRIDE()\r\n");}
void DISABLE_SPEED_OVERRIDE()
{PRINT0("DISABLE_SPEED_OVERRIDE()\r\n");}
void ENABLE_FEED_OVERRIDE()
{PRINT0("ENABLE_FEED_OVERRIDE()\r\n");}
void ENABLE_SPEED_OVERRIDE()
{PRINT0("ENABLE_SPEED_OVERRIDE()\r\n");}
void FLOOD_OFF()
{
PRINT0("FLOOD_OFF()\r\n");
_flood SET_TO 0;
}
void FLOOD_ON()
{
PRINT0("FLOOD_ON()\r\n");
_flood SET_TO 1;
}
void INIT_CANON()
{
}
void MESSAGE(char *s)
{PRINT1("MESSAGE(\"%s\")\r\n", s);}
void MIST_OFF()
{
PRINT0("MIST_OFF()\r\n");
_mist SET_TO 0;
}
void MIST_ON()
{
PRINT0("MIST_ON()\r\n");
_mist SET_TO 1;
}
void PALLET_SHUTTLE()
{PRINT0("PALLET_SHUTTLE()\r\n");}
void TURN_PROBE_OFF()
{PRINT0("TURN_PROBE_OFF()\r\n");}
void TURN_PROBE_ON()
{PRINT0("TURN_PROBE_ON()\r\n");}
void UNCLAMP_AXIS(CANON_AXIS axis)
{
PRINT1("UNCLAMP_AXIS(%s)\r\n",
(axis IS CANON_AXIS_X) ? "CANON_AXIS_X" :
(axis IS CANON_AXIS_Y) ? "CANON_AXIS_Y" :
(axis IS CANON_AXIS_Z) ? "CANON_AXIS_Z" :
(axis IS CANON_AXIS_A) ? "CANON_AXIS_A" :
(axis IS CANON_AXIS_B) ? "CANON_AXIS_B" :
(axis IS CANON_AXIS_C) ? "CANON_AXIS_C" : "UNKNOWN");
}
/* Program Functions */
void PROGRAM_STOP()
{PRINT0("PROGRAM_STOP()\r\n");}
void OPTIONAL_PROGRAM_STOP()
{PRINT0("OPTIONAL_PROGRAM_STOP()\r\n");}
void PROGRAM_END()
{PRINT0("PROGRAM_END()\r\n");}
/*************************************************************************/
/* Canonical "Give me information" functions
In general, returned values are valid only if any canonical do it commands
that may have been called for have been executed to completion. If a function
returns a valid value regardless of execution, that is noted in the comments
below.
*/
/* The interpreter is not using this function
// Returns the system angular unit factor, in units / degree
extern double GET_EXTERNAL_ANGLE_UNIT_FACTOR()
{
return 1;
}
*/
/* Returns the system feed rate */
double GET_EXTERNAL_FEED_RATE()
{
return _feed_rate;
}
/* Returns the system flood coolant setting zero = off, non-zero = on */
int GET_EXTERNAL_FLOOD()
{
return _flood;
}
/* Returns the system length unit factor, in units per mm */
extern double GET_EXTERNAL_LENGTH_UNIT_FACTOR()
{
return 1/_length_unit_factor;
}
/* Returns the system length unit type */
CANON_UNITS GET_EXTERNAL_LENGTH_UNIT_TYPE()
{
return _length_unit_type;
}
/* Returns the system mist coolant setting zero = off, non-zero = on */
extern int GET_EXTERNAL_MIST()
{
return _mist;
}
// Returns the current motion control mode
extern CANON_MOTION_MODE GET_EXTERNAL_MOTION_CONTROL_MODE()
{
return _motion_mode;
}
/* The interpreter is not using these six GET_EXTERNAL_ORIGIN functions
#ifdef AA
// returns the current a-axis origin offset
double GET_EXTERNAL_ORIGIN_A()
{
return _program_origin_a;
}
#endif
#ifdef BB
// returns the current b-axis origin offset
double GET_EXTERNAL_ORIGIN_B()
{
return _program_origin_b;
}
#endif
#ifdef CC
// returns the current c-axis origin offset
double GET_EXTERNAL_ORIGIN_C()
{
return _program_origin_c;
}
#endif
// returns the current x-axis origin offset
double GET_EXTERNAL_ORIGIN_X()
{
return _program_origin_x;
}
// returns the current y-axis origin offset
double GET_EXTERNAL_ORIGIN_Y()
{
return _program_origin_y;
}
// returns the current z-axis origin offset
double GET_EXTERNAL_ORIGIN_Z()
{
return _program_origin_z;
}
*/
void GET_EXTERNAL_PARAMETER_FILE_NAME(
char * file_name, /* string: to copy file name into */
unsigned int max_size) /* maximum number of characters to copy */
{
if (strlen(_parameter_file_name) < max_size)
strcpy(file_name, _parameter_file_name);
else
file_name[0] SET_TO 0;
}
CANON_PLANE GET_EXTERNAL_PLANE()
{
return _active_plane;
}
#ifdef AA
/* returns the current a-axis position */
double GET_EXTERNAL_POSITION_A()
{
return _program_position_a;
}
#endif
#ifdef BB
/* returns the current b-axis position */
double GET_EXTERNAL_POSITION_B()
{
return _program_position_b;
}
#endif
#ifdef CC
/* returns the current c-axis position */
double GET_EXTERNAL_POSITION_C()
{
return _program_position_c;
}
#endif
/* returns the current x-axis position */
double GET_EXTERNAL_POSITION_X()
{
return _program_position_x;
}
/* returns the current y-axis position */
double GET_EXTERNAL_POSITION_Y()
{
return _program_position_y;
}
/* returns the current z-axis position */
double GET_EXTERNAL_POSITION_Z()
{
return _program_position_z;
}
#ifdef AA
/* returns the a-axis position at the last probe trip. This is only valid
once the probe command has executed to completion. */
double GET_EXTERNAL_PROBE_POSITION_A()
{
return _probe_position_a;
}
#endif