-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKIA Post V2.cps
4889 lines (4550 loc) · 172 KB
/
KIA Post V2.cps
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 (C) 2012-2021 by Autodesk, Inc.
All rights reserved.
Doosan Lathe post processor configuration.
$Revision: 43330 6c4c5d47530789703aabfa918ce520add4161286 $
$Date: 2021-05-17 04:31:45 $
FORKID {C7A4BD6C-CF7A-4299-BF94-3C18351E8FA7}
*/
///////////////////////////////////////////////////////////////////////////////
// MANUAL NC COMMANDS
//
// The following ACTION commands are supported by this post.
//
// partEject - Manually eject the part
// transferType:phase,speed - Phase or Speed spindle synchronization for stock-transfer
// transferUseTorque:yes,no - Use torque control for stock-transfer
// useXZCMode - Force XZC mode for next operation
// usePolarMode - Force Polar mode for next operation
// useTailStock:yes,no - Use tailstock until canceled
// syncSpindleStart:error, unclamp, speed - Method to use when starting the spindle while they are connected/synched
//
///////////////////////////////////////////////////////////////////////////////
description = "KIA SKT21LMS with Fanuc 0i-TB";
vendor = "Hyundai KIA/WIA";
vendorUrl = "http://wwww.p3dcreations.com";
legal = "Copyright P3D Creations LLC, Derived from Autodesk Doosan Mill-Turn Post";
certificationLevel = 2;
minimumRevision = 45702;
longDescription = "KIA SKT21LMS Post customized from Doosan Mill-Turn v43330";
extension = "nc";
programNameIsInteger = true;
setCodePage("ascii");
capabilities = CAPABILITY_MILLING | CAPABILITY_TURNING;
tolerance = spatial(0.002, MM);
minimumChordLength = spatial(0.25, MM);
minimumCircularRadius = spatial(0.01, MM);
maximumCircularRadius = spatial(1000, MM);
minimumCircularSweep = toRad(0.01);
maximumCircularSweep = toRad(120); // reduced sweep due to G112 support
allowHelicalMoves = true;
allowedCircularPlanes = undefined; // allow any circular motion
allowSpiralMoves = false;
highFeedrate = (unit == IN) ? 200 : 5000;
// user-defined properties
properties = {
machineType: {
title: "Machine type",
description: "Select type of machine.",
group: 0,
type: "enum",
values: [
{title: "Puma", id: "PUMA"},
{title: "Lynx", id: "LYNX"},
{title: "Lynx with Y-axis", id: "LYNX_YAXIS"},
{title: "Puma MX", id: "PUMA_MX"}
],
value: "LYNX",
scope: "post"
},
reverseAxes: {
title: "Invert AC axes on sub-spindle",
description: "Enable to reverse the Y and C axes when programming on the sub-spindle. If you notice that the geometry is mirrored or conventional cutting on the machine, then disable this property.",
group: 1,
type: "boolean",
value: true,
scope: "post"
},
xAxisMinimum: {
title: "X-axis minimum limit",
description: "Defines the lower limit of X-axis travel as a radius value.",
type: "spatial",
range: [-99999, 0],
group: 1,
value: 0,
scope: "post"
},
reverseSpindle: {
title: "Reverse spindle direction on sub-spindle",
description: "Enable to automatically reverse the secondary spindle direction. Does not apply to live tooling.",
group: 1,
type: "boolean",
value: false,
scope: "post"
},
useSpindlePcodes: {
title: "Use P-codes for spindle selection",
description: "Enable if P11, P12, etc. are used for spindle selection. Disable if unique M-codes are used for spindle selection.",
group: 1,
type: "boolean",
value: false,
scope: "post"
},
gotPartCatcher: {
title: "Use part catcher",
description: "Specifies whether part catcher code should be output.",
group: 1,
type: "boolean",
value: false,
scope: "post"
},
partCatcherPosition: {
title: "Sub spindle position for part catcher",
description: "Defines the position of the sub spindle when the part catcher is activated. A value of 0 will not move the subspindle.",
group: 1,
type: "number",
range: [-1000, 0],
value: 0,
scope: "post"
},
gotChipConveyor: {
title: "Got chip conveyor",
description: "Specifies whether to use a chip conveyor.",
type: "boolean",
group: 1,
presentation: "yesno",
value: false,
scope: "post"
},
maxTool: {
title: "Max tool number",
description: "Defines the maximum tool number.",
group: 2,
type: "integer",
range: [0, 999999999],
value: 12,
scope: "post"
},
maximumSpindleSpeed: {
title: "Max spindle speed",
description: "Defines the maximum spindle speed allowed by your machines.",
group: 2,
type: "integer",
range: [0, 999999999],
value: 3000,
scope: "post"
},
showSequenceNumbers: {
title: "Use sequence numbers",
description: "Use sequence numbers for each block of outputted code.",
group: 3,
type: "boolean",
value: true,
scope: "post"
},
sequenceNumberStart: {
title: "Start sequence number",
description: "The number at which to start the sequence numbers.",
group: 3,
type: "integer",
value: 1,
scope: "post"
},
sequenceNumberIncrement: {
title: "Sequence number increment",
description: "The amount by which the sequence number is incremented by in each block.",
group: 3,
type: "integer",
value: 1,
scope: "post"
},
sequenceNumberToolOnly: {
title: "Sequence numbers only on tool change",
description: "Output sequence numbers on tool changes instead of every line.",
group: 3,
type: "boolean",
value: true,
scope: "post"
},
useRadius: {
title: "Radius arcs",
description: "If yes is selected, arcs are outputted using radius values rather than IJK.",
group: 4,
type: "boolean",
value: false,
scope: "post"
},
useCycles: {
title: "Use cycles",
description: "Specifies if canned drilling cycles should be used.",
group: 4,
type: "boolean",
value: true,
scope: "post"
},
optionalStop: {
title: "Optional stop",
description: "Outputs optional stop code during when necessary in the code.",
group: 4,
type: "boolean",
value: true,
scope: "post"
},
useParametricFeed: {
title: "Parametric feed",
description: "Specifies the feed value that should be output using a Q value.",
group: 4,
type: "boolean",
value: false,
scope: "post"
},
autoEject: {
title: "Auto eject",
description: "Specifies whether the part should automatically eject at the end of a program. 'Use coolant flush' will use flush coolant to eject the part instead of the part ejector.",
group: 4,
type: "enum",
values: [
{title: "Yes", id: "true"},
{title: "No", id: "false"},
{title: "Use coolant flush", id: "flush"}
],
value: "false",
scope: "post"
},
useTailStock: {
title: "Use tailstock",
description: "Specifies whether to use the tailstock or not. 'Sub spindle' will use a live center mounted in the sub spindle.",
group: 4,
type: "enum",
values: [
{title: "Yes", id: "true"},
{title: "No", id: "false"},
{title: "In sub spindle", id: "subSpindle"},
{title: "In sub spindle no torque", id: "noTorque"}
],
value: "false",
scope: "post"
},
useTailStockTorque: {
title: "Tailstock torque value",
description: "Enter the torque value to use with the live center in the sub spindle.",
group: 4,
type: "number",
range: [0, 2000],
value: 100,
scope: "post"
},
useTailStockPositioning: {
title: "Tailstock positioning mode",
description: "Defines the positioning mode for the tailstock in the sub spindle.",
group: 4,
type: "enum",
values: [
{title: "Offset from part", id: "offset"},
{title: "Machine position", id: "machine"},
{title: "WCS position", id: "wcs"}
],
value: "offset",
scope: "post"
},
useTailStockPosition: {
title: "Tailstock position",
description: "Enter the position/offset of the subspindle prior to engaging the tailstock. The default offset is .25in",
group: 4,
type: "spatial",
value: 0,
scope: "post"
},
useG28Zhome: {
title: "Use G28 Z home",
description: "Specifies whether to use a G28 Z home position.",
group: 4,
type: "boolean",
value: true,
scope: "post"
},
zHomePosition: {
title: "Z home position",
description: "Z home position, only output if Use G28 Z Home is not used.",
group: 4,
type: "number",
value: 0,
scope: "post"
},
useG0: {
title: "Use G0 for rapid moves",
description: "Disable to use G1 for rapid moves when multiple axes move in a single block. Enable to use G0 for all rapid moves.",
group: 4,
type: "boolean",
value: true,
scope: "post"
},
useG53ForXfer: {
title: "Sub-spindle Machine position control",
description: "Select how Machine Positions are output in a chuck plane operation. \n G53 = in rapid mode with G53, \n G53.2 = in feed mode (must have G53.2 enabled on control), \n Linear = in G01 feed mode, \n Not supported = will generate an error if Machine position is specified as the Chuck Plane Mode",
group: 4,
type: "enum",
values: [
{title: "G53", id: "g53"},
{title: "G53.2", id: "g532"},
{title: "Linear", id: "linear"},
{title: "Not supported", id: "error"}
],
value: "g53",
scope: "post"
},
transferType: {
title: "Transfer type",
description: "Phase, speed or stop synchronization for stock-transfer.",
group: 4,
type: "enum",
values: [
{title: "Phase", id: "phase"},
{title: "Speed", id: "speed"}
],
value: "speed",
scope: "post"
},
optimizeCaxisSelect: {
title: "Optimize C axis selection",
description: "Optimizes the output of enable/disable C-axis codes.",
group: 4,
type: "boolean",
value: false,
scope: "post"
},
transferUseTorque: {
title: "Stock-transfer torque control",
description: "Use torque control for stock transfer.",
group: 4,
type: "boolean",
value: false,
scope: "post"
},
cutoffConfirmation: {
title: "Parting confirmation",
description: "Use parting confirmation after cutoff.",
group: 4,
type: "enum",
values: [
{title: "G350", id: "true"},
{title: "G133", id: "g133"},
{title: "Disabled", id: "false"}
],
value: "false",
scope: "post"
},
useSimpleThread: {
title: "Use simple threading cycle",
description: "Enable to output G92 simple threading cycle, disable to output G76 standard threading cycle.",
group: 4,
type: "boolean",
value: true,
scope: "post"
},
useYAxisForDrilling: {
title: "Position in Y for axial drilling",
description: "Positions in Y for axial drilling options when it can instead of using the C-axis.",
type: "boolean",
value: false,
scope: "post"
},
useG400: {
title: "Use G400 for milling tools",
description: "Enable to output the G400 compensation block with milling/drilling operations. This option is only valid for the Puma MX model.",
group: 4,
type: "boolean",
value: false,
scope: "post"
},
looping: {
title: "Use M98 looping",
description: "Output program for M98 looping.",
group: 5,
type: "boolean",
value: false,
scope: "post"
},
numberOfRepeats: {
title: "Number of repeats",
description: "How many times to loop the program.",
group: 5,
type: "integer",
range: [0, 99999999],
value: 1,
scope: "post"
},
writeVersion: {
title: "Write version",
description: "Write the version number in the header of the code.",
group: 6,
type: "boolean",
value: false,
scope: "post"
},
separateWordsWithSpace: {
title: "Separate words with space",
description: "Adds spaces between words if 'yes' is selected.",
group: 6,
type: "boolean",
value: true,
scope: "post"
},
showNotes: {
title: "Show notes",
description: "Writes operation notes as comments in the outputted code.",
group: 6,
type: "boolean",
value: true,
scope: "post"
},
writeMachine: {
title: "Write machine",
description: "Output the machine settings in the header of the code.",
group: 6,
type: "boolean",
value: false,
scope: "post"
},
writeTools: {
title: "Write tool list",
description: "Output a tool list in the header of the code.",
group: 6,
type: "boolean",
value: true,
scope: "post"
}
};
var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-";
var gFormat = createFormat({prefix:"G", decimals:0});
var g1Format = createFormat({prefix:"G", decimals:1, forceDecimal:false});
var mFormat = createFormat({prefix:"M", decimals:0});
var spatialFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true});
var xFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true, scale:2}); // diameter mode & IS SCALING POLAR COORDINATES
var yFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true});
var zFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true});
var rFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true}); // radius
var abcFormat = createFormat({decimals:3, forceDecimal:true, scale:DEG});
var bFormat = createFormat({prefix:"(B=", suffix:")", decimals:3, forceDecimal:true, scale:DEG});
var cFormat = createFormat({decimals:3, forceDecimal:true, scale:DEG, cyclicLimit:Math.PI * 2});
var fpmFormat = createFormat({decimals:(unit == MM ? 2 : 3), forceDecimal:true});
var fprFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true});
var feedFormat = createFormat({inherit:fpmFormat});
var pitchFormat = createFormat({decimals:6, forceDecimal:true});
var toolFormat = createFormat({decimals:0, width:4, zeropad:true});
var rpmFormat = createFormat({decimals:0});
var secFormat = createFormat({decimals:3, forceDecimal:true}); // seconds - range 0.001-99999.999
var milliFormat = createFormat({decimals:0}); // milliseconds // range 1-9999
var taperFormat = createFormat({decimals:1, scale:DEG});
var threadP1Format = createFormat({decimals:0, forceDecimal:false, trim:false, width:6, zeropad:true});
var threadPQFormat = createFormat({decimals:0, forceDecimal:false, trim:true, scale:(unit == MM ? 1000 : 10000)});
var dwellFormat = createFormat({prefix:"U", decimals:3});
// var peckFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceDecimal:true});
var peckFormat = createFormat({decimals:0, forceDecimal:false, trim:false, width:4, zeropad:true, scale:(unit == MM ? 1000 : 10000)});
var kerfFormat= createFormat({scale:(unit == MM ? 25.4 : 1)});
var xOutput = createVariable({prefix:"X"}, xFormat);
var yOutput = createVariable({prefix:"Y"}, yFormat);
var zOutput = createVariable({prefix:"Z"}, zFormat);
var aOutput = createVariable({prefix:"A"}, abcFormat);
var bOutput = createVariable({}, bFormat);
var cOutput = createVariable({prefix:"C"}, cFormat);
var subOutput = createVariable({prefix:"B", force:true}, spatialFormat);
var feedOutput = createVariable({prefix:"F"}, feedFormat);
var pitchOutput = createVariable({prefix:"F", force:true}, pitchFormat);
var sOutput = createVariable({prefix:"S", force:true}, rpmFormat);
var pOutput = createVariable({prefix:"P", force:true}, rpmFormat);
var spOutput = createVariable({prefix:"P", force:true}, rpmFormat);
var rOutput = createVariable({prefix:"R", force:true}, rFormat);
var threadP1Output = createVariable({prefix:"P", force:true}, threadP1Format);
var threadP2Output = createVariable({prefix:"P", force:true}, threadPQFormat);
var threadQOutput = createVariable({prefix:"Q", force:true}, threadPQFormat);
var threadROutput = createVariable({prefix:"R", force:true}, threadPQFormat);
var g92ROutput = createVariable({prefix:"R", force:true}, zFormat); // no scaling
var peckOutput = createVariable({prefix:"Q", force:true}, peckFormat);
// circular output
var iOutput = createReferenceVariable({prefix:"I", force:true}, spatialFormat);
var jOutput = createReferenceVariable({prefix:"J", force:true}, spatialFormat);
var kOutput = createReferenceVariable({prefix:"K", force:true}, spatialFormat);
var gMotionModal = createModal({}, gFormat); // modal group 1 // G0-G3, ...
var gPlaneModal = createModal({onchange:function () {gMotionModal.reset();}}, gFormat); // modal group 2 // G17-19
var gFeedModeModal = createModal({}, gFormat); // modal group 5 // G98-99
var gSpindleModeModal = createModal({}, gFormat); // modal group 5 // G96-97
var gUnitModal = createModal({}, gFormat); // modal group 6 // G20-21
var gCycleModal = createModal({}, gFormat); // modal group 9 // G81, ...
var gPolarModal = createModal({}, g1Format); // G12.1, G13.1
var cAxisBrakeModal = createModal({}, mFormat);
var mInterferModal = createModal({}, mFormat);
var cAxisEngageModal = createModal({}, mFormat);
var gWCSModal = createModal({}, g1Format);
var tailStockModal = createModal({}, mFormat);
var mTappingModal = createModal({}, mFormat);
// fixed settings
var firstFeedParameter = 100;
var airCleanChuck = false; // use air to clean off chuck at part transfer and part eject
// defined in defineMachine
var gotYAxis;
var yAxisMinimum;
var yAxisMaximum;
var xAxisMinimum;
var gotBAxis;
var bAxisIsManual;
var gotMultiTurret;
var gotPolarInterpolation;
var gotSecondarySpindle;
var gotDoorControl;
var useMultiAxisFeatures;
var WARNING_WORK_OFFSET = 0;
var WARNING_REPEAT_TAPPING = 1;
var SPINDLE_MAIN = 0;
var SPINDLE_SUB = 1;
var SPINDLE_LIVE = 2;
var TRANSFER_PHASE = 0;
var TRANSFER_SPEED = 1;
var TRANSFER_STOP = 2;
// getSpindle parameters
var TOOL = false;
var PART = true;
// moveSubSpindle parameters
var HOME = 0;
var RAPID = 1;
var FEED = 2;
var TORQUE = 3;
// synchronized spindle start parameters
var SYNC_ERROR = 0;
var SYNC_UNCLAMP = 1;
var SYNC_SPEED = 2;
// clampChuck parameters
var CLAMP = true;
var UNCLAMP = false;
// collected state
var sequenceNumber;
var currentWorkOffset;
var optionalSection = false;
var forceSpindleSpeed = false;
var activeMovements; // do not use by default
var currentFeedId;
var previousSpindle = SPINDLE_MAIN;
var activeSpindle = SPINDLE_MAIN;
var partCutoff = false;
var transferType;
var transferUseTorque;
var showSequenceNumbers;
var forceXZCMode = false; // forces XZC output, activated by Action:useXZCMode
var forcePolarMode = false; // force Polar output, activated by Action:usePolarMode
var forceTailStock = false; // enable/disable TailStock
var tapping = false;
var ejectRoutine = false;
var bestABCIndex = undefined;
var headOffset = 0;
var lastSpindleMode = undefined;
var lastSpindleSpeed = 0;
var lastSpindleDirection = undefined;
var syncStartMethod = SYNC_ERROR; // method used to output spindle block when they are already synched/connected
var activeTurret = 1;
var transferOrientation; // spindle orientation during part transfers
var forceTurningMode = false; // used to force turning mode in onSection after part transfer
var machineState = {
isTurningOperation: undefined,
liveToolIsActive: undefined,
cAxisIsEngaged: undefined,
machiningDirection: undefined,
mainSpindleIsActive: undefined,
subSpindleIsActive: undefined,
mainSpindleBrakeIsActive: undefined,
subSpindleBrakeIsActive: undefined,
tailstockIsActive: undefined,
usePolarMode: undefined,
useXZCMode: undefined,
axialCenterDrilling: undefined,
currentBAxisOrientationTurning: new Vector(0, 0, 0),
mainChuckIsClamped: undefined,
subChuckIsClamped: undefined,
spindlesAreAttached: false,
spindlesAreSynchronized: false,
stockTransferIsActive: false,
cAxesAreSynchronized: false
};
// //Set up macro variables //ANCHOR Bar Puller Variables
// var barPullerPosition = undefined;
// var toolKerf = +properties.partingToolKerf;
// var barPullerVariable = properties.barPullerVariable;
// var barPullerProgram = properties.barPullerProgram;
// var stockDiameter = undefined;
// var barPullerRadius = properties.barPullerRadius;
// //var partLength = 0;
// var partUpperZ = 0;
// var partLowerZ = 0;
// var partLengthMacro = (properties.barPullerVariable + 1);
function getCode(code, spindle) { //ANCHOR M Codes / getCode
switch (code) {
case "PART_CATCHER_ON":
return 73;
case "PART_CATCHER_OFF":
return 74;
case "TAILSTOCK_ON":
machineState.tailstockIsActive = true;
break;
case "TAILSTOCK_OFF":
machineState.tailstockIsActive = false;
break;
case "TAILSTOCK_CONTROL_ON":
break;
case "TAILSTOCK_CONTROL_OFF":
break;
case "SET_SPINDLE_FRAME":
break;
case "ENABLE_C_AXIS":
machineState.cAxisIsEngaged = true;
return (spindle == SPINDLE_MAIN) ? 43 : 116;
case "DISABLE_C_AXIS":
machineState.cAxisIsEngaged = false;
// return (spindle == SPINDLE_MAIN) ? 40 : 117;
if(spindle == SPINDLE_MAIN){
return 40;
};
break;
case "POLAR_INTERPOLATION_ON":
return 12.1;
case "POLAR_INTERPOLATION_OFF":
return 13.1;
case "STOP_SPINDLE":
if (getProperty("useSpindlePcodes")) {
return 5;
} else {
switch (spindle) {
case SPINDLE_MAIN:
return 5;
case SPINDLE_LIVE:
return 15;
case SPINDLE_SUB:
return 115;
}
}
break;
case "ORIENT_SPINDLE":
return (spindle == SPINDLE_MAIN) ? 19 : 19;
case "START_SPINDLE_CW":
if (getProperty("useSpindlePcodes")) {
return (getProperty("reverseSpindle") && spindle == SPINDLE_SUB) ? 4 : 3;
} else {
switch (spindle) {
case SPINDLE_MAIN:
return 3;
case SPINDLE_LIVE:
return 13;
case SPINDLE_SUB:
return 113;
}
}
break;
case "START_SPINDLE_CCW":
if (getProperty("useSpindlePcodes")) {
return (getProperty("reverseSpindle") && spindle == SPINDLE_SUB) ? 3 : 4;
} else {
switch (spindle) {
case SPINDLE_MAIN:
return 4;
case SPINDLE_LIVE:
return 14;
case SPINDLE_SUB:
return getProperty("reverseSpindle") ? 113 : 114;
}
}
break;
case "FEED_MODE_MM_REV":
return 99;
case "FEED_MODE_MM_MIN":
return 98;
case "CONSTANT_SURFACE_SPEED_ON":
return 96;
case "CONSTANT_SURFACE_SPEED_OFF":
return 97;
case "AUTO_AIR_ON":
break;
case "AUTO_AIR_OFF":
break;
case "LOCK_MULTI_AXIS":
if(spindle == SPINDLE_MAIN){
return 90;
};
break;
case "UNLOCK_MULTI_AXIS":
//return (spindle == SPINDLE_MAIN) ? 91 : 117;
if(spindle == SPINDLE_MAIN){
return 91;
};
break;
case "CLAMP_CHUCK":
return (spindle == SPINDLE_MAIN) ? 68 : 118;
case "UNCLAMP_CHUCK":
return (spindle == SPINDLE_MAIN) ? 69 : 119;
case "SPINDLE_SYNCHRONIZATION_PHASE":
machineState.spindlesAreSynchronized = true;
return 162;
case "SPINDLE_SYNCHRONIZATION_SPEED":
machineState.spindlesAreSynchronized = true;
return 160;
case "SPINDLE_SYNCHRONIZATION_OFF":
machineState.spindlesAreSynchronized = false;
return 161;
case "CONNECT_C_AXES":
machineState.cAxesAreSynchronized = true;
return 43;
case "DISCONNECT_C_AXES":
machineState.cAxesAreSynchronized = false;
return 40;
case "TORQUE_SKIP_ON":
break;
case "TORQUE_SKIP_OFF":
break;
case "SELECT_SPINDLE":
switch (spindle) {
case SPINDLE_MAIN:
machineState.mainSpindleIsActive = true;
machineState.subSpindleIsActive = false;
machineState.liveToolIsActive = false;
break;
case SPINDLE_LIVE:
machineState.mainSpindleIsActive = false;
machineState.subSpindleIsActive = false;
machineState.liveToolIsActive = true;
writeBlock(mFormat.format(111));
break;
case SPINDLE_SUB:
machineState.mainSpindleIsActive = false;
machineState.subSpindleIsActive = true;
machineState.liveToolIsActive = false;
writeBlock(mFormat.format(110));
break;
}
break;
case "RIGID_TAPPING":
return 129;
break;
case "INTERLOCK_BYPASS":
//return (spindle == SPINDLE_MAIN) ? 31 : 131;
break;
case "INTERFERENCE_CHECK_OFF":
return 22;
case "INTERFERENCE_CHECK_ON":
return 21;
case "CYCLE_PART_EJECTOR":
break;
// coolant codes
case "COOLANT_FLOOD_ON":
return 8;
case "COOLANT_FLOOD_OFF":
return 9;
case "COOLANT_MIST_ON":
break;
case "COOLANT_MIST_OFF":
break;
case "COOLANT_AIR_ON":
return (spindle == SPINDLE_MAIN) ? 51 : 151;
case "COOLANT_AIR_OFF":
return (spindle == SPINDLE_MAIN) ? 52 : 152;
case "COOLANT_THROUGH_TOOL_ON":
break;
case "COOLANT_THROUGH_TOOL_OFF":
break;
case "COOLANT_SUCTION_ON":
break;
case "COOLANT_OFF":
return 9;
default:
error(localize("Command " + code + " is not defined."));
return 0;
}
return 0;
}
/** Returns the modulus. */
function getModulus(x, y) {
return Math.sqrt(x * x + y * y);
}
/**
Returns the C rotation for the given X and Y coordinates.
*/
function getC(x, y) {
var direction;
if (Vector.dot(machineConfiguration.getAxisU().getAxis(), new Vector(0, 0, 1)) != 0) {
direction = (machineConfiguration.getAxisU().getAxis().getCoordinate(2) >= 0) ? 1 : -1; // C-axis is the U-axis
} else {
direction = (machineConfiguration.getAxisV().getAxis().getCoordinate(2) >= 0) ? 1 : -1; // C-axis is the V-axis
}
return Math.atan2(y, x) * direction;
}
/**
Returns the C rotation for the given X and Y coordinates in the desired rotary direction.
*/
function getCClosest(x, y, _c, clockwise) {
if (_c == Number.POSITIVE_INFINITY) {
_c = 0; // undefined
}
if (!xFormat.isSignificant(x) && !yFormat.isSignificant(y)) { // keep C if XY is on center
return _c;
}
var c = getC(x, y);
if (clockwise != undefined) {
if (clockwise) {
while (c < _c) {
c += Math.PI * 2;
}
} else {
while (c > _c) {
c -= Math.PI * 2;
}
}
} else {
min = _c - Math.PI;
max = _c + Math.PI;
while (c < min) {
c += Math.PI * 2;
}
while (c > max) {
c -= Math.PI * 2;
}
}
return c;
}
/**
Returns the desired tolerance for the given section.
*/
function getTolerance() {
var t = tolerance;
if (hasParameter("operation:tolerance")) {
if (t > 0) {
t = Math.min(t, getParameter("operation:tolerance"));
} else {
t = getParameter("operation:tolerance");
}
}
return t;
}
function formatSequenceNumber() {
if (sequenceNumber > 99999) {
sequenceNumber = getProperty("sequenceNumberStart");
}
var seqno = "N" + sequenceNumber;
sequenceNumber += getProperty("sequenceNumberIncrement");
return seqno;
}
/**
Writes the specified block.
*/
function writeBlock() {
var text = formatWords(arguments);
if (!text) {
return;
}
var seqno = "";
var opskip = "";
if (showSequenceNumbers) {
seqno = formatSequenceNumber();
}
if (optionalSection) {
opskip = "/";
}
if (text) {
writeWords(opskip, seqno, text);
}
}
function writeDebug(_text) {
writeComment("DEBUG - " + _text);
log("DEBUG - " + _text);
}
function formatComment(text) {
return "(" + String(filterText(String(text).toUpperCase(), permittedCommentChars)).replace(/[()]/g, "") + ")";
}
/**
Output a comment.
*/
function writeComment(text) {
writeln(formatComment(text));
}
function getB(abc, section) {
if (section.spindle == SPINDLE_PRIMARY) {
return abc.y;
} else {
return Math.PI - abc.y;
}
}
function writeCommentSeqno(text) {
writeln(formatSequenceNumber() + formatComment(text));
}
function defineMachine() {
machineConfiguration.setVendor("Doosan");
if (getProperty("machineType") == "PUMA") {
machineConfiguration.setModel("Puma");
gotYAxis = true;
yAxisMinimum = toPreciseUnit(-50, MM); // specifies the minimum range for the Y-axis
yAxisMaximum = toPreciseUnit(50, MM); // specifies the maximum range for the Y-axis
xAxisMinimum = getProperty("xAxisMinimum"); // specifies the maximum range for the X-axis (RADIUS MODE VALUE)
gotBAxis = false; // B-axis always requires customization to match the machine specific functions for doing rotations
bAxisIsManual = true; // B-axis is manually set and not programmable
gotMultiTurret = false; // specifies if the machine has several turrets
gotPolarInterpolation = true; // specifies if the machine has XY polar interpolation capabilities
gotSecondarySpindle = true;
gotDoorControl = false;
toolFormat = createFormat({decimals:0, width:4, zeropad:true});
setProperty("useG400", false);
useMultiAxisFeatures = true;
} else if ((getProperty("machineType") == "LYNX") || (getProperty("machineType") == "LYNX_YAXIS")) {
machineConfiguration.setModel("Lynx");
if (getProperty("machineType") == "LYNX_YAXIS") {
gotYAxis = true;
yAxisMinimum = toPreciseUnit(-52.5, MM); // specifies the minimum range for the Y-axis
yAxisMaximum = toPreciseUnit(52.5, MM); // specifies the maximum range for the Y-axis
} else {
gotYAxis = false;
yAxisMinimum = toPreciseUnit(0, MM); // specifies the minimum range for the Y-axis
yAxisMaximum = toPreciseUnit(0, MM); // specifies the maximum range for the Y-axis
}
xAxisMinimum = getProperty("xAxisMinimum"); // specifies the maximum range for the X-axis (RADIUS MODE VALUE)
gotBAxis = false; // B-axis always requires customization to match the machine specific functions for doing rotations
bAxisIsManual = true; // B-axis is manually set and not programmable
gotMultiTurret = false; // specifies if the machine has several turrets
gotPolarInterpolation = true; // specifies if the machine has XY polar interpolation capabilities
gotSecondarySpindle = true;
gotDoorControl = false;
toolFormat = createFormat({decimals:0, width:4, zeropad:true});
setProperty("useG400", false);
useMultiAxisFeatures = false;
} else if (getProperty("machineType") == "PUMA_MX") {
machineConfiguration.setModel("Puma MX");
gotYAxis = true;
yAxisMinimum = toPreciseUnit(-115, MM); // specifies the minimum range for the Y-axis
yAxisMaximum = toPreciseUnit(115, MM); // specifies the maximum range for the Y-axis
xAxisMinimum = getProperty("xAxisMinimum") == 0 ? toPreciseUnit(-125, MM) : getProperty("xAxisMinimum"); // specifies the maximum range for the X-axis (RADIUS MODE VALUE)
gotBAxis = true; // B-axis always requires customization to match the machine specific functions for doing rotations
bAxisIsManual = false; // B-axis is manually set and not programmable
gotMultiTurret = false; // specifies if the machine has several turrets
gotPolarInterpolation = true; // specifies if the machine has XY polar interpolation capabilities
gotSecondarySpindle = true;
gotDoorControl = false;
useMultiAxisFeatures = true;
toolFormat = createFormat({decimals:0, width:5, zeropad:true});
} else {
error(localize("Machine type must be 'Puma', 'Lynx', 'Lynx with Y-Axis', or 'Puma MX"));
}
// define B-axis
if (gotBAxis) {
if (bAxisIsManual) {
bFormat = createFormat({prefix:"(B=", suffix:")", decimals:3, forceDecimal:true, scale:DEG});
bOutput = createVariable({}, bFormat);
gWCSModal.format(69.1);
} else {
bFormat = createFormat({prefix:"B", decimals:3, forceDecimal:true, scale:DEG});
bOutput = createVariable({}, bFormat);
subOutput = createVariable({prefix:"A", force:true}, spatialFormat);
gWCSModal.format(369);
}
}
}
var machineConfigurationMainSpindle;
var machineConfigurationSubSpindle;
var machineConfigurationZ;
var machineConfigurationXC;
var machineConfigurationXB;
function onOpen() {
if (getProperty("useRadius")) {
maximumCircularSweep = toRad(90); // avoid potential center calculation errors for CNC
}
if (!getProperty("useSpindlePcodes")) {
spOutput.disable();
}