Smaller buffer header to prevent overflow

pull/110/head
openbuilds-engineer 2018-08-08 14:31:59 +02:00
rodzic 1367310951
commit beaf33d925
5 zmienionych plików z 42 dodań i 59 usunięć

Wyświetl plik

@ -15,8 +15,8 @@ body {
height: calc(100% - 1px);
width: 100%;
border-top: 1px solid #ccc;
margin-top: 5px;
box-shadow: 0 0 5px 10px #fff;
/* margin-top: 5px; */
box-shadow: 0 0 2px 2px #ddd;
}
#console {
@ -28,7 +28,7 @@ body {
overflow-x: none;
text-align: left;
background-color: #fff;
box-shadow: 0 0 5px 10px #fff;
box-shadow: 0 0 2px 2px #ddd;
padding: 0px;
font-size: 12px;
padding-left: 20px;

Wyświetl plik

@ -520,7 +520,7 @@
<div id="console"></div>
<div class="fixed-bottom m-3 mb-9">
<form class="inline-form" id="commandform">
<input data-prepend="&nbsp;<i class='fas fa-terminal'></i>" data-role="input" data-clear-button="false" data-role="input" id="command" type="text" autocomplete="on" class="needs-connection" style="width: calc(100vw - 170px);" />
<input data-prepend="&nbsp;<i class='fas fa-terminal'></i>" data-role="input" data-clear-button="false" data-role="input" id="command" type="text" autocomplete="on" class=" dark needs-connection" style="width: calc(100vw - 170px);" />
<button id="sendCommand" class="button dark needs-connection" type="button" data-role="hint" data-hint-position="top" data-hint-text="Execute Command" data-cls-hint="bg-light fg-dark drop-shadow">
<i class="fa fa-play" style="margin-right: 10px;"></i> Send
</button>
@ -533,13 +533,15 @@
<div class="section" id="tab-two">
<div id="editor"></div>
<div class="fixed-bottom m-3 mb-9">
<button data-toggle="tooltip" data-placement="bottom" title="Find and Replace" class="button dark" onclick="editor.execCommand('replace')"><i class="fas fa-search"></i></button>
<button data-toggle="tooltip" data-placement="bottom" title="Select All" class="button dark" onclick="editor.execCommand('selectall')"><i class="far fa-check-square"></i></button>
<button data-toggle="tooltip" data-placement="bottom" title="Undo" class="button dark" onclick="editor.execCommand('undo')"><i class="fas fa-undo"></i></button>
<button data-toggle="tooltip" data-placement="bottom" title="Redo" class="button dark" onclick="editor.execCommand('redo')"><i class="fas fa-redo"></i></button>
<button data-toggle="tooltip" data-placement="bottom" title="Go to End" class="button dark" onclick="editor.execCommand('gotoend')"><i class="fas fa-chevron-down"></i></button>
<button data-toggle="tooltip" data-placement="bottom" title="Go to Start" class="button dark" onclick="editor.execCommand('gotostart')"><i class="fas fa-chevron-up"></i></button>
<button data-toggle="tooltip" data-placement="bottom" title="Clear Editor" class="button dark" onclick="editor.execCommand('selectall'); editor.execCommand('del');"><i class="fas fa-eraser"></i></button>
<!-- <form class="inline-form"> -->
<button title="Find and Replace" class="button dark" onclick="editor.execCommand('replace')"><i class="fas fa-search"></i> Find/Replace</button>&nbsp;
<button title="Select All" class="button dark" onclick="editor.execCommand('selectall')"><i class="far fa-check-square"></i> Select All</button>&nbsp;
<button title="Undo" class="button dark" onclick="editor.execCommand('undo')"><i class="fas fa-undo"></i> Undo</button>&nbsp;
<button title="Redo" class="button dark" onclick="editor.execCommand('redo')"><i class="fas fa-redo"></i> Redo</button>&nbsp;
<button title="Go to End" class="button dark" onclick="editor.execCommand('gotoend')"><i class="fas fa-chevron-down"></i></button>&nbsp;
<button title="Go to Start" class="button dark" onclick="editor.execCommand('gotostart')"><i class="fas fa-chevron-up"></i></button>&nbsp;
<button title="Clear Editor" class="button dark" onclick="editor.execCommand('selectall'); editor.execCommand('del');"><i class="fas fa-eraser"></i> Clear</button>&nbsp;
<!-- </form> -->
</div>
</div>
</div>

Wyświetl plik

@ -198,17 +198,21 @@ function checkifchanged() {
function grblSaveSettings() {
var commands = ""
for (var key in grblParams) {
if (grblParams.hasOwnProperty(key)) {
var j = key.substring(1)
var newVal = $("#val-" + j + "-input").val();
// Only send values that changed
if (parseFloat(newVal) != parseFloat(grblParams[key])) {
console.log(key + ' was ' + grblParams[key] + ' but now, its ' + newVal);
sendGcode(key + '=' + newVal);
// console.log(key + ' was ' + grblParams[key] + ' but now, its ' + newVal);
commands += key + '=' + newVal + "\n"
// sendGcode(key + '=' + newVal);
}
}
}
console.log("commands", commands)
socket.emit('runJob', commands);
grblParams = {};
Metro.dialog.create({

Wyświetl plik

@ -130,7 +130,7 @@ function setJogPanel(val, status) {
if (val == 0) { // Not Connected Yet
// Show panel and resize editor
$("#jogcontrols").slideUp(20);
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 250 + 'px)');
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 290 + 'px)');
$("#console").css('height', 'calc(' + 100 + 'vh - ' + 290 + 'px)');
// $('#console').scrollTop($("#console")[0].scrollHeight - $("#console").height());
editor.resize()
@ -141,7 +141,7 @@ function setJogPanel(val, status) {
} else if (val == 0 || val == 2) { // Connected, but not Playing yet
// Show panel and resize editor
$("#jogcontrols").slideDown(20);
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 445 + 'px)');
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 480 + 'px)');
$("#console").css('height', 'calc(' + 100 + 'vh - ' + 480 + 'px)');
// $('#console').scrollTop($("#console")[0].scrollHeight - $("#console").height());
editor.resize()
@ -151,7 +151,7 @@ function setJogPanel(val, status) {
}
} else if (val == 3) { // Busy Streaming GCODE
// Show panel and resize editor
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 445 + 'px)');
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 480 + 'px)');
$("#console").css('height', 'calc(' + 100 + 'vh - ' + 480 + 'px)');
// $('#console').scrollTop($("#console")[0].scrollHeight - $("#console").height());
editor.resize()
@ -163,7 +163,7 @@ function setJogPanel(val, status) {
} else if (val == 4) { // Paused
// Show panel and resize editor
$("#jogcontrols").slideDown(20);
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 445 + 'px)');
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 480 + 'px)');
$("#console").css('height', 'calc(' + 100 + 'vh - ' + 480 + 'px)');
// $('#console').scrollTop($("#console")[0].scrollHeight - $("#console").height());
editor.resize()
@ -174,7 +174,7 @@ function setJogPanel(val, status) {
} else if (val == 5) { // Alarm State
// Show panel and resize editor
$("#jogcontrols").slideUp(20);
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 295 + 'px)');
$("#editor").css('height', 'calc(' + 100 + 'vh - ' + 290 + 'px)');
$("#console").css('height', 'calc(' + 100 + 'vh - ' + 290 + 'px)');
// $('#console').scrollTop($("#console")[0].scrollHeight - $("#console").height());
editor.resize()

Wyświetl plik

@ -199,9 +199,8 @@ var statusLoop;
var queueCounter;
var listPortsLoop;
var GRBL_RX_BUFFER_SIZE = 128; // 128 characters
var GRBL_RX_BUFFER_SIZE = 32; // 128 characters
var grblBufferSize = [];
var new_grbl_buffer = false;
var SMOOTHIE_RX_BUFFER_SIZE = 64; // max. length of one command line
var smoothie_buffer = false;
@ -804,7 +803,7 @@ io.on("connection", function(socket) {
statusLoop = setInterval(function() {
if (status.comms.connectionStatus > 0) {
if (!status.comms.sduploading) {
machineSend("?");
// machineSend("?");
}
}
}, 250);
@ -1084,6 +1083,7 @@ io.on("connection", function(socket) {
socket.on('runJob', function(data) {
// console.log(data)
console.log('Run Job (' + data.length + ')');
if (status.comms.connectionStatus > 0) {
if (data) {
@ -1678,6 +1678,7 @@ function machineSend(gcode) {
data.push(queueTotal);
data.push(status.comms.sduploading)
io.sockets.emit("queueCount", data);
// console.log(gcode)
port.write(gcode);
if (gcode != "?") {
lastGcode.push(gcode);
@ -1719,6 +1720,7 @@ function grblBufferSpace() {
return GRBL_RX_BUFFER_SIZE - total;
}
function send1Q() {
var gcode;
var gcodeLen = 0;
@ -1726,43 +1728,18 @@ function send1Q() {
if (status.comms.connectionStatus > 0) {
switch (status.machine.firmware.type) {
case 'grbl':
if (new_grbl_buffer) {
if (grblBufferSize.length === 0) {
spaceLeft = GRBL_RX_BUFFER_SIZE;
while ((queueLen - queuePointer) > 0 && spaceLeft > 0 && !status.comms.blocked && !status.comms.paused) {
gcodeLen = gcodeQueue[queuePointer].length;
if (gcodeLen < spaceLeft) {
// Add gcode to send buffer
gcode = gcodeQueue[queuePointer];
queuePointer++;
grblBufferSize.push(gcodeLen + 1);
gcodeLine += gcode + '\n';
spaceLeft = GRBL_RX_BUFFER_SIZE - gcodeLine.length;
} else {
// Not enough space left in send buffer
status.comms.blocked = true;
}
}
if (gcodeLine.length > 0) {
// Send the buffer
status.comms.blocked = true;
machineSend(gcodeLine);
// console.log('Sent: ' + gcodeLine + ' Q: ' + (queueLen - queuePointer));
}
}
} else {
while ((queueLen - queuePointer) > 0 && !status.comms.blocked && !status.comms.paused) {
spaceLeft = grblBufferSpace();
gcodeLen = gcodeQueue[queuePointer].length;
if (gcodeLen < spaceLeft) {
gcode = gcodeQueue[queuePointer];
queuePointer++;
grblBufferSize.push(gcodeLen + 1);
machineSend(gcode + '\n');
// console.log('Sent: ' + gcode + ' Q: ' + (queueLen - queuePointer) + ' Bspace: ' + (spaceLeft - gcodeLen - 1));
} else {
status.comms.blocked = true;
}
while ((queueLen - queuePointer) > 0 && !status.comms.blocked && !status.comms.paused) {
spaceLeft = grblBufferSpace();
gcodeLen = gcodeQueue[queuePointer].length;
console.log(gcodeLen, spaceLeft)
if (gcodeLen < spaceLeft) {
gcode = gcodeQueue[queuePointer];
queuePointer++;
grblBufferSize.push(gcodeLen + 1);
machineSend(gcode + '\n');
// console.log('Sent: ' + gcode + ' Q: ' + (queueLen - queuePointer) + ' Bspace: ' + (spaceLeft - gcodeLen - 1));
} else {
status.comms.blocked = true;
}
}
break;
@ -1772,7 +1749,7 @@ function send1Q() {
queuePointer++;
status.comms.blocked = true;
machineSend(gcode + '\n');
// console.log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer));
// console.log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer));
}
break;
}