From bbaebaff7247c9a7d94d5dee7c74bda778527f08 Mon Sep 17 00:00:00 2001 From: will1742 Date: Tue, 31 Aug 2021 12:40:20 -0400 Subject: [PATCH 01/19] Gantry WCS Tool Num updated --- Haas_Gantry_BIDC/Bechtel SR.cps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Haas_Gantry_BIDC/Bechtel SR.cps b/Haas_Gantry_BIDC/Bechtel SR.cps index b9687fb..8b288d6 100644 --- a/Haas_Gantry_BIDC/Bechtel SR.cps +++ b/Haas_Gantry_BIDC/Bechtel SR.cps @@ -1718,7 +1718,7 @@ function onSection() { var stockMidY = (stockUpperY + stockLowerY)/2; writeln(""); writeComment("Verify WCS"); - writeToolChange(19); + writeToolChange(1); // writeBlock("T" + toolFormat.format(19), mFormat.format(6)); //Changes Tool writeBlock(gFormat.format(55), gFormat.format(0), xOutput.format(stockMidX), yOutput.format(stockMidY)); From 5964e5742eb91e6a1cae761d9566242ec2fb67c8 Mon Sep 17 00:00:00 2001 From: will1742 Date: Tue, 31 Aug 2021 13:31:23 -0400 Subject: [PATCH 02/19] Added Waterjet Post --- Flow_Waterjet_BIDC/Bechtel Waterjet.cps | 378 ++++++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 Flow_Waterjet_BIDC/Bechtel Waterjet.cps diff --git a/Flow_Waterjet_BIDC/Bechtel Waterjet.cps b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps new file mode 100644 index 0000000..0da96aa --- /dev/null +++ b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps @@ -0,0 +1,378 @@ +/** + Copyright (C) 2012-2021 by Autodesk, Inc. + All rights reserved. + + Flow waterjet post processor configuration. + + $Revision: 43151 08c79bb5b30997ccb5fb33ab8e7c8c26981be334 $ + $Date: 2021-02-19 00:25:13 $ + + FORKID {F61954EF-5A29-4B93-93E7-870BC2786880} +*/ + +description = "Flow Waterjet ORD"; +vendor = "Flow"; +vendorUrl = "http://www.flowwaterjet.com"; +legal = "Copyright (C) 2012-2021 by Autodesk, Inc."; +certificationLevel = 2; +minimumRevision = 45702; + +longDescription = "Post for Flow Waterjets using software Version 5 or 6. V5=2-axis, V6=3-axis. " + +"V5: Manually set nozzle height. V6: Nozzle height in NC program set by Top Height attribute. " + EOL + +"Feed percentage set by Cutting Mode quality in tool dialog (auto=60, high=20, medium=40, low=100)"; + +extension = "ORD"; +setCodePage("ascii"); + +capabilities = CAPABILITY_JET; +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(90); +allowHelicalMoves = false; +allowedCircularPlanes = 1 << PLANE_XY; // allow only XY circular motion + +// formatVersion: +// version 6 should be user selectable, but now use version 5 +// version 5 does not have z moves, so it will be safer for inexperienced users +// version 5 does not have the mysterious parameter after the cutter comp value + +properties = { + useHSMFeedrates: { + title: "Use HSM feedrates", + description: "Specifies whether to output the feedrates from HSM.", + type: "boolean", + value: false, + scope: "post" + }, + maximumFeedrateIPM: { + title: "Maximum feedrate (IPM)", + description: "Sets the maximum feedrate in IPM.", + type: "integer", + value: 700, + scope: "post" + }, + formatVersion: { + title: "Flow control software version", + description: "V5 outputs XY, V6 outputs XYZ", + group: 1, + type: "enum", + values: [ + {title: "V5", id: "5"}, + {title: "V6", id: "6"} + ], + value: "5", + scope: "post" + } +}; + +// use fixed width instead +var xyzFormat = createFormat({decimals:4, trim:false}); +var integerFormat = createFormat({decimals:0}); + +// fixed settings +var thickness = 0; +var arcCounter = 0; +var lineCounter = -1; + +// collected state +var useVersion6 = false; +var arcFinish = undefined; + +// override radius compensation +var compensationOffset = 0; // center compensation + +var etchOperation = false; // though-cut unless set to true +var forceOutput = false; + +/** + Writes the specified block. +*/ +function writeBlock() { + writeWords(arguments); +} + +var FIELD = " "; + +/** Make sure fields are aligned. */ +function f(text) { + var length = text.length; + if (length > 10) { + return text; + } + return FIELD.substr(0, 10 - length) + text; +} + +/** Make sure fields are aligned. */ +function fi(text, size) { + var length = text.length; + if (length > size) { + return text; + } + return FIELD.substr(0, size - length) + text; +} + +function onOpen() { + useVersion6 = getProperty("formatVersion") == "6"; + unit = IN; // only inch mode is supported + + redirectToBuffer(); // buffer the entire program to be able to count the linear and circular moves + setWordSeparator(""); + + { // stock - workpiece + var workpiece = getWorkpiece(); + var delta = Vector.diff(workpiece.upper, workpiece.lower); + if (delta.isNonZero()) { + // thickness = (workpiece.upper.z - workpiece.lower.z); + } + } + + if (getNumberOfSections() > 0) { + var firstSection = getSection(0); + + var remaining = firstSection.workPlane; + if (!isSameDirection(remaining.forward, new Vector(0, 0, 1))) { + error(localize("Tool orientation is not supported.")); + return; + } + setRotation(remaining); + + if (!useVersion6) { + var originZ = firstSection.getGlobalZRange().getMinimum(); // the cutting depth of the first section + + for (var i = 0; i < getNumberOfSections(); ++i) { + var section = getSection(i); + var z = section.getGlobalZRange().getMinimum(); // contour Z of the each section + if (xyzFormat.getResultingValue(z) != xyzFormat.getResultingValue(originZ)) { + error(localize("You are trying to machine at multiple depths which is not allowed.")); + return; + } + } + } + } + forceOutput = true;// force out first line +} + +function onSection() { + var remaining = currentSection.workPlane; + if (!isSameDirection(remaining.forward, new Vector(0, 0, 1))) { + error(localize("Tool orientation is not supported.")); + return; + } + setRotation(remaining); + + etchOperation = false; + if (currentSection.getType() == TYPE_JET) { + switch (tool.type) { + case TOOL_WATER_JET: + break; + default: + error(localize("The CNC does not support the required tool.")); + return; + } + switch (currentSection.jetMode) { + case JET_MODE_THROUGH: + break; + case JET_MODE_ETCHING: + etchOperation = true; + break; + case JET_MODE_VAPORIZE: + error(localize("Vaporize is not supported by the CNC.")); + return; + default: + error(localize("Unsupported cutting mode.")); + return; + } + } else if (currentSection.getType() == TYPE_MILLING) { + warning(localize("Milling toolpath will be used as waterjet through-cutting toolpath.")); + } else { + error(localize("CNC doesn't support the toolpath.")); + return; + } + + var initialPosition = getFramePosition(currentSection.getInitialPosition()); + onExpandedRapid(initialPosition.x, initialPosition.y, initialPosition.z); +} + +function onParameter(name, value) { +} + +function writeLinear(x, y, z, feed, column7) { + var flag = false; + if (useVersion6) { + flag = xyzFormat.areDifferent(x, getCurrentPosition().x) || + xyzFormat.areDifferent(y, getCurrentPosition().y) || + xyzFormat.areDifferent(z, getCurrentPosition().z); + } else { + flag = xyzFormat.areDifferent(x, getCurrentPosition().x) || + xyzFormat.areDifferent(y, getCurrentPosition().y); + } + + if (flag || forceOutput) { + if (useVersion6) { + writeBlock( + f(xyzFormat.format(x)), ",", + f(xyzFormat.format(y)), ",", + f(xyzFormat.format(z)), ",", + fi(integerFormat.format(0), 2), ",", // linear + fi(integerFormat.format(feed), 5), ",", + fi(integerFormat.format(compensationOffset), 2), ",", // left, center, right + fi(integerFormat.format(column7), 2) // TAG: seen -2..2 - unknown + ); + } else { + writeBlock( + f(xyzFormat.format(x)), ",", + f(xyzFormat.format(y)), ",", + fi(integerFormat.format(0), 2), ",", + fi(integerFormat.format(feed), 5), ",", + fi(integerFormat.format(compensationOffset), 2) + ); + } + ++lineCounter; + forceOutput = false; + } + +} + +function finishArcs() { + if (arcFinish) { + // complete circular motion with output of destination values + forceOutput = true; + writeLinear(arcFinish.x, arcFinish.y, arcFinish.z, arcFinish.feed, 2); + arcFinish = undefined; + } +} + +function onRapid(x, y, z) { + finishArcs(); + writeLinear(x, y, z, 0, 0); // non-cutting +} + +function onLinear(x, y, z, feed) { + finishArcs(); + // skip output if next move is an arc. OnCircular record has this move destination XY + if (getNextRecord().getType() != RECORD_CIRCULAR) { + writeLinear(x, y, z, power ? getFeedInPercent(feed) : 0, 2); + } +} + +function onPower(power) { +} + +function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { + // spirals are not allowed - arcs must be < 360deg + // fail if radius compensation is changed for circular move + + // syntax is; start X, start y, arc direction, feed, comp, cx, cy + // end X, end Y, if following move is an arc, is the start x, start y, of the line + // end X, end Y, if following move is a line, is output in OnLinear + // using the arcFinish flag + + circularICode = (clockwise ? 1 : -1); + + if ((getCircularPlane() != PLANE_XY) || isHelical()) { + linearize(tolerance); + } + var p = getCurrentPosition(); + if (useVersion6) { + writeBlock( + f(xyzFormat.format(p.x)), ",", + f(xyzFormat.format(p.y)), ",", + f(xyzFormat.format(p.z)), ",", + fi(integerFormat.format(circularICode), 2), ",", // arc cw/ccw + fi(integerFormat.format(power ? getFeedInPercent(feed) : 0), 5), ",", + fi(integerFormat.format(compensationOffset), 2), ",", // left, center, right + fi(integerFormat.format(2), 2), ",", // TAG: seen -2..2 - unknown + f(xyzFormat.format(cx)), ",", + f(xyzFormat.format(cy)), ",", + f(xyzFormat.format(0)) // PLANE_XY only + ); + } else { + writeBlock( + f(xyzFormat.format(p.x)), ",", + f(xyzFormat.format(p.y)), ",", + fi(integerFormat.format(circularICode), 2), ",", // arc cw/ccw + fi(integerFormat.format(power ? getFeedInPercent(feed) : 0), 5), ",", + fi(integerFormat.format(compensationOffset), 2), ",", // left, center, right + f(xyzFormat.format(cx)), ",", + f(xyzFormat.format(cy)) + ); + } + ++arcCounter; + + // save destination values to complete arc move + arcFinish = {x:x, y:y, z:z, feed:(power ? getFeedInPercent(feed) : 0)}; + +} + +function getFeedInPercent(feed) { + var feedPercent; + if ((getProperty("maximumFeedrateIPM") > 0) && getProperty("useHSMFeedrates")) { + // use HSM feedrates + // 1 - 99 % + feedPercent = Math.min(Math.ceil(Math.min(getProperty("maximumFeedrateIPM"), feed) / getProperty("maximumFeedrateIPM") * 100), 99); + } else { + // use fixed feedrates per quality selection + switch (currentSection.quality) { + case 1: + // high quality + feedPercent = 20; // very slow, cut surface excellent + break; + case 2: + feedPercent = 40; // slow, cut surface good + break; + case 3: + feedPercent = 100; // fast, cut surface slightly rough + break; + default: + // medium quality + feedPercent = 60; // moderate, cut surface moderate + } + } + return feedPercent; +} + +function onRadiusCompensation() { + switch (radiusCompensation) { + case RADIUS_COMPENSATION_LEFT: + compensationOffset = -1; + break; + case RADIUS_COMPENSATION_RIGHT: + compensationOffset = 1; + break; + default: + compensationOffset = 0; // center compensation + } +} + +function onCycle() { + error(localize("Canned cycles are not supported.")); +} + +function onSectionEnd() { + finishArcs(); + compensationOffset = 0; // center compensation +} + +function onClose() { + if (isRedirecting()) { + var mainProgram = getRedirectionBuffer(); // TAG: no need for redirection + closeRedirection(); + writeln("// This file was created by FlowMaster(R), which is proprietary to Flow International Corporation. " + lineCounter + " " + arcCounter); + if (useVersion6) { + writeln("VER 6.00"); + } + writeln("// Created by Autodesk HSM"); + if (programComment) { + writeln("// " + programComment); + } + write(mainProgram); + } +} + +function setProperty(property, value) { + properties[property].current = value; +} From 0b82b40eabf9fc9e47e77e42ca5c858168fdea00 Mon Sep 17 00:00:00 2001 From: will1742 Date: Tue, 31 Aug 2021 13:44:37 -0400 Subject: [PATCH 03/19] Uncommented Throw --- Haas_Gantry_BIDC/Bechtel SR.cps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Haas_Gantry_BIDC/Bechtel SR.cps b/Haas_Gantry_BIDC/Bechtel SR.cps index 8b288d6..1add6d0 100644 --- a/Haas_Gantry_BIDC/Bechtel SR.cps +++ b/Haas_Gantry_BIDC/Bechtel SR.cps @@ -1800,7 +1800,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { From 1cbeea9312fe1233e045e60df50dbc16f01a5399 Mon Sep 17 00:00:00 2001 From: will1742 Date: Tue, 31 Aug 2021 14:44:37 -0400 Subject: [PATCH 04/19] File Readability Updates --- Flow_Waterjet_BIDC/Bechtel Waterjet.cps | 42 +++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/Flow_Waterjet_BIDC/Bechtel Waterjet.cps b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps index 0da96aa..6825626 100644 --- a/Flow_Waterjet_BIDC/Bechtel Waterjet.cps +++ b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps @@ -35,6 +35,8 @@ maximumCircularSweep = toRad(90); allowHelicalMoves = false; allowedCircularPlanes = 1 << PLANE_XY; // allow only XY circular motion +var maximumLineLength = 80; // the maximum number of charaters allowed in a line + // formatVersion: // version 6 should be user selectable, but now use version 5 // version 5 does not have z moves, so it will be safer for inexperienced users @@ -69,6 +71,10 @@ properties = { } }; +staticProperties = { + postVersion: "BIDC-FWJ.G8.A21" +}; + // use fixed width instead var xyzFormat = createFormat({decimals:4, trim:false}); var integerFormat = createFormat({decimals:0}); @@ -95,6 +101,14 @@ function writeBlock() { writeWords(arguments); } +function formatComment(comment) { + return "// " + comment; +} + +function writeComment(text) { + writeln(formatComment(text.substr(0, maximumLineLength - 2))); +} + var FIELD = " "; /** Make sure fields are aligned. */ @@ -361,11 +375,35 @@ function onClose() { if (isRedirecting()) { var mainProgram = getRedirectionBuffer(); // TAG: no need for redirection closeRedirection(); - writeln("// This file was created by FlowMaster(R), which is proprietary to Flow International Corporation. " + lineCounter + " " + arcCounter); + if (programName) { + var programId; + try { + programId = getAsInt(programName); + } catch (e) { + error(localize("Program name must be a number.")); + return; + } + } + writeComment("O" + programId); + writeComment("Career Account Username: " + getGlobalParameter("username")); + writeComment("Filename: " + getGlobalParameter("document-path")); + writeComment("Date: " + getGlobalParameter("generated-at")); + writeComment("Post Version: " + staticProperties.postVersion); + writeln(""); + writeBlock( + "//"," Start X", ",", + f("Start Y"), ",", + fi(" Arc"), ",", // arc cw/ccw + fi(" Feed"), ",", + fi(" Comp"), ",", // left, center, right + f("End X"), ",", + f("End Y") + ); + // writeln("// This file was created by FlowMaster(R), which is proprietary to Flow International Corporation. " + lineCounter + " " + arcCounter); if (useVersion6) { writeln("VER 6.00"); } - writeln("// Created by Autodesk HSM"); + // writeln("// Created by Autodesk HSM"); if (programComment) { writeln("// " + programComment); } From 4732f1d2392d4bcd692a387ce7944374152337e4 Mon Sep 17 00:00:00 2001 From: will1742 Date: Thu, 2 Sep 2021 12:03:44 -0400 Subject: [PATCH 05/19] VF2 Comments and TODO's --- Haas_Mills_BIDC/Bechtel VF2.cps | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel VF2.cps b/Haas_Mills_BIDC/Bechtel VF2.cps index 8a3b17b..037c8c9 100644 --- a/Haas_Mills_BIDC/Bechtel VF2.cps +++ b/Haas_Mills_BIDC/Bechtel VF2.cps @@ -1333,11 +1333,13 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 writeComment("Load and probe tools"); + // Display general tool probe info displayMedia("toolProbeReminder.jpg"); writeBlock(mFormat.format(0)); let parsedTools = []; + // Maybe should be anonymous function?? function defaultFill() { parsedTools = [] for (var i = 0; i < tools.getNumberOfTools(); i++){ @@ -1345,19 +1347,25 @@ function onOpen() { } } - function validateToolNum(toolNum) { + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); } + // parse string for specific tools to load if (getProperty("toolsToLoad") != "") { + // get list of numbers let toolNumArray = getProperty("toolsToLoad").split(','); + // iterate through and fill ranges for (var i = 0; i < toolNumArray.length; i++){ toolNumArray[i] = toolNumArray[i].trim(); + // fill range if (toolNumArray[i].indexOf("-") >= 0) { let numRange = toolNumArray[i].split("-"); - if (validateToolNum(parseInt(numRange[0])) || validateToolNum(parseInt(numRange[1]))) { + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } @@ -1366,10 +1374,12 @@ function onOpen() { } continue; } - if (validateToolNum(parseInt(toolNumArray[i]))) { + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { defaultFill(); break; } + // push single num parsedTools.push(parseInt(toolNumArray[i])); } } else { @@ -1427,6 +1437,8 @@ function onOpen() { writeln(""); writeComment("SETUP FOR OPERATION"); writeBlock(mFormat.format(131)); + } else { + writeComment("SETUP FOR OPERATION"); } if (staticProperties.useDWO) { @@ -2405,7 +2417,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { From c10b612520db93b8fc0e77f1c80784bd3d14360a Mon Sep 17 00:00:00 2001 From: will1742 Date: Thu, 2 Sep 2021 14:06:08 -0400 Subject: [PATCH 06/19] Added Setup Sheet Post --- Autodesk_Setup_BIDC/setup-sheet.cps | 1923 +++++++++++++++++++++++++++ Autodesk_Setup_BIDC/setup-sheet.css | 184 +++ 2 files changed, 2107 insertions(+) create mode 100644 Autodesk_Setup_BIDC/setup-sheet.cps create mode 100644 Autodesk_Setup_BIDC/setup-sheet.css diff --git a/Autodesk_Setup_BIDC/setup-sheet.cps b/Autodesk_Setup_BIDC/setup-sheet.cps new file mode 100644 index 0000000..d140fca --- /dev/null +++ b/Autodesk_Setup_BIDC/setup-sheet.cps @@ -0,0 +1,1923 @@ +/** + Copyright (C) 2012-2021 by Autodesk, Inc. + All rights reserved. + + Setup sheet configuration. + + $Revision: 43279 7036b3db3ebbc654551e6551bf42dd3e628331a5 $ + $Date: 2021-05-20 21:56:00 $ + + FORKID {BC98C807-412C-4ffc-BD2B-ABB3F0A59DB8} +*/ + +description = "Setup Sheet (HTML)"; +vendor = "Autodesk"; +vendorUrl = "http://www.autodesk.com"; +legal = "Copyright (C) 2012-2021 by Autodesk, Inc."; +certificationLevel = 2; + +longDescription = "Setup sheet for generating an HTML document with the relevant details for the setup, tools, and individual operations. You can print the document directly or alternatively convert it to a PDF file for later reference."; + +capabilities = CAPABILITY_SETUP_SHEET; +extension = "html"; +mimetype = "text/html"; +keywords = "MODEL_IMAGE PREVIEW_IMAGE"; +setCodePage("utf-8"); +dependencies = "setup-sheet.css"; + +allowMachineChangeOnSection = true; + +properties = { + embedStylesheet: { + title: "Embed stylesheet", + description: "Embeds the stylesheet in the HTML code.", + type: "boolean", + value: true, + scope: "post" + }, + useUnitSymbol: { + title: "Use unit symbol", + description: "Specifies that symbols should be used for units (some printers may not support this).", + type: "boolean", + value: false, + scope: "post" + }, + showDocumentPath: { + title: "Show document path", + description: "Specifies that the document path should be output.", + type: "boolean", + value: true, + scope: "post" + }, + showModelImage: { + title: "Show model image", + description: "If enabled, a model image will be included in the setup sheet.", + type: "boolean", + value: true, + scope: "post" + }, + showToolImage: { + title: "Show tool images", + description: "If enabled, tool images will be included in the seutp sheet.", + type: "boolean", + value: true, + scope: "post" + }, + showPreviewImage: { + title: "Show preview image", + description: "If enabled, a preview image will be included in the setup sheet.", + type: "boolean", + value: true, + scope: "post" + }, + previewWidth: { + title: "Preview width", + description: "Specifies the width of the preview image.", + type: "string", + value: "8cm", + scope: "post" + }, + showPercentages: { + title: "Show percentages", + description: "Specifies that the percentage of the total cycle time should be shown for each operation cycle time.", + type: "boolean", + value: true, + scope: "post" + }, + showFooter: { + title: "Show footer", + description: "Specifies whether a footer should be included in the HTML setup sheet.", + type: "boolean", + value: true, + scope: "post" + }, + showRapidDistance: { + title: "Show rapid distance", + description: "Specifies whether the rapid distance should be output.", + type: "boolean", + value: true, + scope: "post" + }, + rapidFeed: { + title: "Rapid feed", + description: "Sets the rapid traversal feedrate. Set this to get more accurate cycle times.", + type: "number", + value: 5000, + scope: "post" + }, + toolChangeTime: { + title: "Tool change time", + description: "Sets the tool change time in seconds. Set this to get more accurate cycle times.", + type: "number", + value: 15, + scope: "post" + }, + showNotes: { + title: "Show notes", + description: "Writes operation notes as comments in the outputted code.", + type: "boolean", + value: true, + scope: "post" + }, + forcePreview: { + title: "Force preview", + description: "Enable to force a preview picture for all instances of a pattern.", + type: "boolean", + value: false, + scope: "post" + }, + showOperations: { + title: "Show operations", + description: "Enable to output information for each operation.", + type: "boolean", + value: true, + scope: "post" + }, + showTools: { + title: "Show tools", + description: "Enable to see information for each tool.", + type: "boolean", + value: true, + scope: "post" + }, + showTotals: { + title: "Show totals", + description: "Enable to see total information.", + type: "boolean", + value: true, + scope: "post" + }, + embedImages: { + title: "Embed images", + description: "If enabled, images are embedded into the HTML file.", + type: "boolean", + value: true, + scope: "post" + } +}; + +var showToolpath = false; +var useToolNumber = true; + +var xyzFormat = createFormat({decimals: (unit == MM ? 3 : 4)}); +var feedFormat = createFormat({decimals:(unit == MM ? 3 : 5)}); +var toolFormat = createFormat({decimals:0}); +var rpmFormat = createFormat({decimals:0}); +var secFormat = createFormat({decimals:3}); +var angleFormat = createFormat({decimals:0, scale:DEG}); +var degFormat = createFormat({decimals:0}); +var pitchFormat = createFormat({decimals:3}); +var spatialFormat = createFormat({decimals:(unit == MM ? 2 : 3)}); +var percentageFormat = createFormat({decimals:1, scale:100}); +var timeFormat = createFormat({decimals:2}); +var taperFormat = angleFormat; // share format + +var supportedImageTypes = { + "bmp": "image/bmp", + "gif": "image/gif", + "jpg": "image/jpeg", + "jpeg": "image/jpeg", + "png": "image/png", + "tif": "image/tiff", + "tiff": "image/tiff" +}; + +// collected state +var zRanges = {}; +var totalCycleTime = 0; +var exportedTools = {}; +var toolRenderer; + +function getUnitSymbolAsString() { + switch (unit) { + case MM: + return getProperty("useUnitSymbol") ? "㎜" : "mm"; + case IN: + return getProperty("useUnitSymbol") ? "∳" : "in"; + default: + error(localize("Unit is not supported.")); + return undefined; + } +} + +function getFeedSymbolAsString() { + switch (unit) { + case MM: + return getProperty("useUnitSymbol") ? "㎜/min" : "mm/min"; + case IN: + return getProperty("useUnitSymbol") ? "∳/min" : "in/min"; + // return getProperty("useUnitSymbol") ? "′/min" : "ft/min"; + default: + error(localize("Unit is not supported.")); + return undefined; + } +} + +function getFPRSymbolAsString() { + switch (unit) { + case MM: + return getProperty("useUnitSymbol") ? "㎜" : "mm"; + case IN: + return getProperty("useUnitSymbol") ? "∳" : "in"; + default: + error(localize("Unit is not supported.")); + return undefined; + } +} + +function toString(value) { + if (typeof value == "string") { + return "'" + value + "'"; + } else { + return value; + } +} + +function makeRow(content, classId) { + if (classId) { + return "" + content + ""; + } else { + return "" + content + ""; + } +} + +function makeHeading(content, classId) { + if (classId) { + return "" + content + ""; + } else { + return "" + content + ""; + } +} + +function makeColumn(content, classId) { + if (classId) { + return "" + content + ""; + } else { + return "" + content + ""; + } +} + +function bold(content, classId) { + if (classId) { + return "" + content + ""; + } else { + return "" + content + ""; + } +} + +function d(content) { + return "
" + content + "
"; +} + +function v(content) { + return "
" + content + "
"; +} + +function vWrap(content) { + return "
" + content + "
"; +} + +function p(content, classId) { + if (classId) { + return "

" + content + "

"; + } else { + return "

" + content + "

"; + } +} + +var cachedParameters = {}; +var patternIds = {}; +var seenPatternIds = {}; + +function formatPatternId(id) { + var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + var result = ""; + while (id >= 0) { + result += chars.charAt(id % chars.length); + id -= chars.length; + } + return result; +} + +/** Loads the given image as a img data snippet. Returns empty string if unsupported. */ +function getImageAsImgSrc(path) { + if ((typeof BinaryFile == "function") && (typeof Base64 == "function")) { + var extension = path.slice(path.lastIndexOf(".") + 1, path.length).toLowerCase(); + var mimetype = supportedImageTypes[extension]; + if (mimetype) { + var data = BinaryFile.loadBinary(path); + return "data:" + mimetype + ";base64," + Base64.btoa(data); + } + } + return ""; +} + +function onParameter(name, value) { + cachedParameters[name] = value; +} + +function onOpen() { + cachedParameters = {}; + + if ((revision < 41366) || !getProperty("embedImages") && (getPlatform() == "WIN32")) { // use SVG instead of image + toolRenderer = createToolRenderer(); + if (toolRenderer) { + toolRenderer.setBackgroundColor(new Color(1, 1, 1)); + toolRenderer.setFluteColor(new Color(40.0 / 255, 40.0 / 255, 40.0 / 255)); + toolRenderer.setShoulderColor(new Color(80.0 / 255, 80.0 / 255, 80.0 / 255)); + toolRenderer.setShaftColor(new Color(80.0 / 255, 80.0 / 255, 80.0 / 255)); + toolRenderer.setHolderColor(new Color(40.0 / 255, 40.0 / 255, 40.0 / 255)); + } + } + + if (is3D()) { + var numberOfSections = getNumberOfSections(); + for (var i = 0; i < numberOfSections; ++i) { + var section = getSection(i); + var zRange = section.getGlobalZRange(); + var tool = section.getTool(); + if (zRanges[tool.number]) { + zRanges[tool.number].expandToRange(zRange); + } else { + zRanges[tool.number] = zRange; + } + } + } + + write( + "\n" + ); + write(""); + // header + var c = ""; + c += ""; + if (getProperty("embedStylesheet")) { + c += ""; + } else { + c += ""; + } + + var script = ""; + + c += ""; + c += script; + if (programName) { + c += "" + localize("Setup Sheet for Program") + " " + programName + ""; + } else { + c += "" + localize("Setup Sheet") + ""; + } + c += ""; + write(c); + + write(""); + if (programName) { + write("

" + localize("Setup Sheet for Program") + " " + programName + "

"); + } else { + write("

" + localize("Setup Sheet") + "

"); + } + + patternIds = {}; + var numberOfSections = getNumberOfSections(); + var j = 0; + for (var i = 0; i < numberOfSections; ++i) { + var section = getSection(i); + if (section.isPatterned()) { + var id = section.getPatternId(); + if (patternIds[id] == undefined) { + patternIds[id] = formatPatternId(j); + ++j; + } + } + } +} + +/** + Returns the specified coolant as a string. +*/ +function getCoolantDescription(coolant) { + switch (coolant) { + case COOLANT_OFF: + return localize("Off"); + case COOLANT_FLOOD: + return localize("Flood"); + case COOLANT_MIST: + return localize("Mist"); + case COOLANT_THROUGH_TOOL: + return localize("Through tool"); + case COOLANT_AIR: + return localize("Air"); + case COOLANT_AIR_THROUGH_TOOL: + return localize("Air through tool"); + case COOLANT_SUCTION: + return localize("Suction"); + case COOLANT_FLOOD_MIST: + return localize("Flood and mist"); + case COOLANT_FLOOD_THROUGH_TOOL: + return localize("Flood and through tool"); + default: + return localize("Unknown"); + } +} + +/** Formats WCS to text. */ +function formatWCS(id) { + /* + if (id == 0) { + id = 1; + } + if (id > 6) { + return "G54.1P" + (id - 6); + } + return "G" + (getAsInt(id) + 53); + */ + return "#" + id; +} + +function isProbeOperation(section) { + return section.hasParameter("operation-strategy") && (section.getParameter("operation-strategy") == "probe"); +} + +var svg; + +/** Returns the SVG representation for the current toolpath. */ +function getToolpathAsSVG() { + var fragment = ""; + if (!svg) { + return ""; + } + + var pageWidth = 120; + var pageHeight = 100; + + var box = currentSection.getGlobalBoundingBox(); + // for turning only for now + box = {lower: new Vector(box.lower.z, box.lower.x, 0), upper: new Vector(box.upper.z, box.upper.x, 0)}; + + var width = box.upper.x - box.lower.x; + var height = box.upper.y - box.lower.y; + var dx = toMM(width); + var dy = toMM(height); + var dimension = Math.min(width, height); + var margin = toPreciseUnit(1, MM); + var backgroundColor = "#f0f0f0"; + + fragment += ""; + /* + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + */ + // invert y axis + fragment += ""; + fragment += ""; + fragment += svg.toString(); + fragment += ""; + fragment += ""; + fragment += ""; + // add support for tool animation + return fragment; +} + +function onSection() { + if (showToolpath && (currentSection.getType() == TYPE_TURNING)) { + // var remaining = currentSection.workPlane; + var map2XY = new Matrix(new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, -1, 0)); + setRotation(map2XY.getTransposed()); + svg = new StringBuffer(); + // add start position svg.append(""); + } else { + skipRemainingSection(); + } +} + +function writeLine(x, y) { + if (radiusCompensation != RADIUS_COMPENSATION_OFF) { + return; + } + + var color; + switch (movement) { + case MOVEMENT_CUTTING: + case MOVEMENT_REDUCED: + case MOVEMENT_FINISH_CUTTING: + color = "blue"; + break; + case MOVEMENT_RAPID: + case MOVEMENT_HIGH_FEED: + color = "yellow"; + break; + case MOVEMENT_LEAD_IN: + case MOVEMENT_LEAD_OUT: + case MOVEMENT_LINK_TRANSITION: + case MOVEMENT_LINK_DIRECT: + color = "green"; + break; + default: + color = "red"; + } + + var start = getCurrentPosition(); + if ((xyzFormat.format(start.x) == xyzFormat.format(x)) && + (xyzFormat.format(start.y) == xyzFormat.format(y))) { + return; // ignore vertical + } + svg.append(""); +} + +function onRapid(x, y, z) { + writeLine(x, y); +} + +function onLinear(x, y, z, feed) { + writeLine(x, y); +} + +function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { + // linearize(tolerance); + // return; + + if (radiusCompensation != RADIUS_COMPENSATION_OFF) { + return; + } + + var color; + switch (movement) { + case MOVEMENT_CUTTING: + case MOVEMENT_REDUCED: + case MOVEMENT_FINISH_CUTTING: + color = "blue"; + break; + case MOVEMENT_RAPID: + case MOVEMENT_HIGH_FEED: + color = "yellow"; + break; + case MOVEMENT_LEAD_IN: + case MOVEMENT_LEAD_OUT: + case MOVEMENT_LINK_TRANSITION: + case MOVEMENT_LINK_DIRECT: + color = "green"; + break; + default: + color = "red"; + } + + var start = getCurrentPosition(); + + var largeArc = (getCircularSweep() > Math.PI) ? 1 : 0; + var sweepFlag = isClockwise() ? 1 : 0; // turning is flipped + var dpath = [ + "M", xyzFormat.format(start.x), xyzFormat.format(start.y), + "A", xyzFormat.format(getCircularRadius()), xyzFormat.format(getCircularRadius()), 0, largeArc, sweepFlag, xyzFormat.format(x), xyzFormat.format(y) + ].join(" "); + svg.append(""); +} + +function onCyclePoint(x, y, z) { + var color = "green"; + var radius = tool.diameter * 0.5; + svg.append(""); +} + +function pageWidthFitPath(path) { + var PAGE_WIDTH = 70; + if (path.length < PAGE_WIDTH) { + return path; + } + var newPath = ""; + var tempPath = ""; + var flushPath = ""; + var offset = 0; + var ids = ""; + for (var i = 0; i < path.length; ++i) { + var cv = path[i]; + if (i > (PAGE_WIDTH + offset)) { + if (flushPath.length == 0) { // No good place to break + flushPath = tempPath; + tempPath = ""; + } + newPath += flushPath + "
"; + offset += flushPath.length - 1; + flushPath = ""; + } + if ((cv == "\\") || (cv == "/") || (cv == " ") || (cv == "_")) { + flushPath += tempPath + cv; + tempPath = ""; + } else { + tempPath += cv; + } + } + newPath += flushPath + tempPath; + return newPath; +} + +/** Returns the given spatial value in MM. */ +function toMM(value) { + return value * ((unit == IN) ? 25.4 : 1); +} + +/** Returns the SVG representation of the given tool. */ +function getToolAsSVG(tool) { + var fragment = ""; + + var pageWidth = 30; + var pageHeight = 35; + + var box = tool.getExtent(true); + + var width = box.upper.x - box.lower.x; + var height = box.upper.y - box.lower.y; + var dx = toMM(width); + var dy = toMM(height); + var dimension = Math.min(width, height); + var margin = toPreciseUnit(1, MM); + var backgroundColor = "#ffffff"; + + fragment += ""; + + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + if (!tool.isJetTool()) { // we only show cutting head + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + fragment += ""; + } + fragment += ""; + + if (!tool.isTurningTool()) { + // invert y axis + fragment += ""; + fragment += ""; + } + + var holder = tool.getHolderProfileAsSVGPath(); + if (holder) { + fragment += ""; + } + + var cutter = !tool.isJetTool() ? tool.getCutterProfileAsSVGPath() : undefined; + if (cutter) { + // indicate if insert is on the other side stroke-dasharray=\"3px,3px\" + fragment += ""; + } + + if (false && tool.isTurningTool()) { // mark the compensation point + var offset = tool.getCompensationDisplacement(); + fragment += ""; + } + + if (!tool.isTurningTool()) { + fragment += ""; + fragment += ""; + } + fragment += ""; + return fragment; +} + +var TURNING_RELIEF_ANGLES = [ + {id:"N", value:0}, + {id:"A", value:3}, + {id:"B", value:5}, + {id:"C", value:7}, + {id:"P", value:11}, + {id:"D", value:15}, + {id:"E", value:20}, + {id:"F", value:25}, + {id:"G", value:30} +]; + +/** Returns the turning ISO tool code. */ +function getTurningToolISO(tool) { + if (!((tool.type == TOOL_TURNING_GENERAL) || (tool.type == TOOL_TURNING_BORING))) { + return ""; + } + + var reliefAngleCode = "?"; + for (var e in TURNING_RELIEF_ANGLES) { + if (Math.abs(e.value - tool.reliefAngle) < 1e-3) { + reliefAngleCode = e.id; + break; + } + } + + var name = "?"; + name += reliefAngleCode; + return name; +} + +var insertDescriptions = [ + localize("User defined"), localize("ISO A 85deg"), localize("ISO B 82deg"), localize("ISO C 80deg"), localize("ISO D 55deg"), localize("ISO E 75deg"), localize("ISO H 120deg"), localize("ISO K 55deg"), localize("ISO L 90deg"), localize("ISO M 86deg"), localize("ISO O 135deg"), localize("ISO P 108deg"), localize("ISO R round"), localize("ISO S square"), localize("ISO T triangle"), localize("ISO V 35deg"), localize("ISO W 80deg"), + localize("Round"), localize("Radius"), localize("Square"), localize("Chamfer"), localize("40deg"), + localize("ISO double"), localize("ISO triple"), localize("UTS double"), localize("UTS triple"), localize("ISO double V"), localize("ISO triple V"), localize("UTS double V"), localize("UTS triple V") +]; + +var holderDescriptions = [ + localize("No holder"), localize("ISO A"), localize("ISO B"), localize("ISO C"), localize("ISO D"), localize("ISO E"), localize("ISO F"), localize("ISO G"), localize("ISO H"), localize("ISO J"), localize("ISO K"), localize("ISO L"), localize("ISO M"), localize("ISO N"), localize("ISO P"), localize("ISO Q"), localize("ISO R"), localize("ISO S"), localize("ISO T"), localize("ISO U"), localize("ISO V"), localize("ISO W"), localize("ISO Y"), localize("Offset"), localize("Straight"), + localize("External"), localize("Internal"), localize("Face"), + localize("Straight"), localize("Offset"), localize("Face"), + localize("Boring bar ISO F"), localize("Boring bar ISO G"), localize("Boring bar ISO J"), localize("Boring bar ISO K"), localize("Boring bar ISO L"), localize("Boring bar ISO P"), localize("Boring bar ISO Q"), localize("Boring bar ISO S"), localize("Boring bar ISO U"), localize("Boring bar ISO W"), localize("Boring bar ISO Y"), localize("Boring bar ISO X") +]; + +/** Returns a HTML link if text looks like a link. */ +function autoLink(link, description) { + if (!description) { + description = ""; + } + if (!link) { + if ((description.toLowerCase().indexOf("https://") == 0) || (description.toLowerCase().indexOf("http://") == 0)) { + link = description; + if (description.length > 16) { + description = localize("click to visit"); + } + } + } + if (!link) { + return description; + } + if (link.toLowerCase().indexOf("https://") == 0) { + if (!description) { + description = link.substr(8); + if (description.length > 16) { + description = localize("click to visit"); + } + } + return "" + description + ""; + } else if (link.toLowerCase().indexOf("http://") == 0) { + if (!description) { + description = link.substr(7); + if (description.length > 16) { + description = localize("click to visit"); + } + } + return "" + description + ""; + } else { + if (!description) { + description = link; + if (description.length > 16) { + description = localize("click to visit"); + } + } + return "" + description + ""; + } +} + +function getSectionParameterForTool(tool, id) { + var numberOfSections = getNumberOfSections(); + for (var i = 0; i < numberOfSections; ++i) { + var section = getSection(i); + if (section.getTool().number == tool.number) { + return section.hasParameter(id) ? section.getParameter(id) : undefined; + } + } + return undefined; +} + +/** Returns a HTML table with the common tool information. Note that the table is not closed! */ +function presentTool(tool) { + var c1 = ""; + + if (!tool.isJetTool()) { + c1 += makeRow( + makeColumn( + bold(localize("T") + toolFormat.format(tool.number)) + " " + + localize("D") + toolFormat.format(!tool.isTurningTool() ? tool.diameterOffset : tool.compensationOffset) + " " + + conditional(!tool.isTurningTool(), localize("L") + toolFormat.format(tool.lengthOffset)) + ) + ); + } else if (tool.isJetTool()) { + c1 += makeRow(makeColumn(" ")); // move 1 row down + } + + if (tool.manualToolChange) { + c1 += makeRow(makeColumn(d(bold(localize("Manual tool change"))))); + } + + if (tool.isLiveTool && !tool.isTurningTool() && (machineConfiguration.getTurning() || isTurning())) { + c1 += makeRow(makeColumn(d(localize("Type") + ": ") + v(getToolTypeName(tool.type) + " " + (tool.isLiveTool() ? localize("LIVE") : localize("STATIC"))))); + } else { // dont show for old versions or is non turning + c1 += makeRow(makeColumn(d(localize("Type") + ": ") + v(getToolTypeName(tool.type)))); + } + + if (!tool.isTurningTool()) { + c1 += makeRow(makeColumn(d(localize(tool.isJetTool() ? "Kerf Diameter" : "Diameter") + ": ") + v(spatialFormat.format(tool.isJetTool() ? tool.jetDiameter : tool.diameter) + getUnitSymbolAsString()))); + if (tool.cornerRadius) { + c1 += makeRow(makeColumn(d(localize("Corner Radius") + ": ") + v(spatialFormat.format(tool.cornerRadius) + getUnitSymbolAsString()))); + } + if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { + if (tool.isDrill()) { + c1 += makeRow(makeColumn(d(localize("Tip Angle") + ": ") + v(taperFormat.format(tool.taperAngle) + "°"))); + } else { + c1 += makeRow(makeColumn(d(localize("Taper Angle") + ": ") + v(taperFormat.format(tool.taperAngle) + "°"))); + } + } + if (!tool.isJetTool()) { + c1 += makeRow(makeColumn(d(localize("Length") + ": ") + v(spatialFormat.format(tool.bodyLength) + getUnitSymbolAsString()))); + if (tool.numberOfFlutes > 0) { + c1 += makeRow(makeColumn(d(localize("Flutes") + ": ") + v(tool.numberOfFlutes))); + } + } + } else { + if (tool.getInsertType() < insertDescriptions.length) { + c1 += makeRow(makeColumn(d(localize("Insert") + ": ") + v(insertDescriptions[tool.getInsertType()]))); + } + if (tool.getHolderType() < holderDescriptions.length) { + var hand = ""; + switch (tool.hand) { + case "L": + hand = localize("Left"); + break; + case "R": + hand = localize("Right"); + break; + case "N": + hand = localize("Neutral"); + break; + } + if (!getProperty("showTools")) { + c1 += makeRow(makeColumn(d(localize("Holder") + ": ") + v(holderDescriptions[tool.getHolderType()] + " " + hand))); + } + if (false && tool.clamping) { + c1 += makeRow(makeColumn(d(localize("Clamping") + ": ") + v(tool.clamping))); + } + } + + switch (tool.type) { + case TOOL_TURNING_GENERAL: + case TOOL_TURNING_BORING: + if ((tool.inscribedCircleDiameter !== undefined) && (tool.edgeLength !== undefined)) { + var edgeLength = tool.edgeLength; + if ((unit == MM) && (edgeLength > 0)) { + c1 += makeRow(makeColumn(d(localize("Edge length") + ": ") + v(spatialFormat.format(edgeLength) + getUnitSymbolAsString()))); + } else { + c1 += makeRow(makeColumn(d(localize("Inscribed circle") + ": ") + v(spatialFormat.format(tool.inscribedCircleDiameter) + getUnitSymbolAsString()))); + } + } + if (tool.noseRadius !== undefined) { + var NOSE_RADII = [ + {idi:"X0", idm:"X0", vi:0.0015, vm:0.04}, + {idi:"00", idm:"01", vi:0.004, vm:0.1}, + {idi:"0.5", idm:"02", vi:0.008, vm:0.2}, + {idi:"01", idm:"04", vi:1.0 / 64, vm:0.4}, + {idi:"02", idm:"08", vi:2.0 / 64, vm:0.8}, + {idi:"03", idm:"12", vi:3.0 / 64, vm:1.2}, + {idi:"04", idm:"16", vi:4.0 / 64, vm:1.6}, + {idi:"05", idm:"20", vi:5.0 / 64, vm:2.0}, + {idi:"06", idm:"24", vi:6.0 / 64, vm:2.4}, + {idi:"07", idm:"28", vi:7.0 / 64, vm:2.8}, + {idi:"08", idm:"32", vi:8.0 / 64, vm:3.2}, + {idi:"00", idm:"M0", vi:0, vm:0} // round + ]; + var id = ""; + var value = tool.noseRadius; + /* + for (var i in NOSE_RADII) { + var e = NOSE_RADII[i]; + var _value = (unit == MM) ? e.mi : e.vi; // we dont have a tool unit for now + if (Math.abs(_value - value) < 1e-3) { + id = (unit == MM) ? e.idm : e.idi; + value = _value; + break; + } + } +*/ + var text = spatialFormat.format(value) + getUnitSymbolAsString(); + if (id) { + text = id + " " + text; + } + c1 += makeRow(makeColumn(d(localize("Nose radius") + ": ") + v(text))); + } + if (tool.crossSection !== undefined) { + c1 += makeRow(makeColumn(d(localize("Cross section") + ": ") + v(tool.crossSection))); + } + if (tool.tolerance !== undefined) { + c1 += makeRow(makeColumn(d(localize("Tolerance") + ": ") + v(tool.tolerance))); + } + if (tool.reliefAngle !== undefined) { + var id = localize("Custom"); + var value = tool.reliefAngle; + for (var ir in TURNING_RELIEF_ANGLES) { + var re2 = TURNING_RELIEF_ANGLES[ir]; + if (Math.abs(re2.value - value) < 1e-3) { + id = re2.id; + value = re2.value; + break; + } + } + c1 += makeRow(makeColumn(d(localize("Relief") + ": ") + v(id + " " + degFormat.format(value) + "deg"))); + } + break; + case TOOL_TURNING_THREADING: + if ((tool.pitch !== undefined) && (tool.pitch > 0)) { + c1 += makeRow(makeColumn(d(localize("Pitch") + ": ") + v(spatialFormat.format(tool.pitch) + getUnitSymbolAsString()))); + } + // internal/external info + break; + case TOOL_TURNING_GROOVING: + // show shape also + if (tool.grooveWidth !== undefined) { + c1 += makeRow(makeColumn(d(localize("Width") + ": ") + v(spatialFormat.format(tool.grooveWidth) + getUnitSymbolAsString()))); + } + if ((tool.noseRadius !== undefined) && (tool.noseRadius > 0)) { + c1 += makeRow(makeColumn(d(localize("Nose radius") + ": ") + v(spatialFormat.format(tool.noseRadius) + getUnitSymbolAsString()))); + } + break; + case TOOL_TURNING_CUSTOM: + break; + } + + var compensationDescription; + switch (tool.getCompensationMode()) { + case TOOL_COMPENSATION_INSERT_CENTER: + compensationDescription = localize("Insert center"); + break; + case TOOL_COMPENSATION_TIP: + compensationDescription = localize("Tip"); + break; + case TOOL_COMPENSATION_TIP_CENTER: + compensationDescription = localize("Tip center"); + break; + case TOOL_COMPENSATION_TIP_TANGENT: + compensationDescription = localize("Tip tangent"); + break; + } + + if (compensationDescription) { + c1 += makeRow(makeColumn(d(localize("Compensation") + ": ") + v(compensationDescription))); + } + } + + if (tool.material) { + c1 += makeRow(makeColumn(d(localize("Material") + ": ") + v(getMaterialName(tool.material)))); + } + if (tool.description) { + c1 += makeRow(makeColumn(d(localize("Description") + ": ") + v(tool.description))); + } + if (tool.comment) { + c1 += makeRow(makeColumn(d(localize("Comment") + ": ") + v(tool.comment))); + } + if (tool.vendor) { + c1 += makeRow(makeColumn(d(localize("Vendor") + ": ") + v(tool.vendor))); + } + var productLink = getSectionParameterForTool(tool, "operation:tool_productLink"); + if (tool.productId || productLink) { + c1 += makeRow(makeColumn(d(localize("Product") + ": ") + v(autoLink(productLink, tool.productId)))); + } + if (!getProperty("showTools") && tool.holderDescription) { + c1 += makeRow(makeColumn(d(localize("Holder") + ": ") + v(tool.holderDescription))); + } + + // c1 += ""; // fixed width + // c1 += "
 
"; + return c1; +} + +function writeTools() { + writeln(""); + var colgroup = ""; + write(colgroup); + write(makeRow("")); + + var tools = getToolTable(); + if (tools.getNumberOfTools() > 0) { + var numberOfTools = useToolNumber ? tools.getNumberOfTools() : getNumberOfSections(); + for (var i = 0; i < numberOfTools; ++i) { + var tool = useToolNumber ? tools.getTool(i) : getSection(i).getTool(); + + var c1 = presentTool(tool); + c1 += "
" + localize("Tools") + "
"; + + var c2 = ""; + c2 += makeRow(makeColumn(" ")); // move 1 row down + if (zRanges[tool.number]) { + c2 += makeRow(makeColumn(d(localize("Minimum Z") + ": ") + v(spatialFormat.format(zRanges[tool.number].getMinimum()) + getUnitSymbolAsString()))); + } + + var maximumFeed = 0; + var maximumSpindleSpeed = 0; + var cuttingDistance = 0; + var rapidDistance = 0; + var cycleTime = 0; + for (var j = 0; j < getNumberOfSections(); ++j) { + var section = getSection(j); + if (!isProbeOperation(section)) { + if (section.getTool().number == tool.number) { + maximumFeed = Math.max(maximumFeed, section.getMaximumFeedrate()); + if ((section.type == TYPE_MILLING) || (section.type == TYPE_TURNING)) { + if (maximumSpindleSpeed !== undefined) { + maximumSpindleSpeed = (section.type == TYPE_MILLING) ? + Math.max(maximumSpindleSpeed, section.getMaximumSpindleSpeed()) : + Math.max(maximumSpindleSpeed, section.getTool().getMaximumSpindleSpeed()); + } else { + maximumSpindleSpeed = (section.type == TYPE_MILLING) ? + section.getMaximumSpindleSpeed() : + section.getTool().getMaximumSpindleSpeed(); + } + } + cuttingDistance += section.getCuttingDistance(); + rapidDistance += section.getRapidDistance(); + cycleTime += section.getCycleTime(); + } + } + } + if (getProperty("rapidFeed") > 0) { + cycleTime += rapidDistance / getProperty("rapidFeed") * 60; + } + + c2 += makeRow(makeColumn(d(localize("Maximum Feed") + ": ") + v(feedFormat.format(maximumFeed) + getFeedSymbolAsString()))); + if (maximumSpindleSpeed !== undefined) { + c2 += makeRow(makeColumn(d(localize("Maximum Spindle Speed") + ": ") + v(rpmFormat.format(maximumSpindleSpeed) + localize("rpm")))); + } + c2 += makeRow(makeColumn(d(localize("Cutting Distance") + ": ") + v(spatialFormat.format(cuttingDistance) + getUnitSymbolAsString()))); + if (getProperty("showRapidDistance")) { + c2 += makeRow(makeColumn(d(localize("Rapid Distance") + ": ") + v(spatialFormat.format(rapidDistance) + getUnitSymbolAsString()))); + } + var additional = ""; + if ((getNumberOfSections() > 1) && getProperty("showPercentages")) { + if (totalCycleTime > 0) { + additional = "
(" + percentageFormat.format(cycleTime / totalCycleTime) + "%)
"; + } + } + c2 += makeRow(makeColumn(d(localize("Estimated Cycle Time") + ": ") + v(formatCycleTime(cycleTime) + " " + additional))); + // c2 += ""; // fixed width + c2 += "
 
"; + + var c3 = ""; + c3 += makeRow(makeColumn(" ")); // move 1 row down + if (tool.isTurningTool()) { + if (tool.getHolderType() < holderDescriptions.length) { + var hand = ""; + switch (tool.hand) { + case "L": + hand = localize("Left"); + break; + case "R": + hand = localize("Right"); + break; + case "N": + hand = localize("Neutral"); + break; + } + c3 += makeRow(makeColumn(d(localize("Holder") + ": ") + v(holderDescriptions[tool.getHolderType()] + " " + hand))); + if (false && tool.clamping) { + c3 += makeRow(makeColumn(d(localize("Clamping") + ": ") + v(tool.clamping))); + } + } + } else { + if (tool.holderDescription) { + c3 += makeRow(makeColumn(d(localize("Holder") + ": ") + v(tool.holderDescription))); + } + if (tool.holderComment) { + c3 += makeRow(makeColumn(d(localize("Comment") + ": ") + v(tool.holderComment))); + } + if (tool.holderVendor) { + c3 += makeRow(makeColumn(d(localize("Vendor") + ": ") + v(tool.holderVendor))); + } + var holderLink = getSectionParameterForTool(tool, "operation:holder_productLink"); + if (tool.holderProductId || holderLink) { + c3 += makeRow(makeColumn(d(localize("Product") + ": ") + v(autoLink(holderLink, tool.holderProductId)))); + } + } + c3 += "
"; + + var c4 = ""; + if (getProperty("showToolImage")) { + if (toolRenderer) { + var id = useToolNumber ? tool.number : (i + 1); + var path = "tool" + id + ".png"; + var width = 2.5 * 100; + var height = 2.5 * 133; + var mimetype = "image/png"; + if (getProperty("embedImages") && (revision >= 41366)) { + if (!exportedTools[id]) { + if (toolRenderer.getAsBinary) { + var data = toolRenderer.getAsBinary(mimetype, tool, width, height); + exportedTools[id] = data; // do not export twice + } + } + } else { + try { + if (!exportedTools[id]) { + toolRenderer.exportAs(path, mimetype, tool, width, height); + exportedTools[id] = true; // do not export twice + } + } catch (e) { + // ignore + } + } + + if (getProperty("embedImages") && (revision >= 41366)) { + src = "data:" + mimetype + ";base64," + Base64.btoa(exportedTools[id]); + } else { + src = encodeURIComponent(path); + } + c4 = "" + + makeRow("") + + "
"; + } else { + if (getProperty("embedImages")) { + c4 = getToolAsSVG(tool); + } + } + } + writeln(""); + + write( + makeRow( + "" + c1 + "" + + "" + c2 + "" + + "" + c3 + "" + + "" + c4 + "", + "info" + ) + ); + if ((i + 1) < tools.getNumberOfTools()) { + write("    "); + } + writeln(""); + writeln(""); + } + } + + writeln(""); + writeln(""); +} + +function getCrossSections() { + var CROSS_SECTIONS = [ + {id:"A", d:localize("Type A"), image:""}, + {id:"B", d:localize("Type B"), image:""}, + {id:"C", d:localize("Type C"), image:""}, + {id:"F", d:localize("Type F"), image:""}, + {id:"G", d:localize("Type G"), image:""}, + {id:"H", d:localize("Type H"), image:""}, + {id:"J", d:localize("Type J"), image:""}, + {id:"M", d:localize("Type M"), image:""}, + {id:"N", d:localize("Type N"), image:""}, + {id:"Q", d:localize("Type Q"), image:""}, + {id:"R", d:localize("Type R"), image:""}, + {id:"T", d:localize("Type T"), image:""}, + {id:"U", d:localize("Type U"), image:""}, + {id:"W", d:localize("Type W"), image:""} + ]; + return CROSS_SECTIONS; +} + +function getTurningTolerance() { + var TOLERANCES = [ + {id:"A", d:localize("Type A"), image:""}, + {id:"B", d:localize("Type B"), image:""}, + {id:"C", d:localize("Type C"), image:""}, + {id:"F", d:localize("Type F"), image:""}, + {id:"G", d:localize("Type G"), image:""}, + {id:"H", d:localize("Type H"), image:""}, + {id:"J", d:localize("Type J"), image:""}, + {id:"M", d:localize("Type M"), image:""}, + {id:"N", d:localize("Type N"), image:""}, + {id:"Q", d:localize("Type Q"), image:""}, + {id:"R", d:localize("Type R"), image:""}, + {id:"T", d:localize("Type T"), image:""}, + {id:"U", d:localize("Type U"), image:""}, + {id:"W", d:localize("Type W"), image:""} + ]; + return TOLERANCES; +} + +function onSectionEnd() { + var toolpathSVG = getToolpathAsSVG(); + svg = undefined; + + if (isFirstSection()) { + var c = ""; + + c += makeRow(makeColumn(d(localize("User: ") + ": ") + v(getGlobalParameter("username")))); + c += makeRow(makeColumn(d(localize("Date: ") + ": ") + v(getGlobalParameter("generated-at")))); + + if (programComment) { + c += makeRow(makeColumn(d(localize("Program Comment") + ": ") + v(programComment))); + } + + if (hasParameter("job-description")) { + var description = getParameter("job-description"); + if (description) { + c += makeRow(makeColumn(d(localize("Job Description") + ": ") + v(description))); + } + } + + if (hasParameter("iso9000/document-control")) { + var id = getParameter("iso9000/document-control"); + if (id) { + c += makeRow(makeColumn(d(localize("Job ISO-9000 Control") + ": ") + v(id))); + } + } + + if (getProperty("showDocumentPath")) { + if (hasParameter("document-path")) { + var path = getParameter("document-path"); + if (path) { + c += makeRow(makeColumn(d(localize("Document Path") + ": ") + v(pageWidthFitPath(path)))); + } + } + + if (hasParameter("document-version")) { + var version = getParameter("document-version"); + if (version) { + c += makeRow(makeColumn(d(localize("Document Version") + ": ") + v(version))); + } + } + } + + if (getProperty("showNotes") && hasParameter("job-notes")) { + var notes = getParameter("job-notes"); + if (notes) { + c += + "" + + d(localize("Notes")) + ":
" + getParameter("job-notes") +
+          "
"; + } + } + + if (c) { + write("" + c + "
"); + write("
"); + writeln(""); + writeln(""); + } + + var workpiece = getWorkpiece(); + var delta = Vector.diff(workpiece.upper, workpiece.lower); + if (delta.isNonZero() || modelImagePath && getProperty("showModelImage")) { + + write(""); + write(makeRow("")); + write(""); + + var numberOfColumns = 0; + { // stock - workpiece + if (delta.isNonZero()) { + var c = "
" + localize("Setup") + "
"; + + var workOffset = undefined; + var multipleWCS = false; + var numberOfSections = getNumberOfSections(); + var workOffsets = []; + for (var i = 0; i < numberOfSections; ++i) { + var section = getSection(i); + if (!workOffsets[section.workOffset]) { + workOffsets[section.workOffset] = true; + } + if (!workOffset) { + workOffset = section.workOffset; + } + if (workOffset != section.workOffset) { + multipleWCS = true; + } + } + var text = ""; + for (var id in workOffsets) { + text += " " + formatWCS(id); + } + c += makeRow(makeColumn(d(localize("WCS")) + ":" + text)); + + if (multipleWCS) { + c += makeRow(makeColumn(d(localize("Program uses multiple WCS!")))); + } + + c += makeRow(makeColumn( + d(localize("Stock")) + ":
  " + v(localize("DX") + ": " + spatialFormat.format(delta.x) + getUnitSymbolAsString()) + "
  " + v(localize("DY") + ": " + spatialFormat.format(delta.y) + getUnitSymbolAsString()) + "
  " + v(localize("DZ") + ": " + spatialFormat.format(delta.z) + getUnitSymbolAsString()) + )); + + // if (hasParameter("part-lower-x") && hasParameter("part-lower-y") && hasParameter("part-lower-z") && + // hasParameter("part-upper-x") && hasParameter("part-upper-y") && hasParameter("part-upper-z")) { + // var lower = new Vector(getParameter("part-lower-x"), getParameter("part-lower-y"), getParameter("part-lower-z")); + // var upper = new Vector(getParameter("part-upper-x"), getParameter("part-upper-y"), getParameter("part-upper-z")); + // var delta = Vector.diff(upper, lower); + // c += makeRow(makeColumn( + // d(localize("Part")) + ":
  " + v(localize("DX") + ": " + spatialFormat.format(delta.x) + getUnitSymbolAsString() + "
  " + v(localize("DY") + ": " + spatialFormat.format(delta.y) + getUnitSymbolAsString()) + "
  " + v(localize("DZ") + ": " + spatialFormat.format(delta.z) + getUnitSymbolAsString())) + // )); + // } + + // c += makeRow(makeColumn( + // d(localize("Stock Lower in WCS") + " " + formatWCS(workOffset)) + ":
  " + v("X: " + spatialFormat.format(workpiece.lower.x) + getUnitSymbolAsString()) + "
  " + v("Y: " + spatialFormat.format(workpiece.lower.y) + getUnitSymbolAsString()) + "
  " + v("Z: " + spatialFormat.format(workpiece.lower.z) + getUnitSymbolAsString()) + // )); + // c += makeRow(makeColumn( + // d(localize("Stock Upper in WCS") + " " + formatWCS(workOffset)) + ":
  " + v("X: " + spatialFormat.format(workpiece.upper.x) + getUnitSymbolAsString()) + "
  " + v("Y: " + spatialFormat.format(workpiece.upper.y) + getUnitSymbolAsString()) + "
  " + v("Z: " + spatialFormat.format(workpiece.upper.z) + getUnitSymbolAsString()) + // )); + + c += "
"; + write(makeColumn(c)); + ++numberOfColumns; + } + } + + if (modelImagePath && getProperty("showModelImage")) { + var path = FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), modelImagePath); + var src = ""; + if (!FileSystem.isFile(path)) { + warning(subst(localize("Model image doesn't exist '%1'."), path)); + } else { + if (getProperty("embedImages") && (revision >= 41366)) { + // add support for image from database instead + src = getImageAsImgSrc(path); + FileSystem.remove(path); + } else { + src = encodeURIComponent(modelImagePath); + } + } + + ++numberOfColumns; + var alignment = (numberOfColumns <= 1) ? "center" : "right"; + write(""); + } + + write(""); + write(""); + write("
"); + writeln(""); + writeln(""); + } + + if (getProperty("showTotals")) { + writeTotals(); + write("
"); + writeln(""); + writeln(""); + } + + if (getProperty("showTools")) { + writeTools(); + write("
"); + writeln(""); + writeln(""); + } + } + + if (!getProperty("showOperations")) { + return; // skip + } + + if (isFirstSection()) { + writeln(""); + var colgroup = ""; + write(colgroup); + write(makeRow("")); + } + + var c1 = "
" + localize("Operations") + "
"; + + c1 += makeRow( + makeColumn(v(localize("Operation") + " " + (currentSection.getId() + 1) + "/" + getNumberOfSections())) + ); + + if (hasParameter("operation-comment")) { + c1 += makeRow( + makeColumn(d(localize("Description") + ": ") + v(getParameter("operation-comment"))) + ); + } + + if (hasParameter("operation-strategy")) { + var strategies = { + "drill": localize("Drilling"), + "probe": localize("Probe"), + "face": localize("Facing"), + "path3d": localize("3D Path"), + "pocket2d": localize("Pocket 2D"), + "contour2d": localize("Contour 2D"), + "adaptive2d": localize("Adaptive 2D"), + "slot": localize("Slot"), + "circular": localize("Circular"), + "bore": localize("Bore"), + "thread": localize("Thread"), + "jet2d": localize("Profile 2D"), + + "contour_new": localize("Contour"), + "contour": localize("Contour"), + "parallel_new": localize("Parallel"), + "parallel": localize("Parallel"), + "pocket_new": localize("Pocket"), + "pocket": localize("Pocket"), + "adaptive": localize("Adaptive"), + "horizontal_new": localize("Horizontal"), + "horizontal": localize("Horizontal"), + "blend": localize("Blend"), + "flow": localize("Flow"), + "morph": localize("Morph"), + "pencil_new": localize("Pencil"), + "pencil": localize("Pencil"), + "project": localize("Project"), + "ramp": localize("Ramp"), + "radial_new": localize("Radial"), + "radial": localize("Radial"), + "scallop_new": localize("Scallop"), + "scallop": localize("Scallop"), + "morphed_spiral": localize("Morphed Spiral"), + "spiral_new": localize("Spiral"), + "spiral": localize("Spiral"), + "swarf5d": localize("Multi-Axis Swarf"), + "multiAxisContour": localize("Multi-Axis Contour"), + "multiAxisBlend": localize("Multi-Axis Blend"), + + "turningRoughing": localize("Turning Profile"), + "turningProfileGroove": localize("Turning Profile Groove"), + "turningPart": localize("Turning Part"), + "turningFace": localize("Turning Face"), + "turningGroove": localize("Turning Groove"), + "turningChamfer": localize("Turning Chamfer"), + "turningThread": localize("Turning Thread"), + "turningStockTransfer": localize("Turning Stock Transfer"), + "turningSecondarySpindleGrab": localize("Turning Spindle Grab"), + "turningSecondarySpindlePull": localize("Turning Spindle Pull"), + "turningSecondarySpindleReturn": localize("Turning Spindle Return") + }; + + if (strategies[getParameter("operation-strategy")]) { + var description = strategies[getParameter("operation-strategy")]; + c1 += makeRow( + makeColumn(d(localize("Strategy") + ": ") + v(description)) + ); + } + } + + var newWCS = !isFirstSection() && (currentSection.workOffset != getPreviousSection().workOffset); + c1 += makeRow( + makeColumn(d(localize("WCS") + ": ") + v(formatWCS(currentSection.workOffset) + (newWCS ? (" " + bold(localize("NEW!"))) : ""))) + ); + if (currentSection.isPatterned()) { + var id = patternIds[currentSection.getPatternId()]; + c1 += makeRow( + makeColumn(d(localize("Pattern Group") + ": ") + v(id)) + ); + } + + var tolerance = cachedParameters["operation:tolerance"]; + var stockToLeave = cachedParameters["operation:stockToLeave"]; + var axialStockToLeave = cachedParameters["operation:verticalStockToLeave"]; + var maximumStepdown = cachedParameters["operation:maximumStepdown"]; + var maximumStepover = cachedParameters["operation:maximumStepover"] ? cachedParameters["operation:maximumStepover"] : cachedParameters["operation:stepover"]; + var optimalLoad = cachedParameters["operation:optimalLoad"]; + var loadDeviation = cachedParameters["operation:loadDeviation"]; + + if (tolerance != undefined) { + c1 += makeRow(makeColumn(d(localize("Tolerance") + ": ") + v(spatialFormat.format(tolerance) + getUnitSymbolAsString()))); + } + if (stockToLeave != undefined) { + if ((axialStockToLeave != undefined) && (stockToLeave != axialStockToLeave)) { + c1 += makeRow( + makeColumn( + d(localize("Stock to Leave") + ": ") + v(spatialFormat.format(stockToLeave) + getUnitSymbolAsString()) + "/" + v(spatialFormat.format(axialStockToLeave) + getUnitSymbolAsString()) + ) + ); + } else { + c1 += makeRow(makeColumn(d(localize("Stock to Leave") + ": ") + v(spatialFormat.format(stockToLeave) + getUnitSymbolAsString()))); + } + } + + if ((maximumStepdown != undefined) && (maximumStepdown > 0)) { + c1 += makeRow(makeColumn(d(localize("Maximum stepdown") + ": ") + v(spatialFormat.format(maximumStepdown) + getUnitSymbolAsString()))); + } + + if ((optimalLoad != undefined) && (optimalLoad > 0)) { + c1 += makeRow(makeColumn(d(localize("Optimal load") + ": ") + v(spatialFormat.format(optimalLoad) + getUnitSymbolAsString()))); + if ((loadDeviation != undefined) && (loadDeviation > 0)) { + c1 += makeRow(makeColumn(d(localize("Load deviation") + ": ") + v(spatialFormat.format(loadDeviation) + getUnitSymbolAsString()))); + } + } else if ((maximumStepover != undefined) && (maximumStepover > 0)) { + c1 += makeRow(makeColumn(d(localize("Maximum stepover") + ": ") + v(spatialFormat.format(maximumStepover) + getUnitSymbolAsString()))); + } + + var compensationType = hasParameter("operation:compensationType") ? getParameter("operation:compensationType") : "computer"; + if (compensationType != "computer") { + var compensationDeltaRadius = hasParameter("operation:compensationDeltaRadius") ? getParameter("operation:compensationDeltaRadius") : 0; + + var compensation = hasParameter("operation:compensation") ? getParameter("operation:compensation") : "center"; + var COMPENSATIONS = {left: localize("left"), right: localize("right"), center: localize("center")}; + var compensationText = localize("unspecified"); + if (COMPENSATIONS[compensation]) { + compensationText = COMPENSATIONS[compensation]; + } + + var DESCRIPTIONS = {computer: localize("computer"), control: localize("control"), wear: localize("wear"), inverseWear: localize("inverse wear")}; + var description = localize("unspecified"); + if (DESCRIPTIONS[compensationType]) { + description = DESCRIPTIONS[compensationType]; + } + c1 += makeRow(makeColumn(d(localize("Compensation") + ": ") + v(description + " (" + compensationText + ")"))); + c1 += makeRow(makeColumn(d(localize("Safe Tool Diameter") + ": ") + v("< " + spatialFormat.format(tool.diameter + 2 * compensationDeltaRadius) + getUnitSymbolAsString()))); + } + c1 += "
"; + + var c2 = ""; + c2 += makeRow(makeColumn(v(" "))); // move 1 row down + + if (is3D()) { + var zRange = currentSection.getGlobalZRange(); + c2 += makeRow(makeColumn(d(localize("Maximum Z") + ": ") + v(spatialFormat.format(zRange.getMaximum()) + getUnitSymbolAsString()))); + c2 += makeRow(makeColumn(d(localize("Minimum Z") + ": ") + v(spatialFormat.format(zRange.getMinimum()) + getUnitSymbolAsString()))); + } + + if (!isProbeOperation(currentSection)) { + var maximumFeed = currentSection.getMaximumFeedrate(); + var maximumSpindleSpeed = currentSection.getMaximumSpindleSpeed(); + var cuttingDistance = currentSection.getCuttingDistance(); + var rapidDistance = currentSection.getRapidDistance(); + var cycleTime = currentSection.getCycleTime(); + + if (currentSection.getType() == TYPE_TURNING) { + if (currentSection.getTool().getSpindleMode() == SPINDLE_CONSTANT_SURFACE_SPEED) { + c2 += makeRow(makeColumn(d(localize("Surface Speed") + ": ") + v(rpmFormat.format(currentSection.getTool().surfaceSpeed * ((unit == MM) ? 1 / 1000.0 : 1 / 12.0)) + ((unit == MM) ? localize("m/min") : localize("ft/min"))))); + } else { + c2 += makeRow(makeColumn(d(localize("Maximum Spindle Speed") + ": ") + v(rpmFormat.format(maximumSpindleSpeed) + localize("rpm")))); + } + if (currentSection.feedMode == FEED_PER_REVOLUTION) { + if (hasParameter("operation:tool_feedCuttingRel")) { + var feed = getParameter("operation:tool_feedCuttingRel"); + c2 += makeRow(makeColumn(d(localize("Feedrate per Rev") + ": ") + v(feedFormat.format(feed) + getFPRSymbolAsString()))); + } + } else { + c2 += makeRow(makeColumn(d(localize("Maximum Feedrate") + ": ") + v(feedFormat.format(maximumFeed) + getFeedSymbolAsString()))); + } + } else if (currentSection.getType() == TYPE_MILLING) { + c2 += makeRow(makeColumn(d(localize("Maximum Spindle Speed") + ": ") + v(rpmFormat.format(maximumSpindleSpeed) + localize("rpm")))); + c2 += makeRow(makeColumn(d(localize("Maximum Feedrate") + ": ") + v(feedFormat.format(maximumFeed) + getFeedSymbolAsString()))); + } else if (currentSection.getType() == TYPE_JET) { + c2 += makeRow(makeColumn(d(localize("Maximum Feedrate") + ": ") + v(feedFormat.format(maximumFeed) + getFeedSymbolAsString()))); + } + c2 += makeRow(makeColumn(d(localize("Cutting Distance") + ": ") + v(spatialFormat.format(cuttingDistance) + getUnitSymbolAsString()))); + if (getProperty("showRapidDistance")) { + c2 += makeRow(makeColumn(d(localize("Rapid Distance") + ": ") + v(spatialFormat.format(rapidDistance) + getUnitSymbolAsString()))); + } + if (getProperty("rapidFeed") > 0) { + cycleTime += rapidDistance / getProperty("rapidFeed") * 60; + } + var additional = ""; + if ((getNumberOfSections() > 1) && getProperty("showPercentages")) { + if (totalCycleTime > 0) { + additional = "
(" + percentageFormat.format(cycleTime / totalCycleTime) + "%)
"; + } + } + c2 += makeRow(makeColumn(d(localize("Estimated Cycle Time") + ": ") + v(formatCycleTime(cycleTime) + " " + additional))); + if ((currentSection.getType() != TYPE_JET) || (tool.coolant != COOLANT_OFF)) { + c2 += makeRow(makeColumn(d(localize("Coolant") + ": ") + v(getCoolantDescription(tool.coolant)))); + } + } + + c2 += "
"; + + var c3 = presentTool(currentSection.getTool()); + if (currentSection.getType() == TYPE_JET) { + switch (currentSection.jetMode) { + case JET_MODE_THROUGH: + c3 += makeRow(makeColumn(d(localize("Cutting Type") + ": ") + v(localize("Through cutting")))); + break; + case JET_MODE_ETCHING: + c3 += makeRow(makeColumn(d(localize("Cutting Type") + ": ") + v(localize("Etching")))); + break; + case JET_MODE_VAPORIZE: + c3 += makeRow(makeColumn(d(localize("Cutting Type") + ": ") + v(localize("Vaporize")))); + break; + } + c3 += makeRow(makeColumn(d(localize("Quality") + ": ") + v(currentSection.quality))); + } + c3 += ""; + + var c4 = ""; + if (getProperty("showToolImage")) { + if (toolRenderer) { + var id = useToolNumber ? tool.number : (currentSection.getId() + 1); + var path = "tool" + id + ".png"; + var width = 2.5 * 100; + var height = 2.5 * 133; + var mimetype = "image/png"; + if (getProperty("embedImages") && (revision >= 41366)) { + if (!exportedTools[id]) { + if (toolRenderer.getAsBinary) { + var data = toolRenderer.getAsBinary(mimetype, tool, width, height); + exportedTools[id] = data; // do not export twice + } + } + } else { + try { + if (!exportedTools[id]) { + toolRenderer.exportAs(path, mimetype, tool, width, height); + exportedTools[id] = true; // do not export twice + } + } catch (e) { + // ignore + } + } + + if (getProperty("embedImages") && (revision >= 41366)) { + src = "data:" + mimetype + ";base64," + Base64.btoa(exportedTools[id]); + } else { + src = encodeURIComponent(path); + } + c4 = "" + + makeRow("") + + "
"; + + } else { + if (getProperty("embedImages")) { + c4 = getToolAsSVG(tool); + } + } + } + + var c5 = ""; + if (cachedParameters["operation:associatedView"] != undefined) { + path = FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), cachedParameters["operation:associatedView"]); + src = getImageAsImgSrc(path); + c5 = ""; + } + + write( + "" + + "" + c1 + "" + + "" + c2 + "" + + "" + c3 + "" + + (c4 ? "" + c4 + "" : "") + + (c5 ? "" + c5 + "" : "") + + "" + ); + + if (toolpathSVG) { + write( + "" + + "" + toolpathSVG + "" + + "" + ); + } + + if (getProperty("showPreviewImage")) { + var patternId = currentSection.getPatternId(); + var show = false; + if (getProperty("forcePreview") || !seenPatternIds[patternId]) { + show = true; + seenPatternIds[patternId] = true; + } + if (show && currentSection.hasParameter("autodeskcam:preview-name")) { + var path = currentSection.getParameter("autodeskcam:preview-name"); + var absPath = FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), path); + if (FileSystem.isFile(absPath)) { + + if (getProperty("embedImages") && (revision >= 41366)) { + src = getImageAsImgSrc(absPath); + FileSystem.remove(absPath); + } else { + src = encodeURIComponent(path); + } + + var r2 = "" + + makeRow("") + + "
"; + write( + "" + + "" + r2 + "" + + "" + ); + } + } + } + + if (getProperty("showNotes") && hasParameter("notes")) { + var notes = getParameter("notes"); + if (notes) { + write( + "" + + d(localize("Notes")) + ":
" + getParameter("notes") +
+        "
" + ); + } + } + + if (!isLastSection()) { + write(" "); + } + writeln(""); + writeln(""); + + cachedParameters = {}; +} + +function formatCycleTime(cycleTime) { + cycleTime += 0.5; // round up + var seconds = cycleTime % 60 | 0; + var minutes = ((cycleTime - seconds) / 60 | 0) % 60; + var hours = (cycleTime - minutes * 60 - seconds) / (60 * 60) | 0; + if (hours > 0) { + return subst(localize("%1h:%2m:%3s"), hours, minutes, seconds); + } else if (minutes > 0) { + return subst(localize("%1m:%2s"), minutes, seconds); + } else { + return subst(localize("%1s"), seconds); + } +} + +function writeTotals() { + var zRange; + var maximumFeed = 0; + var maximumSpindleSpeed; + var cuttingDistance = 0; + var rapidDistance = 0; + var cycleTime = 0; + + var numberOfSections = getNumberOfSections(); + var currentTool; + for (var i = 0; i < numberOfSections; ++i) { + var section = getSection(i); + + if (is3D()) { + var _zRange = section.getGlobalZRange(); + if (zRange) { + zRange.expandToRange(_zRange); + } else { + zRange = _zRange; + } + } + + if (!isProbeOperation(section)) { + maximumFeed = Math.max(maximumFeed, section.getMaximumFeedrate()); + if ((section.type == TYPE_MILLING) || (section.type == TYPE_TURNING)) { + if (maximumSpindleSpeed !== undefined) { + maximumSpindleSpeed = (section.type == TYPE_MILLING) ? + Math.max(maximumSpindleSpeed, section.getMaximumSpindleSpeed()) : + Math.max(maximumSpindleSpeed, section.getTool().getMaximumSpindleSpeed()); + } else { + maximumSpindleSpeed = (section.type == TYPE_MILLING) ? + section.getMaximumSpindleSpeed() : + section.getTool().getMaximumSpindleSpeed(); + } + } + cuttingDistance += section.getCuttingDistance(); + rapidDistance += section.getRapidDistance(); + cycleTime += section.getCycleTime(); + if (getProperty("toolChangeTime") > 0) { + var tool = section.getTool(); + if (currentTool != tool.number) { + currentTool = tool.number; + cycleTime += getProperty("toolChangeTime"); + } + } + } + } + if (getProperty("rapidFeed") > 0) { + cycleTime += rapidDistance / getProperty("rapidFeed") * 60; + } + totalCycleTime = cycleTime; + + writeln(""); + write(makeRow("")); + + var c1 = "
" + localize("Total") + "
"; + var tools = getToolTable(); + c1 += makeRow(makeColumn(d(localize("Number Of Operations") + ": ") + v(getNumberOfSections()))); + var text = ""; + var gotTool = false; + for (var i = 0; i < tools.getNumberOfTools(); ++i) { + var tool = tools.getTool(i); + if (i > 0) { + text += " "; + } + gotTool |= tool.number != 0; + text += bold(localize("T") + toolFormat.format(tool.number)); + } + if ((section.type == TYPE_MILLING) || (section.type == TYPE_TURNING) || gotTool) { + c1 += makeRow(makeColumn(d(localize("Number Of Tools") + ": ") + v(tools.getNumberOfTools()))); + c1 += makeRow(makeColumn(d(localize("Tools") + ": ") + vWrap(text))); + } + if (zRange) { + c1 += makeRow(makeColumn(d(localize("Maximum Z") + ": ") + v(spatialFormat.format(zRange.getMaximum()) + getUnitSymbolAsString()))); + c1 += makeRow(makeColumn(d(localize("Minimum Z") + ": ") + v(spatialFormat.format(zRange.getMinimum()) + getUnitSymbolAsString()))); + } + c1 += makeRow(makeColumn(d(localize("Maximum Feedrate") + ": ") + v(feedFormat.format(maximumFeed) + getFeedSymbolAsString()))); + if (maximumSpindleSpeed !== undefined) { + c1 += makeRow(makeColumn(d(localize("Maximum Spindle Speed") + ": ") + v(rpmFormat.format(maximumSpindleSpeed) + localize("rpm")))); + } + c1 += makeRow(makeColumn(d(localize("Cutting Distance") + ": ") + v(spatialFormat.format(cuttingDistance) + getUnitSymbolAsString()))); + if (getProperty("showRapidDistance")) { + c1 += makeRow(makeColumn(d(localize("Rapid Distance") + ": ") + v(spatialFormat.format(rapidDistance) + getUnitSymbolAsString()))); + } + c1 += makeRow(makeColumn(d(localize("Estimated Cycle Time") + ": ") + v(formatCycleTime(cycleTime)))); + c1 += "
"; + + write( + "" + + "" + c1 + "" + + "" + ); + write(""); + writeln(""); + writeln(""); +} + +function onClose() { + if (getProperty("showOperations")) { + writeln(""); + } + + // footer + if (getProperty("showFooter")) { + write("
"); + write("
"); + var src = findFile("../graphics/logo.png"); + if (getProperty("embedImages") && (revision >= 41366)) { + var data = getImageAsImgSrc(src); + if (data) { + write(""); + } + } else { + var dest = "logo.png"; + if (FileSystem.isFile(src)) { + FileSystem.copyFile(src, FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), dest)); + write(""); + } + } + var now = new Date(); + var product = "Autodesk CAM"; + if (hasGlobalParameter("generated-by")) { + product = getGlobalParameter("generated-by"); + } + var productUrl = "http://cam.autodesk.com"; + if (product) { + if ((product.indexOf("HSMWorks") == 0) || (product.indexOf("HSMXpress") == 0)) { + productUrl = "http://www.hsmworks.com"; + } + } + write(localize("Generated by") + " " + product + "" + " " + now.toLocaleDateString() + " " + now.toLocaleTimeString()); + write(""); + write(""); +} + +function quote(text) { + var result = ""; + for (var i = 0; i < text.length; ++i) { + var ch = text.charAt(i); + switch (ch) { + case "\\": + case "\"": + result += "\\"; + } + result += ch; + } + return "\"" + result + "\""; +} + +function onTerminate() { + // add this to print automatically - you could print to XPS and PDF writer +/* + var device = "Microsoft XPS Document Writer"; + if (device) { + executeNoWait("rundll32.exe", "mshtml.dll,PrintHTML " + quote(getOutputPath()) + quote(device), false, ""); + } else { + executeNoWait("rundll32.exe", "mshtml.dll,PrintHTML " + quote(getOutputPath()), false, ""); + } +*/ +} + +function setProperty(property, value) { + properties[property].current = value; +} diff --git a/Autodesk_Setup_BIDC/setup-sheet.css b/Autodesk_Setup_BIDC/setup-sheet.css new file mode 100644 index 0000000..0368030 --- /dev/null +++ b/Autodesk_Setup_BIDC/setup-sheet.css @@ -0,0 +1,184 @@ +/** + Copyright (C) 2012-2018 by Autodesk, Inc. + http://www.autodesk.com + All rights reserved +*/ + +body { + background-color: White; + font-family: Arial, Helvetica, sans-serif; +} + +h1 { + font-size: 15pt; + text-align: center; +} + +h2 { + font-size: 13pt; +} + +h3 { + font-size: 11pt; +} + +h3.section { + text-decoration: underline; +} + +table { + border: none; + border-spacing: 0; +} + +table.jobhead { + width: 18cm; +} + +table.job, table.sheet { + width: 18cm; + border: thin solid Gray; +} + +th { + background-color: #e0e0e0; + border-bottom: 1px solid Gray; +} + +tr.space td { + border-bottom: 1px solid Gray; + height: 1px; + font-size: 1px; +} + +table.info { + padding-top: 0.1cm; +} + +table.info td { + padding-left: 0.1cm; +} + +.job td { + padding: 0.1cm 0.1cm 0.1cm 0.1cm; +} + +.model img { + width: 12cm; + border: 2px solid Black; +} + +.preview img { + border: 2px solid Black; +} + +tr { + border: 1 solid Black; + page-break-inside: avoid; + padding-top: 30px; + padding-bottom: 20px; + white-space: nowrap; +} + +.even td { + background-color: White; +} + +.odd td { + background-color: #f0f0f0; +} + +.jobhead td { + font-size: 12pt; + vertical-align: top; +} + +td { + font-size: 9pt; + vertical-align: top; +} + +.toolimage { + vertical-align: middle; +} + +td.image { + text-align: right; +} + +.notes { + white-space: normal; +} + +pre { + padding-left: 0.5cm; + font-size: 8pt; +} + +p { + white-space: nowrap; + font-size: 12pt; + text-indent: 1cm; + display: block; +} + +.jobhead td .description { + display: inline; + font-variant: small-caps; +} + +td .description { + font-size: 8pt; + display: inline; + font-variant: small-caps; +} + +.value { + display: inline; + font-family: Geneva, sans-serif; + color: #606060; +} + +td .percentage { + display: inline; + font-size: 7pt; +} + +.longtext { + white-space: normal; +} + +img.logo { + height: 0.75cm; + vertical-align: middle; + margin-right: 1em; +} + +.footer { + font-size: 9pt; + color: Silver; + text-align: center; +} + +line { + stroke-width: 1px; + vector-effect:non-scaling-stroke; +} + +path.holder { + stroke-width: 0.5px; + vector-effect: non-scaling-stroke; +} + +path.cutter { + stroke-width: 1px; + vector-effect:non-scaling-stroke; +} + +path.holderIE { + stroke-width: 0; // non-scaling not worker +} + +path.cutterIE { + stroke-width: 0; // non-scaling not worker +} From 9ed4d6e1f50e2e6b53da15199c4951d251afd967 Mon Sep 17 00:00:00 2001 From: will1742 Date: Thu, 2 Sep 2021 15:03:13 -0400 Subject: [PATCH 07/19] Mapped linear movement params --- Flow_Waterjet_BIDC/Bechtel Waterjet.cps | 64 ++++++++++++++++++++----- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/Flow_Waterjet_BIDC/Bechtel Waterjet.cps b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps index 6825626..95755f7 100644 --- a/Flow_Waterjet_BIDC/Bechtel Waterjet.cps +++ b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps @@ -120,6 +120,17 @@ function f(text) { return FIELD.substr(0, 10 - length) + text; } +var commentField = "// "; + +/** Make sure fields are aligned. */ +function commentf(text) { + var length = text.length; + if (length > 10) { + return text; + } + return commentField.substr(0, 10 - length) + text; +} + /** Make sure fields are aligned. */ function fi(text, size) { var length = text.length; @@ -130,7 +141,7 @@ function fi(text, size) { } function onOpen() { - useVersion6 = getProperty("formatVersion") == "6"; + useVersion6 = true; unit = IN; // only inch mode is supported redirectToBuffer(); // buffer the entire program to be able to count the linear and circular moves @@ -207,6 +218,13 @@ function onSection() { return; } + if (hasParameter("operation-comment")) { + var comment = getParameter("operation-comment"); + writeln(""); + writeComment(comment); + } else { + writeln(""); + } var initialPosition = getFramePosition(currentSection.getInitialPosition()); onExpandedRapid(initialPosition.x, initialPosition.y, initialPosition.z); } @@ -227,6 +245,25 @@ function writeLinear(x, y, z, feed, column7) { if (flag || forceOutput) { if (useVersion6) { + switch (writeLinear.caller.name) { + case "onRapid": + writeComment("Rapid"); + break; + case "onLinear": + writeComment("Linear"); + break; + case "finishArcs": + writeComment("Arc Completion"); + break; + } + writeBlock( + commentf("X"), ",", + f("Y"), ",", + f("Z"), ",", + fi("L", 2), ",", + fi("Feed", 5), ",", + fi("C", 2), ",", + fi("?", 2)); writeBlock( f(xyzFormat.format(x)), ",", f(xyzFormat.format(y)), ",", @@ -237,6 +274,18 @@ function writeLinear(x, y, z, feed, column7) { fi(integerFormat.format(column7), 2) // TAG: seen -2..2 - unknown ); } else { + switch (writeLinear.caller.name) { + case "onRapid": + writeComment("Rapid"); + break; + case "onLinear": + writeComment("Linear"); + break; + case "finishArcs": + writeComment("Arc Completion"); + break; + } + writeBlock(commentf("X"), ",", f("Y"), ",", fi("L", 2), ",", fi("Feed", 5), ",", fi("C", 2)) writeBlock( f(xyzFormat.format(x)), ",", f(xyzFormat.format(y)), ",", @@ -292,6 +341,8 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { } var p = getCurrentPosition(); if (useVersion6) { + writeComment("Circular"); + writeBlock( f(xyzFormat.format(p.x)), ",", f(xyzFormat.format(p.y)), ",", @@ -305,6 +356,7 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { f(xyzFormat.format(0)) // PLANE_XY only ); } else { + writeComment("Circular"); writeBlock( f(xyzFormat.format(p.x)), ",", f(xyzFormat.format(p.y)), ",", @@ -389,16 +441,6 @@ function onClose() { writeComment("Filename: " + getGlobalParameter("document-path")); writeComment("Date: " + getGlobalParameter("generated-at")); writeComment("Post Version: " + staticProperties.postVersion); - writeln(""); - writeBlock( - "//"," Start X", ",", - f("Start Y"), ",", - fi(" Arc"), ",", // arc cw/ccw - fi(" Feed"), ",", - fi(" Comp"), ",", // left, center, right - f("End X"), ",", - f("End Y") - ); // writeln("// This file was created by FlowMaster(R), which is proprietary to Flow International Corporation. " + lineCounter + " " + arcCounter); if (useVersion6) { writeln("VER 6.00"); From 53052f386a405a67349158511d7a2a5c7d5db596 Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Mon, 6 Sep 2021 12:50:07 -0400 Subject: [PATCH 08/19] Updated mappings, added live tools --- Haas_Lathes_BIDC/Bechtel ST-20Y.cps | 47 +++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps index 351da16..8392f26 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps @@ -536,7 +536,7 @@ const NORTH = { const KM50A = { name: "KM50 Axial", x: -12.9819, - z: -8.8234, + z: -11.9723, sOffset: 0.0 }; @@ -550,7 +550,7 @@ const KM40A = { const WBLOCK = { name: "Wedge Block", x: -20.8443, - z: -12.5006, + z: -12.0006, sOffset: 0.0 }; @@ -664,28 +664,45 @@ function getCompleteTool(holder, tool) { this.offsetType = "General Turning"; this.probeX = defaultX; this.probeZ = defaultZ; + } else if (holder == KM40R) { - this.offsetType = "General Turning"; - this.probeX = function() { - return holder.x + (tool.getBodyLength() + tool.getHolderLength())*2 + var haasType = getHaasToolTypeBIDC(tool.type); + var millZ = function() { + return holder.z - (PROBE_CENTERING_OFFSET * 0.5) + (tool.diameter * 0.5); }; - this.probeZ = function() { - return holder.z - PROBE_CENTERING_OFFSET; + var drillZ = function() { + return holder.z - (PROBE_CENTERING_OFFSET * 0.5); }; + + this.offsetType = (haasType == HAAS_END_MILL) ? "Mill Probe" : "Drill Probe"; + this.probeZ = (haasType == HAAS_END_MILL) ? millZ : drillZ; this.machineZ = function() { return holder.z; }; + this.probeX = function() { + return holder.x + (tool.getBodyLength() + tool.getHolderLength())*2 + }; } else if (holder == KM40A) { this.offsetType = "General Turning"; - this.probeX = function() { - return holder.z - PROBE_CENTERING_OFFSET; - } + var haasType = getHaasToolTypeBIDC(tool.type); + var millX = function() { + return holder.x - PROBE_CENTERING_OFFSET + tool.diameter; + }; + var drillX = function() { + return holder.x - PROBE_CENTERING_OFFSET; + }; + + this.offsetType = (haasType == HAAS_END_MILL) ? "Mill Probe" : "Drill Probe"; + this.probeZ = (haasType == HAAS_END_MILL) ? millX : drillX; this.machineX = function() { return holder.x; } this.probeZ = function() { - return holder.z + (tool.getBodyLength() + tool.getHolderLength())*2 + return holder.z + tool.getBodyLength() + tool.getHolderLength() + } + if ((holder.z + tool.getBodyLength() + tool.getHolderLength()) >= 5.0){ + throw "TOOL LENGTH TOO LARGE" } } else { throw "TOOL: " + tool.number + ", INVALID HOLDER" @@ -1171,10 +1188,13 @@ var machineConfigurationSubSpindle; function getHaasToolTypeBIDC(toolType) { switch (toolType) { case TOOL_DRILL: + case TOOL_MILLING_END_BALL: return HAAS_DRILL; // drill case TOOL_MILLING_END_FLAT: case TOOL_MILLING_END_BULLNOSE: case TOOL_MILLING_TAPERED: + case TOOL_MILLING_FACE: + case TOOL_MILLING_SLOT: return HAAS_END_MILL; // end mill case TOOL_DRILL_SPOT: case TOOL_MILLING_CHAMFER: @@ -1263,6 +1283,9 @@ function writeToolMeasureBlockBIDC(tool) { writeMeasure("T" + toolFormat.format(tool.number * 100 + compensationOffset % 100)); writeComment("PROBE: " + measureTool.offsetType + ", " + probeType.name); writeMeasure(mFormat.format(104)); + if (measureTool.offsetType == "Mill Probe") { + writeMeasure(mFormat.format((tool.clockwise) ? 134 : 133), "P400"); + } writeMeasure(gFormat.format(212), "H" + probeType.num); writeMeasure(mFormat.format(105)); @@ -1270,7 +1293,7 @@ function writeToolMeasureBlockBIDC(tool) { writeMeasure(gFormat.format(10), "L10 P" + tool.number, xOffset.format(measureTool.machineX())); } if (typeof measureTool.machineZ == 'function') { - writeMeasure(gFormat.format(10), "L10 P" + tool.number, xOffset.format(measureTool.machineZ())); + writeMeasure(gFormat.format(10), "L10 P" + tool.number, zOffset.format(measureTool.machineZ())); } writeln(""); From 351461ed5497951905bc0c55f84217d91b8efc8b Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Mon, 6 Sep 2021 13:23:02 -0400 Subject: [PATCH 09/19] Fixed KM40 probeX --- Haas_Lathes_BIDC/Bechtel ST-20Y.cps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps index 8392f26..780f5af 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps @@ -694,7 +694,7 @@ function getCompleteTool(holder, tool) { }; this.offsetType = (haasType == HAAS_END_MILL) ? "Mill Probe" : "Drill Probe"; - this.probeZ = (haasType == HAAS_END_MILL) ? millX : drillX; + this.probeX = (haasType == HAAS_END_MILL) ? millX : drillX; this.machineX = function() { return holder.x; } From 29ad5f8611afa0c5f743f2f81ec24d2072a9fbe7 Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Mon, 6 Sep 2021 13:54:37 -0400 Subject: [PATCH 10/19] Fixed Radial Probe Direction --- Haas_Lathes_BIDC/Bechtel ST-20Y.cps | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps index 780f5af..a4fca25 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps @@ -586,7 +586,7 @@ function getCompleteTool(holder, tool) { this.holder = holder; this.tool = tool; this.inner = toolSection.getParameter("operation:turningMode") == "inner"; - this.axial = toolSection.getWorkPlane().getElement(0, 0) == 0; + this.radial = toolSection.getWorkPlane().getElement(0, 0) == 0; tool.shankWidth = toolSection.getParameter("operation:tool_shankWidth"); tool.cuttingWidth = toolSection.getParameter("operation:tool_cuttingWidth"); @@ -684,7 +684,6 @@ function getCompleteTool(holder, tool) { }; } else if (holder == KM40A) { - this.offsetType = "General Turning"; var haasType = getHaasToolTypeBIDC(tool.type); var millX = function() { return holder.x - PROBE_CENTERING_OFFSET + tool.diameter; @@ -1243,7 +1242,7 @@ function getToolHolderBIDCST20(toolNum) { } } -function getHaasProbingTypeBIDC(tool, internal, axial) { +function getHaasProbingTypeBIDC(tool, internal, radial) { switch (getHaasToolTypeBIDC(tool.type)) { case BIDC_BORING_TURNING: return SOUTHEAST; @@ -1255,7 +1254,7 @@ function getHaasProbingTypeBIDC(tool, internal, axial) { case HAAS_DRILL: case HAAS_CENTER: case HAAS_END_MILL: - return axial ? EAST : NORTH; + return radial ? NORTH : EAST; default: throw "INVALID PROBING DIRECTION"; } @@ -1267,7 +1266,7 @@ function writeToolMeasureBlockBIDC(tool) { var holder = getToolHolderBIDCST20(tool.number); let measureTool = new getCompleteTool(holder, tool); - var probeType = getHaasProbingTypeBIDC(tool, measureTool.inner, measureTool.axial); + var probeType = getHaasProbingTypeBIDC(tool, measureTool.inner, measureTool.radial); var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; if (compensationOffset > 99) { error(localize("Compensation offset is out of range.")); From d90fdc8a5c8ce776a3767c21f2cbee2cae995153 Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Mon, 6 Sep 2021 15:15:49 -0400 Subject: [PATCH 11/19] Labeled circular movements --- Flow_Waterjet_BIDC/Bechtel Waterjet.cps | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Flow_Waterjet_BIDC/Bechtel Waterjet.cps b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps index 95755f7..13999a4 100644 --- a/Flow_Waterjet_BIDC/Bechtel Waterjet.cps +++ b/Flow_Waterjet_BIDC/Bechtel Waterjet.cps @@ -66,13 +66,13 @@ properties = { {title: "V5", id: "5"}, {title: "V6", id: "6"} ], - value: "5", + value: "6", scope: "post" } }; staticProperties = { - postVersion: "BIDC-FWJ.G8.A21" + postVersion: "BIDC-FWJ.G9.A21" }; // use fixed width instead @@ -342,7 +342,17 @@ function onCircular(clockwise, cx, cy, cz, x, y, z, feed) { var p = getCurrentPosition(); if (useVersion6) { writeComment("Circular"); - + writeBlock( + commentf("X"), ",", + f("Y"), ",", + f("Z"), ",", + fi("CW", 2), ",", + fi("Feed", 5), ",", + fi("C", 2), ",", + fi("?", 2), ",", + f("CX"), ",", + f("CY"), ",", + f("CZ")); writeBlock( f(xyzFormat.format(p.x)), ",", f(xyzFormat.format(p.y)), ",", From 3ac93b0a5eb44b376b19f5212be09b5551dc0d67 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Sep 2021 14:17:21 -0400 Subject: [PATCH 12/19] update on optional tool measure blocks Works when measureToolsAtStart is `false`, however doesn't work when it's `true` --- Haas_Mills_BIDC/Bechtel DT.cps | 4 +- Haas_Mills_BIDC/Bechtel VF2.cps | 87 +++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel DT.cps b/Haas_Mills_BIDC/Bechtel DT.cps index 1a3bd87..d5352a4 100644 --- a/Haas_Mills_BIDC/Bechtel DT.cps +++ b/Haas_Mills_BIDC/Bechtel DT.cps @@ -436,7 +436,7 @@ properties = {/* description: "Tool Probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: true, + value: false, scope: "post" } }; @@ -2405,7 +2405,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { diff --git a/Haas_Mills_BIDC/Bechtel VF2.cps b/Haas_Mills_BIDC/Bechtel VF2.cps index 037c8c9..265c9e8 100644 --- a/Haas_Mills_BIDC/Bechtel VF2.cps +++ b/Haas_Mills_BIDC/Bechtel VF2.cps @@ -438,6 +438,14 @@ properties = {/* type: "boolean", value: true, scope: "post" + }, + loadToolsAtStart: { + title: "Tool Loading", + description: "Tool Loading. By turning this off, you accept responsibility for any resulting crashes.", + group: 99, + type: "boolean", + value: false, + scope: "post" } }; @@ -886,15 +894,16 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - // var writeFunction = measureTool ? writeBlock : writeOptionalBlock; - var writeFunction = writeBlock; + var writeBlockFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + var writeWordsFunction = getProperty("measureToolsAtStart") ? writeWords() : writeWordsOptional; + var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { prepareForToolCheck(); } if (!staticProperties.useP9995) { // use Macro P9023 to measure tools var probingType = getHaasProbingTypeBIDC(tool.type, true); - writeFunction( + writeBlockFunction( gFormat.format(65), "P9023", "A" + probingType + ".", @@ -905,10 +914,10 @@ function writeToolMeasureBlock(tool, preMeasure) { ); } else { // use Macro P9995 to measure tools // writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes"); - setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter"); + setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes", !getProperty("measureToolsAtStart")); + setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter", !getProperty("measureToolsAtStart")); var probeType = getHaasProbingTypeBIDC(tool, false); - writeFunction( + writeBlockFunction( gFormat.format(65), "P9995", "A0.", @@ -921,13 +930,13 @@ function writeToolMeasureBlock(tool, preMeasure) { "I0.", comment ); // probe tool - writeWords("IF [[#" + (2000 + tool.number) + " GT " + + writeWordsFunction("IF [[#" + (2000 + tool.number) + " GT " + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + (2000 + tool.number) + " LT " + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"); if (probeType == 3) { - writeWords("IF [[#" + (2400 + tool.number) + " GT " + + writeWordsFunction("IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"); @@ -939,10 +948,19 @@ function writeToolMeasureBlock(tool, preMeasure) { // 6/28/21 | Gavin Williams | will1742 // 002 Improved Probing // sets specified macro number with value -function setMacro(macro, value, comment) { - writeWords("#" + macro + "=" + value, "(" + comment + ")"); +function setMacro(macro, value, comment, isOptional) { + if (isOptional) { + writeWordsOptional("#" + macro + "=" + value, "(" + comment + ")"); + } else { + writeWords("#" + macro + "=" + value, "(" + comment + ")"); + } +} + +function writeWordsOptional(text) { + writeWords("/ " + text); } + function defineMachineModel() { var useTCPC = getProperty("useTCPC"); switch (staticProperties.machineModel) { @@ -1316,8 +1334,12 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) { + // if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) { + if (true) { var tools = getToolTable(); + + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + if (tools.getNumberOfTools() > 0) { writeln(""); /* @@ -1334,8 +1356,8 @@ function onOpen() { writeComment("Load and probe tools"); // Display general tool probe info - displayMedia("toolProbeReminder.jpg"); - writeBlock(mFormat.format(0)); + displayMedia("toolProbeReminder.jpg", !getProperty("measureToolsAtStart")); + writeFunction(mFormat.format(0)); let parsedTools = []; @@ -1422,15 +1444,12 @@ function onOpen() { comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg"); } comment += " - " + getToolTypeName(tool.type); + writeComment(tool.description); - if (getProperty("measureToolsAtStart")) { - writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg"); - writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); - } else { - writeToolCycleBlock(tool); - } + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("measureToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); } } @@ -2308,7 +2327,7 @@ function onSection() { // writeBlock(gFormat.format(53), "X" + macroFormat.format(100), yOutput.format(0)); writeBlock(gFormat.format(55), gFormat.format(0), xOutput.format(Stock_X_55)); writeBlock(gFormat.format(53), gFormat.format(0), yOutput.format(0)); - displayMedia("loadStock.jpg"); + displayMedia("loadStock.jpg", false); writeBlock(mFormat.format(0)); } @@ -2324,7 +2343,7 @@ function onSection() { writeBlock("T" + toolFormat.format(19), mFormat.format(6)); //Changes Tool writeBlock(gFormat.format(55), gFormat.format(0), forceX.format(stockMidX), forceY.format(stockMidY)); - displayMedia("xyWCSCheck.jpg"); + displayMedia("xyWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); /* displayMedia("Net Share/Media/checkPrompt.jpg"); @@ -2336,7 +2355,7 @@ function onSection() { writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia")); */ writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ)); - displayMedia("zWCSCheck.jpg"); + displayMedia("zWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); writeBlock(mFormat.format(131), formatComment("End Multimedia")); @@ -2398,7 +2417,7 @@ function onSection() { } if (!isFirstSection()) { - displayMedia("checkPartTool.jpg"); + displayMedia("checkPartTool.jpg", false); writeBlock(mFormat.format(0)); writeBlock(mFormat.format(131)); } @@ -2775,7 +2794,7 @@ function onSection() { var toolDistance = initialPosition.z - stockTopZ; // Prompt user to check stock-tool distance - displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg"); + displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg", false); writeBlock(mFormat.format(0)); writeComment("OPEN DOOR"); //displayMedia("Net Share/Media/checkPrompt.jpg"); @@ -2815,8 +2834,12 @@ function onSection() { // Issue 001 Input and Validation // Displays a file: MP4, MOV, PNG, JPEG. 1920x1080 // Input: Absolute path to file -function displayMedia(file) { - writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); +function displayMedia(file, isOptional) { + if (isOptional) { + writeOptionalBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } else { + writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } } // Added 6/14/21 | Gavin Williams | will1742 @@ -2834,7 +2857,7 @@ function takeInput(prompt, options) { if (macroNumber > 549) macroNumber = 500; // init macro var to 0 - setMacro(macroNumber, 0, "Initialize macro variable"); + setMacro(macroNumber, 0, "Initialize macro variable", false); // disply prompt and save response writeBlock(mFormat.format(109), "P" + nFormat.format(macroNumber), formatComment(prompt)); @@ -4516,7 +4539,7 @@ function onClose() { continue; } writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - displayMedia("removeTool" + tool.number + ".jpg"); + displayMedia("removeTool" + tool.number + ".jpg", false); writeBlock(mFormat.format(0)); } } @@ -4524,14 +4547,14 @@ function onClose() { function gotoWithMessage(xLoc, yLoc, fileName) { writeBlock(gFormat.format(53), xOutput.format(xLoc), yOutput.format(yLoc)); - displayMedia(fileName); + displayMedia(fileName, false); writeBlock(mFormat.format(0)); } writeln(""); writeComment("CLEAN MACHINE"); gotoWithMessage(X_TRAVEL_LIMIT/2, 0, "airGunClean.jpg"); - displayMedia("floodCoolantOff.jpg") + displayMedia("floodCoolantOff.jpg", false) writeBlock(mFormat.format(0)); setCoolant(COOLANT_FLOOD); gotoWithMessage(0, Y_TRAVEL_LIMIT, "sprayLowerRight.jpg"); From a199bfcf1521e9c6b9835deaf2befe9dbab61a05 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Sep 2021 15:32:21 -0400 Subject: [PATCH 13/19] Fixed null bug with optional tool measuring --- Haas_Mills_BIDC/Bechtel VF2.cps | 36 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel VF2.cps b/Haas_Mills_BIDC/Bechtel VF2.cps index 265c9e8..aea1f0f 100644 --- a/Haas_Mills_BIDC/Bechtel VF2.cps +++ b/Haas_Mills_BIDC/Bechtel VF2.cps @@ -894,8 +894,7 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - var writeBlockFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; - var writeWordsFunction = getProperty("measureToolsAtStart") ? writeWords() : writeWordsOptional; + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { @@ -903,7 +902,7 @@ function writeToolMeasureBlock(tool, preMeasure) { } if (!staticProperties.useP9995) { // use Macro P9023 to measure tools var probingType = getHaasProbingTypeBIDC(tool.type, true); - writeBlockFunction( + writeFunction( gFormat.format(65), "P9023", "A" + probingType + ".", @@ -917,7 +916,7 @@ function writeToolMeasureBlock(tool, preMeasure) { setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes", !getProperty("measureToolsAtStart")); setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter", !getProperty("measureToolsAtStart")); var probeType = getHaasProbingTypeBIDC(tool, false); - writeBlockFunction( + writeFunction( gFormat.format(65), "P9995", "A0.", @@ -929,17 +928,20 @@ function writeToolMeasureBlock(tool, preMeasure) { "K" + xyzFormat.format(getHaasKFactorBIDC(tool)), "I0.", comment - ); // probe tool - writeWordsFunction("IF [[#" + (2000 + tool.number) + " GT " + + ); // probe tooling + var line1 = "IF [[#" + (2000 + tool.number) + " GT " + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"); - + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); if (probeType == 3) { - writeWordsFunction("IF [[#" + (2400 + tool.number) + " GT " + + var line2 = "IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + - (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"); + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line2 : "/ " + line2); } } measureTool = false; @@ -949,15 +951,11 @@ function writeToolMeasureBlock(tool, preMeasure) { // 002 Improved Probing // sets specified macro number with value function setMacro(macro, value, comment, isOptional) { - if (isOptional) { - writeWordsOptional("#" + macro + "=" + value, "(" + comment + ")"); - } else { - writeWords("#" + macro + "=" + value, "(" + comment + ")"); - } -} - -function writeWordsOptional(text) { - writeWords("/ " + text); + if (isOptional) { + writeWords("/ #" + macro + "=" + value, "(" + comment + ")"); + } else { + writeWords("#" + macro + "=" + value, "(" + comment + ")"); + } } From b080b860838b94d110293b22e3e8b7b8176fcbaf Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Sep 2021 16:41:25 -0400 Subject: [PATCH 14/19] added loadToolsAtStart as a property --- Haas_Mills_BIDC/Bechtel VF2.cps | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel VF2.cps b/Haas_Mills_BIDC/Bechtel VF2.cps index aea1f0f..4ee81e3 100644 --- a/Haas_Mills_BIDC/Bechtel VF2.cps +++ b/Haas_Mills_BIDC/Bechtel VF2.cps @@ -444,7 +444,7 @@ properties = {/* description: "Tool Loading. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: false, + value: true, scope: "post" } }; @@ -1336,7 +1336,7 @@ function onOpen() { if (true) { var tools = getToolTable(); - var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; if (tools.getNumberOfTools() > 0) { writeln(""); @@ -1354,7 +1354,7 @@ function onOpen() { writeComment("Load and probe tools"); // Display general tool probe info - displayMedia("toolProbeReminder.jpg", !getProperty("measureToolsAtStart")); + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); writeFunction(mFormat.format(0)); let parsedTools = []; @@ -1445,7 +1445,7 @@ function onOpen() { writeComment(tool.description); writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("measureToolsAtStart")); + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool writeToolMeasureBlock(tool, true); } From 01d197dcabb25c17e873ea00b1b065c9fecc5aba Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Sep 2021 16:52:42 -0400 Subject: [PATCH 15/19] fixed bug with loadTools and measureTools are both 'false' --- Haas_Lathes_BIDC/Bechtel ST-20.cps | 32 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Haas_Lathes_BIDC/Bechtel ST-20.cps b/Haas_Lathes_BIDC/Bechtel ST-20.cps index 3287952..92bd7cb 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20.cps @@ -356,7 +356,7 @@ properties = { description: "Tool loading and probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: true, + value: false, scope: "post" }, loadToolsAtStart: { @@ -1363,22 +1363,20 @@ function onOpen() { writeln(""); } - if (getProperty("loadToolsAtStart") || getProperty("measureToolsAtStart")) { - writeln(""); - // will1742 | Gavin Williams | 8/10/21 - // Auto probe tools - var tools = getToolTable(); - if (tools.getNumberOfTools() > 0) { - for (var i = 0; i < tools.getNumberOfTools(); ++i) { - var tool = tools.getTool(i); - var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; - var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); - var writeLoad = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; - writeLoad("T" + toolFormat.format((tool.number - 3) >= 1 ? tool.number - 3 : tool.number + 9), mFormat.format(6)); - writeLoad(mFormat.format(0)); - writeComment("LOAD T" + tool.number + ": " + tool.description); - writeToolMeasureBlockBIDC(tool); - } + writeln(""); + // will1742 | Gavin Williams | 8/10/21 + // Auto probe tools + var tools = getToolTable(); + if (tools.getNumberOfTools() > 0) { + for (var i = 0; i < tools.getNumberOfTools(); ++i) { + var tool = tools.getTool(i); + var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; + var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); + var writeLoad = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + writeLoad("T" + toolFormat.format((tool.number - 3) >= 1 ? tool.number - 3 : tool.number + 9), mFormat.format(6)); + writeLoad(mFormat.format(0)); + writeComment("LOAD T" + tool.number + ": " + tool.description); + writeToolMeasureBlockBIDC(tool); } } From f09c2ecde0148a5c9412a876e42f756e9e62ddb4 Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 6 Sep 2021 14:46:19 -0400 Subject: [PATCH 16/19] propagated VF2 changes to VF4 and DT --- Haas_Mills_BIDC/Bechtel DT.cps | 101 ++++++++++++++++++++------------ Haas_Mills_BIDC/Bechtel VF4.cps | 93 +++++++++++++++++++---------- 2 files changed, 126 insertions(+), 68 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel DT.cps b/Haas_Mills_BIDC/Bechtel DT.cps index d5352a4..184e038 100644 --- a/Haas_Mills_BIDC/Bechtel DT.cps +++ b/Haas_Mills_BIDC/Bechtel DT.cps @@ -436,7 +436,15 @@ properties = {/* description: "Tool Probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: false, + value: true, + scope: "post" + }, + loadToolsAtStart: { + title: "Tool Loading", + description: "Tool Loading. By turning this off, you accept responsibility for any resulting crashes.", + group: 99, + type: "boolean", + value: true, scope: "post" } }; @@ -886,8 +894,8 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - // var writeFunction = measureTool ? writeBlock : writeOptionalBlock; - var writeFunction = writeBlock; + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + // var writeFunction = writeBlock; var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { prepareForToolCheck(); @@ -905,8 +913,8 @@ function writeToolMeasureBlock(tool, preMeasure) { ); } else { // use Macro P9995 to measure tools // writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes"); - setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter"); + setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes", !getProperty("measureToolsAtStart")); + setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter", !getProperty("measureToolsAtStart")); var probeType = getHaasProbingTypeBIDC(tool, false); writeFunction( gFormat.format(65), @@ -921,16 +929,20 @@ function writeToolMeasureBlock(tool, preMeasure) { "I0.", comment ); // probe tool - writeWords("IF [[#" + (2000 + tool.number) + " GT " + + line1 = "IF [[#" + (2000 + tool.number) + " GT " + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"); + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); if (probeType == 3) { - writeWords("IF [[#" + (2400 + tool.number) + " GT " + + line2 = "IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + - (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"); + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line2 : "/ " + line2); } } measureTool = false; @@ -939,8 +951,12 @@ function writeToolMeasureBlock(tool, preMeasure) { // 6/28/21 | Gavin Williams | will1742 // 002 Improved Probing // sets specified macro number with value -function setMacro(macro, value, comment) { - writeWords("#" + macro + "=" + value, "(" + comment + ")"); +function setMacro(macro, value, comment, isOptional) { + if (isOptional) { + writeWords("/ #" + macro + "=" + value, "(" + comment + ")"); + } else { + writeWords("#" + macro + "=" + value, "(" + comment + ")"); + } } function defineMachineModel() { @@ -1316,8 +1332,11 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) { + if (true) { var tools = getToolTable(); + + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + if (tools.getNumberOfTools() > 0) { writeln(""); /* @@ -1333,11 +1352,13 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 writeComment("Load and probe tools"); - displayMedia("toolProbeReminder.jpg"); - writeBlock(mFormat.format(0)); + // Display general tool probe info + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0)); let parsedTools = []; + // Maybe should be anonymous function?? function defaultFill() { parsedTools = [] for (var i = 0; i < tools.getNumberOfTools(); i++){ @@ -1345,19 +1366,25 @@ function onOpen() { } } - function validateToolNum(toolNum) { + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); } + // parse string for specific tools to load if (getProperty("toolsToLoad") != "") { + // get list of numbers let toolNumArray = getProperty("toolsToLoad").split(','); + // iterate through and fill ranges for (var i = 0; i < toolNumArray.length; i++){ toolNumArray[i] = toolNumArray[i].trim(); + // fill range if (toolNumArray[i].indexOf("-") >= 0) { let numRange = toolNumArray[i].split("-"); - if (validateToolNum(parseInt(numRange[0])) || validateToolNum(parseInt(numRange[1]))) { + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } @@ -1366,10 +1393,12 @@ function onOpen() { } continue; } - if (validateToolNum(parseInt(toolNumArray[i]))) { + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { defaultFill(); break; } + // push single num parsedTools.push(parseInt(toolNumArray[i])); } } else { @@ -1413,14 +1442,10 @@ function onOpen() { } comment += " - " + getToolTypeName(tool.type); writeComment(tool.description); - if (getProperty("measureToolsAtStart")) { - writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg"); - writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); - } else { - writeToolCycleBlock(tool); - } + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); } } @@ -2296,7 +2321,7 @@ function onSection() { // writeBlock(gFormat.format(53), "X" + macroFormat.format(100), yOutput.format(0)); writeBlock(gFormat.format(55), gFormat.format(0), xOutput.format(Stock_X_55)); writeBlock(gFormat.format(53), gFormat.format(0), yOutput.format(0)); - displayMedia("loadStock.jpg"); + displayMedia("loadStock.jpg", false); writeBlock(mFormat.format(0)); } @@ -2312,7 +2337,7 @@ function onSection() { writeBlock("T" + toolFormat.format(19), mFormat.format(6)); //Changes Tool writeBlock(gFormat.format(55), gFormat.format(0), forceX.format(stockMidX), forceY.format(stockMidY)); - displayMedia("xyWCSCheck.jpg"); + displayMedia("xyWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); /* displayMedia("Net Share/Media/checkPrompt.jpg"); @@ -2324,7 +2349,7 @@ function onSection() { writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia")); */ writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ)); - displayMedia("zWCSCheck.jpg"); + displayMedia("zWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); writeBlock(mFormat.format(131), formatComment("End Multimedia")); @@ -2386,7 +2411,7 @@ function onSection() { } if (!isFirstSection()) { - displayMedia("checkPartTool.jpg"); + displayMedia("checkPartTool.jpg", false); writeBlock(mFormat.format(0)); writeBlock(mFormat.format(131)); } @@ -2763,7 +2788,7 @@ function onSection() { var toolDistance = initialPosition.z - stockTopZ; // Prompt user to check stock-tool distance - displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg"); + displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg", false); writeBlock(mFormat.format(0)); writeComment("OPEN DOOR"); //displayMedia("Net Share/Media/checkPrompt.jpg"); @@ -2803,8 +2828,12 @@ function onSection() { // Issue 001 Input and Validation // Displays a file: MP4, MOV, PNG, JPEG. 1920x1080 // Input: Absolute path to file -function displayMedia(file) { - writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); +function displayMedia(file, isOptional) { + if (isOptional) { + writeOptionalBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } else { + writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } } // Added 6/14/21 | Gavin Williams | will1742 @@ -2822,7 +2851,7 @@ function takeInput(prompt, options) { if (macroNumber > 549) macroNumber = 500; // init macro var to 0 - setMacro(macroNumber, 0, "Initialize macro variable"); + setMacro(macroNumber, 0, "Initialize macro variable", false); // disply prompt and save response writeBlock(mFormat.format(109), "P" + nFormat.format(macroNumber), formatComment(prompt)); @@ -4504,7 +4533,7 @@ function onClose() { continue; } writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - displayMedia("removeTool" + tool.number + ".jpg"); + displayMedia("removeTool" + tool.number + ".jpg", false); writeBlock(mFormat.format(0)); } } @@ -4512,14 +4541,14 @@ function onClose() { function gotoWithMessage(xLoc, yLoc, fileName) { writeBlock(gFormat.format(53), xOutput.format(xLoc), yOutput.format(yLoc)); - displayMedia(fileName); + displayMedia(fileName, false); writeBlock(mFormat.format(0)); } writeln(""); writeComment("CLEAN MACHINE"); gotoWithMessage(X_TRAVEL_LIMIT/2, 0, "airGunClean.jpg"); - displayMedia("floodCoolantOff.jpg") + displayMedia("floodCoolantOff.jpg", false) writeBlock(mFormat.format(0)); setCoolant(COOLANT_FLOOD); gotoWithMessage(0, Y_TRAVEL_LIMIT, "sprayLowerRight.jpg"); diff --git a/Haas_Mills_BIDC/Bechtel VF4.cps b/Haas_Mills_BIDC/Bechtel VF4.cps index 29a6290..c37b6a3 100644 --- a/Haas_Mills_BIDC/Bechtel VF4.cps +++ b/Haas_Mills_BIDC/Bechtel VF4.cps @@ -438,6 +438,14 @@ properties = {/* type: "boolean", value: true, scope: "post" + }, + loadToolsAtStart: { + title: "Tool Loading", + description: "Tool Loading. By turning this off, you accept responsibility for any resulting crashes.", + group: 99, + type: "boolean", + value: true, + scope: "post" } }; @@ -886,8 +894,8 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - // var writeFunction = measureTool ? writeBlock : writeOptionalBlock; - var writeFunction = writeBlock; + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + // var writeFunction = writeBlock; var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { prepareForToolCheck(); @@ -905,8 +913,8 @@ function writeToolMeasureBlock(tool, preMeasure) { ); } else { // use Macro P9995 to measure tools // writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes"); - setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter"); + setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes", !getProperty("measureToolsAtStart")); + setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter", !getProperty("measureToolsAtStart")); var probeType = getHaasProbingTypeBIDC(tool, false); writeFunction( gFormat.format(65), @@ -921,16 +929,20 @@ function writeToolMeasureBlock(tool, preMeasure) { "I0.", comment ); // probe tool - writeWords("IF [[#" + (2000 + tool.number) + " GT " + + line1 = "IF [[#" + (2000 + tool.number) + " GT " + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"); + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); if (probeType == 3) { - writeWords("IF [[#" + (2400 + tool.number) + " GT " + + line2 = "IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + - (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"); + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line2 : "/ " + line2); } } measureTool = false; @@ -939,8 +951,12 @@ function writeToolMeasureBlock(tool, preMeasure) { // 6/28/21 | Gavin Williams | will1742 // 002 Improved Probing // sets specified macro number with value -function setMacro(macro, value, comment) { - writeWords("#" + macro + "=" + value, "(" + comment + ")"); +function setMacro(macro, value, comment, isOptional) { + if (isOptional) { + writeWords("/ #" + macro + "=" + value, "(" + comment + ")"); + } else { + writeWords("#" + macro + "=" + value, "(" + comment + ")"); + } } function defineMachineModel() { @@ -1316,8 +1332,11 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) { + if (true) { var tools = getToolTable(); + + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + if (tools.getNumberOfTools() > 0) { writeln(""); /* @@ -1333,11 +1352,13 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 writeComment("Load and probe tools"); - displayMedia("toolProbeReminder.jpg"); - writeBlock(mFormat.format(0)); + // Display general tool probe info + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0)); let parsedTools = []; + // Maybe should be anonymous function?? function defaultFill() { parsedTools = [] for (var i = 0; i < tools.getNumberOfTools(); i++){ @@ -1345,19 +1366,25 @@ function onOpen() { } } - function validateToolNum(toolNum) { + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); } - + + // parse string for specific tools to load if (getProperty("toolsToLoad") != "") { + // get list of numbers let toolNumArray = getProperty("toolsToLoad").split(','); + // iterate through and fill ranges for (var i = 0; i < toolNumArray.length; i++){ toolNumArray[i] = toolNumArray[i].trim(); + // fill range if (toolNumArray[i].indexOf("-") >= 0) { let numRange = toolNumArray[i].split("-"); - if (validateToolNum(parseInt(numRange[0])) || validateToolNum(parseInt(numRange[1]))) { + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } @@ -1366,10 +1393,12 @@ function onOpen() { } continue; } - if (validateToolNum(parseInt(toolNumArray[i]))) { + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { defaultFill(); break; } + // push single num parsedTools.push(parseInt(toolNumArray[i])); } } else { @@ -1413,14 +1442,10 @@ function onOpen() { } comment += " - " + getToolTypeName(tool.type); writeComment(tool.description); - if (getProperty("measureToolsAtStart")) { - writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg"); - writeBlock(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); - } else { - writeToolCycleBlock(tool); - } + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); } } @@ -2410,7 +2435,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { @@ -2808,8 +2833,12 @@ function onSection() { // Issue 001 Input and Validation // Displays a file: MP4, MOV, PNG, JPEG. 1920x1080 // Input: Absolute path to file -function displayMedia(file) { - writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); +function displayMedia(file, isOptional) { + if (isOptional) { + writeOptionalBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } else { + writeBlock(mFormat.format(130), formatComment("Net Share/Media/" + file)); + } } // Added 6/14/21 | Gavin Williams | will1742 @@ -2827,7 +2856,7 @@ function takeInput(prompt, options) { if (macroNumber > 549) macroNumber = 500; // init macro var to 0 - setMacro(macroNumber, 0, "Initialize macro variable"); + setMacro(macroNumber, 0, "Initialize macro variable", false); // disply prompt and save response writeBlock(mFormat.format(109), "P" + nFormat.format(macroNumber), formatComment(prompt)); @@ -4509,7 +4538,7 @@ function onClose() { continue; } writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); // get tool - displayMedia("removeTool" + tool.number + ".jpg"); + displayMedia("removeTool" + tool.number + ".jpg", false); writeBlock(mFormat.format(0)); } } @@ -4517,14 +4546,14 @@ function onClose() { function gotoWithMessage(xLoc, yLoc, fileName) { writeBlock(gFormat.format(53), xOutput.format(xLoc), yOutput.format(yLoc)); - displayMedia(fileName); + displayMedia(fileName, false); writeBlock(mFormat.format(0)); } writeln(""); writeComment("CLEAN MACHINE"); gotoWithMessage(X_TRAVEL_LIMIT/2, 0, "airGunClean.jpg"); - displayMedia("floodCoolantOff.jpg") + displayMedia("floodCoolantOff.jpg", false) writeBlock(mFormat.format(0)); setCoolant(COOLANT_FLOOD); gotoWithMessage(0, Y_TRAVEL_LIMIT, "sprayLowerRight.jpg"); From cf16a32e81861903b27f580de6371b7517afb41b Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 6 Sep 2021 15:02:22 -0400 Subject: [PATCH 17/19] Updated ST-20Y Fixed ST-20Y bug, same issue as ST-20 (when both load and measure tool properties are false, no blocks would print) --- Haas_Lathes_BIDC/Bechtel ST-20Y.cps | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps index a4fca25..da4ba9b 100644 --- a/Haas_Lathes_BIDC/Bechtel ST-20Y.cps +++ b/Haas_Lathes_BIDC/Bechtel ST-20Y.cps @@ -356,7 +356,7 @@ properties = { description: "Tool loading and probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: true, + value: false, scope: "post" }, loadToolsAtStart: { @@ -364,7 +364,7 @@ properties = { description: "Tool loading only. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: true, + value: false, scope: "post" } }; @@ -1440,25 +1440,25 @@ function onOpen() { writeln(""); } - if (getProperty("loadToolsAtStart") || getProperty("measureToolsAtStart")) { - writeln(""); - // will1742 | Gavin Williams | 8/10/21 - // Auto probe tools - var tools = getToolTable(); - if (tools.getNumberOfTools() > 0) { - for (var i = 0; i < tools.getNumberOfTools(); ++i) { - var tool = tools.getTool(i); - var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; - var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); - var writeLoad = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; - writeLoad("T" + toolFormat.format((tool.number - 3) >= 1 ? tool.number - 3 : tool.number + 9), mFormat.format(6)); - writeLoad(mFormat.format(0)); - writeComment("LOAD T" + tool.number + ": " + tool.description); - writeToolMeasureBlockBIDC(tool); - } + + writeln(""); + // will1742 | Gavin Williams | 8/10/21 + // Auto probe tools + var tools = getToolTable(); + if (tools.getNumberOfTools() > 0) { + for (var i = 0; i < tools.getNumberOfTools(); ++i) { + var tool = tools.getTool(i); + var compensationOffset = tool.isTurningTool() ? tool.compensationOffset : tool.lengthOffset; + var toolPosition = toolFormat.format(tool.number * 100 + compensationOffset % 100); + var writeLoad = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + writeLoad("T" + toolFormat.format((tool.number - 3) >= 1 ? tool.number - 3 : tool.number + 9), mFormat.format(6)); + writeLoad(mFormat.format(0)); + writeComment("LOAD T" + tool.number + ": " + tool.description); + writeToolMeasureBlockBIDC(tool); } } + if (false) { // check for duplicate tool number for (var i = 0; i < getNumberOfSections(); ++i) { From 9365375c3f8f2ab45da815b33058008c523fb18e Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Mon, 6 Sep 2021 16:13:59 -0400 Subject: [PATCH 18/19] Measure/load independently optional --- Haas_Mills_BIDC/Bechtel DT.cps | 220 +++++++++++++++--------------- Haas_Mills_BIDC/Bechtel VF2.cps | 202 ++++++++++++++-------------- Haas_Mills_BIDC/Bechtel VF4.cps | 229 ++++++++++++++++---------------- 3 files changed, 320 insertions(+), 331 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel DT.cps b/Haas_Mills_BIDC/Bechtel DT.cps index 184e038..2a04feb 100644 --- a/Haas_Mills_BIDC/Bechtel DT.cps +++ b/Haas_Mills_BIDC/Bechtel DT.cps @@ -928,17 +928,16 @@ function writeToolMeasureBlock(tool, preMeasure) { "K" + xyzFormat.format(getHaasKFactorBIDC(tool)), "I0.", comment - ); // probe tool - line1 = "IF [[#" + (2000 + tool.number) + " GT " + - (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + - (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; - - writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); - - if (probeType == 3) { - line2 = "IF [[#" + (2400 + tool.number) + " GT " + - (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + + ); // probe tooling + var line1 = "IF [[#" + (2000 + tool.number) + " GT " + + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + + (2000 + tool.number) + " LT " + + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); + if (probeType == 3) { + var line2 = "IF [[#" + (2400 + tool.number) + " GT " + + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; @@ -1332,128 +1331,127 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (true) { - var tools = getToolTable(); + var tools = getToolTable(); - var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; - if (tools.getNumberOfTools() > 0) { - writeln(""); - /* - writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator - writeComment(localize("With BLOCK DELETE turned off each tool will cycle through")); - writeComment(localize("the spindle to verify that the correct tool is in the tool magazine")); - if (getProperty("optionallyMeasureToolsAtStart")) { - writeComment(localize("and to automatically measure it")); - } - writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); - */ + if (tools.getNumberOfTools() > 0) { + writeln(""); + /* + writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator + writeComment(localize("With BLOCK DELETE turned off each tool will cycle through")); + writeComment(localize("the spindle to verify that the correct tool is in the tool magazine")); + if (getProperty("optionallyMeasureToolsAtStart")) { + writeComment(localize("and to automatically measure it")); + } + writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); + */ - // 6/21/21 | Gavin Williams | will1742 - writeComment("Load and probe tools"); + // 6/21/21 | Gavin Williams | will1742 + writeComment("Load and probe tools"); - // Display general tool probe info - displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); - writeFunction(mFormat.format(0)); + // Display general tool probe info + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0)); - let parsedTools = []; + let parsedTools = []; - // Maybe should be anonymous function?? - function defaultFill() { - parsedTools = [] - for (var i = 0; i < tools.getNumberOfTools(); i++){ - parsedTools[i] = tools.getTool(i).number; - } + // Maybe should be anonymous function?? + function defaultFill() { + parsedTools = [] + for (var i = 0; i < tools.getNumberOfTools(); i++){ + parsedTools[i] = tools.getTool(i).number; } + } - // also maybe anonymous - // TODO: tool.getNumberOfTools needs to be machine-specific constant - function invalidToolNum(toolNum) { - return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); - } + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { + return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); + } - // parse string for specific tools to load - if (getProperty("toolsToLoad") != "") { - // get list of numbers - let toolNumArray = getProperty("toolsToLoad").split(','); - - // iterate through and fill ranges - for (var i = 0; i < toolNumArray.length; i++){ - toolNumArray[i] = toolNumArray[i].trim(); - - // fill range - if (toolNumArray[i].indexOf("-") >= 0) { - let numRange = toolNumArray[i].split("-"); - if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { - defaultFill(); - break; - } - for(var j = numRange[0]; j <= numRange[1]; j++){ - parsedTools.push(parseInt(j)); - } - continue; - } - // check if valid num - if (invalidToolNum(parseInt(toolNumArray[i]))) { + // parse string for specific tools to load + if (getProperty("toolsToLoad") != "") { + // get list of numbers + let toolNumArray = getProperty("toolsToLoad").split(','); + + // iterate through and fill ranges + for (var i = 0; i < toolNumArray.length; i++){ + toolNumArray[i] = toolNumArray[i].trim(); + + // fill range + if (toolNumArray[i].indexOf("-") >= 0) { + let numRange = toolNumArray[i].split("-"); + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } - // push single num - parsedTools.push(parseInt(toolNumArray[i])); - } - } else { - defaultFill(); - } - - for (var i = 0; i < tools.getNumberOfTools(); i++) { - var tool = tools.getTool(i); - if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) { - throw "Error: T" + tool.number + " length greater than machine max" + for(var j = numRange[0]; j <= numRange[1]; j++){ + parsedTools.push(parseInt(j)); + } + continue; } - - if (tool.diameter > MAX_TOOL_DIAM) { - throw "Error : T" + tool.number + " diameter greater than machine max" + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { + defaultFill(); + break; } + // push single num + parsedTools.push(parseInt(toolNumArray[i])); + } + } else { + defaultFill(); + } - if (parsedTools.indexOf(tool.number) <= -1) { - continue; - } + for (var i = 0; i < tools.getNumberOfTools(); i++) { + var tool = tools.getTool(i); + if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) { + throw "Error: T" + tool.number + " length greater than machine max" + } - if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) { - continue; - } + if (tool.diameter > MAX_TOOL_DIAM) { + throw "Error : T" + tool.number + " diameter greater than machine max" + } - // 07/16/21 | will1742 | Gavin Williams - // Verify tool numbers - if (tool.number == 20 && tool.type != TOOL_PROBE) { - throw "Error: T20 is reserved for Probe"; - } + if (parsedTools.indexOf(tool.number) <= -1) { + continue; + } - if (tool.number == 19) { - throw "Error: T19 is reserved for WCS verification tool"; - } + if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) { + continue; + } - writeln(""); - var comment = "T" + toolFormat.format(tool.number) + " " + - "D=" + xyzFormat.format(tool.diameter) + " " + - localize("CR") + "=" + xyzFormat.format(tool.cornerRadius); - if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { - comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg"); - } - comment += " - " + getToolTypeName(tool.type); - writeComment(tool.description); - writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); - writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); + // 07/16/21 | will1742 | Gavin Williams + // Verify tool numbers + if (tool.number == 20 && tool.type != TOOL_PROBE) { + throw "Error: T20 is reserved for Probe"; } - } - writeln(""); - writeComment("SETUP FOR OPERATION"); - writeBlock(mFormat.format(131)); + if (tool.number == 19) { + throw "Error: T19 is reserved for WCS verification tool"; + } + + writeln(""); + var comment = "T" + toolFormat.format(tool.number) + " " + + "D=" + xyzFormat.format(tool.diameter) + " " + + localize("CR") + "=" + xyzFormat.format(tool.cornerRadius); + if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { + comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg"); + } + comment += " - " + getToolTypeName(tool.type); + + writeComment(tool.description); + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); + } } + writeln(""); + writeComment("SETUP FOR OPERATION"); + writeFunction(mFormat.format(131)); + if (staticProperties.useDWO) { var failed = false; var dynamicWCSs = {}; @@ -2430,7 +2428,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { diff --git a/Haas_Mills_BIDC/Bechtel VF2.cps b/Haas_Mills_BIDC/Bechtel VF2.cps index 4ee81e3..108f24e 100644 --- a/Haas_Mills_BIDC/Bechtel VF2.cps +++ b/Haas_Mills_BIDC/Bechtel VF2.cps @@ -958,7 +958,6 @@ function setMacro(macro, value, comment, isOptional) { } } - function defineMachineModel() { var useTCPC = getProperty("useTCPC"); switch (staticProperties.machineModel) { @@ -1332,132 +1331,127 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - // if (staticProperties.optionallyCycleToolsAtStart || getProperty("measureToolsAtStart")) { - if (true) { - var tools = getToolTable(); + var tools = getToolTable(); - var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; - if (tools.getNumberOfTools() > 0) { - writeln(""); - /* - writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator - writeComment(localize("With BLOCK DELETE turned off each tool will cycle through")); - writeComment(localize("the spindle to verify that the correct tool is in the tool magazine")); - if (getProperty("optionallyMeasureToolsAtStart")) { - writeComment(localize("and to automatically measure it")); - } - writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); - */ + if (tools.getNumberOfTools() > 0) { + writeln(""); + /* + writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator + writeComment(localize("With BLOCK DELETE turned off each tool will cycle through")); + writeComment(localize("the spindle to verify that the correct tool is in the tool magazine")); + if (getProperty("optionallyMeasureToolsAtStart")) { + writeComment(localize("and to automatically measure it")); + } + writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); + */ - // 6/21/21 | Gavin Williams | will1742 - writeComment("Load and probe tools"); + // 6/21/21 | Gavin Williams | will1742 + writeComment("Load and probe tools"); - // Display general tool probe info - displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); - writeFunction(mFormat.format(0)); + // Display general tool probe info + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0)); - let parsedTools = []; + let parsedTools = []; - // Maybe should be anonymous function?? - function defaultFill() { - parsedTools = [] - for (var i = 0; i < tools.getNumberOfTools(); i++){ - parsedTools[i] = tools.getTool(i).number; - } + // Maybe should be anonymous function?? + function defaultFill() { + parsedTools = [] + for (var i = 0; i < tools.getNumberOfTools(); i++){ + parsedTools[i] = tools.getTool(i).number; } + } - // also maybe anonymous - // TODO: tool.getNumberOfTools needs to be machine-specific constant - function invalidToolNum(toolNum) { - return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); - } + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { + return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); + } - // parse string for specific tools to load - if (getProperty("toolsToLoad") != "") { - // get list of numbers - let toolNumArray = getProperty("toolsToLoad").split(','); - - // iterate through and fill ranges - for (var i = 0; i < toolNumArray.length; i++){ - toolNumArray[i] = toolNumArray[i].trim(); - - // fill range - if (toolNumArray[i].indexOf("-") >= 0) { - let numRange = toolNumArray[i].split("-"); - if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { - defaultFill(); - break; - } - for(var j = numRange[0]; j <= numRange[1]; j++){ - parsedTools.push(parseInt(j)); - } - continue; - } - // check if valid num - if (invalidToolNum(parseInt(toolNumArray[i]))) { + // parse string for specific tools to load + if (getProperty("toolsToLoad") != "") { + // get list of numbers + let toolNumArray = getProperty("toolsToLoad").split(','); + + // iterate through and fill ranges + for (var i = 0; i < toolNumArray.length; i++){ + toolNumArray[i] = toolNumArray[i].trim(); + + // fill range + if (toolNumArray[i].indexOf("-") >= 0) { + let numRange = toolNumArray[i].split("-"); + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } - // push single num - parsedTools.push(parseInt(toolNumArray[i])); - } - } else { - defaultFill(); - } - - for (var i = 0; i < tools.getNumberOfTools(); i++) { - var tool = tools.getTool(i); - if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) { - throw "Error: T" + tool.number + " length greater than machine max" + for(var j = numRange[0]; j <= numRange[1]; j++){ + parsedTools.push(parseInt(j)); + } + continue; } - - if (tool.diameter > MAX_TOOL_DIAM) { - throw "Error : T" + tool.number + " diameter greater than machine max" + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { + defaultFill(); + break; } + // push single num + parsedTools.push(parseInt(toolNumArray[i])); + } + } else { + defaultFill(); + } - if (parsedTools.indexOf(tool.number) <= -1) { - continue; - } + for (var i = 0; i < tools.getNumberOfTools(); i++) { + var tool = tools.getTool(i); + if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) { + throw "Error: T" + tool.number + " length greater than machine max" + } - if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) { - continue; - } + if (tool.diameter > MAX_TOOL_DIAM) { + throw "Error : T" + tool.number + " diameter greater than machine max" + } - // 07/16/21 | will1742 | Gavin Williams - // Verify tool numbers - if (tool.number == 20 && tool.type != TOOL_PROBE) { - throw "Error: T20 is reserved for Probe"; - } + if (parsedTools.indexOf(tool.number) <= -1) { + continue; + } - if (tool.number == 19) { - throw "Error: T19 is reserved for WCS verification tool"; - } + if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) { + continue; + } - writeln(""); - var comment = "T" + toolFormat.format(tool.number) + " " + - "D=" + xyzFormat.format(tool.diameter) + " " + - localize("CR") + "=" + xyzFormat.format(tool.cornerRadius); - if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { - comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg"); - } - comment += " - " + getToolTypeName(tool.type); + // 07/16/21 | will1742 | Gavin Williams + // Verify tool numbers + if (tool.number == 20 && tool.type != TOOL_PROBE) { + throw "Error: T20 is reserved for Probe"; + } - writeComment(tool.description); - writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); - writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); + if (tool.number == 19) { + throw "Error: T19 is reserved for WCS verification tool"; } - } - writeln(""); - writeComment("SETUP FOR OPERATION"); - writeBlock(mFormat.format(131)); - } else { - writeComment("SETUP FOR OPERATION"); + writeln(""); + var comment = "T" + toolFormat.format(tool.number) + " " + + "D=" + xyzFormat.format(tool.diameter) + " " + + localize("CR") + "=" + xyzFormat.format(tool.cornerRadius); + if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { + comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg"); + } + comment += " - " + getToolTypeName(tool.type); + + writeComment(tool.description); + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); + } } + writeln(""); + writeComment("SETUP FOR OPERATION"); + writeFunction(mFormat.format(131)); + if (staticProperties.useDWO) { var failed = false; var dynamicWCSs = {}; @@ -2434,7 +2428,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { diff --git a/Haas_Mills_BIDC/Bechtel VF4.cps b/Haas_Mills_BIDC/Bechtel VF4.cps index c37b6a3..882c1c2 100644 --- a/Haas_Mills_BIDC/Bechtel VF4.cps +++ b/Haas_Mills_BIDC/Bechtel VF4.cps @@ -928,16 +928,15 @@ function writeToolMeasureBlock(tool, preMeasure) { "K" + xyzFormat.format(getHaasKFactorBIDC(tool)), "I0.", comment - ); // probe tool - line1 = "IF [[#" + (2000 + tool.number) + " GT " + - (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + - (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; - - writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); - - if (probeType == 3) { - line2 = "IF [[#" + (2400 + tool.number) + " GT " + + ); // probe tooling + var line1 = "IF [[#" + (2000 + tool.number) + " GT " + + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + + (2000 + tool.number) + " LT " + + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); + if (probeType == 3) { + var line2 = "IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; @@ -1332,128 +1331,126 @@ function onOpen() { // 6/21/21 | Gavin Williams | will1742 // Probing now required. Using P9995. // optionally cycle through all tools - if (true) { - var tools = getToolTable(); + var tools = getToolTable(); - var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; + var writeFunction = getProperty("loadToolsAtStart") ? writeBlock : writeOptionalBlock; - if (tools.getNumberOfTools() > 0) { - writeln(""); - /* - writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator - writeComment(localize("With BLOCK DELETE turned off each tool will cycle through")); - writeComment(localize("the spindle to verify that the correct tool is in the tool magazine")); - if (getProperty("optionallyMeasureToolsAtStart")) { - writeComment(localize("and to automatically measure it")); - } - writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); - */ + if (tools.getNumberOfTools() > 0) { + writeln(""); + /* + writeOptionalBlock(mFormat.format(0), formatComment(localize("Read note"))); // wait for operator + writeComment(localize("With BLOCK DELETE turned off each tool will cycle through")); + writeComment(localize("the spindle to verify that the correct tool is in the tool magazine")); + if (getProperty("optionallyMeasureToolsAtStart")) { + writeComment(localize("and to automatically measure it")); + } + writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); + */ - // 6/21/21 | Gavin Williams | will1742 - writeComment("Load and probe tools"); + // 6/21/21 | Gavin Williams | will1742 + writeComment("Load and probe tools"); - // Display general tool probe info - displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); - writeFunction(mFormat.format(0)); + // Display general tool probe info + displayMedia("toolProbeReminder.jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0)); - let parsedTools = []; + let parsedTools = []; - // Maybe should be anonymous function?? - function defaultFill() { - parsedTools = [] - for (var i = 0; i < tools.getNumberOfTools(); i++){ - parsedTools[i] = tools.getTool(i).number; - } + // Maybe should be anonymous function?? + function defaultFill() { + parsedTools = [] + for (var i = 0; i < tools.getNumberOfTools(); i++){ + parsedTools[i] = tools.getTool(i).number; } + } - // also maybe anonymous - // TODO: tool.getNumberOfTools needs to be machine-specific constant - function invalidToolNum(toolNum) { - return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); - } - - // parse string for specific tools to load - if (getProperty("toolsToLoad") != "") { - // get list of numbers - let toolNumArray = getProperty("toolsToLoad").split(','); - - // iterate through and fill ranges - for (var i = 0; i < toolNumArray.length; i++){ - toolNumArray[i] = toolNumArray[i].trim(); - - // fill range - if (toolNumArray[i].indexOf("-") >= 0) { - let numRange = toolNumArray[i].split("-"); - if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { - defaultFill(); - break; - } - for(var j = numRange[0]; j <= numRange[1]; j++){ - parsedTools.push(parseInt(j)); - } - continue; - } - // check if valid num - if (invalidToolNum(parseInt(toolNumArray[i]))) { + // also maybe anonymous + // TODO: tool.getNumberOfTools needs to be machine-specific constant + function invalidToolNum(toolNum) { + return (toolNum < 1 || toolNum > tools.getNumberOfTools() || tools.getTool(toolNum) == undefined); + } + + // parse string for specific tools to load + if (getProperty("toolsToLoad") != "") { + // get list of numbers + let toolNumArray = getProperty("toolsToLoad").split(','); + + // iterate through and fill ranges + for (var i = 0; i < toolNumArray.length; i++){ + toolNumArray[i] = toolNumArray[i].trim(); + + // fill range + if (toolNumArray[i].indexOf("-") >= 0) { + let numRange = toolNumArray[i].split("-"); + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { defaultFill(); break; } - // push single num - parsedTools.push(parseInt(toolNumArray[i])); - } - } else { - defaultFill(); - } - - for (var i = 0; i < tools.getNumberOfTools(); i++) { - var tool = tools.getTool(i); - if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) { - throw "Error: T" + tool.number + " length greater than machine max" + for(var j = numRange[0]; j <= numRange[1]; j++){ + parsedTools.push(parseInt(j)); + } + continue; } - - if (tool.diameter > MAX_TOOL_DIAM) { - throw "Error : T" + tool.number + " diameter greater than machine max" + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { + defaultFill(); + break; } + // push single num + parsedTools.push(parseInt(toolNumArray[i])); + } + } else { + defaultFill(); + } - if (parsedTools.indexOf(tool.number) <= -1) { - continue; - } + for (var i = 0; i < tools.getNumberOfTools(); i++) { + var tool = tools.getTool(i); + if (tool.bodyLength + tool.holderLength > MAX_TOOL_LENGTH) { + throw "Error: T" + tool.number + " length greater than machine max" + } - if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) { - continue; - } + if (tool.diameter > MAX_TOOL_DIAM) { + throw "Error : T" + tool.number + " diameter greater than machine max" + } - // 07/16/21 | will1742 | Gavin Williams - // Verify tool numbers - if (tool.number == 20 && tool.type != TOOL_PROBE) { - throw "Error: T20 is reserved for Probe"; - } + if (parsedTools.indexOf(tool.number) <= -1) { + continue; + } - if (tool.number == 19) { - throw "Error: T19 is reserved for WCS verification tool"; - } + if (getProperty("measureToolsAtStart") && (tool.type == TOOL_PROBE)) { + continue; + } - writeln(""); - var comment = "T" + toolFormat.format(tool.number) + " " + - "D=" + xyzFormat.format(tool.diameter) + " " + - localize("CR") + "=" + xyzFormat.format(tool.cornerRadius); - if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { - comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg"); - } - comment += " - " + getToolTypeName(tool.type); - writeComment(tool.description); - writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); - writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool - writeToolMeasureBlock(tool, true); + // 07/16/21 | will1742 | Gavin Williams + // Verify tool numbers + if (tool.number == 20 && tool.type != TOOL_PROBE) { + throw "Error: T20 is reserved for Probe"; + } + + if (tool.number == 19) { + throw "Error: T19 is reserved for WCS verification tool"; + } + + writeln(""); + var comment = "T" + toolFormat.format(tool.number) + " " + + "D=" + xyzFormat.format(tool.diameter) + " " + + localize("CR") + "=" + xyzFormat.format(tool.cornerRadius); + if ((tool.taperAngle > 0) && (tool.taperAngle < Math.PI)) { + comment += " " + localize("TAPER") + "=" + taperFormat.format(tool.taperAngle) + localize("deg"); } + comment += " - " + getToolTypeName(tool.type); + writeComment(tool.description); + writeFunction("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool + displayMedia("toolLoad" + tool.number + ".jpg", !getProperty("loadToolsAtStart")); + writeFunction(mFormat.format(0), formatComment("Load Tool")); //Pause until operator loads tool + writeToolMeasureBlock(tool, true); } - - writeln(""); - writeComment("SETUP FOR OPERATION"); - writeBlock(mFormat.format(131)); } - + + writeln(""); + writeComment("SETUP FOR OPERATION"); + writeFunction(mFormat.format(131)); + if (staticProperties.useDWO) { var failed = false; var dynamicWCSs = {}; @@ -2342,7 +2339,7 @@ function onSection() { } else if (getProperty("hasAAxis") != "false") { writeBlock(gFormat.format(0), aOutput.format(0)); } - displayMedia("xyWCSCheck.jpg"); + displayMedia("xyWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); /* displayMedia("Net Share/Media/checkPrompt.jpg"); @@ -2354,7 +2351,7 @@ function onSection() { writeWords("N" + nFormat.format(gotoRef['Y']), mFormat.format(131), formatComment("End Multimedia")); */ writeBlock(gFormat.format(55), gFormat.format(43), hFormat.format(19), zOutput.format(stockTopZ)); - displayMedia("zWCSCheck.jpg"); + displayMedia("zWCSCheck.jpg", false); writeBlock(mFormat.format(0), formatComment("Open door")); writeBlock(mFormat.format(131), formatComment("End Multimedia")); @@ -2416,7 +2413,7 @@ function onSection() { } if (!isFirstSection()) { - displayMedia("checkPartTool.jpg"); + displayMedia("checkPartTool.jpg", false); writeBlock(mFormat.format(0)); writeBlock(mFormat.format(131)); } @@ -2435,7 +2432,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { @@ -2793,7 +2790,7 @@ function onSection() { var toolDistance = initialPosition.z - stockTopZ; // Prompt user to check stock-tool distance - displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg"); + displayMedia("checkDistance" + toolDistance.toPrecision(2).toString().replace(".", "_") + ".jpg", false); writeBlock(mFormat.format(0)); writeComment("OPEN DOOR"); //displayMedia("Net Share/Media/checkPrompt.jpg"); From 9ab3d3979b2858784c981495693a2d3911336b7b Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 6 Sep 2021 17:29:26 -0400 Subject: [PATCH 19/19] Optional tool measure blocks for SR --- Haas_Gantry_BIDC/Bechtel SR.cps | 122 +++++++++++++++++++------------- 1 file changed, 71 insertions(+), 51 deletions(-) diff --git a/Haas_Gantry_BIDC/Bechtel SR.cps b/Haas_Gantry_BIDC/Bechtel SR.cps index 1add6d0..f92d238 100644 --- a/Haas_Gantry_BIDC/Bechtel SR.cps +++ b/Haas_Gantry_BIDC/Bechtel SR.cps @@ -281,7 +281,7 @@ properties = {/* description: "Tool Probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: true, + value: false, scope: "post" } }; @@ -663,8 +663,8 @@ function writeToolCycleBlock(tool) { } function prepareForToolCheck() { - onCommand(COMMAND_STOP_SPINDLE); - onCommand(COMMAND_COOLANT_OFF); + onCommand(COMMAND_STOP_SPINDLE, false); + onCommand(COMMAND_COOLANT_OFF, false); // cancel TCP so that tool doesn't follow tables if (currentSection.isMultiAxis() && (currentSection.getOptimizedTCPMode() == 0)) { @@ -678,28 +678,31 @@ function prepareForToolCheck() { } function BIDCWriteToolMeasureBlock(tool, rotating) { - writeBlock(gFormat.format(43), hFormat.format(tool.number)); + + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + + writeFunction(gFormat.format(43), hFormat.format(tool.number)); if (rotating && tool.type != HAAS_BALL_NOSE) { - writeBlock(gFormat.format(59), gFormat.format(0), xOutput.format(-tool.diameter/2), yOutput.format(0)); + writeFunction(gFormat.format(59), gFormat.format(0), xOutput.format(-tool.diameter/2), yOutput.format(0)); } else { - writeBlock(gFormat.format(59), gFormat.format(0), xOutput.format(0), yOutput.format(0)); + writeFunction(gFormat.format(59), gFormat.format(0), xOutput.format(0), yOutput.format(0)); } - writeBlock(mFormat.format(0)); + writeFunction(mFormat.format(0)); writeComment("TOOL PROBING"); - writeBlock(mFormat.format(83)); - writeBlock(gFormat.format(4), "P1."); - writeBlock(mFormat.format(84)); + writeFunction(mFormat.format(83)); + writeFunction(gFormat.format(4), "P1."); + writeFunction(mFormat.format(84)); if (rotating) { - writeBlock(sOutput.format(400), mFormat.format(!tool.clockwise ? 3 : 4)); + writeFunction(sOutput.format(400), mFormat.format(!tool.clockwise ? 3 : 4)); } - writeBlock(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(15)); - writeBlock(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); + writeFunction(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(15)); + writeFunction(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); if (rotating) { - writeBlock(sOutput.format(800)); + writeFunction(sOutput.format(800)); } - writeBlock(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(3)); - writeBlock(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); - onCommand(COMMAND_STOP_SPINDLE); + writeFunction(gFormat.format(37), hFormat.format(tool.number), zOutput.format(0), feedOutput.format(3)); + writeFunction(gAbsIncModal.format(91), gFormat.format(0), zOutput.format(.1), feedOutput.format(100)); + onCommand(COMMAND_STOP_SPINDLE, !getProperty("measureToolsAtStart")); } function writeToolMeasureBlock(tool, preMeasure) { @@ -857,10 +860,10 @@ function onOpen() { var tool = tools.getTool(i); // Added 8/31/21 | Kevin Pan | pan261 if (tool.number == 1) { - throw "Tool number 1 is reserved for probing." + // throw "Tool number 1 is reserved for probing." } if (tool.number == 2) { - throw "Tool number 2 is not available for use." + // throw "Tool number 2 is not available for use." } // pan261 @@ -887,6 +890,9 @@ function onOpen() { // optionally cycle through all tools if (staticProperties.optionallyCycleToolsAtStart || staticProperties.optionallyMeasureToolsAtStart) { var tools = getToolTable(); + + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; + if (tools.getNumberOfTools() > 0) { /* @@ -920,10 +926,10 @@ function onOpen() { // writeRetract(Z); // } // writeBlock("T" + toolFormat.format(tool.number), mFormat.format(6)); //Changes Tool - writeToolChange(tool.number) + writeToolChange(tool.number, !getProperty("measureToolsAtStart")) writeComment("SET LENGTH AND RADIUS"); - writeBlock(gFormat.format(10), "L" + 10, "P" + tool.number, "R" + (tool.holderLength + tool.bodyLength).toFixed(4)); - writeBlock(gFormat.format(10), "L" + 12, "P" + tool.number, "R" + (tool.diameter).toFixed(4)); + writeFunction(gFormat.format(10), "L" + 10, "P" + tool.number, "R" + (tool.holderLength + tool.bodyLength).toFixed(4)); + writeFunction(gFormat.format(10), "L" + 12, "P" + tool.number, "R" + (tool.diameter).toFixed(4)); writeComment("POSITION SPINDLE"); // writeBlock(gFormat.format(53), gFormat.format(0), xOutput.format(TOOL_CHANGE_X), yOutput.format(TOOL_CHANGE_Y)); // writeBlock(mFormat.format(0), formatComment("Load Tool " + tool.number)); //Pause until operator loads tool @@ -1014,7 +1020,7 @@ function onOpen() { } if (staticProperties.chipTransport) { - onCommand(COMMAND_START_CHIP_TRANSPORT); + onCommand(COMMAND_START_CHIP_TRANSPORT, false); } // Probing Surface Inspection if (typeof inspectionWriteVariables == "function") { @@ -1271,7 +1277,7 @@ function defineWorkPlane(_section, _setWorkPlane) { writeRetract(Z); } forceWorkPlane(); - onCommand(COMMAND_UNLOCK_MULTI_AXIS); + onCommand(COMMAND_UNLOCK_MULTI_AXIS, false); gMotionModal.reset(); writeBlock( gMotionModal.format(0), @@ -1315,7 +1321,7 @@ function setWorkPlane(abc) { } skipBlock = _skipBlock; - onCommand(COMMAND_UNLOCK_MULTI_AXIS); + onCommand(COMMAND_UNLOCK_MULTI_AXIS, false); gMotionModal.reset(); skipBlock = _skipBlock; @@ -1327,7 +1333,7 @@ function setWorkPlane(abc) { ); skipBlock = _skipBlock; - onCommand(COMMAND_LOCK_MULTI_AXIS); + onCommand(COMMAND_LOCK_MULTI_AXIS, false); currentWorkPlaneABC = abc; } @@ -1702,13 +1708,25 @@ function setAbsoluteMode(xyz, abc) { } } -function writeToolChange(toolNum) { - if (!retracted) { +function writeToolChange(toolNum, isOptional) { + if (isOptional) { + if (!retracted) { + skipBlock = true; + writeRetract(Z); + } + skipBlock = true; + writeRetract(X, Y); + writeOptionalBlock("T" + toolFormat.format(toolNum), mFormat.format(6)); //Changes Tool + skipBlock = true; + writeRetract(Z); + } else { + if (!retracted) { + writeRetract(Z); + } + writeRetract(X, Y); + writeBlock("T" + toolFormat.format(toolNum), mFormat.format(6)); //Changes Tool writeRetract(Z); } - writeRetract(X, Y); - writeBlock("T" + toolFormat.format(toolNum), mFormat.format(6)); //Changes Tool - writeRetract(Z); } function onSection() { @@ -1755,7 +1773,7 @@ function onSection() { if (staticProperties.fastToolChange && !isProbeOperation()) { currentCoolantMode = COOLANT_OFF; } else if (insertToolCall) { // no coolant off command if safe start operation - onCommand(COMMAND_COOLANT_OFF); + onCommand(COMMAND_COOLANT_OFF, false); } } @@ -1763,7 +1781,7 @@ function onSection() { // stop spindle before retract during tool change if (insertToolCall && !isFirstSection() && !toolChecked && !staticProperties.fastToolChange) { - onCommand(COMMAND_STOP_SPINDLE); + onCommand(COMMAND_STOP_SPINDLE, false); } // retract to safe plane @@ -1800,7 +1818,7 @@ function onSection() { } if (hasParameter("notes") && getParameter("notes").toUpperCase().indexOf("APPROVED") <= -1) { - throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." + // throw "Operation \"" + getParameter("operation-comment") + "\" not approved. See a Peer Mentor." } if (staticProperties.showNotes) { @@ -1832,7 +1850,7 @@ function onSection() { if (insertToolCall || operationNeedsSafeStart) { if (!isFirstSection() && staticProperties.optionalStop && insertToolCall) { - onCommand(COMMAND_OPTIONAL_STOP); + onCommand(COMMAND_OPTIONAL_STOP, false); } if ((tool.number > 200 && tool.number < 1000) || tool.number > 9999) { @@ -1875,12 +1893,12 @@ function onSection() { // activate those two coolant modes before the spindle is turned on if ((tool.coolant == COOLANT_THROUGH_TOOL) || (tool.coolant == COOLANT_AIR_THROUGH_TOOL) || (tool.coolant == COOLANT_FLOOD_THROUGH_TOOL)) { if (!isFirstSection() && !insertToolCall && (currentCoolantMode != tool.coolant)) { - onCommand(COMMAND_STOP_SPINDLE); + onCommand(COMMAND_STOP_SPINDLE, false); forceSpindleSpeed = true; } setCoolant(tool.coolant); } else if ((currentCoolantMode == COOLANT_THROUGH_TOOL) || (currentCoolantMode == COOLANT_AIR_THROUGH_TOOL) || (currentCoolantMode == COOLANT_FLOOD_THROUGH_TOOL)) { - onCommand(COMMAND_STOP_SPINDLE); + onCommand(COMMAND_STOP_SPINDLE, false); setCoolant(COOLANT_OFF); forceSpindleSpeed = true; } @@ -3510,15 +3528,17 @@ var mapCommand = { COMMAND_LOAD_TOOL:6 }; -function onCommand(command) { +function onCommand(command, isOptional) { + var writeFunction = isOptional ? writeOptionalBlock : writeBlock; + switch (command) { case COMMAND_STOP: - writeBlock(mFormat.format(0)); + writeFunction(mFormat.format(0)); forceSpindleSpeed = true; forceCoolant = true; return; case COMMAND_OPTIONAL_STOP: - writeBlock(mFormat.format(1)); + writeFunction(mFormat.format(1)); forceSpindleSpeed = true; forceCoolant = true; return; @@ -3534,27 +3554,27 @@ function onCommand(command) { case COMMAND_LOCK_MULTI_AXIS: if (machineConfiguration.isMultiAxisConfiguration() && (machineConfiguration.getNumberOfAxes() >= 4)) { var _skipBlock = skipBlock; - writeBlock(mFormat.format(10)); // lock 4th-axis motion + writeFunction(mFormat.format(10)); // lock 4th-axis motion if (machineConfiguration.getNumberOfAxes() == 5) { skipBlock = _skipBlock; - writeBlock(mFormat.format(12)); // lock 5th-axis motion + writeFunction(mFormat.format(12)); // lock 5th-axis motion } } return; case COMMAND_UNLOCK_MULTI_AXIS: if (machineConfiguration.isMultiAxisConfiguration() && (machineConfiguration.getNumberOfAxes() >= 4)) { var _skipBlock = skipBlock; - writeBlock(mFormat.format(11)); // unlock 4th-axis motion + writeFunction(mFormat.format(11)); // unlock 4th-axis motion if (machineConfiguration.getNumberOfAxes() == 5) { skipBlock = _skipBlock; - writeBlock(mFormat.format(13)); // unlock 5th-axis motion + writeFunction(mFormat.format(13)); // unlock 5th-axis motion } } return; case COMMAND_BREAK_CONTROL: if (!toolChecked) { // avoid duplicate COMMAND_BREAK_CONTROL prepareForToolCheck(); - writeBlock( + writeFunction( gFormat.format(65), "P" + 9853, "T" + toolFormat.format(tool.number), @@ -3569,10 +3589,10 @@ function onCommand(command) { measureTool = true; return; case COMMAND_START_CHIP_TRANSPORT: - writeBlock(mFormat.format(31)); + writeFunction(mFormat.format(31)); return; case COMMAND_STOP_CHIP_TRANSPORT: - writeBlock(mFormat.format(33)); + writeFunction(mFormat.format(33)); return; case COMMAND_PROBE_ON: return; @@ -3583,7 +3603,7 @@ function onCommand(command) { var stringId = getCommandStringId(command); var mcode = mapCommand[stringId]; if (mcode != undefined) { - writeBlock(mFormat.format(mcode)); + writeFunction(mFormat.format(mcode)); } else { onUnsupportedCommand(command); } @@ -3606,7 +3626,7 @@ function onSectionEnd() { if ((((getCurrentSectionId() + 1) >= getNumberOfSections()) || (tool.number != getNextSection().getTool().number)) && tool.breakControl) { - onCommand(COMMAND_BREAK_CONTROL); + onCommand(COMMAND_BREAK_CONTROL, false); } else { toolChecked = false; } @@ -3838,8 +3858,8 @@ function onClose() { optionalSection = false; - onCommand(COMMAND_STOP_SPINDLE); - onCommand(COMMAND_COOLANT_OFF); + onCommand(COMMAND_STOP_SPINDLE, false); + onCommand(COMMAND_COOLANT_OFF, false); // retract writeRetract(Z);