mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
Merge branch 'feature/printerdriver' of https://github.com/Doodle3D/doodle3d-client into feature/printerdriver
# By peteruithoven # Via peteruithoven * 'feature/printerdriver' of https://github.com/Doodle3D/doodle3d-client: Check gcode generation feasibility check to prevent iPad/iPhone crashes Removing confirm stop status checks on override and start them again when there is a first response reset the status check when printer state is overruled
This commit is contained in:
commit
5c9c8c8e8c
@ -61,7 +61,7 @@ function Printer() {
|
|||||||
console.log(" wifiboxURL: ",this.wifiboxURL);
|
console.log(" wifiboxURL: ",this.wifiboxURL);
|
||||||
|
|
||||||
if(autoUpdate) {
|
if(autoUpdate) {
|
||||||
this.checkStatus();
|
this.startStatusCheckInterval();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ function Printer() {
|
|||||||
if (completed) {
|
if (completed) {
|
||||||
console.log("Printer:sendPrintPart:gcode sending completed");
|
console.log("Printer:sendPrintPart:gcode sending completed");
|
||||||
this.gcode = [];
|
this.gcode = [];
|
||||||
btnStop.css("display","block");
|
btnStop.css("display","block"); // hack
|
||||||
//self.targetTemperature = settings["printer.temperature"]; // slight hack
|
//self.targetTemperature = settings["printer.temperature"]; // slight hack
|
||||||
} else {
|
} else {
|
||||||
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode
|
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode
|
||||||
@ -163,6 +163,12 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// after we know the first gcode packed has bin received or failed
|
||||||
|
// (and the driver had time to update the printer.state)
|
||||||
|
// we start checking the status again
|
||||||
|
if(sendIndex == 0) {
|
||||||
|
self.startStatusCheckInterval();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Printer:sendPrintPart: failed");
|
console.log("Printer:sendPrintPart: failed");
|
||||||
@ -171,6 +177,11 @@ function Printer() {
|
|||||||
console.log("request printer:sendPrintPart failed retry");
|
console.log("request printer:sendPrintPart failed retry");
|
||||||
self.sendPrintPart(sendIndex, sendLength)
|
self.sendPrintPart(sendIndex, sendLength)
|
||||||
},self.retryDelay); // retry after delay
|
},self.retryDelay); // retry after delay
|
||||||
|
|
||||||
|
// after we know the gcode packed has bin received or failed
|
||||||
|
// (and the driver had time to update the printer.state)
|
||||||
|
// we start checking the status again
|
||||||
|
self.startStatusCheckInterval();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log ("Printer >> f:sendPrintPart() >> communicateWithWifibox is false, so not executing this function");
|
console.log ("Printer >> f:sendPrintPart() >> communicateWithWifibox is false, so not executing this function");
|
||||||
@ -188,17 +199,38 @@ function Printer() {
|
|||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
console.log("Printer:stop response: ", data);
|
console.log("Printer:stop response: ", data);
|
||||||
|
|
||||||
|
// after we know the stop has bin received or failed
|
||||||
|
// (and the driver had time to update the printer.state)
|
||||||
|
// we start checking the status again
|
||||||
|
self.startStatusCheckInterval();
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Printer:stop: failed");
|
console.log("Printer:stop: failed");
|
||||||
clearTimeout(self.retryStopDelay);
|
clearTimeout(self.retryStopDelay);
|
||||||
self.retryStopDelay = setTimeout(function() { self.stop() },self.retryDelay); // retry after delay
|
self.retryStopDelay = setTimeout(function() { self.stop() },self.retryDelay); // retry after delay
|
||||||
|
|
||||||
|
// after we know the stop has bin received or failed
|
||||||
|
// (and the driver had time to update the printer.state)
|
||||||
|
// we start checking the status again
|
||||||
|
self.startStatusCheckInterval();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log ("Printer >> f:communicateWithWifibox() >> communicateWithWifibox is false, so not executing this function");
|
console.log ("Printer >> f:communicateWithWifibox() >> communicateWithWifibox is false, so not executing this function");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.startStatusCheckInterval = function() {
|
||||||
|
console.log("Printer:startStatusCheckInterval");
|
||||||
|
self.checkStatus();
|
||||||
|
clearTimeout(self.checkStatusDelay);
|
||||||
|
clearTimeout(self.retryCheckStatusDelay);
|
||||||
|
self.checkStatusDelay = setTimeout(function() { self.checkStatus() }, self.checkStatusInterval);
|
||||||
|
}
|
||||||
|
this.stopStatusCheckInterval = function() {
|
||||||
|
console.log("Printer:stopStatusCheckInterval");
|
||||||
|
clearTimeout(self.checkStatusDelay);
|
||||||
|
clearTimeout(self.retryCheckStatusDelay);
|
||||||
|
}
|
||||||
this.checkStatus = function() {
|
this.checkStatus = function() {
|
||||||
console.log("Printer:checkStatus");
|
console.log("Printer:checkStatus");
|
||||||
this.stateOverruled = false;
|
this.stateOverruled = false;
|
||||||
@ -267,5 +299,7 @@ function Printer() {
|
|||||||
self.state = newState;
|
self.state = newState;
|
||||||
|
|
||||||
$(document).trigger(Printer.UPDATE);
|
$(document).trigger(Printer.UPDATE);
|
||||||
|
|
||||||
|
this.stopStatusCheckInterval();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -192,7 +192,7 @@ function initButtonBehavior() {
|
|||||||
}
|
}
|
||||||
function stopPrint() {
|
function stopPrint() {
|
||||||
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
||||||
if (!confirm("Weet je zeker dat je huidige print wilt stoppen?")) return;
|
//if (!confirm("Weet je zeker dat je huidige print wilt stoppen?")) return;
|
||||||
if (sendPrintCommands) printer.stop();
|
if (sendPrintCommands) printer.stop();
|
||||||
//setState(Printer.STOPPING_STATE,printer.hasControl);
|
//setState(Printer.STOPPING_STATE,printer.hasControl);
|
||||||
printer.overruleState(Printer.STOPPING_STATE);
|
printer.overruleState(Printer.STOPPING_STATE);
|
||||||
@ -212,23 +212,26 @@ function print(e) {
|
|||||||
|
|
||||||
//$(".btnPrint").css("display","none");
|
//$(".btnPrint").css("display","none");
|
||||||
|
|
||||||
|
|
||||||
if (_points.length > 2) {
|
if (_points.length > 2) {
|
||||||
|
|
||||||
//setState(Printer.BUFFERING_STATE,printer.hasControl);
|
//setState(Printer.BUFFERING_STATE,printer.hasControl);
|
||||||
printer.overruleState(Printer.BUFFERING_STATE);
|
printer.overruleState(Printer.BUFFERING_STATE);
|
||||||
|
|
||||||
btnStop.css("display","none");
|
btnStop.css("display","none"); // hack
|
||||||
|
|
||||||
// we put the gcode generation in a little delay
|
// we put the gcode generation in a little delay
|
||||||
// so that for example the print button is disabled right away
|
// so that for example the print button is disabled right away
|
||||||
clearTimeout(gcodeGenerateDelayer);
|
clearTimeout(gcodeGenerateDelayer);
|
||||||
gcodeGenerateDelayer = setTimeout(function() {
|
gcodeGenerateDelayer = setTimeout(function() {
|
||||||
var gcode = generate_gcode();
|
|
||||||
//startPrint(gencode);
|
|
||||||
|
|
||||||
if (sendPrintCommands) {
|
var gcode = generate_gcode();
|
||||||
printer.print(gcode);
|
if (sendPrintCommands) {
|
||||||
|
if(gcode.length > 0) {
|
||||||
|
printer.print(gcode);
|
||||||
|
} else {
|
||||||
|
printer.overruleState(Printer.IDLE_STATE);
|
||||||
|
printer.startStatusCheckInterval();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
|
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,10 @@ gcodeEnd.push("G90"); // absolute positioning
|
|||||||
gcodeEnd.push("M117 Done "); // display message (20 characters to clear whole screen)*/
|
gcodeEnd.push("M117 Done "); // display message (20 characters to clear whole screen)*/
|
||||||
|
|
||||||
|
|
||||||
|
var MAX_POINTS_TO_PRINT = 400000; //80000; //40000;
|
||||||
var gcode = [];
|
var gcode = [];
|
||||||
function generate_gcode(callback) {
|
|
||||||
|
function generate_gcode() {
|
||||||
console.log("f:generategcode()");
|
console.log("f:generategcode()");
|
||||||
|
|
||||||
var startGcode = [];
|
var startGcode = [];
|
||||||
@ -124,7 +126,6 @@ function generate_gcode(callback) {
|
|||||||
|
|
||||||
// copy array without reference -> http://stackoverflow.com/questions/9885821/copying-of-an-array-of-objects-to-another-array-without-object-reference-in-java
|
// copy array without reference -> http://stackoverflow.com/questions/9885821/copying-of-an-array-of-objects-to-another-array-without-object-reference-in-java
|
||||||
var points = JSON.parse(JSON.stringify(_points));
|
var points = JSON.parse(JSON.stringify(_points));
|
||||||
console.log("f:generategcode() >> points.length: " + points.length);
|
|
||||||
|
|
||||||
// console.log("f:generategcode() >> paths: " + paths.toString());
|
// console.log("f:generategcode() >> paths: " + paths.toString());
|
||||||
// console.log("paths.toString(): " + paths.toString());
|
// console.log("paths.toString(): " + paths.toString());
|
||||||
@ -153,6 +154,19 @@ function generate_gcode(callback) {
|
|||||||
console.log("f:generategcode() >> layers: " + layers);
|
console.log("f:generategcode() >> layers: " + layers);
|
||||||
if (layers == Infinity) return;
|
if (layers == Infinity) return;
|
||||||
|
|
||||||
|
// check feasibility of design
|
||||||
|
var pointsToPrint = points.length * layers*(objectHeight/maxObjectHeight)
|
||||||
|
//console.log(" points.length: ",points.length);
|
||||||
|
//console.log(" numLayers: ",(layers*(objectHeight/maxObjectHeight)));
|
||||||
|
//console.log(" pointsToPrint: ",pointsToPrint);
|
||||||
|
//console.log(" MAX_POINTS_TO_PRINT: ",MAX_POINTS_TO_PRINT);
|
||||||
|
|
||||||
|
if(pointsToPrint > MAX_POINTS_TO_PRINT) {
|
||||||
|
alert("Sorry, your doodle to to complex and / or to high");
|
||||||
|
console.log("WARNING: to many points to convert to gcode");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
for (var layer = 0; layer < layers; layer++) {
|
for (var layer = 0; layer < layers; layer++) {
|
||||||
|
|
||||||
var p = JSON.parse(JSON.stringify(points)); // [].concat(points);
|
var p = JSON.parse(JSON.stringify(points)); // [].concat(points);
|
||||||
@ -262,21 +276,10 @@ function generate_gcode(callback) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add gcode end commands
|
// add gcode end commands
|
||||||
gcode = gcode.concat(endGcode);
|
gcode = gcode.concat(endGcode);
|
||||||
|
|
||||||
// debug
|
return gcode;
|
||||||
// var _gc = gc.join("\n");
|
|
||||||
// console.log("f:generategcode() >> _gc = " + _gc);
|
|
||||||
|
|
||||||
// Return the gcode array, joined to one string with '\n' (line break) as the join parameter
|
|
||||||
// This should result in a nice long string with line breaks
|
|
||||||
if (callback == undefined) {
|
|
||||||
return gcode;
|
|
||||||
} else {
|
|
||||||
// post
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function scaleFunction(percent) {
|
function scaleFunction(percent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user