diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6a2fc69..27ec869 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,7 @@ -v1.0.207: Added LEAD1010 Laser Profile, fix bug #107 (Disable CheckSize button on PC's that doesnt support WebGL), fix bug with inch-mode Check Size +v1.0.210: Focussed on close button of alarm/error dialogs to ease closing, added Driver Install button for beginners, beta probing wizards (internal testing only) +v1.0.209: Added Node-Debugger to help check not-responding issue, disabled console.log debugging in server process +v1.0.208: Removed accidental S-Word from coolant menu commands +v1.0.207: Added LEAD1010 Laser Profile, fix bug #107 (Disable CheckSize button on PCs that doesn't support WebGL), fix bug with inch-mode Check Size v1.0.206: Fixed update check to comply with Github deprecations: https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/ v1.0.205: Updated version of avrgirl backend for Firmware flashing, fixes to CI v1.0.204: Soft-Limits support in Keyboard Continuous Jogging diff --git a/app/css/probev2.css b/app/css/probev2.css new file mode 100644 index 0000000..c5428b1 --- /dev/null +++ b/app/css/probev2.css @@ -0,0 +1,76 @@ +.probe-label:hover { + fill: #ccc; +} + +.probe-label path { + pointer-events: none; +} + +.areaactive { + fill: #dd0000; +} + +.areaactive:hover { + fill: #ff0000; +} + +.probe-label, #probe-c-text, #probe-fl-text, #probe-fr-text, #probe-rl-text, #probe-rr-text { + cursor: default; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: -moz-none; + -o-user-select: none; + user-select: none; +} + +.B { + stroke-linejoin: round +} + +.C { + fill: #000 +} + +.D { + stroke: #000 +} + +.E { + word-spacing: 0px +} + +.F { + font-family: Arial Black +} + +.G { + text-anchor: middle +} + +.H { + stroke: none +} + +.I { + font-size: 10.033px +} + +.J { + overflow: visible +} + +.K { + fill-rule: evenodd +} + +.L { + stroke-width: 1pt +} + +.M { + stroke-width: 1.09 +} + +.N { + stroke-linejoin: miter +} \ No newline at end of file diff --git a/app/img/xyzprobe/auto.png b/app/img/xyzprobe/auto.png new file mode 100644 index 0000000..8008ea8 Binary files /dev/null and b/app/img/xyzprobe/auto.png differ diff --git a/app/img/xyzprobe/endmill.png b/app/img/xyzprobe/endmill.png new file mode 100644 index 0000000..32fd2c5 Binary files /dev/null and b/app/img/xyzprobe/endmill.png differ diff --git a/app/img/xyzprobe/x.png b/app/img/xyzprobe/x.png new file mode 100644 index 0000000..faf4ef9 Binary files /dev/null and b/app/img/xyzprobe/x.png differ diff --git a/app/img/xyzprobe/xyz.png b/app/img/xyzprobe/xyz.png new file mode 100644 index 0000000..0c52344 Binary files /dev/null and b/app/img/xyzprobe/xyz.png differ diff --git a/app/img/xyzprobe/xyztouch.png b/app/img/xyzprobe/xyztouch.png new file mode 100644 index 0000000..e951c26 Binary files /dev/null and b/app/img/xyzprobe/xyztouch.png differ diff --git a/app/img/xyzprobe/y.png b/app/img/xyzprobe/y.png new file mode 100644 index 0000000..248290b Binary files /dev/null and b/app/img/xyzprobe/y.png differ diff --git a/app/img/xyzprobe/z.png b/app/img/xyzprobe/z.png new file mode 100644 index 0000000..059189f Binary files /dev/null and b/app/img/xyzprobe/z.png differ diff --git a/app/img/xyzprobe/zplate.png b/app/img/xyzprobe/zplate.png new file mode 100644 index 0000000..cae0241 Binary files /dev/null and b/app/img/xyzprobe/zplate.png differ diff --git a/app/img/xyzprobe/ztouch.png b/app/img/xyzprobe/ztouch.png new file mode 100644 index 0000000..e880af4 Binary files /dev/null and b/app/img/xyzprobe/ztouch.png differ diff --git a/app/index.html b/app/index.html index 82cb889..7010494 100644 --- a/app/index.html +++ b/app/index.html @@ -13,6 +13,7 @@ + @@ -128,9 +129,11 @@ - - - + + + + + @@ -239,8 +242,8 @@
  • Plasma On (M3 S1000)
  • - -
  • Coolant On (M8)
  • + +
  • Coolant On (M8)
  • @@ -260,7 +263,7 @@ @@ -286,6 +289,7 @@ Settings @@ -437,6 +440,9 @@ @@ -469,6 +475,9 @@ @@ -502,7 +511,9 @@
  • Goto Z0 (Work Coord) (G0 Z0)
  • Goto Z0 (Machine Coord) (G53 G0 Z0)
  • -
  • Probe Z0 Wizard
  • + +
  • Probe Z-Zero Wizard with XYZ Plate
  • +
  • Probe XYZ-Zero Wizard
  • @@ -1190,16 +1201,13 @@
  • Launches the installer for the new version
  • You may want to wait until your machine is idle before continuing +
    - - - -
    Jog Widget
    @@ -1232,18 +1240,237 @@
    + + +
    +
    Probing Wizard
    +
    + + + + + + + + + +
    +
    + probe-auto + + + + + + +
    + +
    + + +
    + XYZ Probe Routine: This routine is used to find the XYZ origins +
    + Position the endmill above the hole in the probe plate as shown to the left just above the plate, clip + on the magnetic connecting clip, then click Probe +
    + + + + +
    +
    + + +
    +
    + +
    +
    + +
    + + Where is the XY Zero Datum / Origin in your CAM setup, relevant to the front-left corner we are + probing? +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CENTER + + + + FRONT + LEFT + + + + FRONT + RIGHT + + + + REAR + RIGHT + + + + REAR + LEFT + + + + +
    + If the origin is not Front, Left (Default): Then provide stock dimensions to calculate correct + offset of X0, Y0: +
    + + + + + +
    + +
    +
    +
    +
    +
    + + + + Prototype OpenBuilds XYZ Probe + + + + + +
    +
    + + + +
    +
    Confirm Probe Hardware
    +
    +
    +
    +
    + + +
    +
    +
    + + + + +
    +
    Completed
    +
    +
    +
    +
    + +
    +
    +
    + + + + @@ -1303,6 +1530,7 @@ + diff --git a/app/js/diagnostics.js b/app/js/diagnostics.js index 2cef0a7..0ab690b 100644 --- a/app/js/diagnostics.js +++ b/app/js/diagnostics.js @@ -14,6 +14,7 @@ function saveDiagnostics() { localStorage.setItem('disable3Dgcodepreview', disable3Dgcodepreview); localStorage.setItem('disableSerialLog', disableSerialLog); localStorage.setItem('disableDROupdates', disableDROupdates); + } function initDiagnostics() { @@ -81,6 +82,7 @@ function initDiagnostics() { } else { disableDROupdates = false; } + }; initDiagnostics(); \ No newline at end of file diff --git a/app/js/main.js b/app/js/main.js index e13d212..45c59dd 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -17,6 +17,15 @@ function getChangelog() { } template2 += `` $("#changelog").html(template2); + var template3 = `Changelog:
    ` + + $("#changelogupdate").html(template3); + + }); } diff --git a/app/js/probev2.js b/app/js/probev2.js new file mode 100644 index 0000000..e14406a --- /dev/null +++ b/app/js/probev2.js @@ -0,0 +1,517 @@ +var protoxyzprobeplate = { + xoffset: 6, + yoffset: 6, + zoffset: 5, + name: "Prototype OpenBuilds XYZ Touchplate", + xyzmode: true +} + +var xyzprobeplate = { + xoffset: 10, + yoffset: 10, + zoffset: 9, + name: "OpenBuilds XYZ Touchplate", + xyzmode: true +} + +var zprobeplate = { + xoffset: 0, + yoffset: 0, + zoffset: 20, + name: "OpenBuilds Z Touchplate", + xyzmode: false +} + +var probemode = { + mode: "auto", // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + endmilldia: 0, + stock: { + x: 0, + y: 0, + position: "fl" // fl, fr, rl, rr, c + }, + plate: { + traveldistance: 25, + thickness: 20, + feedrate: 500 + }, + probe: protoxyzprobeplate, +} + +// still beta, lets hide it from users +// if (!enableBetaFeatures) { +// $(".needsXYZProbe").hide(); +// } + +function openProbeDialog() { + Metro.dialog.open("#xyzProbeWindow"); + if (localStorage.getItem('probeType')) { + probetype(localStorage.getItem('probeType')) + if (localStorage.getItem('probeType') == "z") { + setTimeout(function() { + probezplatetab() + $(".probetabxyz").removeClass("active") + $("#probezplatetab").addClass("active") + }, 100) + } else { + setTimeout(function() { + probexyztab() + $(".probetabxyz").removeClass("active") + $("#probexyztab").addClass("active") + }, 100) + } + } +} + +function openProbeXDialog() { + Metro.dialog.open("#xyzProbeWindow"); + if (localStorage.getItem('probeType')) { + probetype(localStorage.getItem('probeType')) + if (localStorage.getItem('probeType') == "z") { + // setTimeout(function() { + // probezplatetab() + // $(".probetabxyz").removeClass("active") + // $("#probezplatetab").addClass("active") + // }, 100) + } else { + setTimeout(function() { + probextab() + $(".probetabxyz").removeClass("active") + $("#probextab").addClass("active") + }, 100) + } + } +} + +function openProbeYDialog() { + Metro.dialog.open("#xyzProbeWindow"); + if (localStorage.getItem('probeType')) { + probetype(localStorage.getItem('probeType')) + if (localStorage.getItem('probeType') == "z") { + // setTimeout(function() { + // probezplatetab() + // $(".probetabxyz").removeClass("active") + // $("#probezplatetab").addClass("active") + // }, 100) + } else { + setTimeout(function() { + probeytab() + $(".probetabxyz").removeClass("active") + $("#probeytab").addClass("active") + }, 100) + } + } +} + +function openProbeZDialog() { + Metro.dialog.open("#xyzProbeWindow"); + if (localStorage.getItem('probeType')) { + probetype(localStorage.getItem('probeType')) + if (localStorage.getItem('probeType') == "z") { + setTimeout(function() { + probezplatetab() + $(".probetabxyz").removeClass("active") + $("#probezplatetab").addClass("active") + }, 100) + } else { + setTimeout(function() { + probeztab() + $(".probetabxyz").removeClass("active") + $("#probeztab").addClass("active") + }, 100) + } + } +} + +function probeautotab() { + probemode.mode = "auto"; // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + $(".probe-tab-content").hide(); + $("#probe-auto").show(); + $("#xyzdatum").show(); + $(".img-probe").hide(); + $("#img-probe-auto").show(); + $("#toggle-probe-advanced").show(); + $("#endmilldiameterform").hide(); + if (probemode.stock.position == "fl") { + $("#toggle-probe-advanced-content").data('collapse').collapse() + } else { + $("#toggle-probe-advanced-content").data('collapse').expand() + } + +} + +function probexyztab() { + probemode.mode = "xyz"; // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + $(".probe-tab-content").hide(); + $("#probe-xyz").show(); + $("#xyzdatum").show(); + $(".img-probe").hide(); + $("#img-probe-xyz").show(); + $("#toggle-probe-advanced").show(); + $("#endmilldiameterform").show(); + if (probemode.stock.position == "fl") { + $("#toggle-probe-advanced-content").data('collapse').collapse() + } else { + $("#toggle-probe-advanced-content").data('collapse').expand() + } + +} + +function probextab() { + probemode.mode = "xzero"; // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + resetOffsetFL(); + $(".probe-tab-content").hide(); + $("#probe-x").show(); + $("#xyzdatum").hide(); + $(".img-probe").hide(); + $("#img-probe-x").show(); + $("#toggle-probe-advanced").hide(); + $("#endmilldiameterform").show(); + $("#toggle-probe-advanced-content").data('collapse').collapse() +} + +function probeytab() { + probemode.mode = "yzero"; // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + resetOffsetFL(); + $(".probe-tab-content").hide(); + $("#probe-y").show(); + $("#xyzdatum").hide(); + $(".img-probe").hide(); + $("#img-probe-y").show(); + $("#toggle-probe-advanced").hide(); + $("#endmilldiameterform").show(); + $("#toggle-probe-advanced-content").data('collapse').collapse() +} + +function probeztab() { + probemode.mode = "zzero"; // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + resetOffsetFL(); + $(".probe-tab-content").hide(); + $("#probe-z").show(); + $("#xyzdatum").hide(); + $(".img-probe").hide(); + $("#img-probe-z").show(); + $("#toggle-probe-advanced").hide(); + $("#endmilldiameterform").hide(); + $("#toggle-probe-advanced-content").data('collapse').collapse() +} + +function probezplatetab() { + probemode.mode = "zplate"; // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + resetOffsetFL(); + $(".probe-tab-content").hide(); + $("#probe-z").show(); + $("#xyzdatum").hide(); + $(".img-probe").hide(); + $("#img-probe-zplate").show(); + $("#toggle-probe-advanced").hide(); + $("#endmilldiameterform").hide(); + $("#toggle-probe-advanced-content").data('collapse').expand() +} + +function probeendmilltab() { + probemode.mode = "endmilldia"; // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + resetOffsetFL(); + $(".probe-tab-content").hide(); + $("#probe-endmill").show(); + $("#xyzdatum").hide(); + $(".img-probe").hide(); + $("#img-probe-endmill").show(); + $("#toggle-probe-advanced").hide(); + $("#endmilldiameterform").hide(); + $("#toggle-probe-advanced-content").data('collapse').collapse() +} + +function resetOffsetFL() { + $(".probe-label").removeClass("areaactive") + $("#probe-fl").addClass("areaactive") + probemode.stock.position = "fl" // fl, fr, rl, rr, c +} + +$("#probe-fl, #probe-fl-text").on("click", function() { + resetOffsetFL(); +}); + +$("#probe-fr, #probe-fr-text").on("click", function() { + $(".probe-label").removeClass("areaactive") + $("#probe-fr").addClass("areaactive") + probemode.stock.position = "fr" // fl, fr, rl, rr, c +}); + +$("#probe-rl, #probe-rl-text").on("click", function() { + $(".probe-label").removeClass("areaactive") + $("#probe-rl").addClass("areaactive") + probemode.stock.position = "rl" // fl, fr, rl, rr, c +}); + +$("#probe-rr, #probe-rr-text").on("click", function() { + $(".probe-label").removeClass("areaactive") + $("#probe-rr").addClass("areaactive") + probemode.stock.position = "rr" // fl, fr, rl, rr, c +}); + +$("#probe-c, #probe-c-text").on("click", function() { + $(".probe-label").removeClass("areaactive") + $("#probe-c").addClass("areaactive") + probemode.stock.position = "c" // fl, fr, rl, rr, c +}); + +function probetype(type) { + localStorage.setItem('probeType', type); + if (type == "xyz") { + probemode.probe = xyzprobeplate // protoxyzprobeplate, xyzprobeplate, zprobeplate + var template = ` OpenBuilds XYZ Probe`; + $("#probetypebtn").html(template) + $(".probetabz").hide(); + $(".probetabxyz").show(); + probexyztab() + } else if (type == "protoxyz") { + probemode.probe = protoxyzprobeplate // protoxyzprobeplate, xyzprobeplate, zprobeplate + var template = ` Prototype OpenBuilds XYZ Probe`; + $("#probetypebtn").html(template) + $(".probetabz").hide(); + $(".probetabxyz").show(); + probexyztab() + } else if (type == "z") { + probemode.probe = zprobeplate // protoxyzprobeplate, xyzprobeplate, zprobeplate + var template = `OpenBuilds Z Touch Plate`; + $("#probetypebtn").html(template) + $(".probetabxyz").hide(); + $(".probetabz").show(); + probezplatetab(); + } +} + +function confirmProbeInPlace(operation) { + + var imgurl = "./img/xyzprobe/xyz.png" + if (probemode.mode == "xyz") { // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + imgurl = "./img/xyzprobe/xyz.png" + } else if (probemode.mode == "xzero") { // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + imgurl = "./img/xyzprobe/x.png" + } else if (probemode.mode == "yzero") { // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + imgurl = "./img/xyzprobe/y.png" + } else if (probemode.mode == "zzero") { // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + imgurl = "./img/xyzprobe/z.png" + } else if (probemode.mode == "zplate") { // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + imgurl = "./img/xyzprobe/zplate.png" + } else if (probemode.mode == "endmilldia") { // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + imgurl = "./img/xyzprobe/endmill.png" + } else if (probemode.mode == "auto") { // auto, xyz, xzero, yzero, zzero, zplate, endmilldia + imgurl = "./img/xyzprobe/auto.png" + } + + var confirmTemplate = ` + + + + + +
    + +
      +
    • Are you sure the probe plate was placed onto the front, left corner of the stock/workpiece?
    • +
    • Are you sure the probe clip is attached to the bit?
    • +
    • Are you sure you jogged the bit to the correct approximate position as shown, prior to initiating the probe?
    • +
    +
    + ` + + $("#confirmXYZprobeDiv").html(confirmTemplate); + setTimeout(function() { + Metro.dialog.open("#confirmXYZprobeModal") + }, 100); + +} + + +function runProbeNew() { + $("#consoletab").click() + probemode.stock.x = $("#stockwidth").val(); + probemode.stock.y = $("#stocklength").val(); + + template = `Code todo: run: \n` + template += `Mode: ` + probemode.mode + `\n` + template += `Probe: ` + probemode.probe.name + `\n` + template += `Probe: X:` + probemode.probe.xoffset + `\n` + template += `Probe: Y:` + probemode.probe.yoffset + `\n` + template += `Probe: Z:` + probemode.probe.zoffset + `\n` + + if (probemode.mode == "xyz" || probemode.mode == "xzero" || probemode.mode == "yzero" || probemode.mode == "zzero") { + probemode.endmilldia = $("#probediameterxyz").val(); + template += `Endmill: ` + probemode.endmilldia + `mm\n` + } + + var stockoffset = { + x: 0, + y: 0 + } + if (probemode.stock.position == "fl") { // fl, fr, rl, rr, c + template += `Offset: NONE\n` + } + if (probemode.stock.position == "fr") { // fl, fr, rl, rr, c + template += `Stock x:` + probemode.stock.x + `\n`; + template += `Stock y: ` + probemode.stock.y + `\n`; + template += `Offset: Front Right:\n`; + template += `Offset x:` + probemode.stock.x + `\n`; + template += `Offset y: ` + 0 + `\n`; + stockoffset.x = probemode.stock.x + } + if (probemode.stock.position == "rl") { // fl, fr, rl, rr, c + template += `Stock x:` + probemode.stock.x + `\n`; + template += `Stock y: ` + probemode.stock.y + `\n`; + template += `Offset: Rear Left:\n`; + template += `Offset x:` + 0 + `\n`; + template += `Offset y: ` + probemode.stock.y + `\n`; + stockoffset.y = probemode.stock.y + } + if (probemode.stock.position == "rr") { // fl, fr, rl, rr, c + template += `Stock x:` + probemode.stock.x + `\n`; + template += `Stock y: ` + probemode.stock.y + `\n`; + template += `Offset: Rear Right:\n`; + template += `Offset x:` + probemode.stock.x + `\n`; + template += `Offset y: ` + probemode.stock.y + `\n`; + stockoffset.x = probemode.stock.x + stockoffset.y = probemode.stock.y + } + if (probemode.stock.position == "c") { // fl, fr, rl, rr, c + template += `Stock x:` + probemode.stock.x + `\n`; + template += `Stock y: ` + probemode.stock.y + `\n`; + template += `Offset: Center:\n`; + template += `Offset x:` + probemode.stock.x / 2 + `\n`; + template += `Offset y: ` + probemode.stock.y / 2 + `\n`; + stockoffset.x = probemode.stock.y / 2 + stockoffset.y = probemode.stock.y / 2 + } + + // alert(template) + + if (probemode.mode == "xzero") { + var xoffset = (probemode.probe.xoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the left too far from x0 + var yoffset = (probemode.probe.yoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the front too far from y0 + var zoffset = probemode.probe.zoffset // not *-1 as its offset in z pos + + var xmacro = ` + ; Header + G21 ; mm mode + G10 P1 L20 X0 ; zero out current location + + ; Probe X + G38.2 X25 F100 ; Probe X + G4 P0.4 + G10 P1 L20 X` + xoffset + ` ; set X as offset and half endmill diameter + G0 X` + (xoffset - 2).toFixed(3) + ` + ` + + + socket.emit('runJob', { + data: xmacro, + isJob: false, + completedMsg: "Probe Complete: Remove the Probe Clip and Probe Plate before continuing... " + }); + + } + + if (probemode.mode == "yzero") { + var xoffset = (probemode.probe.xoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the left too far from x0 + var yoffset = (probemode.probe.yoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the front too far from y0 + var zoffset = probemode.probe.zoffset // not *-1 as its offset in z pos + + var ymacro = ` + ; Header + G21 ; mm mode + G10 P1 L20 Y0 ; zero out current location + + G38.2 Y25 F100 ; probe Y + G4 P0.4 + G10 P1 L20 Y` + yoffset + ` ; set Y as offset and half endmill diameter + G0 Y` + (yoffset - 2).toFixed(3) + ` + ` + socket.emit('runJob', { + data: ymacro, + isJob: false, + completedMsg: "Probe Complete: Remove the Probe Clip and Probe Plate before continuing... " + }); + } + + if (probemode.mode == "zzero") { + var xoffset = (probemode.probe.xoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the left too far from x0 + var yoffset = (probemode.probe.yoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the front too far from y0 + var zoffset = probemode.probe.zoffset // not *-1 as its offset in z pos + + var zmacro = ` + ; Header + G21 ; mm mode + G10 P1 L20 Z0 ; zero out current location + + ; Probe Z + G38.2 Z-25 F100 ; Probe Z + G4 P0.4 + G10 P1 L20 Z` + zoffset + ` ; Set Z6 where 6 is thickness of plate + G0 Z10 ; retract + ` + + socket.emit('runJob', { + data: zmacro, + isJob: false, + completedMsg: "Probe Complete: Remove the Probe Clip and Probe Plate before continuing... " + }); + + } + + if (probemode.mode == "xyz") { + var xoffset = (probemode.probe.xoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the left too far from x0 + var yoffset = (probemode.probe.yoffset + probemode.endmilldia / 2) * -1 // *-1 to make negative as we are off to the front too far from y0 + var zoffset = probemode.probe.zoffset // not *-1 as its offset in z pos + + var xyzmacro = ` + ; Header + G21 ; mm mode + G10 P1 L20 X0 Y0 Z0 ; zero out current location + + ; Probe Z + G0 X22.5 Y22.5 ; position to center of logo + G38.2 Z-25 F100 ; Probe Z + G4 P0.4 + G10 P1 L20 Z` + zoffset + ` ; Set Z6 where 6 is thickness of plate + G0 Z10 ; retract + G0 X0 Y0 ; return + + ; Probe X + G0 X-20 ; position to left side + G0 Y15 ; and move forward a little to be closer to center of edge + G0 Z0 ; drop down to be next to plate + G38.2 X25 F100 ; Probe X + G4 P0.4 + G10 P1 L20 X` + xoffset + ` ; set X as offset and half endmill diameter + G0 X` + (xoffset - 2).toFixed(3) + ` + G0 Z10 ; retract + G0 X0 Y0 ; return + + ; Probe Y + G0 Y-20 ; position to front side + G0 X15 ; and move right a little to be closer to center of edge + G0 Z0 ; drop down to be next to plate + G38.2 Y25 F100 ; probe Y + G4 P0.4 + G10 P1 L20 Y` + yoffset + ` ; set Y as offset and half endmill diameter + G0 Y` + (yoffset - 2).toFixed(3) + ` + G0 Z10 ; retract + G0 X0 Y0 ; return + ` + + if (stockoffset.x != 0 || stockoffset.y != 0) { + xyzmacro += ` + G10 P1 L20 X-` + stockoffset.x + ` ; set X stock offset + G10 P1 L20 Y-` + stockoffset.y + ` ; set Y stock offset + G0 X0 Y0 ; return + ` + } + socket.emit('runJob', { + data: xyzmacro, + isJob: false, + completedMsg: "Probe Complete: Remove the Probe Clip and Probe Plate before continuing... " + }); + + } +} \ No newline at end of file diff --git a/app/js/ui.js b/app/js/ui.js index 1fff41f..a98f157 100644 --- a/app/js/ui.js +++ b/app/js/ui.js @@ -8,6 +8,7 @@ function setConnectBar(val, status) { $("#flashBtn").hide(); $('#portUSB').parent().show(); $("#connectBtn").show(); + $("#driverBtn").show(); if ($('#portUSB').val() != "") { $("#connectBtn").attr('disabled', false); } else { @@ -29,6 +30,7 @@ function setConnectBar(val, status) { $('#connectStatus').html("Port: Connected"); // Connect/Disconnect Button $("#connectBtn").hide(); + $("#driverBtn").hide(); $('#portUSB').parent().hide(); $("#connectBtn").attr('disabled', false); $("#disconnectBtn").show(); @@ -45,6 +47,7 @@ function setConnectBar(val, status) { $('#connectStatus').html("Port: Connected"); // Connect/Disconnect Button $("#connectBtn").hide(); + $("#driverBtn").hide(); $('#portUSB').parent().hide(); $("#connectBtn").attr('disabled', false); $("#disconnectBtn").show(); @@ -61,6 +64,7 @@ function setConnectBar(val, status) { $('#connectStatus').html("Port: Connected"); // Connect/Disconnect Button $("#connectBtn").hide(); + $("#driverBtn").hide(); $('#portUSB').parent().hide(); $("#connectBtn").attr('disabled', false); $("#disconnectBtn").show(); @@ -77,6 +81,7 @@ function setConnectBar(val, status) { $('#connectStatus').html("Port: Connected"); // Connect/Disconnect Button $("#connectBtn").hide(); + $("#driverBtn").hide(); $('#portUSB').parent().hide(); $("#connectBtn").attr('disabled', false); $("#disconnectBtn").show(); @@ -92,6 +97,7 @@ function setConnectBar(val, status) { $('#connectStatus').html("Port: Flashing"); // Connect/Disconnect Button $("#connectBtn").hide(); + $("#driverBtn").hide(); $('#portUSB').parent().hide(); $("#connectBtn").attr('disabled', false); $("#disconnectBtn").hide(); diff --git a/app/js/websocket.js b/app/js/websocket.js index c12351f..c4deefd 100644 --- a/app/js/websocket.js +++ b/app/js/websocket.js @@ -116,6 +116,7 @@ function initSocket() { // 6 = Firmware Upgrade State if (laststatus.comms.connectionStatus < 3 && !continuousJogRunning) { $('#availVersion').html(data) + getChangelog(); Metro.dialog.open('#downloadUpdate') } @@ -153,7 +154,17 @@ function initSocket() { }); socket.on("jobComplete", function(data) { - console.log("Job Complete", data) + + console.log("jobComplete", data) + + if (data.completed) { + console.log("Job Complete", data) + } + if (data.jobCompletedMsg && data.jobCompletedMsg.length > 0) { + $("#completeMsgDiv").html(data.jobCompletedMsg); + Metro.dialog.open("#completeMsgModal"); + } + }); socket.on("machinename", function(data) { @@ -231,6 +242,9 @@ function initSocket() { } ] }); + setTimeout(function() { + $(".closeAlarmBtn").focus(); + }, 200, ) // }); @@ -240,8 +254,18 @@ function initSocket() { Metro.dialog.create({ title: " Grbl Error:", content: " " + data, - clsDialog: 'dark' + clsDialog: 'dark', + actions: [{ + caption: "OK", + cls: "js-dialog-close alert closeErrorBtn", + onclick: function() { + socket.emit('clearAlarm', 2) + } + }] }); + setTimeout(function() { + $(".closeErrorBtn").focus(); + }, 200, ) // }); @@ -586,7 +610,10 @@ function populatePortsMenu() { response += ``; }; if (!laststatus.comms.interfaces.ports.length) { - response += `` + $("#driverBtn").show(); + } else { + $("#driverBtn").hide(); } response += `` var select = $("#portUSB").data("select"); diff --git a/index.js b/index.js index 8bdea34..779dba7 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,24 @@ -//v1.0.152 process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = '1'; +// To see console.log output run with `DEBUGCONTROL=true electron .` or set environment variable for DEBUGCONTROL=true +// debug_log debug overhead +DEBUG = false; +if (process.env.DEBUGCONTROL) { + DEBUG = true; + console.log("Console Debugging Enabled") +} + +function debug_log() { + if (DEBUG) { + console.log.apply(this, arguments); + } +} // end Debug Logger + process.on("uncaughtException", (err) => { - console.log(err) + debug_log(err) }); -console.log("Starting OpenBuilds CONTROL v" + require('./package').version) +debug_log("Starting OpenBuilds CONTROL v" + require('./package').version) var config = {}; config.webPort = process.env.WEB_PORT || 3000; @@ -35,11 +48,11 @@ var httpsOptions = { }; const httpsserver = https.createServer(httpsOptions, app).listen(3001, function() { - console.log('https: listening on:' + ip.address() + ":3001"); + debug_log('https: listening on:' + ip.address() + ":3001"); }); const httpserver = http.listen(config.webPort, '0.0.0.0', function() { - console.log('http: listening on:' + ip.address() + ":" + config.webPort); + debug_log('http: listening on:' + ip.address() + ":" + config.webPort); }); io.attach(httpserver); @@ -62,7 +75,7 @@ const electronApp = electron.app; if (isElectron()) { - console.log("Local User Data: " + electronApp.getPath('userData')) + debug_log("Local User Data: " + electronApp.getPath('userData')) electronApp.commandLine.appendSwitch('ignore-gpu-blacklist', 'true') electronApp.commandLine.appendSwitch('enable-gpu-rasterization', 'true') electronApp.commandLine.appendSwitch('enable-zero-copy', 'true') @@ -70,7 +83,7 @@ if (isElectron()) { electronApp.commandLine.appendSwitch('enable-native-gpu-memory-buffers', 'true') // Removing max-old-space-size switch (Introduced in 1.0.168 and removed in 1.0.169) due it causing High CPU load on some PCs. //electronApp.commandLine.appendSwitch('js-flags', '--max-old-space-size=8192') - console.log('Command Line Arguments for Electron: Set OK') + debug_log('Command Line Arguments for Electron: Set OK') } const BrowserWindow = electron.BrowserWindow; const Tray = electron.Tray; @@ -105,7 +118,7 @@ if (isElectron()) { 'response': string } io.sockets.emit('updatedata', output); - console.log(JSON.stringify(ev)) + debug_log(JSON.stringify(ev)) }) autoUpdater.on('update-not-available', (ev, info) => { var string = 'Update not available. Installed version: ' + require('./package').version + " / Available version: " + ev.version + ".\n"; @@ -117,7 +130,7 @@ if (isElectron()) { 'response': string } io.sockets.emit('updatedata', output); - console.log(JSON.stringify(ev)) + debug_log(JSON.stringify(ev)) }) autoUpdater.on('error', (ev, err) => { if (err) { @@ -134,7 +147,7 @@ if (isElectron()) { autoUpdater.on('download-progress', (ev, progressObj) => { updateIsDownloading = true; var string = 'Download update ... ' + ev.percent.toFixed(1) + '%'; - console.log(string) + debug_log(string) var output = { 'command': 'autoupdate', 'response': string @@ -158,7 +171,7 @@ if (isElectron()) { updateIsDownloading = false; }); } else { - console.log("Running outside Electron: Disabled AutoUpdater") + debug_log("Running outside Electron: Disabled AutoUpdater") } if (isElectron()) { @@ -166,12 +179,13 @@ if (isElectron()) { } else { var uploadsDir = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + 'Library/Preferences' : '/var/local') } +var jobCompletedMsg = ""; // message sent when job is done var uploadedgcode = ""; // var to store uploaded gcode var uploadedworkspace = ""; // var to store uploaded OpenBuildsCAM Workspace mkdirp(uploadsDir, function(err) { if (err) console.error(err) - else console.log('Created Uploads Temp Directory') + else debug_log('Created Uploads Temp Directory') }); var oldportslist; @@ -301,11 +315,11 @@ var PortCheckinterval = setInterval(function() { if (!_.isEqual(ports, oldportslist)) { var newPorts = _.differenceWith(ports, oldportslist, _.isEqual) if (newPorts.length > 0) { - console.log("Plugged " + newPorts[0].comName); + debug_log("Plugged " + newPorts[0].comName); } var removedPorts = _.differenceWith(oldportslist, ports, _.isEqual) if (removedPorts.length > 0) { - console.log("Unplugged " + removedPorts[0].comName); + debug_log("Unplugged " + removedPorts[0].comName); } } oldportslist = ports; @@ -327,7 +341,7 @@ app.get('/api/version', (req, res) => { }) app.get('/activate', (req, res) => { - console.log(req.hostname) + debug_log(req.hostname) res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); res.send('Host: ' + req.hostname + ' asked to activate OpenBuilds CONTROL v' + require('./package').version); @@ -374,15 +388,15 @@ app.get('/workspace', (req, res) => { app.post('/upload', function(req, res) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); - //console.log(req) + //debug_log(req) uploadprogress = 0 var form = new formidable.IncomingForm(); form.parse(req, function(err, fields, files) { - // console.log(files); + // debug_log(files); }); form.on('fileBegin', function(name, file) { - console.log('Uploading ' + file.name); + debug_log('Uploading ' + file.name); file.path = uploadsDir + file.name; }); @@ -394,7 +408,7 @@ app.post('/upload', function(req, res) { }); form.on('file', function(name, file) { - console.log('Uploaded ' + file.path); + debug_log('Uploaded ' + file.path); if (jogWindow === null) { createJogWindow(); @@ -440,7 +454,7 @@ io.on("connection", function(socket) { for (i = 0; i < status.machine.inputs.length; i++) { switch (status.machine.inputs[i]) { case 'R': - // console.log('PIN: SOFTRESET'); + // debug_log('PIN: SOFTRESET'); safetosend = true; break; } @@ -455,21 +469,22 @@ io.on("connection", function(socket) { var interval = setInterval(function() { io.sockets.emit("status", status); - if (jogWindow) { - if (status.comms.connectionStatus == 0) { - jogWindow.setOverlayIcon(nativeImage.createFromPath(iconNoComm), 'Not Connected'); - } else if (status.comms.connectionStatus == 1) { - jogWindow.setOverlayIcon(nativeImage.createFromPath(iconStop), 'Port Connected'); - } else if (status.comms.connectionStatus == 2) { - jogWindow.setOverlayIcon(nativeImage.createFromPath(iconStop), 'Connected, and Firmware'); - } else if (status.comms.connectionStatus == 3) { - jogWindow.setOverlayIcon(nativeImage.createFromPath(iconPlay), 'Playing'); - } else if (status.comms.connectionStatus == 4) { - jogWindow.setOverlayIcon(nativeImage.createFromPath(iconPause), 'Paused'); - } else if (status.comms.connectionStatus == 5) { - jogWindow.setOverlayIcon(nativeImage.createFromPath(iconAlarm), 'Alarm'); - } - } + // v1.0.210 - testing if this caused hangs + // if (jogWindow) { + // if (status.comms.connectionStatus == 0) { + // jogWindow.setOverlayIcon(nativeImage.createFromPath(iconNoComm), 'Not Connected'); + // } else if (status.comms.connectionStatus == 1) { + // jogWindow.setOverlayIcon(nativeImage.createFromPath(iconStop), 'Port Connected'); + // } else if (status.comms.connectionStatus == 2) { + // jogWindow.setOverlayIcon(nativeImage.createFromPath(iconStop), 'Connected, and Firmware'); + // } else if (status.comms.connectionStatus == 3) { + // jogWindow.setOverlayIcon(nativeImage.createFromPath(iconPlay), 'Playing'); + // } else if (status.comms.connectionStatus == 4) { + // jogWindow.setOverlayIcon(nativeImage.createFromPath(iconPause), 'Paused'); + // } else if (status.comms.connectionStatus == 5) { + // jogWindow.setOverlayIcon(nativeImage.createFromPath(iconAlarm), 'Alarm'); + // } + // } }, 400); @@ -495,6 +510,13 @@ io.on("connection", function(socket) { shell.openExternal('https://openbuilds.com/threads/openbuilds-control-software.13121/') }); + socket.on("opendriverspage", function(data) { + const { + shell + } = require('electron') + shell.openExternal('https://docs.openbuilds.com/blackbox/#41-devicedrivers.html') + }); + socket.on("minimisetotray", function(data) { jogWindow.hide(); }); @@ -521,7 +543,7 @@ io.on("connection", function(socket) { if (typeof autoUpdater !== 'undefined') { autoUpdater.checkForUpdates(); } else { - console.log("autoUpdater not found") + debug_log("autoUpdater not found") } } }) @@ -535,14 +557,14 @@ io.on("connection", function(socket) { const Avrgirl = require('avrgirl-arduino'); if (status.comms.connectionStatus > 0) { - console.log('WARN: Closing Port ' + port); + debug_log('WARN: Closing Port ' + port); stopPort(); } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } function flashGrblCallback(debugString, port) { - console.log(port, debugString); + debug_log(port, debugString); var data = { 'port': port, 'string': debugString @@ -560,7 +582,7 @@ io.on("connection", function(socket) { } }); - console.log(JSON.stringify(avrgirl)); + debug_log(JSON.stringify(avrgirl)); status.comms.connectionStatus = 6; avrgirl.flash(path.join(__dirname, file), function(error) { @@ -584,7 +606,7 @@ io.on("connection", function(socket) { if (status.comms.connectionStatus < 1) { data = data.split(","); - console.log("Connecting via " + data[0] + " to " + data[1] + " at baud " + data[2]); + debug_log("Connecting via " + data[0] + " to " + data[1] + " at baud " + data[2]); port = new SerialPort(data[1], { baudRate: parseInt(data[2]) @@ -596,7 +618,7 @@ io.on("connection", function(socket) { port.on("error", function(err) { if (err.message != "Port is not open") { - console.log("Error: ", err.message); + debug_log("Error: ", err.message); var output = { 'command': '', 'response': "PORT ERROR: " + err.message @@ -604,17 +626,17 @@ io.on("connection", function(socket) { io.sockets.emit('data', output); if (status.comms.connectionStatus > 0) { - console.log('WARN: Closing Port ' + port.path); + debug_log('WARN: Closing Port ' + port.path); status.comms.connectionStatus = 0; stopPort(); } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } } }); port.on("open", function() { - console.log("PORT INFO: Connected to " + port.path + " at " + port.baudRate); + debug_log("PORT INFO: Connected to " + port.path + " at " + port.baudRate); var output = { 'command': 'connect', 'response': "PORT INFO: Port is now open: " + port.path + " - Attempting to detect Firmware" @@ -638,27 +660,27 @@ io.on("connection", function(socket) { setTimeout(function() { //wait for controller to be ready if (status.machine.firmware.type.length < 1) { - console.log("Didnt detect firmware after AutoReset. Lets see if we have Grbl instance with a board that doesnt have AutoReset"); + debug_log("Didnt detect firmware after AutoReset. Lets see if we have Grbl instance with a board that doesnt have AutoReset"); var output = { 'command': 'connect', 'response': "Detecting Firmware: Method 2 (Ctrl+X)" } io.sockets.emit('data', output); addQRealtime(String.fromCharCode(0x18)); // ctrl-x (needed for rx/tx connection) - console.log("Sent: Ctrl+x"); + debug_log("Sent: Ctrl+x"); } }, config.grblWaitTime * 1000); setTimeout(function() { //wait for controller to be ready if (status.machine.firmware.type.length < 1) { - console.log("No firmware yet, probably not Grbl then. lets see if we have Smoothie?"); + debug_log("No firmware yet, probably not Grbl then. lets see if we have Smoothie?"); var output = { 'command': 'connect', 'response': "Detecting Firmware: Method 3 (others that are not supported)" } io.sockets.emit('data', output); addQRealtime("version\n"); // Check if it's Smoothieware? - console.log("Sent: version"); + debug_log("Sent: version"); } }, config.grblWaitTime * 2000); @@ -666,7 +688,7 @@ io.on("connection", function(socket) { setTimeout(function() { // Close port if we don't detect supported firmware after 2s. if (status.machine.firmware.type.length < 1) { - console.log("No supported firmware detected. Closing port " + port.path); + debug_log("No supported firmware detected. Closing port " + port.path); var output = { 'command': 'connect', 'response': "ERROR!: No supported firmware detected - you need a controller with Grbl 1.1x on it, or there is a problem with your controller. Closing port " + port.path @@ -690,7 +712,7 @@ io.on("connection", function(socket) { }); // end port .onopen port.on("close", function() { // open errors will be emitted as an error event - console.log("PORT INFO: Port closed"); + debug_log("PORT INFO: Port closed"); var output = { 'command': 'disconnect', 'response': "PORT INFO: Port closed" @@ -703,7 +725,7 @@ io.on("connection", function(socket) { var command = sentBuffer[0]; if (data.indexOf("<") != 0) { - console.log('data:', data) + debug_log('data:', data) } // Grbl $I parser @@ -731,67 +753,67 @@ io.on("connection", function(socket) { features.push(grblOpts[0].charAt(i)) switch (grblOpts[0].charAt(i)) { case 'Q': - console.log('SPINDLE_IS_SERVO Enabled') + debug_log('SPINDLE_IS_SERVO Enabled') // break; case 'V': // Variable spindle enabled - console.log('Variable spindle enabled') + debug_log('Variable spindle enabled') // break; case 'N': // Line numbers enabled - console.log('Line numbers enabled') + debug_log('Line numbers enabled') // break; case 'M': // Mist coolant enabled - console.log('Mist coolant enabled') + debug_log('Mist coolant enabled') // break; case 'C': // CoreXY enabled - console.log('CoreXY enabled') + debug_log('CoreXY enabled') // break; case 'P': // Parking motion enabled - console.log('Parking motion enabled') + debug_log('Parking motion enabled') // break; case 'Z': // Homing force origin enabled - console.log('Homing force origin enabled') + debug_log('Homing force origin enabled') // break; case 'H': // Homing single axis enabled - console.log('Homing single axis enabled') + debug_log('Homing single axis enabled') // break; case 'T': // Two limit switches on axis enabled - console.log('Two limit switches on axis enabled') + debug_log('Two limit switches on axis enabled') // break; case 'A': // Allow feed rate overrides in probe cycles - console.log('Allow feed rate overrides in probe cycles') + debug_log('Allow feed rate overrides in probe cycles') // break; case '$': // Restore EEPROM $ settings disabled - console.log('Restore EEPROM $ settings disabled') + debug_log('Restore EEPROM $ settings disabled') // break; case '#': // Restore EEPROM parameter data disabled - console.log('Restore EEPROM parameter data disabled') + debug_log('Restore EEPROM parameter data disabled') // break; case 'I': // Build info write user string disabled - console.log('Build info write user string disabled') + debug_log('Build info write user string disabled') // break; case 'E': // Force sync upon EEPROM write disabled - console.log('Force sync upon EEPROM write disabled') + debug_log('Force sync upon EEPROM write disabled') // break; case 'W': // Force sync upon work coordinate offset change disabled - console.log('Force sync upon work coordinate offset change disabled') + debug_log('Force sync upon work coordinate offset change disabled') // break; case 'L': // Homing init lock sets Grbl into an alarm state upon power up - console.log('Homing init lock sets Grbl into an alarm state upon power up') + debug_log('Homing init lock sets Grbl into an alarm state upon power up') // break; } @@ -804,7 +826,7 @@ io.on("connection", function(socket) { // [PRB:0.000,0.000,0.000:0] if (data.indexOf("[PRB:") === 0) { if (status.machine.probe.request.plate) { - console.log(data) + debug_log(data) var prbLen = data.substr(5).search(/\]/); var prbData = data.substr(5, prbLen).split(/,/); var success = data.split(':')[2].split(']')[0]; @@ -834,19 +856,19 @@ io.on("connection", function(socket) { // Machine Identification if (data.indexOf("Grbl") === 0) { // Check if it's Grbl - console.log(data) + debug_log(data) status.comms.blocked = false; status.machine.firmware.type = "grbl"; status.machine.firmware.version = data.substr(5, 4); // get version if (parseFloat(status.machine.firmware.version) < 1.1) { // If version is too old if (status.machine.firmware.version.length < 3) { - console.log('invalid version string, stay connected') + debug_log('invalid version string, stay connected') } else { if (status.comms.connectionStatus > 0) { - console.log('WARN: Closing Port ' + port.path + " / v" + parseFloat(status.machine.firmware.version)); + debug_log('WARN: Closing Port ' + port.path + " / v" + parseFloat(status.machine.firmware.version)); // stopPort(); } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } var output = { 'command': command, @@ -856,7 +878,7 @@ io.on("connection", function(socket) { } } status.machine.firmware.date = ""; - console.log("GRBL detected"); + debug_log("GRBL detected"); setTimeout(function() { io.sockets.emit('grbl') }, 600) @@ -868,7 +890,7 @@ io.on("connection", function(socket) { }, 250); } else if (data.indexOf("LPC176") >= 0) { // LPC1768 or LPC1769 should be Smoothieware status.comms.blocked = false; - console.log("Smoothieware detected"); + debug_log("Smoothieware detected"); status.machine.firmware.type = "smoothie"; status.machine.firmware.version = data.substr(data.search(/version:/i) + 9).split(/,/); status.machine.firmware.date = new Date(data.substr(data.search(/Build date:/i) + 12).split(/,/)).toDateString(); @@ -888,31 +910,31 @@ io.on("connection", function(socket) { // Machine Feedback: Position if (data.indexOf("<") === 0) { - // console.log(' Got statusReport (Grbl & Smoothieware)') + // debug_log(' Got statusReport (Grbl & Smoothieware)') // statusfeedback func parseFeedback(data) - // console.log(data) + // debug_log(data) } else if (data.indexOf("ok") === 0) { // Got an OK so we are clear to send - // console.log("OK FOUND") + // debug_log("OK FOUND") if (status.machine.firmware.type === "grbl") { - // console.log('got OK from ' + command) + // debug_log('got OK from ' + command) command = sentBuffer.shift(); } if (status.machine.firmware.type === "smoothie") { - // console.log('got OK from ' + command) + // debug_log('got OK from ' + command) command = sentBuffer.shift(); } status.comms.blocked = false; send1Q(); } else if (data.indexOf('ALARM') === 0) { //} || data.indexOf('HALTED') === 0) { - console.log("ALARM: " + data) + debug_log("ALARM: " + data) status.comms.connectionStatus = 5; switch (status.machine.firmware.type) { case 'grbl': // sentBuffer.shift(); var alarmCode = parseInt(data.split(':')[1]); - console.log('ALARM: ' + alarmCode + ' - ' + grblStrings.alarms(alarmCode)); + debug_log('ALARM: ' + alarmCode + ' - ' + grblStrings.alarms(alarmCode)); status.comms.alarm = alarmCode + ' - ' + grblStrings.alarms(alarmCode) if (alarmCode != 5) { io.sockets.emit("toastErrorAlarm", 'ALARM: ' + alarmCode + ' - ' + grblStrings.alarms(alarmCode) + " [ " + command + " ]") @@ -931,7 +953,7 @@ io.on("connection", function(socket) { } else if (data.indexOf('WARNING: After HALT you should HOME as position is currently unknown') != -1) { //} || data.indexOf('HALTED') === 0) { status.comms.connectionStatus = 2; } else if (data.indexOf('Emergency Stop Requested') != -1) { //} || data.indexOf('HALTED') === 0) { - console.log("Emergency Stop Requested") + debug_log("Emergency Stop Requested") status.comms.connectionStatus = 5; } else if (data.indexOf('wait') === 0) { // Got wait from Repetier -> ignore // do nothing @@ -940,7 +962,7 @@ io.on("connection", function(socket) { case 'grbl': // sentBuffer.shift(); var errorCode = parseInt(data.split(':')[1]); - console.log('error: ' + errorCode + ' - ' + grblStrings.errors(errorCode) + " [ " + command + " ]"); + debug_log('error: ' + errorCode + ' - ' + grblStrings.errors(errorCode) + " [ " + command + " ]"); var output = { 'command': '', 'response': 'error: ' + errorCode + ' - ' + grblStrings.errors(errorCode) + " [ " + command + " ]" @@ -957,7 +979,7 @@ io.on("connection", function(socket) { // io.sockets.emit('data', data); break; } - console.log("error;") + debug_log("error;") sentBuffer.shift(); status.comms.connectionStatus = 5; } else if (data === ' ') { @@ -969,7 +991,7 @@ io.on("connection", function(socket) { if (data.indexOf("[MSG:Reset to continue]") === 0) { switch (status.machine.firmware.type) { case 'grbl': - console.log("[MSG:Reset to continue] -> Sending Reset") + debug_log("[MSG:Reset to continue] -> Sending Reset") addQRealtime(String.fromCharCode(0x18)); // ctrl-x break; // case 'smoothie': @@ -984,7 +1006,7 @@ io.on("connection", function(socket) { if (command) { command = command.replace(/(\r\n|\n|\r)/gm, ""); - // console.log("CMD: " + command + " / DATA RECV: " + data.replace(/(\r\n|\n|\r)/gm, "")); + // debug_log("CMD: " + command + " / DATA RECV: " + data.replace(/(\r\n|\n|\r)/gm, "")); if (command != "?" && command != "M105" && data.length > 0 && data.indexOf('<') == -1) { var string = ""; @@ -996,7 +1018,7 @@ io.on("connection", function(socket) { 'command': command, 'response': string } - // console.log(output.response) + // debug_log(output.response) io.sockets.emit('data', output); } } else { @@ -1018,18 +1040,23 @@ io.on("connection", function(socket) { socket.on('setqueuePointer', function(data) { - console.log('Setting queuePointer to ' + data) + debug_log('Setting queuePointer to ' + data) queuePointer = data }); socket.on('runJob', function(object) { - // console.log(data) + // debug_log(data) var data = object.data if (object.isJob) { uploadedgcode = data; } - // console.log('Run Job (' + data.length + ')'); + if (object.completedMsg) { + jobCompletedMsg = object.completedMsg + } + + + // debug_log('Run Job (' + data.length + ')'); if (status.comms.connectionStatus > 0) { if (data) { data = data.split('\n'); @@ -1052,7 +1079,7 @@ io.on("connection", function(socket) { } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); @@ -1061,7 +1088,7 @@ io.on("connection", function(socket) { }); socket.on('runCommand', function(data) { - console.log('Run Command (' + data.replace('\n', '|') + ')'); + debug_log('Run Command (' + data.replace('\n', '|') + ')'); if (status.comms.connectionStatus > 0) { if (data) { data = data.split('\n'); @@ -1074,17 +1101,17 @@ io.on("connection", function(socket) { } if (i > 0) { status.comms.runStatus = 'Running' - // console.log('sending ' + JSON.stringify(gcodeQueue)) + // debug_log('sending ' + JSON.stringify(gcodeQueue)) send1Q(); } } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('zProbe', function(data) { - console.log('Probing ' + data.direction + ' down to ' + data.dist + "mm at " + data.feedrate + "mm/min and then subtracting a plate of " + data.plate + "mm") + debug_log('Probing ' + data.direction + ' down to ' + data.dist + "mm at " + data.feedrate + "mm/min and then subtracting a plate of " + data.plate + "mm") status.machine.probe.request = data; status.machine.probe.x = 0.00; status.machine.probe.y = 0.00; @@ -1104,16 +1131,16 @@ io.on("connection", function(socket) { // addQToEnd('G90'); // send1Q(); // break; - console.log('ERROR: Unsupported firmware!'); + debug_log('ERROR: Unsupported firmware!'); break; default: - console.log('ERROR: Unsupported firmware!'); + debug_log('ERROR: Unsupported firmware!'); break; } }); socket.on('jog', function(data) { - console.log('Jog ' + data); + debug_log('Jog ' + data); if (status.comms.connectionStatus > 0) { data = data.split(','); var dir = data[0]; @@ -1126,7 +1153,7 @@ io.on("connection", function(socket) { } } if (dir && dist && feed) { - console.log('Adding jog commands to queue. Firmw=' + status.machine.firmware.type + ', blocked=' + status.comms.blocked + ', paused=' + status.comms.paused + ', Q=' + gcodeQueue.length); + debug_log('Adding jog commands to queue. Firmw=' + status.machine.firmware.type + ', blocked=' + status.comms.blocked + ', paused=' + status.comms.paused + ', Q=' + gcodeQueue.length); switch (status.machine.firmware.type) { case 'grbl': addQToEnd('$J=G91G21' + dir + dist + feed); @@ -1139,19 +1166,19 @@ io.on("connection", function(socket) { send1Q(); break; default: - console.log('ERROR: Unknown firmware!'); + debug_log('ERROR: Unknown firmware!'); break; } } else { - console.log('ERROR: Invalid params!'); + debug_log('ERROR: Invalid params!'); } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('jogXY', function(data) { - console.log('Jog XY' + data); + debug_log('Jog XY' + data); if (status.comms.connectionStatus > 0) { // var data = { // x: xincrement, @@ -1166,7 +1193,7 @@ io.on("connection", function(socket) { } if (xincrement && yincrement && feed) { - console.log('Adding jog commands to queue. blocked=' + status.comms.blocked + ', paused=' + status.comms.paused + ', Q=' + gcodeQueue.length); + debug_log('Adding jog commands to queue. blocked=' + status.comms.blocked + ', paused=' + status.comms.paused + ', Q=' + gcodeQueue.length); switch (status.machine.firmware.type) { case 'grbl': addQToEnd('$J=G91G21X' + xincrement + " Y" + yincrement + " " + feed); @@ -1179,19 +1206,19 @@ io.on("connection", function(socket) { send1Q(); break; default: - console.log('ERROR: Unknown firmware!'); + debug_log('ERROR: Unknown firmware!'); break; } } else { - console.log('ERROR: Invalid params!'); + debug_log('ERROR: Invalid params!'); } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('jogTo', function(data) { // data = {x:xVal, y:yVal, z:zVal, mode:0(absulute)|1(relative), feed:fVal} - console.log('JogTo ' + JSON.stringify(data)); + debug_log('JogTo ' + JSON.stringify(data)); if (status.comms.connectionStatus > 0) { if (data.x !== undefined || data.y !== undefined || data.z !== undefined) { var xVal = (data.x !== undefined ? 'X' + parseFloat(data.x) : ''); @@ -1199,7 +1226,7 @@ io.on("connection", function(socket) { var zVal = (data.z !== undefined ? 'Z' + parseFloat(data.z) : ''); var mode = ((data.mode == 0) ? 0 : 1); var feed = (data.feed !== undefined ? 'F' + parseInt(data.feed) : ''); - console.log('Adding jog commands to queue. blocked=' + status.comms.blocked + ', paused=' + status.comms.paused + ', Q=' + gcodeQueue.length); + debug_log('Adding jog commands to queue. blocked=' + status.comms.blocked + ', paused=' + status.comms.paused + ', Q=' + gcodeQueue.length); switch (status.machine.firmware.type) { case 'grbl': addQToEnd('$J=G91G21' + mode + xVal + yVal + zVal + feed); @@ -1211,19 +1238,19 @@ io.on("connection", function(socket) { send1Q(); break; default: - console.log('ERROR: Unknown firmware!'); + debug_log('ERROR: Unknown firmware!'); break; } } else { - console.log('error Invalid params!'); + debug_log('error Invalid params!'); } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('setZero', function(data) { - console.log('setZero(' + data + ')'); + debug_log('setZero(' + data + ')'); if (status.comms.connectionStatus > 0) { switch (data) { case 'x': @@ -1247,12 +1274,12 @@ io.on("connection", function(socket) { } send1Q(); } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('gotoZero', function(data) { - console.log('gotoZero(' + data + ')'); + debug_log('gotoZero(' + data + ')'); if (status.comms.connectionStatus > 0) { switch (data) { case 'x': @@ -1276,12 +1303,12 @@ io.on("connection", function(socket) { } send1Q(); } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('setPosition', function(data) { - console.log('setPosition(' + JSON.stringify(data) + ')'); + debug_log('setPosition(' + JSON.stringify(data) + ')'); if (status.comms.connectionStatus > 0) { if (data.x !== undefined || data.y !== undefined || data.z !== undefined) { var xVal = (data.x !== undefined ? 'X' + parseFloat(data.x) + ' ' : ''); @@ -1292,12 +1319,12 @@ io.on("connection", function(socket) { send1Q(); } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('probe', function(data) { - console.log('probe(' + JSON.stringify(data) + ')'); + debug_log('probe(' + JSON.stringify(data) + ')'); if (status.comms.connectionStatus > 0) { switch (status.machine.firmware.type) { case 'smoothie': @@ -1318,21 +1345,21 @@ io.on("connection", function(socket) { break; default: //not supported - console.log('Command not supported by firmware!'); + debug_log('Command not supported by firmware!'); break; } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('feedOverride', function(data) { - console.log(data) + debug_log(data) if (status.comms.connectionStatus > 0) { switch (status.machine.firmware.type) { case 'grbl': - console.log("current FRO = " + status.machine.overrides.feedOverride) - console.log("requested FRO = " + data) + debug_log("current FRO = " + status.machine.overrides.feedOverride) + debug_log("requested FRO = " + data) var curfro = parseInt(status.machine.overrides.feedOverride) var reqfro = parseInt(data) var delta; @@ -1342,10 +1369,10 @@ io.on("connection", function(socket) { } else if (curfro < reqfro) { // FRO Increase delta = reqfro - curfro - console.log("delta = " + delta) + debug_log("delta = " + delta) var tens = Math.floor(delta / 10) - console.log("need to send " + tens + " x10s increase") + debug_log("need to send " + tens + " x10s increase") // for (i = 0; i < tens; i++) { // addQRealtime(String.fromCharCode(0x91)); // } @@ -1357,7 +1384,7 @@ io.on("connection", function(socket) { } var ones = delta - (10 * tens); - console.log("need to send " + ones + " x1s increase") + debug_log("need to send " + ones + " x1s increase") // for (i = 0; i < ones; i++) { // addQRealtime(String.fromCharCode(0x93)); // } @@ -1370,10 +1397,10 @@ io.on("connection", function(socket) { } else if (curfro > reqfro) { // FRO Decrease delta = curfro - reqfro - console.log("delta = " + delta) + debug_log("delta = " + delta) var tens = Math.floor(delta / 10) - console.log("need to send " + tens + " x10s decrease") + debug_log("need to send " + tens + " x10s decrease") // for (i = 0; i < tens; i++) { // addQRealtime(String.fromCharCode(0x92)); // } @@ -1385,7 +1412,7 @@ io.on("connection", function(socket) { } var ones = delta - (10 * tens); - console.log("need to send " + ones + " x1s decrease") + debug_log("need to send " + ones + " x1s decrease") // for (i = 0; i < tens; i++) { // addQRealtime(String.fromCharCode(0x94)); // } @@ -1414,7 +1441,7 @@ io.on("connection", function(socket) { break; } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); @@ -1422,8 +1449,8 @@ io.on("connection", function(socket) { if (status.comms.connectionStatus > 0) { switch (status.machine.firmware.type) { case 'grbl': - console.log("current SRO = " + status.machine.overrides.spindleOverride) - console.log("requested SRO = " + data) + debug_log("current SRO = " + status.machine.overrides.spindleOverride) + debug_log("requested SRO = " + data) var cursro = parseInt(status.machine.overrides.spindleOverride) var reqsro = parseInt(data) var delta; @@ -1433,10 +1460,10 @@ io.on("connection", function(socket) { } else if (cursro < reqsro) { // FRO Increase delta = reqsro - cursro - console.log("delta = " + delta) + debug_log("delta = " + delta) var tens = Math.floor(delta / 10) - console.log("need to send " + tens + " x10s increase") + debug_log("need to send " + tens + " x10s increase") // for (i = 0; i < tens; i++) { // addQRealtime(String.fromCharCode(154)); // } @@ -1448,7 +1475,7 @@ io.on("connection", function(socket) { } var ones = delta - (10 * tens); - console.log("need to send " + ones + " x1s increase") + debug_log("need to send " + ones + " x1s increase") // for (i = 0; i < ones; i++) { // addQRealtime(String.fromCharCode(156)); // } @@ -1461,10 +1488,10 @@ io.on("connection", function(socket) { } else if (cursro > reqsro) { // FRO Decrease delta = cursro - reqsro - console.log("delta = " + delta) + debug_log("delta = " + delta) var tens = Math.floor(delta / 10) - console.log("need to send " + tens + " x10s decrease") + debug_log("need to send " + tens + " x10s decrease") // for (i = 0; i < tens; i++) { // addQRealtime(String.fromCharCode(155)); // } @@ -1476,7 +1503,7 @@ io.on("connection", function(socket) { } var ones = delta - (10 * tens); - console.log("need to send " + ones + " x1s decrease") + debug_log("need to send " + ones + " x1s decrease") // for (i = 0; i < tens; i++) { // addQRealtime(String.fromCharCode(157)); // } @@ -1505,7 +1532,7 @@ io.on("connection", function(socket) { break; } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); @@ -1528,42 +1555,42 @@ io.on("connection", function(socket) { socket.on('clearAlarm', function(data) { // Clear Alarm if (status.comms.connectionStatus > 0) { data = parseInt(data); - console.log('Clearing Queue: Method ' + data); + debug_log('Clearing Queue: Method ' + data); switch (data) { case 1: - console.log('Clearing Lockout'); + debug_log('Clearing Lockout'); switch (status.machine.firmware.type) { case 'grbl': addQRealtime('$X\n'); - console.log('Sent: $X'); + debug_log('Sent: $X'); break; case 'smoothie': addQRealtime('$X\n'); - console.log('Sent: $X'); + debug_log('Sent: $X'); break; } - console.log('Resuming Queue Lockout'); + debug_log('Resuming Queue Lockout'); break; case 2: - console.log('Emptying Queue'); + debug_log('Emptying Queue'); status.comms.queue = 0 queuePointer = 0; gcodeQueue.length = 0; // Dump the queue sentBuffer.length = 0; // Dump bufferSizes queuePointer = 0; - console.log('Clearing Lockout'); + debug_log('Clearing Lockout'); switch (status.machine.firmware.type) { case 'grbl': addQRealtime(String.fromCharCode(0x18)); // ctrl-x addQRealtime('$X\n'); - console.log('Sent: $X'); + debug_log('Sent: $X'); status.comms.blocked = false; status.comms.paused = false; break; case 'smoothie': addQToStart('M999'); //M999 send1Q(); - console.log('Sent: M999'); + debug_log('Sent: M999'); status.comms.blocked = false; status.comms.paused = false; break; @@ -1573,34 +1600,34 @@ io.on("connection", function(socket) { status.comms.runStatus = 'Stopped' status.comms.connectionStatus = 2; } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('resetMachine', function() { if (status.comms.connectionStatus > 0) { - console.log('Reset Machine'); + debug_log('Reset Machine'); switch (status.machine.firmware.type) { case 'grbl': addQRealtime(String.fromCharCode(0x18)); // ctrl-x - console.log('Sent: Code(0x18)'); + debug_log('Sent: Code(0x18)'); break; case 'smoothie': addQRealtime(String.fromCharCode(0x18)); // ctrl-x - console.log('Sent: Code(0x18)'); + debug_log('Sent: Code(0x18)'); break; } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); socket.on('closePort', function(data) { // Close machine port and dump queue if (status.comms.connectionStatus > 0) { - console.log('WARN: Closing Port ' + port.path); + debug_log('WARN: Closing Port ' + port.path); stopPort(); } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } }); @@ -1609,11 +1636,11 @@ io.on("connection", function(socket) { function readFile(path) { if (path) { if (path.length > 1) { - console.log('readfile: ' + path) + debug_log('readfile: ' + path) fs.readFile(path, 'utf8', function(err, data) { if (err) { - console.log(err); + debug_log(err); var output = { 'command': '', 'response': "ERROR: File Upload Failed" @@ -1640,7 +1667,7 @@ function readFile(path) { function machineSend(gcode) { // console.time('MachineSend'); - // console.log("SENDING: " + gcode) + // debug_log("SENDING: " + gcode) if (port.isOpen) { if (gcode.match(/T([\d.]+)/i)) { var tool = parseFloat(RegExp.$1); @@ -1649,15 +1676,15 @@ function machineSend(gcode) { } var queueLeft = (gcodeQueue.length - queuePointer) var queueTotal = gcodeQueue.length - // console.log("Q: " + queueLeft) + // debug_log("Q: " + queueLeft) var data = [] data.push(queueLeft); data.push(queueTotal); io.sockets.emit("queueCount", data); - // console.log(gcode) + // debug_log(gcode) port.write(gcode); } else { - console.log("PORT NOT OPEN") + debug_log("PORT NOT OPEN") } // console.timeEnd('MachineSend'); } @@ -1678,17 +1705,17 @@ function stopPort() { } function parseFeedback(data) { - // console.log(data) + // debug_log(data) var state = data.substring(1, data.search(/(,|\|)/)); status.comms.runStatus = state if (state == "Alarm") { - // console.log("ALARM: " + data) + // debug_log("ALARM: " + data) status.comms.connectionStatus = 5; switch (status.machine.firmware.type) { case 'grbl': // sentBuffer.shift(); var alarmCode = parseInt(data.split(':')[1]); - // console.log('ALARM: ' + alarmCode + ' - ' + grblStrings.alarms(alarmCode)); + // debug_log('ALARM: ' + alarmCode + ' - ' + grblStrings.alarms(alarmCode)); status.comms.alarm = alarmCode + ' - ' + grblStrings.alarms(alarmCode) break; case 'smoothie': @@ -1735,7 +1762,7 @@ function parseFeedback(data) { } // If we got a WPOS if (Array.isArray(wPos)) { - // console.log('wpos') + // debug_log('wpos') if (xPos !== parseFloat(wPos[0]).toFixed(config.posDecimals)) { xPos = parseFloat(wPos[0]).toFixed(config.posDecimals); } @@ -1763,7 +1790,7 @@ function parseFeedback(data) { } // end is WPOS } else if (Array.isArray(mPos)) { - // console.log('mpos', mPos) + // debug_log('mpos', mPos) if (xPos !== parseFloat(mPos[0]).toFixed(config.posDecimals)) { xPos = parseFloat(mPos[0]).toFixed(config.posDecimals); } @@ -1934,7 +1961,7 @@ function parseFeedback(data) { var startBuf = data.search(/Bf:/i) + 3; if (startBuf > 3) { var buffer = data.replace(">", "").replace("\r", "").substr(startBuf).split(/,|\|/, 2); - // console.log("BUF: " + JSON.stringify(buffer, null, 2)); + // debug_log("BUF: " + JSON.stringify(buffer, null, 2)); status.machine.firmware.buffer = buffer; } else { status.machine.firmware.buffer = []; @@ -1951,7 +1978,7 @@ function laserTest(data) { if (power > 0) { if (!laserTestOn) { // laserTest is off - // console.log('laserTest: ' + 'Power ' + power + ', Duration ' + duration + ', maxS ' + maxS); + // debug_log('laserTest: ' + 'Power ' + power + ', Duration ' + duration + ', maxS ' + maxS); if (duration >= 0) { switch (status.machine.firmware.type) { case 'grbl': @@ -1989,7 +2016,7 @@ function laserTest(data) { } } } else { - // console.log('laserTest: ' + 'Power off'); + // debug_log('laserTest: ' + 'Power off'); switch (status.machine.firmware.type) { case 'grbl': addQToEnd('M5S0'); @@ -2006,7 +2033,7 @@ function laserTest(data) { } } } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } } @@ -2040,7 +2067,7 @@ function send1Q() { queuePointer++; sentBuffer.push(gcode); machineSend(gcode + '\n'); - // console.log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer) + ' Bspace: ' + (spaceLeft - gcode.length - 1)); + // debug_log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer) + ' Bspace: ' + (spaceLeft - gcode.length - 1)); } else { status.comms.blocked = true; } @@ -2053,7 +2080,7 @@ function send1Q() { status.comms.blocked = true; sentBuffer.push(gcode); machineSend(gcode + '\n'); - // console.log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer)); + // debug_log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer)); } break; } @@ -2063,16 +2090,21 @@ function send1Q() { gcodeQueue.length = 0; // Dump the Queye queuePointer = 0; status.comms.connectionStatus = 2; // finished - io.sockets.emit('jobComplete', true); + var data = { + completed: true, + jobCompletedMsg: jobCompletedMsg + } + io.sockets.emit('jobComplete', data); + jobCompletedMsg = "" } } else { - console.log('Not Connected') + debug_log('Not Connected') } // console.timeEnd('send1Q'); } function addQToEnd(gcode) { - // console.log('added ' + gcode) + // debug_log('added ' + gcode) gcodeQueue.push(gcode); } @@ -2100,14 +2132,14 @@ if (isElectron()) { const gotTheLock = electronApp.requestSingleInstanceLock() var lauchGUI = true; if (!gotTheLock) { - console.log("Already running! Check the System Tray") + debug_log("Already running! Check the System Tray") electronApp.exit(0); electronApp.quit(); } else { electronApp.on('second-instance', (event, commandLine, workingDirectory) => { //Someone tried to run a second instance, we should focus our window. - // console.log('SingleInstance') - // console.log(commandLine) + // debug_log('SingleInstance') + // debug_log(commandLine) lauchGUI = true; var openFilePath = commandLine[1]; if (openFilePath !== "") { @@ -2149,14 +2181,14 @@ if (isElectron()) { function createApp() { createTrayIcon(); if (process.platform == 'darwin') { - console.log("Creating MacOS Menu"); + debug_log("Creating MacOS Menu"); createMenu(); status.driver.operatingsystem = 'macos'; } if (process.platform == 'win32' && process.argv.length >= 2) { var openFilePath = process.argv[1]; if (openFilePath !== "") { - console.log("path" + openFilePath); + debug_log("path" + openFilePath); readFile(openFilePath); } status.driver.operatingsystem = 'windows'; @@ -2229,7 +2261,7 @@ if (isElectron()) { const contextMenu = Menu.buildFromTemplate([{ label: 'Open User Interface (GUI)', click() { - // console.log("Clicked Systray") + // debug_log("Clicked Systray") if (jogWindow === null) { createJogWindow(); jogWindow.show() @@ -2254,7 +2286,7 @@ if (isElectron()) { }]) if (appIcon) { appIcon.on('click', function() { - // console.log("Clicked Systray") + // debug_log("Clicked Systray") if (jogWindow === null) { createJogWindow(); jogWindow.show() @@ -2272,7 +2304,7 @@ if (isElectron()) { if (appIcon) { appIcon.on('balloon-click', function() { - // console.log("Clicked Systray") + // debug_log("Clicked Systray") if (jogWindow === null) { createJogWindow(); jogWindow.show() @@ -2409,12 +2441,12 @@ if (isElectron()) { } else { var isPi = require('detect-rpi'); if (isPi()) { - console.log('Running on Raspberry Pi!'); + debug_log('Running on Raspberry Pi!'); status.driver.operatingsystem = 'rpi' startChrome(); status.driver.operatingsystem = 'raspberrypi'; } else { - console.log("Running under NodeJS..."); + debug_log("Running under NodeJS..."); } } @@ -2422,24 +2454,24 @@ if (isElectron()) { function stop(jog) { if (status.comms.connectionStatus > 0) { status.comms.paused = true; - console.log('STOP'); + debug_log('STOP'); switch (status.machine.firmware.type) { case 'grbl': if (jog) { addQRealtime(String.fromCharCode(0x85)); // canceljog - console.log('Sent: 0x85 Jog Cancel'); + debug_log('Sent: 0x85 Jog Cancel'); } else { addQRealtime('!'); // hold - console.log('Sent: !'); + debug_log('Sent: !'); } if (status.machine.firmware.version === '1.1d') { addQRealtime(String.fromCharCode(0x9E)); // Stop Spindle/Laser - console.log('Sent: Code(0x9E)'); + debug_log('Sent: Code(0x9E)'); } - console.log('Cleaning Queue'); + debug_log('Cleaning Queue'); if (!jog) { addQRealtime(String.fromCharCode(0x18)); // ctrl-x - console.log('Sent: Code(0x18)'); + debug_log('Sent: Code(0x18)'); } status.comms.connectionStatus = 2; break; @@ -2451,7 +2483,7 @@ function stop(jog) { send1Q(); }, 1000); status.comms.connectionStatus = 5; - console.log('Sent: M112'); + debug_log('Sent: M112'); break; } clearInterval(queueCounter); @@ -2465,48 +2497,48 @@ function stop(jog) { status.comms.paused = false; status.comms.runStatus = 'Stopped'; } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } } function pause() { if (status.comms.connectionStatus > 0) { status.comms.paused = true; - console.log('PAUSE'); + debug_log('PAUSE'); switch (status.machine.firmware.type) { case 'grbl': addQRealtime('!'); // Send hold command - console.log('Sent: !'); + debug_log('Sent: !'); if (status.machine.firmware.version === '1.1d') { addQRealtime(String.fromCharCode(0x9E)); // Stop Spindle/Laser - console.log('Sent: Code(0x9E)'); + debug_log('Sent: Code(0x9E)'); } break; case 'smoothie': addQToStart('M600'); // Laser will be turned off by smoothie (in default config!) send1Q(); - console.log('Sent: M600'); + debug_log('Sent: M600'); break; } status.comms.runStatus = 'Paused'; status.comms.connectionStatus = 4; } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } } function unpause() { if (status.comms.connectionStatus > 0) { - console.log('UNPAUSE'); + debug_log('UNPAUSE'); switch (status.machine.firmware.type) { case 'grbl': addQRealtime('~'); // Send resume command - console.log('Sent: ~'); + debug_log('Sent: ~'); break; case 'smoothie': addQToStart('M601'); // Send resume command send1Q(); - console.log('Sent: M601'); + debug_log('Sent: M601'); break; } status.comms.paused = false; @@ -2517,7 +2549,7 @@ function unpause() { status.comms.runStatus = 'Resuming'; status.comms.connectionStatus = 3; } else { - console.log('ERROR: Machine connection not open!'); + debug_log('ERROR: Machine connection not open!'); } } @@ -2546,12 +2578,12 @@ function startChrome() { } = require('child_process'); const chrome = spawn('chromium-browser', ['-app=http://127.0.0.1:3000']); chrome.on('close', (code) => { - console.log(`Chromium process exited with code ${code}`); - console.log(`If you want to continue using OpenBuildsCONTROL, please open Chromium Browser to http://` + ip.address() + `:3000`); + debug_log(`Chromium process exited with code ${code}`); + debug_log(`If you want to continue using OpenBuildsCONTROL, please open Chromium Browser to http://` + ip.address() + `:3000`); }); } else { - console.log('Not a Raspberry Pi. Please use Electron Instead'); + debug_log('Not a Raspberry Pi. Please use Electron Instead'); } } -process.on('exit', () => console.log('exit')) \ No newline at end of file +process.on('exit', () => debug_log('exit')) \ No newline at end of file diff --git a/package.json b/package.json index 19d76ea..56b38f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "OpenBuildsCONTROL", - "version": "1.0.207", + "version": "1.0.210", "license": "AGPL-3.0", "description": "Machine Interface Driver for OpenBuilds", "author": "github.com/openbuilds ", diff --git a/rose1.svg b/rose1.svg new file mode 100644 index 0000000..1295a8c --- /dev/null +++ b/rose1.svg @@ -0,0 +1 @@ +