0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-25 18:47:57 +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:
  Fixing double printer.print call
  Starting print right away, remove some target temp display hacks
This commit is contained in:
Adriaan Wormgoor 2013-10-11 15:44:22 +02:00
commit d61b9cb0d8
3 changed files with 16 additions and 10 deletions

View File

@ -111,7 +111,7 @@ function Printer() {
return; return;
} }
this.targetTemperature = settings["printer.temperature"]; // slight hack //this.targetTemperature = settings["printer.temperature"]; // slight hack
this.sendPrintPart(this.sendIndex, this.sendLength); this.sendPrintPart(this.sendIndex, this.sendLength);
} }
@ -122,15 +122,18 @@ function Printer() {
console.log("Printer:sendPrintPart sendIndex: " + sendIndex + "/" + this.gcode.length + ", sendLength: " + sendLength); console.log("Printer:sendPrintPart sendIndex: " + sendIndex + "/" + this.gcode.length + ", sendLength: " + sendLength);
var firstOne = (sendIndex == 0)? true : false; var firstOne = (sendIndex == 0)? true : false;
var lastOne = false; var start = true; // start printing right away
var completed = false;
if (this.gcode.length < (sendIndex + sendLength)) { if (this.gcode.length < (sendIndex + sendLength)) {
console.log(" sending less than max sendLength (and last)"); console.log(" sending less than max sendLength (and last)");
sendLength = this.gcode.length - sendIndex; sendLength = this.gcode.length - sendIndex;
lastOne = true; //lastOne = true;
completed = true;
} }
var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength); var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength);
var postData = { gcode: gcodePart.join("\n"), first: firstOne, last: lastOne}; var postData = { gcode: gcodePart.join("\n"), first: firstOne, start: start};
var self = this; var self = this;
if (communicateWithWifibox) { if (communicateWithWifibox) {
$.ajax({ $.ajax({
@ -143,11 +146,12 @@ function Printer() {
console.log("Printer:sendPrintPart response: ",data); console.log("Printer:sendPrintPart response: ",data);
if(data.status == "success") { if(data.status == "success") {
if (lastOne) { if (completed) {
console.log("Printer:sendPrintPart:gcode sending completed"); console.log("Printer:sendPrintPart:gcode sending completed");
this.gcode = []; this.gcode = [];
self.targetTemperature = settings["printer.temperature"]; // slight hack //self.targetTemperature = settings["printer.temperature"]; // slight hack
} else { } else {
console.log("sending next part");
self.sendPrintPart(sendIndex + sendLength, sendLength); self.sendPrintPart(sendIndex + sendLength, sendLength);
} }
} }
@ -155,7 +159,10 @@ function Printer() {
}).fail(function() { }).fail(function() {
console.log("Printer:sendPrintPart: failed"); console.log("Printer:sendPrintPart: failed");
clearTimeout(self.retrySendPrintPartDelay); clearTimeout(self.retrySendPrintPartDelay);
self.retrySendPrintPartDelay = setTimeout(function() { self.sendPrintPart(sendIndex, sendLength) },self.retryDelay); // retry after delay self.retrySendPrintPartDelay = setTimeout(function() {
console.log("request printer:sendPrintPart failed retry");
self.sendPrintPart(sendIndex, sendLength)
},self.retryDelay); // retry after delay
}); });
} 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");
@ -173,8 +180,6 @@ 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);
setTimeout(function() { console.log("send: ",gcodeEnd); self.print(gcodeEnd) },self.sendStopGCodeDelay);
} }
}).fail(function() { }).fail(function() {
console.log("Printer:stop: failed"); console.log("Printer:stop: failed");

View File

@ -5,7 +5,7 @@ var $displayThermometer = $("#thermometerContainer");
//TODO 2013-09-18 allow displaying temperatures HIGHER than the targTemp (it's now being capped at targTemp). //TODO 2013-09-18 allow displaying temperatures HIGHER than the targTemp (it's now being capped at targTemp).
function Thermometer() { function Thermometer() {
this.currentTemperature = 0; // default val this.currentTemperature = 0; // default val
this.targetTemperature = 180; // default val this.targetTemperature = 0; // default val
this.thermoOverlayImg = new Image(); this.thermoOverlayImg = new Image();
this.thermoOverlayImgSrc = "img/thermometer_fg_overlay.png"; // ../img/thermometer_fg_overlay.png this.thermoOverlayImgSrc = "img/thermometer_fg_overlay.png"; // ../img/thermometer_fg_overlay.png

View File

@ -309,6 +309,7 @@ function setState(newState) { //TODO add hasControl
switch(newState) { switch(newState) {
case Printer.IDLE_STATE: case Printer.IDLE_STATE:
btnPrint.removeClass("disabled"); // enable print button btnPrint.removeClass("disabled"); // enable print button
btnPrint.unbind('touchstart mousedown');
btnPrint.bind('touchstart mousedown',print); btnPrint.bind('touchstart mousedown',print);
break; break;
default: default: