-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdatron next.cps
More file actions
executable file
·2436 lines (2187 loc) · 91.4 KB
/
datron next.cps
File metadata and controls
executable file
·2436 lines (2187 loc) · 91.4 KB
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-2018 by Autodesk, Inc.
All rights reserved.
DATRON post processor configuration.
$Revision$
$Date$
FORKID {21ADEFBF-939E-4D3F-A935-4E61F5958698}
*/
description = "DATRON next";
vendor = "DATRON";
vendorUrl = "http://www.datron.com";
legal = "Copyright (C) 2012-2018 by Autodesk, Inc.";
certificationLevel = 2;
minimumRevision = 40783;
longDescription = "Post for Datron next control. This post is for use with the Datron neo CNC.";
extension = "simpl";
setCodePage("utf-8");
capabilities = CAPABILITY_MILLING;
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);
allowHelicalMoves = true;
allowedCircularPlanes = (1 << PLANE_XY); // allow XY plane only
// user-defined properties
properties = {
writeMachine : true, // write machine
showNotes : false, // specifies that operation notes should be output
useSmoothing : true, // specifies if smoothing should be used or not
useDynamic : true, // specifies using dynamic mode or not
machineType : "NEO", // specifiees the DATRON machine type
useParkPosition : true, // specifies to use park position at the end of the program
writeToolTable : true, // write the table with the geometric tool informations
useSequences : true, // this use a sequence in the output format to perform on large files
useExternalSequencesFiles : false, // this property create one external sequence files for each operation
writeCoolantCommands : true, // disable the coolant commands in the file
useParametricFeed : true, // specifies that feed should be output using parameters
waitAfterOperation : false, // optional stop
rotationAxisSetup : "none", // define the rotatry axis setup for the machine
useSuction: false, // activate suction support
createThreadChamfer: false, // create a chamfer with the thread milling tool
preloadTool : false, //prepare a Tool for the DATROn tool assist
writePathOffset : true, //write the definition for the PathOffset variable for every Operation
useZAxisOffset : false,
useRtcp : false // use the NEXT feature RTCP for multiaxis operations
};
// user-defined property definitions
propertyDefinitions = {
writeMachine: {title:"Write machine", description:"Output the machine settings in the header of the code.", group:0, type:"boolean"},
showNotes: {title:"Show notes", description:"Writes operation notes as comments in the outputted code.", type:"boolean"},
useSmoothing: {title:"Use smoothing", description:"Specifies if smoothing should be used or not.", type:"boolean"},
useDynamic: {title:"Dynamic mode", description:"Specifies the using of dynamic mode or not.", type:"boolean"},
machineType:{title:"Machine type", description:"Specifies the DATRON machine type.", type:"enum",
values:[
{title:"NEO",id:"NEO"},
{title:"MX Cube",id:"MX"},
{title:"Cube",id:"Cube"}
]},
useParkPosition: {title: "Park at end of program", description:"Enable to use the park position at end of program.", type:"boolean"},
writeToolTable: {title:"Write tool table", description:"Write a tool table containing geometric tool information.", group:0, type:"boolean"},
useSequences: {title:"Use sequences", description:"If enables, sequences are used in the output format on large files.", type:"boolean"},
useExternalSequencesFiles: {title:"Use external sequence files", description:"If enabled, an external sequence file is created for each operation.", type:"boolean"},
writeCoolantCommands: {title:"Write coolant commands", description:"Enable/disable coolant code outputs for the entire program.", type:"boolean"},
useParametricFeed: {title:"Parametric feed", description:"Specifies the feed value that should be output using a Q value.", type:"boolean"},
waitAfterOperation: {title:"Wait after operation", description:"If enabled, an optional stop is outputted to pause after each operation.", type:"boolean"},
rotationAxisSetup : {title:"Setup rotary axis",description:"define if the machine is setup with additional rotary axis.", type:"enum",
values:[
{title:"No rotary axis",id:"NONE"},
{title:"4th axis along X+",id:"4th"},
{title:"DST (4th & 5th axis)",id:"DST"}
]},
useSuction: {title:"Use Suction", description:"Enable the suction for every operation.", type:"boolean"},
createThreadChamfer: {title:"Create a Thread Chamfer",description:"create a chamfer with the thread milling tool", type:"boolean"},
preloadTool:{title:"Preload the next Tool", description:"Preload the next Tool in the DATRON Tool assist.", type: "boolean"},
writePathOffset:{title:"Write Path Offset", description:"Write the PathOffset declaration.", type: "boolean"},
useZAxisOffset:{title:"Output Z Offset command",description:"This creates a command to allow a manual Z offset for each operation.",type:"boolean"},
useRtcp:{title:"Use RTCP", description:"Use the NEXT 5axis setup correction.",type:"boolean"}
}
var gFormat = createFormat({prefix:"G", width:2, zeropad:true, decimals:1});
var mFormat = createFormat({prefix:"M", width:2, zeropad:true, decimals:1});
var xyzFormat = createFormat({decimals:(unit == MM ? 5 : 5), forceDecimal:false});
var abcFormat = createFormat({decimals:5, scale:DEG});
var feedFormat = createFormat({decimals:(unit == MM ? 2 : 2)});
var toolFormat = createFormat({decimals:0});
var dimensionFormat = createFormat({decimals:(unit == MM ? 3 : 5), forceDecimal:false});
var rpmFormat = createFormat({decimals:0, scale:1});
var sleepFormat = createFormat({decimals:0, scale:1000}); // milliseconds
var workpieceFormat = createFormat({decimals:(unit == MM ? 3 : 4), forceSign:true, trim:false});
var toolOutput = createVariable({prefix:"Tool_", force:true}, toolFormat);
var feedOutput = createVariable({prefix:""}, feedFormat);
var xOutput = createVariable({prefix:" X="}, xyzFormat);
var yOutput = createVariable({prefix:" Y="}, xyzFormat);
var zOutput = createVariable({prefix:" Z="}, xyzFormat);
var aOutput = createVariable({prefix:" A="}, abcFormat);
var bOutput = createVariable({prefix:" B="}, abcFormat);
var cOutput = createVariable({prefix:" C="}, abcFormat);
var iOutput = createVariable({prefix:" dX=", force : true}, xyzFormat);
var jOutput = createVariable({prefix:" dY=", force : true}, xyzFormat);
var kOutput = createVariable({prefix:" dZ="}, xyzFormat);
// fixed settings
var useDatronFeedCommand = false; // unsupported for now, keep false
var language = "de"; // specifies the language, replace with getLangId()
var spacingDepth = 0;
var spacingString = " ";
var spacing = "##########################################################";
// buffer for building up a program not serial created
var sequenceBuffer = new StringBuffer();
function NewOperation(operationCall){
this.operationCall = operationCall;
this.operationProgram = new StringBuffer();
this.operationProgram.append("");
}
var currentOperation;
function NewSimPLProgram(){
this.moduleName = new StringBuffer();
this.measuringSystem = "Metric";
this.toolDescriptionList = new Array();
this.workpieceGeometry = "";
this.sequenceList = new Array();
this.usingList = new Array();
this.externalUsermodules = new Array();
this.globalVariableList = new Array();
this.mainProgram = new StringBuffer();
this.operationList = new Array();
}
var SimPLProgram = new NewSimPLProgram();
// collected state
var currentFeedValue = -1;
var optionalSection = false;
var activeMovements; // do not use by default
var currentFeedId;
// format date + time
var timeFormat = createFormat({decimals:0, width:2, zeropad:true});
var now = new Date();
var nowDay = now.getDate();
var nowMonth = now.getMonth() + 1;
var nowHour = now.getHours();
var nowMin = now.getMinutes();
var nowSec = now.getSeconds();
function getSequenceName(section) {
var sequenceName = "";
if (properties.useExternalSequencesFiles) {
sequenceName += FileSystem.getFilename(getOutputPath().substr(0, getOutputPath().lastIndexOf("."))) + "_";
}
sequenceName += "SEQUENCE_" + mapComment(getOperationDescription(section));
return sequenceName;
}
function getFilename(){
var filePath = getOutputPath();
var filename = filePath.slice(filePath.lastIndexOf("\\")+1, filePath.lastIndexOf("."));
return filename;
}
function getOperationName(section) {
return "Operation_" + getOperationDescription(section);
}
function capitalizeFirstLetter(text) {
return text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase();
}
function getSpacing() {
var space = "";
for (var i = 0; i < spacingDepth; i++) {
space += spacingString;
}
return space;
}
/**
Redirect the output to an infinite number of buffers ;-)
works like a stack you can use many redirection levels and go back again
*/
var writeRedirectionStack = new Array();
function SetWriteRedirection(redirectionbuffer){
writeRedirectionStack.push(redirectionbuffer);
}
function ResetWriteRedirection(){
return writeRedirectionStack.pop();
}
/**
Writes the specified block.
*/
function writeBlock(arguments) {
var text = getSpacing() + formatWords(arguments);
if (writeRedirectionStack.length == 0){
writeWords(text);
} else {
writeRedirectionStack[writeRedirectionStack.length-1].append(text + "\r\n");
}
}
/**
Output a comment.
*/
function writeComment(text) {
if (text) {
text = getSpacing() + "# " + text;
if (writeRedirectionStack.length == 0){
writeln(text);
} else {
writeRedirectionStack[writeRedirectionStack.length-1].append(text + "\r\n");
}
}
}
var charMap = {
"\u00c4" : "Ae",
"\u00e4" : "ae",
"\u00dc" : "Ue",
"\u00fc" : "ue",
"\u00d6" : "Oe",
"\u00f6" : "oe",
"\u00df" : "ss",
"\u002d" : "_",
"\u0020" : "_"
};
/** Map specific chars. */
function mapComment(text) {
text = formatVariable(text);
var result = "";
for (var i = 0; i < text.length; ++i) {
var ch = charMap[text[i]];
result += ch ? ch : text[i];
}
return result;
}
function formatComment(text) {
return mapComment(text);
}
function formatVariable(text) {
return String(text).replace(/[^A-Za-z0-9\-_]/g, "");
}
function onOpen() {
// note: setup your machine here
if (properties.rotationAxisSetup == "4th") {
var aAxis = createAxis({coordinate:0, table:true, axis:[1, 0, 0], range:[0, 360], cyclic:true, preference:0});
machineConfiguration = new MachineConfiguration(aAxis);
machineConfiguration.setVendor("DATRON");
machineConfiguration.setModel("NEO with A Axis");
machineConfiguration.setDescription("DATRON NEXT Control with additional A-Axis");
setMachineConfiguration(machineConfiguration);
optimizeMachineAngles2(1); // TCP mode 0:Full TCP 1: Map Tool Tip to Axis
}
// note: setup your machine here
if (properties.rotationAxisSetup == "DST") {
var aAxis = createAxis({coordinate:0, table:true, axis:[1, 0, 0], range:[-10, 110], cyclic:false, preference:0});
var cAxis = createAxis({coordinate:2, table:true, axis:[0, 0, 1], range:[-360, 360], cyclic:true, preference:0});
machineConfiguration = new MachineConfiguration(aAxis,cAxis);
machineConfiguration.setVendor("DATRON");
machineConfiguration.setModel("NEXT with DST");
machineConfiguration.setDescription("DATRON NEXT Control with additional DST");
setMachineConfiguration(machineConfiguration);
optimizeMachineAngles2(1); // TCP mode 0:Full TCP 1: Map Tool Tip to Axis
}
if (!machineConfiguration.isMachineCoordinate(0)) {
aOutput.disable();
}
if (!machineConfiguration.isMachineCoordinate(1)) {
bOutput.disable();
}
if (!machineConfiguration.isMachineCoordinate(2)) {
cOutput.disable();
}
// header of the main program
writeProgramHeader();
spacingDepth -= 1;
ResetWriteRedirection();
// the rest of program main will be set at closing when all the code is analysed
}
function getOperationDescription(section) {
// creates the name of the operation
var operationComment = "";
if (section.hasParameter("operation-comment")) {
operationComment = section.getParameter("operation-comment");
operationComment = formatComment(operationComment);
}
var cycleTypeString = "";
if (section.hasParameter("operation:cycleType")) {
cycleTypeString = localize(section.getParameter("operation:cycleType")).toString();
cycleTypeString = formatComment(cycleTypeString);
}
var sectionID = section.getId() + 1;
var description = operationComment + "_" + cycleTypeString + "_" + sectionID;
return description;
}
function createToolVariables() {
var tools = getToolTable();
var toolVariables = new Array();
if (tools.getNumberOfTools() > 0 && !properties.writeToolTable) {
for (var i = 0; i < tools.getNumberOfTools(); ++i) {
var tool = tools.getTool(i);
toolVariables.push(toolOutput.format(tool.number) + ":number");
}
}
return toolVariables;
}
function getNextTool(number) {
var currentSectionId = getCurrentSectionId();
if (currentSectionId < 0) {
return null;
}
for (var i = currentSectionId + 1; i < getNumberOfSections(); ++i) {
var section = getSection(i);
var sectionTool = section.getTool();
if (number != sectionTool.number) {
return sectionTool; // found next tool
}
}
return null; // not found
}
function createToolDescriptionTable() {
if (!properties.writeToolTable) {
return;
}
var toolDescriptionArray = new Array();
var toolNameList = new Array();
var numberOfSections = getNumberOfSections();
for (var i = 0; i < numberOfSections; ++i) {
var section = getSection(i);
var tool = section.getTool();
if (tool.type != TOOL_PROBE) {
var toolName = createToolName(tool);
var toolProgrammed = createToolDescription(tool);
if (toolNameList.indexOf(toolName) == -1) {
toolNameList.push(toolName);
toolDescriptionArray.push(toolProgrammed);
} else {
/*
if (toolDescriptionArray.indexOf(toolProgrammed) == -1) {
error("\r\n#####################################\r\nOne ore more tools have the same name!\r\nPlease change the tool number to make the name unique.\r\n" + toolDescriptionArray.join("\r\n") + "\r\n\r\n" +
toolNameList.join("\r\n") + "#####################################\r\n");
}
*/
}
}
}
return toolDescriptionArray;
}
function createToolDescription(tool) {
var toolProgrammed = "@ ToolDescription : " +
"\"" + "Name" + "\"" + ":" + "\"" + createToolName(tool) + "\"" + ", " +
"\"" + "Category" + "\"" + ":" + "\"" + translateToolType(tool.type) + "\"" + ", " +
"\"" + "ArticleNr" + "\"" + ":" + "\"" + tool.productId + "\"" + ", " +
"\"" + "ToolNumber" + "\"" + ":" + toolFormat.format(tool.number) + ", " +
"\"" + "Vendor" + "\"" + ":" + "\"" + tool.vendor + "\"" + ", " +
"\"" + "Diameter" + "\"" + ":" + dimensionFormat.format(tool.diameter) + ", " +
"\"" + "TipAngle" + "\"" + ":" + dimensionFormat.format(toDeg(tool.taperAngle)) + ", " +
"\"" + "TipDiameter" + "\"" + ":" + dimensionFormat.format(tool.tipDiameter) + ", " +
"\"" + "FluteLength" + "\"" + ":" + dimensionFormat.format(tool.fluteLength) + ", " +
"\"" + "CornerRadius" + "\"" + ":" + dimensionFormat.format(tool.cornerRadius) + ", " +
"\"" + "ShoulderLength" + "\"" + ":" + dimensionFormat.format(tool.shoulderLength) + ", " +
"\"" + "ShoulderDiameter" + "\"" + ":" + dimensionFormat.format(tool.diameter) + ", " +
"\"" + "BodyLength" + "\"" + ":" + dimensionFormat.format(tool.bodyLength) + ", " +
"\"" + "NumberOfFlutes" + "\"" + ":" + toolFormat.format(tool.numberOfFlutes) + ", " +
"\"" + "ThreadPitch" + "\"" + ":" + dimensionFormat.format(tool.threadPitch) + ", " +
"\"" + "ShaftDiameter" + "\"" + ":" + dimensionFormat.format(tool.shaftDiameter) + ", " +
"\"" + "OverallLength" + "\"" + ":" + dimensionFormat.format(tool.bodyLength + 2 * tool.shaftDiameter) +
" @";
return toolProgrammed;
}
/**
Generate the logical tool name for the assignment table of used tools.
*/
function createToolName(tool) {
var toolName = toolFormat.format(tool.number);
toolName += "_" + translateToolType(tool.type);
if (tool.comment) {
toolName += "_" + tool.comment;
}
if (tool.diameter) {
toolName += "_D" + tool.diameter;
}
var description = tool.getDescription();
if (description) {
toolName += "_" + description;
}
toolName = formatVariable(toolName);
return toolName;
}
/**
Translate HSM tools to Datron tool categories.
*/
function translateToolType(toolType) {
var datronCategoryName = "";
toolCategory = toolType;
switch (toolType) {
case TOOL_UNSPECIFIED:
datronCategoryName = "Unspecified";
break;
case TOOL_DRILL:
datronCategoryName = "Drill";
break;
case TOOL_DRILL_CENTER:
datronCategoryName = "DrillCenter";
break;
case TOOL_DRILL_SPOT:
datronCategoryName = "DrillSpot";
break;
case TOOL_DRILL_BLOCK:
datronCategoryName = "DrillBlock";
break;
case TOOL_MILLING_END_FLAT:
datronCategoryName = "MillingEndFlat";
break;
case TOOL_MILLING_END_BALL:
datronCategoryName = "MillingEndBall";
break;
case TOOL_MILLING_END_BULLNOSE:
datronCategoryName = "MillingEndBullnose";
break;
case TOOL_MILLING_CHAMFER:
datronCategoryName = "Graver";
break;
case TOOL_MILLING_FACE:
datronCategoryName = "MillingFace";
break;
case TOOL_MILLING_SLOT:
datronCategoryName = "MillingSlot";
break;
case TOOL_MILLING_RADIUS:
datronCategoryName = "MillingRadius";
break;
case TOOL_MILLING_DOVETAIL:
datronCategoryName = "MillingDovetail";
break;
case TOOL_MILLING_TAPERED:
datronCategoryName = "MillingTapered";
break;
case TOOL_MILLING_LOLLIPOP:
datronCategoryName = "MillingLollipop";
break;
case TOOL_TAP_RIGHT_HAND:
datronCategoryName = "TapRightHand";
break;
case TOOL_TAP_LEFT_HAND:
datronCategoryName = "TapLeftHand";
break;
case TOOL_REAMER:
datronCategoryName = "Reamer";
break;
case TOOL_BORING_BAR:
datronCategoryName = "BoringBar";
break;
case TOOL_COUNTER_BORE:
datronCategoryName = "CounterBore";
break;
case TOOL_COUNTER_SINK:
datronCategoryName = "CounterSink";
break;
case TOOL_HOLDER_ONLY:
datronCategoryName = "HolderOnly";
break;
case TOOL_PROBE:
datronCategoryName = "XYZSensor";
break;
default:
datronCategoryName = "Unspecified";
}
return datronCategoryName;
}
function writeProgramHeader() {
// write creation Date
var date = timeFormat.format(nowDay) + "." + timeFormat.format(nowMonth) + "." + now.getFullYear();
var time = timeFormat.format(nowHour) + ":" + timeFormat.format(nowMin);
SetWriteRedirection(SimPLProgram.moduleName);
writeComment("!File ; generated at " + date + " - " + time);
if (programComment) {
writeComment(formatComment(programComment));
}
writeBlock(" ");
// dump machine configuration
var vendor = machineConfiguration.getVendor();
var model = machineConfiguration.getModel();
var description = machineConfiguration.getDescription();
if (properties.writeMachine && (vendor || model || description)) {
writeComment(localize("Machine"));
if (vendor) {
writeComment(" " + localize("vendor") + ": " + vendor);
}
if (model) {
writeComment(" " + localize("model") + ": " + model);
}
if (description) {
writeComment(" " + localize("description") + ": " + description);
}
}
writeBlock("module " + "CamGeneratedModule");
writeBlock(" ");
writeBlock("@ MeasuringSystem = " + (unit == MM ? "\"" + "Metric" + "\"" + " @" : "\"" + "Imperial" + "\"" + " @"));
ResetWriteRedirection();
// set the table of used tools in the header of the program
SimPLProgram.toolDescriptionList = createToolDescriptionTable();
// set the workpiece information
SimPLProgram.workpieceGeometry = writeWorkpiece();
// set the sequence header in the program file
if (properties.useSequences) {
var sequences = new Array();
var numberOfSections = getNumberOfSections();
for (var i = 0; i < numberOfSections; ++i) {
var section = getSection(i);
if (!isProbeOperation(section)) {
sequences.push("sequence " + getSequenceName(section));
}
}
if (properties.useExternalSequencesFiles) {
writeBlock("@ EmbeddedSequences = false @");
}
SimPLProgram.sequenceList = sequences;
}
// set usings
SimPLProgram.usingList.push("using Base");
if (properties.rotationAxisSetup != "NONE"){
SimPLProgram.usingList.push("using Rtcp");
}
if (properties.waitAfterOperation) {
SimPLProgram.usingList.push("import System");
}
// set paramtric feed variables
//var feedDeclaration = new Array();
var currentMovements = new Array();
var numberOfSections = getNumberOfSections();
for (var i = 0; i < numberOfSections; ++i) {
var section = getSection(i);
if (properties.useParametricFeed && (!useDatronFeedCommand)) {
activeFeeds = initializeActiveFeeds(section);
for (var j = 0; j < activeFeeds.length; ++j) {
var feedContext = activeFeeds[j];
var feedDescription = formatVariable(feedContext.description);
if (SimPLProgram.globalVariableList.indexOf(feedDescription + ":number") == -1) {
SimPLProgram.globalVariableList.push(feedDescription + ":number");
}
}
}
}
// if (!useDatronFeedCommand) {
// if (feedDeclaration != 0) {
// SimPLProgram.globalVariableList.push(feedDeclaration);
// }
// }
SetWriteRedirection(SimPLProgram.mainProgram);
writeBlock("export program Main # " + (programName ? (SP + formatComment(programName)) : "") + ((unit == MM) ? " MM" : " INCH"));
spacingDepth += 1;
writeBlock("Absolute");
// ste the multiaxis mode
if(properties.rotationAxisSetup != "NONE" && properties.useRtcp){
writeBlock("MultiAxisMode On");
}
// set the parameter tool table
SimPLProgram.globalVariableList.push(createToolVariables());
if (!properties.writeToolTable) {
var tools = getToolTable();
writeComment("Number of tools in use" + ": " + tools.getNumberOfTools());
if (tools.getNumberOfTools() > 0) {
for (var i = 0; i < tools.getNumberOfTools(); ++i) {
var tool = tools.getTool(i);
var toolAsigment = toolOutput.format(tool.number) + " = " + (tool.number) + "# " +
formatComment(getToolTypeName(tool.type)) + " " +
"D:" + dimensionFormat.format(tool.diameter) + " " +
"L2:" + dimensionFormat.format(tool.fluteLength) + " " +
"L3:" + dimensionFormat.format(tool.shoulderLength) + " " +
"ProductID:" + formatComment(tool.productId);
writeBlock(toolAsigment);
}
writeBlock(" ");
}
}
ResetWriteRedirection();
}
function writeWorkpiece() {
var workpieceString = new StringBuffer();
SetWriteRedirection(workpieceString);
var workpiece = getWorkpiece();
var delta = Vector.diff(workpiece.upper, workpiece.lower);
writeBlock("# Workpiece dimensions");
writeBlock(
"# min: X: " + workpieceFormat.format(workpiece.lower.x) + ";" +
" Y: " + workpieceFormat.format(workpiece.lower.y) + ";" +
" Z: " + workpieceFormat.format(workpiece.lower.z));
writeBlock(
"# max: X: " + workpieceFormat.format(workpiece.upper.x) + ";" +
" Y: " + workpieceFormat.format(workpiece.upper.y) + ";" +
" Z: " + workpieceFormat.format(workpiece.upper.z));
writeBlock(
"# Part size X: " + workpieceFormat.format(delta.x) + ";" +
" Y: " + workpieceFormat.format(delta.y) + ";" +
" Z: " + workpieceFormat.format(delta.z));
writeBlock("@ WorkpieceGeometry : " + "\"" + "MinEdge" + "\"" + ":{" + "\"" + "X" + "\"" + ":" + workpieceFormat.format(workpiece.lower.x) + "," +
"\"" + "Y" + "\"" + ":" + workpieceFormat.format(workpiece.lower.y) + "," +
"\"" + "Z" + "\"" + ":" + workpieceFormat.format(workpiece.lower.z) + "}," +
"\"" + "MaxEdge" + "\"" + ":{" + "\"" +"X" + "\"" + ":" + workpieceFormat.format(workpiece.upper.x) + "," +
"\"" + "Y" + "\"" + ":" + workpieceFormat.format(workpiece.upper.y) + "," +
"\"" + "Z" + "\"" + ":" + workpieceFormat.format(workpiece.upper.z) + "}" +
" @");
ResetWriteRedirection();
return workpieceString;
}
function onComment(message) {
var comments = String(message).split(";");
for (comment in comments) {
writeComment(comments[comment]);
}
}
/** Force output of X, Y, and Z. */
function forceXYZ() {
xOutput.reset();
yOutput.reset();
zOutput.reset();
}
/** Force output of A, B, and C. */
function forceABC() {
aOutput.reset();
bOutput.reset();
cOutput.reset();
}
function forceFeed() {
currentFeedId = undefined;
feedOutput.reset();
currentFeedValue = -1;
}
/** Force output of X, Y, Z, A, B, C, and F on next output. */
function forceAny() {
forceXYZ();
forceABC();
forceFeed();
}
function FeedContext(id, description, datronFeedName, feed) {
this.id = id;
this.description = description;
this.datronFeedName = datronFeedName;
if (revision < 41759) {
this.feed = (unit == MM ? feed : toPreciseUnit(feed, MM)); // temporary solution
} else {
this.feed = feed;
}
}
/** Maps the specified feed value to Q feed or formatted feed. */
function getFeed(f) {
if (activeMovements) {
var feedContext = activeMovements[movement];
if (feedContext != undefined) {
if (!feedFormat.areDifferent(feedContext.feed, f)) {
if (feedContext.id == currentFeedId) {
return ""; // nothing has changed
}
forceFeed();
currentFeedId = feedContext.id;
if (useDatronFeedCommand) {
return ("Feed " + capitalizeFirstLetter(feedContext.datronFeedName));
} else {
return ("Feed=" + formatVariable(feedContext.description));
}
}
}
currentFeedId = undefined; // force Q feed next time
}
if (feedFormat.areDifferent(currentFeedValue, f)) {
currentFeedValue = f;
return "Feed=" + feedFormat.format(f);
}
return "";
}
function initializeActiveFeeds(section) {
var activeFeeds = new Array();
if (section.hasAnyCycle && section.hasAnyCycle()) {
return activeFeeds;
}
activeMovements = new Array();
var movements = section.getMovements();
var id = 0;
if (section.hasParameter("operation:tool_feedCutting")) {
if (movements & ((1 << MOVEMENT_CUTTING) | (1 << MOVEMENT_LINK_TRANSITION) | (1 << MOVEMENT_EXTENDED))) {
var feedContext = new FeedContext(id, localize("Cutting"), "roughing", section.getParameter("operation:tool_feedCutting"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_CUTTING] = feedContext;
activeMovements[MOVEMENT_LINK_TRANSITION] = feedContext;
activeMovements[MOVEMENT_EXTENDED] = feedContext;
}
++id;
if (movements & (1 << MOVEMENT_PREDRILL)) {
feedContext = new FeedContext(id, localize("Predrilling"), "plunge", section.getParameter("operation:tool_feedCutting"));
activeMovements[MOVEMENT_PREDRILL] = feedContext;
addFeedContext(feedContext, activeFeeds);
}
++id;
if (section.hasParameter("operation-strategy") && (section.getParameter("operation-strategy") == "drill")) {
var feedContext = new FeedContext(id, localize("Cutting"), "roughing", section.getParameter("operation:tool_feedCutting"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_CUTTING] = feedContext;
}
++id;
}
if (section.hasParameter("operation:finishFeedrate")) {
if (movements & (1 << MOVEMENT_FINISH_CUTTING)) {
var feedContext = new FeedContext(id, localize("Finish"), "finishing", section.getParameter("operation:finishFeedrate"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_FINISH_CUTTING] = feedContext;
}
++id;
} else if (section.hasParameter("operation:tool_feedCutting")) {
if (movements & (1 << MOVEMENT_FINISH_CUTTING)) {
var feedContext = new FeedContext(id, localize("Finish"), "finishing", section.getParameter("operation:tool_feedCutting"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_FINISH_CUTTING] = feedContext;
}
++id;
}
if (section.hasParameter("operation:tool_feedEntry")) {
if (movements & (1 << MOVEMENT_LEAD_IN)) {
var feedContext = new FeedContext(id, localize("Entry"), "approach", section.getParameter("operation:tool_feedEntry"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_LEAD_IN] = feedContext;
}
++id;
}
if (section.hasParameter("operation:tool_feedExit")) {
if (movements & (1 << MOVEMENT_LEAD_OUT)) {
var feedContext = new FeedContext(id, localize("Exit"), "approach", section.getParameter("operation:tool_feedExit"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_LEAD_OUT] = feedContext;
}
++id;
}
if (section.hasParameter("operation:noEngagementFeedrate")) {
if (movements & (1 << MOVEMENT_LINK_DIRECT)) {
var feedContext = new FeedContext(id, localize("Direct"), "approach", section.getParameter("operation:noEngagementFeedrate"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_LINK_DIRECT] = feedContext;
}
++id;
} else if (section.hasParameter("operation:tool_feedCutting") &&
section.hasParameter("operation:tool_feedEntry") &&
section.hasParameter("operation:tool_feedExit")) {
if (movements & (1 << MOVEMENT_LINK_DIRECT)) {
var feedContext = new FeedContext(id, localize("Direct"), "approach", Math.max(section.getParameter("operation:tool_feedCutting"), section.getParameter("operation:tool_feedEntry"), section.getParameter("operation:tool_feedExit")));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_LINK_DIRECT] = feedContext;
}
++id;
}
if (section.hasParameter("operation:reducedFeedrate")) {
if (movements & (1 << MOVEMENT_REDUCED)) {
var feedContext = new FeedContext(id, localize("Reduced"), "finishing", section.getParameter("operation:reducedFeedrate"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_REDUCED] = feedContext;
}
++id;
}
if (section.hasParameter("operation:tool_feedRamp")) {
if (movements & ((1 << MOVEMENT_RAMP) | (1 << MOVEMENT_RAMP_HELIX) | (1 << MOVEMENT_RAMP_PROFILE) | (1 << MOVEMENT_RAMP_ZIG_ZAG))) {
var feedContext = new FeedContext(id, localize("Ramping"), "ramp", section.getParameter("operation:tool_feedRamp"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_RAMP] = feedContext;
activeMovements[MOVEMENT_RAMP_HELIX] = feedContext;
activeMovements[MOVEMENT_RAMP_PROFILE] = feedContext;
activeMovements[MOVEMENT_RAMP_ZIG_ZAG] = feedContext;
}
++id;
}
if (section.hasParameter("operation:tool_feedPlunge")) {
if (movements & (1 << MOVEMENT_PLUNGE)) {
var feedContext = new FeedContext(id, localize("Plunge"), "plunge", section.getParameter("operation:tool_feedPlunge"));
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_PLUNGE] = feedContext;
}
++id;
}
// this part allows us to use feedContext also for the cycles
if (hasParameter("operation:cycleType")) {
var cycleType = getParameter("operation:cycleType");
if (hasParameter("movement:plunge")) {
var feedContext = new FeedContext(id, localize("Plunge"), "plunge", section.getParameter("movement:plunge"));
addFeedContext(feedContext, activeFeeds);
++id;
}
switch (cycleType) {
case "thread-milling":
if (hasParameter("movement:plunge")) {
var feedContext = new FeedContext(id, localize("Plunge"), "plunge", section.getParameter("movement:plunge"));
addFeedContext(feedContext, activeFeeds);
++id;
}
if (hasParameter("movement:ramp")) {
var feedContext = new FeedContext(id, localize("Ramping"), "ramp", section.getParameter("movement:ramp"));
addFeedContext(feedContext, activeFeeds);
++id;
}
if (hasParameter("movement:finish_cutting")) {
var feedContext = new FeedContext(id, localize("Finish"), "finishing", section.getParameter("movement:finish_cutting"));
addFeedContext(feedContext, activeFeeds);
++id;
}
break;
case "bore-milling":
if (section.hasParameter("movement:plunge")) {
var feedContext = new FeedContext(id, localize("Plunge"), "plunge", section.getParameter("movement:plunge"));
addFeedContext(feedContext, activeFeeds);
++id;
}
if (section.hasParameter("movement:ramp")) {
var feedContext = new FeedContext(id, localize("Ramping"), "ramp", section.getParameter("movement:ramp"));
addFeedContext(feedContext, activeFeeds);
++id;
}
if (hasParameter("movement:finish_cutting")) {
var feedContext = new FeedContext(id, localize("Finish"), "finishing", section.getParameter("movement:finish_cutting"));
addFeedContext(feedContext, activeFeeds);
++id;
}
break;
}
}
if (true) { // high feed
if (movements & (1 << MOVEMENT_HIGH_FEED)) {
var feedContext = new FeedContext(id, localize("High Feed"), "roughing", this.highFeedrate);
addFeedContext(feedContext, activeFeeds);
activeMovements[MOVEMENT_HIGH_FEED] = feedContext;
}
++id;
}
return activeFeeds;
}
/** Check that all elements are only one time in the result list. */
function addFeedContext(feedContext, activeFeeds) {
if (activeFeeds.indexOf(feedContext) == -1) {
activeFeeds.push(feedContext);
}
}
var currentWorkPlaneABC = undefined;
function forceWorkPlane() {
currentWorkPlaneABC = undefined;
}
function setWorkPlane(abc) {
if (!machineConfiguration.isMultiAxisConfiguration()) {
return; // ignore
}
forceWorkPlane(); // always need the new workPlane
forceABC();
if((properties.rotationAxisSetup != "NONE") && properties.useRtcp){
writeBlock("MoveToSafetyPosition");
}else{
writeBlock("MoveToSafetyPosition");
}
writeBlock("Rapid" + aOutput.format(abc.x) + bOutput.format(abc.y) + cOutput.format(abc.z));
currentWorkPlaneABC = abc;
}
var closestABC = false; // choose closest machine angles
var currentMachineABC;
function getWorkPlaneMachineABC(workPlane) {
var W = workPlane; // map to global frame
var abc = machineConfiguration.getABC(W);
if (closestABC) {
if (currentMachineABC) {
abc = machineConfiguration.remapToABC(abc, currentMachineABC);
} else {
abc = machineConfiguration.getPreferredABC(abc);
}
} else {
abc = machineConfiguration.getPreferredABC(abc);
}
try {
abc = machineConfiguration.remapABC(abc);
currentMachineABC = abc;
} catch (e) {
error(
localize("Machine angles not supported") + ":"
+ conditional(machineConfiguration.isMachineCoordinate(0), " A" + abcFormat.format(abc.x))
+ conditional(machineConfiguration.isMachineCoordinate(1), " B" + abcFormat.format(abc.y))
+ conditional(machineConfiguration.isMachineCoordinate(2), " C" + abcFormat.format(abc.z)));
}
var direction = machineConfiguration.getDirection(abc);
if (!isSameDirection(direction, W.forward)) {
error(localize("Orientation not supported."));
}
if (!machineConfiguration.isABCSupported(abc)) {
error(
localize("Work plane is not supported") + ":"
+ conditional(machineConfiguration.isMachineCoordinate(0), " A" + abcFormat.format(abc.x))
+ conditional(machineConfiguration.isMachineCoordinate(1), " B" + abcFormat.format(abc.y))
+ conditional(machineConfiguration.isMachineCoordinate(2), " C" + abcFormat.format(abc.z)));
}
var tcp = false;
if (tcp) {
setRotation(W); // TCP mode
} else {
var O = machineConfiguration.getOrientation(abc);
var R = machineConfiguration.getRemainingOrientation(abc, W);
setRotation(R);
}
return abc;
}
function onSection() {
// this is the container that hold all operation informations...
currentOperation = new NewOperation(getOperationName(currentSection))
SetWriteRedirection(currentOperation.operationProgram);
var forceToolAndRetract = optionalSection && !currentSection.isOptional();
optionalSection = currentSection.isOptional();
var tool = currentSection.getTool();
if (!isProbeOperation(currentSection) && hasParameter("operation:cycleTime")) {
writeComment("Operation Time: " + formatCycleTime(currentSection.getCycleTime()));
}