2018-06-19 08:07:03 +00:00
|
|
|
|
var socket, laststatus;;
|
|
|
|
|
var server = ''; //192.168.14.100';
|
|
|
|
|
var programBoard = {};
|
|
|
|
|
var grblParams = {}
|
|
|
|
|
var smoothieParams = {}
|
|
|
|
|
var nostatusyet = true;
|
2018-06-19 20:25:40 +00:00
|
|
|
|
var safeToUpdateSliders = false;
|
|
|
|
|
var laststatus
|
|
|
|
|
var simstopped = false;
|
2018-06-21 21:04:41 +00:00
|
|
|
|
var bellstate = false;
|
2018-06-25 17:25:19 +00:00
|
|
|
|
var toast = Metro.toast.create;
|
2019-05-10 18:36:51 +00:00
|
|
|
|
var unit = "mm"
|
2018-06-19 20:25:40 +00:00
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
initSocket();
|
2018-06-21 20:02:40 +00:00
|
|
|
|
|
2018-08-07 10:05:49 +00:00
|
|
|
|
$("#command").inputHistory({
|
|
|
|
|
enter: function() {
|
2018-06-21 20:02:40 +00:00
|
|
|
|
$("#sendCommand").click();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("form").submit(function() {
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2019-09-03 18:36:09 +00:00
|
|
|
|
});
|
|
|
|
|
|
2019-09-13 18:39:59 +00:00
|
|
|
|
function showGrbl(bool) {
|
|
|
|
|
if (bool) {
|
|
|
|
|
sendGcode('$$')
|
|
|
|
|
sendGcode('$I')
|
|
|
|
|
$("#grblButtons").show()
|
|
|
|
|
$("#firmwarename").html('Grbl')
|
|
|
|
|
} else {
|
|
|
|
|
$("#grblButtons").hide()
|
|
|
|
|
$("#firmwarename").html('')
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
|
|
|
|
|
function printLog(string) {
|
2019-10-18 18:55:41 +00:00
|
|
|
|
if (!disableSerialLog) {
|
|
|
|
|
if (document.getElementById("console") !== null) {
|
|
|
|
|
if (string.isString) {
|
|
|
|
|
// split(/\r\n|\n|\r/);
|
|
|
|
|
string = string.replace(/\r\n|\n|\r/, "<br />");
|
|
|
|
|
}
|
|
|
|
|
if ($('#console p').length > 100) {
|
|
|
|
|
// remove oldest if already at 300 lines
|
|
|
|
|
$('#console p').first().remove();
|
|
|
|
|
}
|
|
|
|
|
var template = '<p class="pf">';
|
|
|
|
|
var time = new Date();
|
2018-06-19 20:25:40 +00:00
|
|
|
|
|
2019-10-18 18:55:41 +00:00
|
|
|
|
template += '<span class="fg-brandColor1">[' + (time.getHours() < 10 ? '0' : '') + time.getHours() + ":" + (time.getMinutes() < 10 ? '0' : '') + time.getMinutes() + ":" + (time.getSeconds() < 10 ? '0' : '') + time.getSeconds() + ']</span> ';
|
|
|
|
|
template += string;
|
|
|
|
|
$('#console').append(template);
|
|
|
|
|
$('#console').scrollTop(($("#console")[0].scrollHeight - $("#console").height()) + 20);
|
|
|
|
|
}
|
2018-08-24 19:00:03 +00:00
|
|
|
|
}
|
2019-10-18 18:55:41 +00:00
|
|
|
|
};
|
2018-06-19 20:25:40 +00:00
|
|
|
|
|
2018-06-19 08:07:03 +00:00
|
|
|
|
function initSocket() {
|
2018-06-19 20:25:40 +00:00
|
|
|
|
socket = io.connect(server); // socket.io init
|
2018-09-18 19:26:29 +00:00
|
|
|
|
printLog("<span class='fg-red'>[ Websocket ] </span><span class='fg-green'>Bidirectional Websocket Interface Started</span>")
|
2018-06-19 20:25:40 +00:00
|
|
|
|
setTimeout(function() {
|
|
|
|
|
populatePortsMenu();
|
|
|
|
|
}, 2000);
|
|
|
|
|
|
2018-06-20 13:16:46 +00:00
|
|
|
|
socket.on('disconnect', function() {
|
|
|
|
|
console.log("WEBSOCKET DISCONNECTED")
|
2018-11-23 16:13:16 +00:00
|
|
|
|
printLog("<span class='fg-red'>[ Websocket ] </span><span class='fg-brown'> Disconnected. OpenBuilds CONTROL probably quit or crashed</span>")
|
2018-08-07 10:05:49 +00:00
|
|
|
|
$("#websocketstatus").html("Disconnected")
|
2018-06-20 13:16:46 +00:00
|
|
|
|
});
|
|
|
|
|
|
2018-08-07 10:05:49 +00:00
|
|
|
|
socket.on('connect', function() {
|
|
|
|
|
$("#websocketstatus").html("Connected")
|
|
|
|
|
});
|
2018-06-29 19:48:34 +00:00
|
|
|
|
|
|
|
|
|
socket.on('gcodeupload', function(data) {
|
|
|
|
|
printLog("Received new GCODE from API")
|
|
|
|
|
editor.session.setValue(data);
|
2018-09-06 17:50:01 +00:00
|
|
|
|
parseGcodeInWebWorker(data)
|
2018-08-08 17:56:11 +00:00
|
|
|
|
$('#controlTab').click()
|
2019-10-18 18:55:41 +00:00
|
|
|
|
if (webgl) {
|
2018-08-29 08:11:14 +00:00
|
|
|
|
$('#gcodeviewertab').click();
|
|
|
|
|
} else {
|
|
|
|
|
$('#gcodeeditortab').click()
|
|
|
|
|
}
|
2018-06-29 19:48:34 +00:00
|
|
|
|
});
|
|
|
|
|
|
2018-08-09 12:20:42 +00:00
|
|
|
|
socket.on('gcodeupload', function(data) {
|
|
|
|
|
printLog("Activated window");
|
|
|
|
|
});
|
|
|
|
|
|
2018-08-08 17:56:11 +00:00
|
|
|
|
socket.on('integrationpopup', function(data) {
|
|
|
|
|
printLog("Integration called from " + data)
|
|
|
|
|
// editor.session.setValue(data);
|
|
|
|
|
$('#controlTab').click()
|
|
|
|
|
$('#consoletab').click()
|
|
|
|
|
// gcodeeditortab
|
|
|
|
|
});
|
2018-06-29 19:48:34 +00:00
|
|
|
|
|
2018-07-12 13:06:53 +00:00
|
|
|
|
socket.on('updatedata', function(data) {
|
|
|
|
|
// console.log(data.length, data)
|
|
|
|
|
var toPrint = data.response;
|
2018-08-10 19:42:30 +00:00
|
|
|
|
printLog("<span class='fg-red'>[ " + data.command + " ]</span> <span class='fg-green'>" + toPrint + "</span>")
|
2018-07-12 13:06:53 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('updateready', function(data) {
|
2019-07-17 15:14:18 +00:00
|
|
|
|
// 0 = not connected
|
|
|
|
|
// 1 = Connected, but not Playing yet
|
|
|
|
|
// 2 = Connected, but not Playing yet
|
|
|
|
|
// 3 = Busy Streaming GCODE
|
|
|
|
|
// 4 = Paused
|
|
|
|
|
// 5 = Alarm State
|
|
|
|
|
// 6 = Firmware Upgrade State
|
2020-01-08 13:39:24 +00:00
|
|
|
|
if (laststatus.comms.connectionStatus < 3 && !continuousJogRunning) {
|
2019-07-17 15:14:18 +00:00
|
|
|
|
$('#availVersion').html(data)
|
2020-03-06 15:59:58 +00:00
|
|
|
|
getChangelog();
|
2019-07-17 15:14:18 +00:00
|
|
|
|
Metro.dialog.open('#downloadUpdate')
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-12 13:06:53 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('updateprogress', function(data) {
|
|
|
|
|
$('#downloadprogress').html(data + "%");
|
|
|
|
|
});
|
2018-06-29 19:48:34 +00:00
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
socket.on('data', function(data) {
|
2018-12-21 13:56:11 +00:00
|
|
|
|
// console.log(data)
|
2018-09-27 15:00:49 +00:00
|
|
|
|
var toPrint = escapeHTML(data.response);
|
2018-06-19 08:07:03 +00:00
|
|
|
|
|
2018-06-20 13:00:05 +00:00
|
|
|
|
// Parse Grbl Settings Feedback
|
2018-06-27 20:53:07 +00:00
|
|
|
|
if (data.response.indexOf('$') === 0) {
|
2018-08-24 19:00:03 +00:00
|
|
|
|
if (typeof grblSettings !== 'undefined') {
|
|
|
|
|
grblSettings(data.response)
|
|
|
|
|
var key = data.response.split('=')[0].substr(1);
|
|
|
|
|
var descr = grblSettingCodes[key];
|
|
|
|
|
toPrint = data.response + " ;" + descr
|
|
|
|
|
printLog("<span class='fg-red'>[ " + data.command + " ]</span> <span class='fg-green'>" + toPrint + "</span>")
|
|
|
|
|
}
|
2018-09-27 15:00:49 +00:00
|
|
|
|
} else {
|
|
|
|
|
printLog("<span class='fg-red'>[ " + data.command + " ]</span> <span class='fg-green'>" + toPrint + "</span>")
|
2018-06-19 20:25:40 +00:00
|
|
|
|
};
|
2018-06-20 13:00:05 +00:00
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
});
|
|
|
|
|
|
2018-06-21 20:02:40 +00:00
|
|
|
|
socket.on("grbl", function(data) {
|
|
|
|
|
showGrbl(true)
|
|
|
|
|
});
|
|
|
|
|
|
2018-12-28 21:28:44 +00:00
|
|
|
|
socket.on("prbResult", function(data) {
|
|
|
|
|
z0proberesult(data)
|
|
|
|
|
});
|
|
|
|
|
|
2019-09-13 18:39:59 +00:00
|
|
|
|
socket.on("jobComplete", function(data) {
|
2020-03-06 15:59:58 +00:00
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 18:39:59 +00:00
|
|
|
|
});
|
2019-01-23 19:07:58 +00:00
|
|
|
|
|
|
|
|
|
socket.on("machinename", function(data) {
|
2019-04-22 19:17:09 +00:00
|
|
|
|
if (typeof setMachineButton !== 'undefined') {
|
2019-04-22 14:52:10 +00:00
|
|
|
|
setMachineButton(data)
|
|
|
|
|
}
|
2019-01-23 19:07:58 +00:00
|
|
|
|
});
|
2019-09-13 18:39:59 +00:00
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
socket.on("queueCount", function(data) {
|
2018-08-01 20:20:17 +00:00
|
|
|
|
// calc percentage
|
|
|
|
|
var left = parseInt(data[0])
|
|
|
|
|
var total = parseInt(data[1])
|
|
|
|
|
var done = total - left;
|
|
|
|
|
var donepercent = parseInt(done / total * 100)
|
|
|
|
|
var progressbar = $("#progressbar").data("progress");
|
2018-08-24 19:00:03 +00:00
|
|
|
|
if (progressbar) {
|
|
|
|
|
progressbar.val(donepercent);
|
|
|
|
|
}
|
2019-04-18 14:23:51 +00:00
|
|
|
|
if (laststatus) {
|
|
|
|
|
if (laststatus.comms.connectionStatus == 3) {
|
|
|
|
|
editor.gotoLine(parseInt(data[1]) - parseInt(data[0]));
|
|
|
|
|
}
|
2019-04-22 14:52:10 +00:00
|
|
|
|
if (typeof object !== 'undefined' && done > 0) {
|
2019-09-13 18:39:59 +00:00
|
|
|
|
if (object.userData !== 'undefined' && object.userData && object.userData.lines.length > 2) {
|
2019-05-10 18:36:51 +00:00
|
|
|
|
var timeremain = object.userData.lines[object.userData.lines.length - 1].p2.timeMinsSum - object.userData.lines[done].p2.timeMinsSum;
|
|
|
|
|
}
|
2019-04-18 14:23:51 +00:00
|
|
|
|
if (!isNaN(timeremain)) {
|
|
|
|
|
var mins_num = parseFloat(timeremain, 10); // don't forget the second param
|
|
|
|
|
var hours = Math.floor(mins_num / 60);
|
|
|
|
|
var minutes = Math.floor((mins_num - ((hours * 3600)) / 60));
|
|
|
|
|
var seconds = Math.floor((mins_num * 60) - (hours * 3600) - (minutes * 60));
|
|
|
|
|
|
|
|
|
|
// Appends 0 when unit is less than 10
|
|
|
|
|
if (hours < 10) {
|
|
|
|
|
hours = "0" + hours;
|
|
|
|
|
}
|
|
|
|
|
if (minutes < 10) {
|
|
|
|
|
minutes = "0" + minutes;
|
|
|
|
|
}
|
|
|
|
|
if (seconds < 10) {
|
|
|
|
|
seconds = "0" + seconds;
|
|
|
|
|
}
|
|
|
|
|
var formattedTime = hours + ':' + minutes + ':' + seconds;
|
|
|
|
|
console.log('Remaining time: ', formattedTime)
|
|
|
|
|
// output formattedTime to UI here
|
|
|
|
|
$('#timeRemaining').html(" / " + formattedTime);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#timeRemaining').empty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$('#gcodesent').html("Job Queue: " + parseInt(data[0]));
|
2018-06-19 20:25:40 +00:00
|
|
|
|
})
|
|
|
|
|
|
2019-03-06 19:26:09 +00:00
|
|
|
|
socket.on('toastErrorAlarm', function(data) {
|
2019-04-22 14:52:10 +00:00
|
|
|
|
console.log("toast", data)
|
2019-03-06 19:26:09 +00:00
|
|
|
|
// toast("<i class='fas fa-exclamation-triangle'></i> " + data, null, 2300, "bg-red fg-white");
|
|
|
|
|
Metro.dialog.create({
|
2019-06-03 17:07:46 +00:00
|
|
|
|
clsDialog: 'dark',
|
|
|
|
|
title: "<i class='fas fa-exclamation-triangle'></i> Grbl Alarm:",
|
2019-03-06 19:26:09 +00:00
|
|
|
|
content: "<i class='fas fa-exclamation-triangle fg-red'></i> " + data,
|
|
|
|
|
actions: [{
|
|
|
|
|
caption: "Clear Alarm",
|
2019-04-22 14:52:10 +00:00
|
|
|
|
cls: "js-dialog-close alert closeAlarmBtn",
|
2019-03-06 19:26:09 +00:00
|
|
|
|
onclick: function() {
|
|
|
|
|
socket.emit('clearAlarm', 2)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
caption: "Cancel",
|
|
|
|
|
cls: "js-dialog-close",
|
|
|
|
|
onclick: function() {
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
2020-03-06 15:59:58 +00:00
|
|
|
|
setTimeout(function() {
|
|
|
|
|
$(".closeAlarmBtn").focus();
|
|
|
|
|
}, 200, )
|
2019-03-06 19:26:09 +00:00
|
|
|
|
//
|
|
|
|
|
});
|
|
|
|
|
|
2018-06-25 17:25:19 +00:00
|
|
|
|
socket.on('toastError', function(data) {
|
|
|
|
|
// console.log("toast", data)
|
2018-10-25 19:25:57 +00:00
|
|
|
|
// toast("<i class='fas fa-exclamation-triangle'></i> " + data, null, 2300, "bg-red fg-white");
|
|
|
|
|
Metro.dialog.create({
|
2019-06-03 17:07:46 +00:00
|
|
|
|
title: "<i class='fas fa-exclamation-triangle'></i> Grbl Error:",
|
|
|
|
|
content: "<i class='fas fa-exclamation-triangle fg-red'></i> " + data,
|
2020-03-06 15:59:58 +00:00
|
|
|
|
clsDialog: 'dark',
|
|
|
|
|
actions: [{
|
|
|
|
|
caption: "OK",
|
|
|
|
|
cls: "js-dialog-close alert closeErrorBtn",
|
|
|
|
|
onclick: function() {
|
|
|
|
|
socket.emit('clearAlarm', 2)
|
|
|
|
|
}
|
|
|
|
|
}]
|
2018-10-25 19:25:57 +00:00
|
|
|
|
});
|
2020-03-06 15:59:58 +00:00
|
|
|
|
setTimeout(function() {
|
|
|
|
|
$(".closeErrorBtn").focus();
|
|
|
|
|
}, 200, )
|
2018-06-25 17:25:19 +00:00
|
|
|
|
//
|
|
|
|
|
});
|
2018-10-25 19:25:57 +00:00
|
|
|
|
|
2018-06-25 17:25:19 +00:00
|
|
|
|
socket.on('toastSuccess', function(data) {
|
|
|
|
|
console.log("toast", data)
|
2018-06-25 20:13:58 +00:00
|
|
|
|
toast("<i class='fas fa-exclamation-triangle'></i> " + data, null, 2300, "bg-green fg-white");
|
2018-06-25 17:25:19 +00:00
|
|
|
|
//
|
|
|
|
|
});
|
|
|
|
|
|
2019-12-30 19:56:20 +00:00
|
|
|
|
|
2018-12-20 19:22:02 +00:00
|
|
|
|
socket.on('progStatus', function(data) {
|
|
|
|
|
$('#controlTab').click();
|
|
|
|
|
$('#consoletab').click();
|
|
|
|
|
console.log(data.port, data.string)
|
|
|
|
|
var string = data.string
|
|
|
|
|
if (string) {
|
|
|
|
|
if (string.indexOf('flash complete') != -1) {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
populatePortsMenu();
|
|
|
|
|
}, 400)
|
|
|
|
|
}
|
|
|
|
|
string = string.replace('[31mflash complete.[39m', "<span class='fg-red'><i class='fas fa-times fa-fw fg-red fa-fw'> </i> FLASH FAILED!</span> ");
|
|
|
|
|
string = string.replace('[32m', "<span class='fg-green'><i class='fas fa-check fa-fw fg-green fa-fw'></i> ");
|
|
|
|
|
string = string.replace('[39m', "</span>");
|
|
|
|
|
printLog("<span class='fg-red'>[ Firmware Upgrade ] </span>" + string)
|
|
|
|
|
|
|
|
|
|
// $('#sendCommand').click();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
socket.on('status', function(status) {
|
2018-08-07 10:05:49 +00:00
|
|
|
|
|
2018-06-26 10:33:13 +00:00
|
|
|
|
if (nostatusyet) {
|
2018-11-23 16:13:16 +00:00
|
|
|
|
$('#windowtitle').html("OpenBuilds CONTROL v" + status.driver.version)
|
2019-06-06 19:11:48 +00:00
|
|
|
|
if (status.driver.operatingsystem == "rpi") {
|
|
|
|
|
$('#windowtitlebar').hide();
|
|
|
|
|
}
|
2018-06-26 10:33:13 +00:00
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
nostatusyet = false;
|
2018-06-26 10:33:13 +00:00
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
// if (!_.isEqual(status, laststatus)) {
|
|
|
|
|
if (laststatus !== undefined) {
|
|
|
|
|
if (!_.isEqual(status.comms.interfaces.ports, laststatus.comms.interfaces.ports)) {
|
|
|
|
|
var string = "Detected a change in available ports: ";
|
|
|
|
|
for (i = 0; i < status.comms.interfaces.ports.length; i++) {
|
2020-03-19 15:13:52 +00:00
|
|
|
|
string += "[" + status.comms.interfaces.ports[i].path + "]"
|
2018-06-19 20:25:40 +00:00
|
|
|
|
}
|
2019-04-16 13:17:42 +00:00
|
|
|
|
|
|
|
|
|
if (!status.comms.interfaces.ports.length) {
|
|
|
|
|
string += "[ No devices connected ]"
|
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
printLog(string)
|
|
|
|
|
laststatus.comms.interfaces.ports = status.comms.interfaces.ports;
|
|
|
|
|
populatePortsMenu();
|
2018-06-19 08:07:03 +00:00
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
}
|
2018-06-27 19:23:34 +00:00
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
$('#runStatus').html("Controller: " + status.comms.runStatus);
|
|
|
|
|
|
2019-10-18 18:55:41 +00:00
|
|
|
|
if (!disableDROupdates) {
|
|
|
|
|
if (unit == "mm") {
|
|
|
|
|
var xpos = status.machine.position.work.x + unit;
|
|
|
|
|
var ypos = status.machine.position.work.y + unit;
|
|
|
|
|
var zpos = status.machine.position.work.z + unit;
|
|
|
|
|
} else if (unit == "in") {
|
|
|
|
|
var xpos = (status.machine.position.work.x / 25.4).toFixed(2) + unit;
|
|
|
|
|
var ypos = (status.machine.position.work.y / 25.4).toFixed(2) + unit;
|
|
|
|
|
var zpos = (status.machine.position.work.z / 25.4).toFixed(2) + unit;
|
|
|
|
|
}
|
2018-08-07 10:05:49 +00:00
|
|
|
|
|
2019-10-18 18:55:41 +00:00
|
|
|
|
if ($('#xPos').html() != xpos) {
|
|
|
|
|
$('#xPos').html(xpos);
|
|
|
|
|
}
|
|
|
|
|
if ($('#yPos').html() != ypos) {
|
|
|
|
|
$('#yPos').html(ypos);
|
|
|
|
|
}
|
|
|
|
|
if ($('#zPos').html() != zpos) {
|
|
|
|
|
$('#zPos').html(zpos);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$('#xPos').html('disabled');
|
|
|
|
|
$('#yPos').html('disabled');
|
|
|
|
|
$('#zPos').html('disabled');
|
2018-06-25 17:25:19 +00:00
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
|
2018-08-28 15:16:17 +00:00
|
|
|
|
if (webgl) {
|
2019-10-18 18:55:41 +00:00
|
|
|
|
if (!disable3Drealtimepos) {
|
|
|
|
|
if (!isJogWidget) {
|
|
|
|
|
if (!simRunning) {
|
|
|
|
|
if (object) {
|
|
|
|
|
// if (object.userData.inch) {
|
|
|
|
|
// cone.position.x = status.machine.position.work.x * 0.0393701
|
|
|
|
|
// cone.position.y = status.machine.position.work.y * 0.0393701
|
|
|
|
|
// cone.position.z = (parseFloat(status.machine.position.work.z * 0.0393701) + 20)
|
|
|
|
|
// } else {
|
2018-09-18 15:06:03 +00:00
|
|
|
|
cone.position.x = status.machine.position.work.x
|
|
|
|
|
cone.position.y = status.machine.position.work.y
|
|
|
|
|
cone.position.z = (parseFloat(status.machine.position.work.z) + 20)
|
2019-10-18 18:55:41 +00:00
|
|
|
|
// }
|
2018-09-18 15:06:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 18:55:41 +00:00
|
|
|
|
}
|
2018-08-28 15:16:17 +00:00
|
|
|
|
}
|
2018-08-28 15:09:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
if (safeToUpdateSliders) {
|
2018-08-24 19:00:03 +00:00
|
|
|
|
if ($('#fro').data('slider') && $('#tro').data('slider')) {
|
|
|
|
|
$('#fro').data('slider').val(status.machine.overrides.feedOverride)
|
|
|
|
|
$('#tro').data('slider').val(status.machine.overrides.spindleOverride)
|
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-07 10:05:49 +00:00
|
|
|
|
// Grbl Pins Input Status
|
|
|
|
|
$('.pinstatus').removeClass('alert').addClass('success').html('OFF')
|
2019-01-23 19:07:58 +00:00
|
|
|
|
$('#holdpin').html('HOLD:OFF')
|
|
|
|
|
$('#resetpin').html('RST:OFF')
|
|
|
|
|
$('#startpin').html('START:OFF')
|
2018-08-07 10:05:49 +00:00
|
|
|
|
if (status.machine.inputs.length > 0) {
|
|
|
|
|
for (i = 0; i < status.machine.inputs.length; i++) {
|
|
|
|
|
switch (status.machine.inputs[i]) {
|
|
|
|
|
case 'X':
|
|
|
|
|
// console.log('PIN: X-LIMIT');
|
|
|
|
|
$('#xpin').removeClass('success').addClass('alert').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'Y':
|
|
|
|
|
// console.log('PIN: Y-LIMIT');
|
|
|
|
|
$('#ypin').removeClass('success').addClass('alert').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'Z':
|
|
|
|
|
// console.log('PIN: Z-LIMIT');
|
|
|
|
|
$('#zpin').removeClass('success').addClass('alert').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'P':
|
|
|
|
|
// console.log('PIN: PROBE');
|
|
|
|
|
$('#prbpin').removeClass('success').addClass('alert').html('ON')
|
|
|
|
|
break;
|
2019-01-23 19:07:58 +00:00
|
|
|
|
case 'D':
|
|
|
|
|
// console.log('PIN: DOOR');
|
|
|
|
|
$('#doorpin').removeClass('success').addClass('alert').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'H':
|
|
|
|
|
// console.log('PIN: HOLD');
|
|
|
|
|
$('#holdpin').removeClass('success').addClass('alert').html('HOLD:ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'R':
|
|
|
|
|
// console.log('PIN: SOFTRESET');
|
|
|
|
|
$('#resetpin').removeClass('success').addClass('alert').html('RST:ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'S':
|
|
|
|
|
// console.log('PIN: CYCLESTART');
|
|
|
|
|
$('#startpin').removeClass('success').addClass('alert').html('START:ON')
|
|
|
|
|
break;
|
2018-08-07 10:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#driverver').html("v" + status.driver.version);
|
|
|
|
|
if (!status.machine.firmware.type) {
|
|
|
|
|
$('#firmwarever').html("NOCOMM");
|
|
|
|
|
} else {
|
|
|
|
|
$('#firmwarever').html(status.machine.firmware.type + " v" + status.machine.firmware.version);
|
|
|
|
|
}
|
|
|
|
|
$('#commblocked').html(status.comms.blocked ? "BLOCKED" : "Ready");
|
|
|
|
|
var string = '';
|
|
|
|
|
switch (status.comms.connectionStatus) {
|
|
|
|
|
case 0:
|
|
|
|
|
string += "Not Connected"
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
string += "Connected"
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
string += "Streaming"
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
string += "Paused"
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
string += "Alarmed"
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$('#commstatus').html(string);
|
|
|
|
|
$('#drvqueue').html(status.comms.queue);
|
2019-05-07 17:26:26 +00:00
|
|
|
|
|
2018-12-21 13:56:11 +00:00
|
|
|
|
if (status.comms.interfaces.activePort) {
|
|
|
|
|
$('#activeportstatus').html(status.comms.interfaces.activePort)
|
|
|
|
|
} else {
|
|
|
|
|
$('#activeportstatus').html("none")
|
|
|
|
|
}
|
2018-08-07 10:05:49 +00:00
|
|
|
|
|
2018-08-25 16:54:28 +00:00
|
|
|
|
// Set the Connection Toolbar option
|
|
|
|
|
setConnectBar(status.comms.connectionStatus, status);
|
|
|
|
|
setControlBar(status.comms.connectionStatus, status)
|
|
|
|
|
setJogPanel(status.comms.connectionStatus, status)
|
|
|
|
|
setConsole(status.comms.connectionStatus, status)
|
|
|
|
|
if (status.comms.connectionStatus != 5) {
|
|
|
|
|
bellstate = false
|
|
|
|
|
};
|
|
|
|
|
if (status.comms.connectionStatus == 0) {
|
|
|
|
|
showGrbl(false)
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
laststatus = status;
|
|
|
|
|
});
|
|
|
|
|
|
2019-07-23 19:04:50 +00:00
|
|
|
|
socket.on('features', function(data) {
|
|
|
|
|
console.log('FEATURES', data)
|
2019-09-03 18:36:09 +00:00
|
|
|
|
for (i = 0; i < data.length; i++) {
|
|
|
|
|
switch (data[i]) {
|
2019-07-23 19:04:50 +00:00
|
|
|
|
case 'Q':
|
|
|
|
|
console.log('SPINDLE_IS_SERVO Enabled')
|
|
|
|
|
$('#enServo').removeClass('alert').addClass('success').html('ON')
|
2019-09-03 18:36:09 +00:00
|
|
|
|
$(".servo-active").show()
|
2019-07-23 19:04:50 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'V': // Variable spindle enabled
|
|
|
|
|
console.log('Variable spindle enabled')
|
|
|
|
|
$('#enVariableSpindle').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'N': // Line numbers enabled
|
|
|
|
|
console.log('Line numbers enabled')
|
|
|
|
|
$('#enLineNumbers').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'M': // Mist coolant enabled
|
|
|
|
|
console.log('Mist coolant enabled')
|
|
|
|
|
$('#menuMisting').show();
|
|
|
|
|
$('#enMisting').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'C': // CoreXY enabled
|
|
|
|
|
console.log('CoreXY enabled')
|
|
|
|
|
$('#enCoreXY').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'P': // Parking motion enabled
|
|
|
|
|
console.log('Parking motion enabled')
|
|
|
|
|
$('#enParking').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'Z': // Homing force origin enabled
|
|
|
|
|
console.log('Homing force origin enabled')
|
|
|
|
|
$('#enHomingOrigin').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'H': // Homing single axis enabled
|
|
|
|
|
console.log('Homing single axis enabled')
|
|
|
|
|
$('#enSingleAxisHome').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'T': // Two limit switches on axis enabled
|
|
|
|
|
console.log('Two limit switches on axis enabled')
|
|
|
|
|
$('#enTwoLimits').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'A': // Allow feed rate overrides in probe cycles
|
|
|
|
|
console.log('Allow feed rate overrides in probe cycles')
|
|
|
|
|
$('#enFeedOVProbe').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case '$': // Restore EEPROM $ settings disabled
|
|
|
|
|
console.log('Restore EEPROM $ settings disabled')
|
|
|
|
|
$('#enEepromSettingsDisable').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case '#': // Restore EEPROM parameter data disabled
|
|
|
|
|
console.log('Restore EEPROM parameter data disabled')
|
|
|
|
|
$('#enEepromParamsDisable').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'I': // Build info write user string disabled
|
|
|
|
|
console.log('Build info write user string disabled')
|
|
|
|
|
$('#enBuildInfoDisabled').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'E': // Force sync upon EEPROM write disabled
|
|
|
|
|
console.log('Force sync upon EEPROM write disabled')
|
|
|
|
|
$('#enForceSyncEeprom').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
case 'W': // Force sync upon work coordinate offset change disabled
|
|
|
|
|
console.log('Force sync upon work coordinate offset change disabled')
|
|
|
|
|
$('#enForceSyncWco').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
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')
|
|
|
|
|
$('#enHomingInitLock').removeClass('alert').addClass('success').html('ON')
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
$('#sendCommand').on('click', function() {
|
|
|
|
|
var commandValue = $('#command').val();
|
|
|
|
|
sendGcode(commandValue);
|
2018-08-07 10:05:49 +00:00
|
|
|
|
// $('#command').val('');
|
2018-06-19 20:25:40 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#command').on('keypress', function(e) {
|
|
|
|
|
if (e.which === 13) {
|
|
|
|
|
$(this).attr("disabled", "disabled");
|
|
|
|
|
var commandValue = $('#command').val();
|
|
|
|
|
sendGcode(commandValue);
|
|
|
|
|
$('#command').val('');
|
|
|
|
|
$(this).removeAttr("disabled");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var bellflash = setInterval(function() {
|
|
|
|
|
if (!nostatusyet) {
|
2018-06-24 14:14:28 +00:00
|
|
|
|
if (laststatus) {
|
|
|
|
|
if (laststatus.comms.connectionStatus == 5) {
|
|
|
|
|
if (bellstate == false) {
|
|
|
|
|
$('#navbell').hide();
|
2018-06-25 20:13:58 +00:00
|
|
|
|
$('#navbellBtn1').hide();
|
|
|
|
|
$('#navbellBtn2').hide();
|
|
|
|
|
$('#navbellBtn3').hide();
|
2018-06-24 14:14:28 +00:00
|
|
|
|
bellstate = true
|
|
|
|
|
} else {
|
|
|
|
|
$('#navbell').show();
|
2018-06-25 20:13:58 +00:00
|
|
|
|
$('#navbellBtn1').show();
|
|
|
|
|
$('#navbellBtn2').show();
|
|
|
|
|
$('#navbellBtn3').show();
|
2018-06-24 14:14:28 +00:00
|
|
|
|
bellstate = false
|
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
} else {
|
2018-06-24 14:14:28 +00:00
|
|
|
|
$('#navbell').hide();
|
2018-06-25 20:13:58 +00:00
|
|
|
|
$('#navbellBtn1').hide();
|
|
|
|
|
$('#navbellBtn2').hide();
|
|
|
|
|
$('#navbellBtn3').hide();
|
2018-06-19 08:07:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
}
|
|
|
|
|
}, 200);
|
2018-06-19 08:07:03 +00:00
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function selectPort() {
|
2019-03-25 19:10:26 +00:00
|
|
|
|
$('#consoletab').click();
|
2018-06-19 20:25:40 +00:00
|
|
|
|
socket.emit('connectTo', 'usb,' + $("#portUSB").val() + ',' + '115200');
|
2018-06-19 08:07:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function closePort() {
|
|
|
|
|
socket.emit('closePort', 1);
|
|
|
|
|
populatePortsMenu();
|
|
|
|
|
$('.mdata').val('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function populatePortsMenu() {
|
2018-06-20 13:00:05 +00:00
|
|
|
|
var response = `<select id="select1" data-role="select" class="mt-4"><optgroup label="USB Ports">`
|
2018-06-19 20:25:40 +00:00
|
|
|
|
for (i = 0; i < laststatus.comms.interfaces.ports.length; i++) {
|
|
|
|
|
var port = friendlyPort(i)
|
2020-03-19 15:13:52 +00:00
|
|
|
|
response += `<option value="` + laststatus.comms.interfaces.ports[i].path + `">` + port.note + " " + laststatus.comms.interfaces.ports[i].path.replace("/dev/tty.", "") + `</option>`;
|
2018-06-19 20:25:40 +00:00
|
|
|
|
};
|
2019-04-16 13:17:42 +00:00
|
|
|
|
if (!laststatus.comms.interfaces.ports.length) {
|
2020-03-06 15:59:58 +00:00
|
|
|
|
response += `<option value="">Waiting for USB</option>`
|
|
|
|
|
$("#driverBtn").show();
|
|
|
|
|
} else {
|
|
|
|
|
$("#driverBtn").hide();
|
2019-04-16 13:17:42 +00:00
|
|
|
|
}
|
2018-06-20 13:00:05 +00:00
|
|
|
|
response += `</optgroup></select>`
|
|
|
|
|
var select = $("#portUSB").data("select");
|
|
|
|
|
select.data(response);
|
2018-12-21 13:56:11 +00:00
|
|
|
|
var select2 = $("#portUSB2").data("select");
|
2019-04-22 14:52:10 +00:00
|
|
|
|
if (select2) {
|
|
|
|
|
select2.data(response);
|
|
|
|
|
}
|
2018-06-21 20:02:40 +00:00
|
|
|
|
$('#portUSB').parent(".select").removeClass('disabled')
|
2018-12-21 13:56:11 +00:00
|
|
|
|
$('#portUSB2').parent(".select").removeClass('disabled')
|
2018-06-27 19:23:34 +00:00
|
|
|
|
$("#connectBtn").attr('disabled', false);
|
2018-06-19 08:07:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function sendGcode(gcode) {
|
2018-06-19 20:25:40 +00:00
|
|
|
|
if (gcode) {
|
|
|
|
|
socket.emit('runCommand', gcode);
|
|
|
|
|
}
|
2018-06-19 08:07:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function feedOverride(step) {
|
2018-06-25 17:25:19 +00:00
|
|
|
|
if (socket) {
|
|
|
|
|
socket.emit('feedOverride', step);
|
2019-04-12 13:32:56 +00:00
|
|
|
|
$('#fro').data('slider').buff(((step - 10) * 100) / (200 - 10))
|
2018-06-25 17:25:19 +00:00
|
|
|
|
}
|
2018-06-19 08:07:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function spindleOverride(step) {
|
2018-06-25 17:25:19 +00:00
|
|
|
|
if (socket) {
|
|
|
|
|
socket.emit('spindleOverride', step);
|
2019-04-12 13:32:56 +00:00
|
|
|
|
$('#tro').data('slider').buff(((step - 10) * 100) / (200 - 10))
|
2018-06-25 17:25:19 +00:00
|
|
|
|
}
|
2018-06-19 08:07:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function friendlyPort(i) {
|
2018-06-19 20:25:40 +00:00
|
|
|
|
// var likely = false;
|
|
|
|
|
var img = 'usb.png';
|
|
|
|
|
var note = '';
|
|
|
|
|
var manufacturer = laststatus.comms.interfaces.ports[i].manufacturer
|
|
|
|
|
if (manufacturer == `(Standard port types)`) {
|
|
|
|
|
img = 'serial.png'
|
|
|
|
|
note = 'Motherboard Serial Port';
|
|
|
|
|
} else if (laststatus.comms.interfaces.ports[i].productId && laststatus.comms.interfaces.ports[i].vendorId) {
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '6015' && laststatus.comms.interfaces.ports[i].vendorId == '1D50') {
|
|
|
|
|
// found Smoothieboard
|
|
|
|
|
img = 'smoothieboard.png';
|
|
|
|
|
note = 'Smoothieware USB Port';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '6001' && laststatus.comms.interfaces.ports[i].vendorId == '0403') {
|
|
|
|
|
// found FTDI FT232
|
|
|
|
|
img = 'usb.png';
|
|
|
|
|
note = 'FTDI USB to Serial';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '6015' && laststatus.comms.interfaces.ports[i].vendorId == '0403') {
|
|
|
|
|
// found FTDI FT230x
|
|
|
|
|
img = 'usb.png';
|
|
|
|
|
note = 'FTDI USD to Serial';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '606D' && laststatus.comms.interfaces.ports[i].vendorId == '1D50') {
|
|
|
|
|
// found TinyG G2
|
|
|
|
|
img = 'usb.png';
|
|
|
|
|
note = 'Tiny G2';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '003D' && laststatus.comms.interfaces.ports[i].vendorId == '2341') {
|
|
|
|
|
// found Arduino Due Prog Port
|
|
|
|
|
img = 'due.png';
|
|
|
|
|
note = 'Arduino Due Prog';
|
2018-06-19 08:07:03 +00:00
|
|
|
|
}
|
2018-06-19 20:25:40 +00:00
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '0043' && laststatus.comms.interfaces.ports[i].vendorId == '2341' || laststatus.comms.interfaces.ports[i].productId == '0001' && laststatus.comms.interfaces.ports[i].vendorId == '2341' || laststatus.comms.interfaces.ports[i].productId == '0043' && laststatus.comms.interfaces.ports[i].vendorId == '2A03') {
|
|
|
|
|
// found Arduino Uno
|
|
|
|
|
img = 'uno.png';
|
|
|
|
|
note = 'Arduino Uno';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '2341' && laststatus.comms.interfaces.ports[i].vendorId == '0042') {
|
|
|
|
|
// found Arduino Mega
|
|
|
|
|
img = 'mega.png';
|
|
|
|
|
note = 'Arduino Mega';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '7523' && laststatus.comms.interfaces.ports[i].vendorId == '1A86') {
|
|
|
|
|
// found CH340
|
|
|
|
|
img = 'uno.png';
|
|
|
|
|
note = 'CH340 Arduino Fake';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == 'EA60' && laststatus.comms.interfaces.ports[i].vendorId == '10C4') {
|
|
|
|
|
// found CP2102
|
|
|
|
|
img = 'nodemcu.png';
|
|
|
|
|
note = 'NodeMCU';
|
|
|
|
|
}
|
|
|
|
|
if (laststatus.comms.interfaces.ports[i].productId == '2303' && laststatus.comms.interfaces.ports[i].vendorId == '067B') {
|
|
|
|
|
// found CP2102
|
|
|
|
|
// img = 'nodemcu.png';
|
|
|
|
|
note = 'Prolific USB to Serial';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
img = "usb.png";
|
|
|
|
|
}
|
2018-06-19 08:07:03 +00:00
|
|
|
|
|
2018-06-19 20:25:40 +00:00
|
|
|
|
return {
|
|
|
|
|
img: img,
|
|
|
|
|
note: note
|
|
|
|
|
};
|
2018-09-27 15:00:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function escapeHTML(html) {
|
|
|
|
|
return document.createElement('div').appendChild(document.createTextNode(html)).parentNode.innerHTML;
|
2019-09-03 18:36:09 +00:00
|
|
|
|
}
|