From eb82fe139dade6732f8a3bb89da095279d53f306 Mon Sep 17 00:00:00 2001 From: will1742 Date: Fri, 18 Jun 2021 11:08:11 -0400 Subject: [PATCH] Streamlined Validation G Code --- Haas_Next_Generation/haas vf2.cps | 62 +++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/Haas_Next_Generation/haas vf2.cps b/Haas_Next_Generation/haas vf2.cps index bd86140..fb25d02 100644 --- a/Haas_Next_Generation/haas vf2.cps +++ b/Haas_Next_Generation/haas vf2.cps @@ -2037,6 +2037,11 @@ function onSection() { writeRetract(Z); } } + + // 6/18/21 | Gavin Williams | will1742 + // Terminate any media that may have been active at beginning of section + // Issue 001: Input and validation + cancelMedia(); if (insertToolCall || operationNeedsSafeStart) { @@ -2343,6 +2348,7 @@ function onSection() { } } + writeComment("BEGIN VALIDATION SECTION") // Added 06/15/21 | Gavin Williams | will1742 // Verifies tool-stock distance. Post fails if tool fails clearance standards var toolDistance = initialPosition.z - stockTopZ; @@ -2353,35 +2359,51 @@ function onSection() { if (toolDistance == Infinity) { throw "Error: invalid tool distance. Contact a TA."; } - // asks user if height is accurate - var gotoRef = takeInput(("Is the tool " + toolDistance.toPrecision(3) + "in from the stock? [Y/N]"), ['Y', 'N']); - // if correct, carry on - writeln("N" + gotoRef[0][1] + " GOTO" + sequenceNumber); + // Prompt user to check stock-tool distance + displayMedia("Net Share/checkDistance.png"); + + // Allow door to be opened + linePrint("M0" + " (Halt program)"); + displayMedia("Net Share/arrowDown.png"); + + // asks user if measured height is accurate to displayed + var gotoRef = takeInput(("Is the tool " + toolDistance.toPrecision(3) + "in from the stock? [Y/N]"), ['N', 'Y']); + + // Create GOTO cases for Y/N selection, halt if N + getTA("getTAWarning.png", gotoRef[0][1], onSecGotoRef); + + writeComment("END VALIDATION SECTION") + + // initialize spindle and engage coolant if heights are correct + writeln("N" + gotoRef[1][1] + " M" + (tool.clockwise ? 3 : 4) + " (Restart spindle)"); - // if incorrect stop program and call for TA - getTA(gotoRef[1][1], onSecGotoRef); // Modified 06/09/21 | Gavin Williams | will1742 // Issue 000 Init coolant after positioning setCoolant(tool.coolant); + // define subprogram subprogramDefine(initialPosition, abc, retracted, zIsOutput); } +// print with sequence number +function linePrint(message) { + writeln("N" + sequenceNumber + " " + message); + sequenceNumber += getProperty("sequenceNumberIncrement"); +} + // Added 6/14/21 | Gavin Williams | will1742 // Issue 001 Input and Validation // Displays a file: MP4, MOV, PNG, JPEG. 1920x1080 // Input: Absolute path to file function displayMedia(file) { - writeln("N" + sequenceNumber + " M130 (" + file + ")"); - sequenceNumber += getProperty("sequenceNumberIncrement"); + linePrint("M130 (" + file + ")"); } // Ends displayed media function cancelMedia() { - writeln("N" + sequenceNumber + " M131 (End Media)"); - sequenceNumber += getProperty("sequenceNumberIncrement"); + linePrint("M131" + " (End multimedia)"); } // Added 6/14/21 | Gavin Williams | will1742 @@ -2389,6 +2411,7 @@ function cancelMedia() { // Takes input from the user // Input: string prompt, will be displayed to users // char array options, capital letters accepted as input +// int opSeqNum, optional arg to init prompt at specific value // Output: 2D array [Letter, Coorresponding GOTO] // EX: [Y, 56][N, 57] var macroNumber = 500; @@ -2397,17 +2420,16 @@ function takeInput(prompt, options) { // Cycle through macro variables, reset at end of general purpose vars if (macroNumber > 549) macroNumber = 500; - // init var to 0 - writeln("#" + macroNumber + "=0"); + // init macro var to 0 + writeln("#" + macroNumber + "=0" + " (Initialize macro variable)"); // disply prompt and save response writeln("N" + sequenceNumber + " M109 " + "P" + macroNumber + " (" + prompt + ")"); var gotoRef = sequenceNumber; // wait for input - writeln("IF[#" + macroNumber + " EQ 0.] GOTO" + gotoRef) + writeln("IF[#" + macroNumber + " EQ 0.] GOTO" + gotoRef + " (NULL)"); - // TODO: Line number and GOTO optimization // print if's and goto's var gotoMap =[]; var gotoInc = 1; @@ -2417,12 +2439,13 @@ function takeInput(prompt, options) { gotoInc += 1; }); + // adjust sequence number if needed for (i = 5; i < gotoInc; i+=5) { sequenceNumber += getProperty("sequenceNumberIncrement"); } // return to input until valid option is entered - writeln("GOTO" + gotoRef) + writeln("GOTO" + gotoRef + " (INVALID INPUT)") // increase var number, iterate sequence number macroNumber += 1; @@ -2433,10 +2456,11 @@ function takeInput(prompt, options) { // Added 06/15/21 | Gavin Williamas | will1742 // Issue 001 Input and validation // Halts program until TA arrives. Returns to beginning of onSection -function getTA(seqNum, gotoRef) { - writeln("N" + seqNum + " G53 G0 Z0."); - var conRef = takeInput("GET A TA", ['X']) - writeln("N" + conRef[0][1] + " GOTO" + gotoRef + " (Return to beginning of operation)"); +function getTA(file, seqNum, gotoRef) { + writeln("N" + seqNum + " G53 G0 Z0." + " (Retract spindle)"); + writeln("M130 (" + file + ")"); + writeln("M0" + " (Halt program)"); + writeln("GOTO" + gotoRef + " (Return to beginning of operation)"); } function onDwell(seconds) {