mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
Fix spelling error.
This commit is contained in:
parent
98e0418eb8
commit
2e93202bfc
@ -11,7 +11,7 @@ function setPrintprogress(val) {
|
|||||||
//*/
|
//*/
|
||||||
|
|
||||||
function Printer() {
|
function Printer() {
|
||||||
|
|
||||||
Printer.WIFIBOX_DISCONNECTED_STATE = "wifibox disconnected";
|
Printer.WIFIBOX_DISCONNECTED_STATE = "wifibox disconnected";
|
||||||
Printer.UNKNOWN_STATE = "unknown"; // happens when a printer is connection but there isn't communication yet
|
Printer.UNKNOWN_STATE = "unknown"; // happens when a printer is connection but there isn't communication yet
|
||||||
Printer.DISCONNECTED_STATE = "disconnected"; // printer disconnected
|
Printer.DISCONNECTED_STATE = "disconnected"; // printer disconnected
|
||||||
@ -21,22 +21,22 @@ function Printer() {
|
|||||||
Printer.STOPPING_STATE = "stopping"; // when you stop (abort) a print it prints the endcode
|
Printer.STOPPING_STATE = "stopping"; // when you stop (abort) a print it prints the endcode
|
||||||
|
|
||||||
Printer.ON_BEFORE_UNLOAD_MESSAGE = "You're doodle is still being send to the printer, leaving will result in a incomplete 3D print";
|
Printer.ON_BEFORE_UNLOAD_MESSAGE = "You're doodle is still being send to the printer, leaving will result in a incomplete 3D print";
|
||||||
|
|
||||||
this.temperature = 0;
|
this.temperature = 0;
|
||||||
this.targetTemperature = 0;
|
this.targetTemperature = 0;
|
||||||
this.currentLine = 0;
|
this.currentLine = 0;
|
||||||
this.totalLines = 0;
|
this.totalLines = 0;
|
||||||
this.bufferedLines = 0;
|
this.bufferedLines = 0;
|
||||||
this.state = Printer.UNKNOWN_STATE;
|
this.state = Printer.UNKNOWN_STATE;
|
||||||
this.hasControl = true; // whether this client has control access
|
this.hasControl = true; // whether this client has control access
|
||||||
|
|
||||||
this.wifiboxURL;
|
this.wifiboxURL;
|
||||||
|
|
||||||
this.checkStatusInterval = 3000;
|
this.checkStatusInterval = 3000;
|
||||||
this.checkStatusDelay;
|
this.checkStatusDelay;
|
||||||
this.timeoutTime = 3000;
|
this.timeoutTime = 3000;
|
||||||
this.sendPrintPartTimeoutTime = 5000;
|
this.sendPrintPartTimeoutTime = 5000;
|
||||||
|
|
||||||
this.gcode; // gcode to be printed
|
this.gcode; // gcode to be printed
|
||||||
this.sendLength = 1500; // max amount of gcode lines per post (limited because WiFi box can't handle to much)
|
this.sendLength = 1500; // max amount of gcode lines per post (limited because WiFi box can't handle to much)
|
||||||
|
|
||||||
@ -45,16 +45,16 @@ function Printer() {
|
|||||||
this.retryCheckStatusDelay; // retry setTimout instance
|
this.retryCheckStatusDelay; // retry setTimout instance
|
||||||
this.retryStopDelay; // retry setTimout instance
|
this.retryStopDelay; // retry setTimout instance
|
||||||
this.retryPreheatDelay; // retry setTimout instance
|
this.retryPreheatDelay; // retry setTimout instance
|
||||||
|
|
||||||
this.maxGCodeSize = 10; // max size of gcode in MB's (estimation)
|
this.maxGCodeSize = 10; // max size of gcode in MB's (estimation)
|
||||||
|
|
||||||
this.stateOverruled = false;
|
this.stateOverruled = false;
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
Printer.UPDATE = "update";
|
Printer.UPDATE = "update";
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.init = function() {
|
this.init = function() {
|
||||||
console.log("Printer:init");
|
console.log("Printer:init");
|
||||||
//this.wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
|
//this.wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
|
||||||
@ -62,21 +62,21 @@ function Printer() {
|
|||||||
this.wifiboxURL = wifiboxURL;
|
this.wifiboxURL = wifiboxURL;
|
||||||
//this.wifiboxURL = "proxy5.php";
|
//this.wifiboxURL = "proxy5.php";
|
||||||
console.log(" wifiboxURL: ",this.wifiboxURL);
|
console.log(" wifiboxURL: ",this.wifiboxURL);
|
||||||
|
|
||||||
if(autoUpdate) {
|
if(autoUpdate) {
|
||||||
this.startStatusCheckInterval();
|
this.startStatusCheckInterval();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preheat = function() {
|
this.preheat = function() {
|
||||||
console.log("Printer:preheat");
|
console.log("Printer:preheat");
|
||||||
|
|
||||||
if( this.state == Printer.BUFFERING_STATE ||
|
if( this.state == Printer.BUFFERING_STATE ||
|
||||||
this.state == Printer.PRINTING_STATE ||
|
this.state == Printer.PRINTING_STATE ||
|
||||||
this.state == Printer.STOPPING_STATE) {
|
this.state == Printer.STOPPING_STATE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -91,7 +91,7 @@ function Printer() {
|
|||||||
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Printer:preheat: failed");
|
console.log("Printer:preheat: failed");
|
||||||
clearTimeout(self.retryPreheatDelay);
|
clearTimeout(self.retryPreheatDelay);
|
||||||
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
||||||
@ -100,34 +100,34 @@ function Printer() {
|
|||||||
console.log ("Printer >> f:preheat() >> communicateWithWifibox is false, so not executing this function");
|
console.log ("Printer >> f:preheat() >> communicateWithWifibox is false, so not executing this function");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.print = function(gcode) {
|
this.print = function(gcode) {
|
||||||
console.log("Printer:print");
|
console.log("Printer:print");
|
||||||
console.log(" gcode total # of lines: " + gcode.length);
|
console.log(" gcode total # of lines: " + gcode.length);
|
||||||
|
|
||||||
message.set("Sending doodle to printer...",Message.NOTICE);
|
message.set("Sending doodle to printer...",Message.NOTICE);
|
||||||
self.addLeaveWarning();
|
self.addLeaveWarning();
|
||||||
|
|
||||||
/*for (i = 0; i < gcode.length; i++) {
|
/*for (i = 0; i < gcode.length; i++) {
|
||||||
gcode[i] += " (" + i + ")";
|
gcode[i] += " (" + i + ")";
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
this.sendIndex = 0;
|
this.sendIndex = 0;
|
||||||
this.gcode = gcode;
|
this.gcode = gcode;
|
||||||
|
|
||||||
//console.log(" gcode[20]: ",gcode[20]);
|
//console.log(" gcode[20]: ",gcode[20]);
|
||||||
var gcodeLineSize = this.byteSize(gcode[20]);
|
var gcodeLineSize = this.byteSize(gcode[20]);
|
||||||
//console.log(" gcodeLineSize: ",gcodeLineSize);
|
//console.log(" gcodeLineSize: ",gcodeLineSize);
|
||||||
var gcodeSize = gcodeLineSize*gcode.length/1024/1024; // estimate gcode size in MB's
|
var gcodeSize = gcodeLineSize*gcode.length/1024/1024; // estimate gcode size in MB's
|
||||||
console.log(" gcodeSize: ",gcodeSize);
|
console.log(" gcodeSize: ",gcodeSize);
|
||||||
|
|
||||||
if(gcodeSize > this.maxGCodeSize) {
|
if(gcodeSize > this.maxGCodeSize) {
|
||||||
console.log("Error: Printer:print: gcode file is probably to big ("+gcodeSize+"MB) (max: "+this.maxGCodeSize+"MB)");
|
console.log("Error: Printer:print: gcode file is probably to big ("+gcodeSize+"MB) (max: "+this.maxGCodeSize+"MB)");
|
||||||
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);
|
||||||
}
|
}
|
||||||
this.byteSize = function(s){
|
this.byteSize = function(s){
|
||||||
@ -135,10 +135,10 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
this.sendPrintPart = function(sendIndex,sendLength) {
|
this.sendPrintPart = function(sendIndex,sendLength) {
|
||||||
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 start = firstOne; // start printing right away
|
var start = firstOne; // start printing right away
|
||||||
|
|
||||||
var completed = false;
|
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)");
|
||||||
@ -147,7 +147,7 @@ function Printer() {
|
|||||||
completed = 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, start: start};
|
var postData = { gcode: gcodePart.join("\n"), first: firstOne, start: start};
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
@ -159,19 +159,19 @@ function Printer() {
|
|||||||
timeout: this.sendPrintPartTimeoutTime,
|
timeout: this.sendPrintPartTimeoutTime,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
console.log("Printer:sendPrintPart response: ",data);
|
console.log("Printer:sendPrintPart response: ",data);
|
||||||
|
|
||||||
if(data.status == "success") {
|
if(data.status == "success") {
|
||||||
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"); // hack
|
btnStop.css("display","block"); // hack
|
||||||
self.removeLeaveWarning();
|
self.removeLeaveWarning();
|
||||||
message.set("Doodle is sent to printer...",Message.INFO,true);
|
message.set("Doodle has been sent to printer...",Message.INFO,true);
|
||||||
//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
|
||||||
|
|
||||||
console.log("Printer:sendPrintPart:gcode part received (state: ",self.state,")");
|
console.log("Printer:sendPrintPart:gcode part received (state: ",self.state,")");
|
||||||
if(self.state == Printer.PRINTING_STATE || self.state == Printer.BUFFERING_STATE) {
|
if(self.state == Printer.PRINTING_STATE || self.state == Printer.BUFFERING_STATE) {
|
||||||
console.log("Printer:sendPrintPart:sending next part");
|
console.log("Printer:sendPrintPart:sending next part");
|
||||||
self.sendPrintPart(sendIndex + sendLength, sendLength);
|
self.sendPrintPart(sendIndex + sendLength, sendLength);
|
||||||
@ -179,22 +179,22 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// after we know the first gcode packed has bin received or failed
|
// after we know the first gcode packed has bin received or failed
|
||||||
// (and the driver had time to update the printer.state)
|
// (and the driver had time to update the printer.state)
|
||||||
// we start checking the status again
|
// we start checking the status again
|
||||||
if(sendIndex == 0) {
|
if(sendIndex == 0) {
|
||||||
self.startStatusCheckInterval();
|
self.startStatusCheckInterval();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).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.retrySendPrintPartDelay = setTimeout(function() {
|
||||||
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
|
// after we know the gcode packed has bin received or failed
|
||||||
// (and the driver had time to update the printer.state)
|
// (and the driver had time to update the printer.state)
|
||||||
// we start checking the status again
|
// we start checking the status again
|
||||||
self.startStatusCheckInterval();
|
self.startStatusCheckInterval();
|
||||||
});
|
});
|
||||||
@ -202,7 +202,7 @@ function Printer() {
|
|||||||
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.stop = function() {
|
this.stop = function() {
|
||||||
console.log("Printer:stop");
|
console.log("Printer:stop");
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -214,19 +214,19 @@ 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
|
// after we know the stop has bin received or failed
|
||||||
// (and the driver had time to update the printer.state)
|
// (and the driver had time to update the printer.state)
|
||||||
// we start checking the status again
|
// we start checking the status again
|
||||||
self.startStatusCheckInterval();
|
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
|
// after we know the stop has bin received or failed
|
||||||
// (and the driver had time to update the printer.state)
|
// (and the driver had time to update the printer.state)
|
||||||
// we start checking the status again
|
// we start checking the status again
|
||||||
self.startStatusCheckInterval();
|
self.startStatusCheckInterval();
|
||||||
});
|
});
|
||||||
@ -258,9 +258,9 @@ function Printer() {
|
|||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
//console.log(" Printer:status: ",response.data.state); //," response: ",response);
|
//console.log(" Printer:status: ",response.data.state); //," response: ",response);
|
||||||
|
|
||||||
self.handleStatusUpdate(response);
|
self.handleStatusUpdate(response);
|
||||||
|
|
||||||
clearTimeout(self.checkStatusDelay);
|
clearTimeout(self.checkStatusDelay);
|
||||||
clearTimeout(self.retryCheckStatusDelay);
|
clearTimeout(self.retryCheckStatusDelay);
|
||||||
self.checkStatusDelay = setTimeout(function() { self.checkStatus() }, self.checkStatusInterval);
|
self.checkStatusDelay = setTimeout(function() { self.checkStatus() }, self.checkStatusInterval);
|
||||||
@ -289,11 +289,11 @@ function Printer() {
|
|||||||
self.state = data.state;
|
self.state = data.state;
|
||||||
//console.log(" state > ",self.state);
|
//console.log(" state > ",self.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// temperature
|
// temperature
|
||||||
self.temperature = data.hotend;
|
self.temperature = data.hotend;
|
||||||
self.targetTemperature = data.hotend_target;
|
self.targetTemperature = data.hotend_target;
|
||||||
|
|
||||||
// progress
|
// progress
|
||||||
self.currentLine = data.current_line;
|
self.currentLine = data.current_line;
|
||||||
self.totalLines = data.total_lines;
|
self.totalLines = data.total_lines;
|
||||||
@ -301,7 +301,7 @@ function Printer() {
|
|||||||
|
|
||||||
// access
|
// access
|
||||||
self.hasControl = data.has_control;
|
self.hasControl = data.has_control;
|
||||||
|
|
||||||
if(self.state == Printer.PRINTING_STATE || self.state == Printer.STOPPING_STATE) {
|
if(self.state == Printer.PRINTING_STATE || self.state == Printer.STOPPING_STATE) {
|
||||||
console.log("progress: ",self.currentLine+"/"+self.totalLines+" ("+self.bufferedLines+") ("+self.state+")");
|
console.log("progress: ",self.currentLine+"/"+self.totalLines+" ("+self.bufferedLines+") ("+self.state+")");
|
||||||
}
|
}
|
||||||
@ -311,14 +311,14 @@ function Printer() {
|
|||||||
this.overruleState = function(newState) {
|
this.overruleState = function(newState) {
|
||||||
this.stateOverruled = true;
|
this.stateOverruled = true;
|
||||||
console.log(" stateOverruled: ",this.stateOverruled);
|
console.log(" stateOverruled: ",this.stateOverruled);
|
||||||
|
|
||||||
self.state = newState;
|
self.state = newState;
|
||||||
|
|
||||||
$(document).trigger(Printer.UPDATE);
|
$(document).trigger(Printer.UPDATE);
|
||||||
|
|
||||||
this.stopStatusCheckInterval();
|
this.stopStatusCheckInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeLeaveWarning = function() {
|
this.removeLeaveWarning = function() {
|
||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
}
|
}
|
||||||
@ -327,4 +327,4 @@ function Printer() {
|
|||||||
return Printer.ON_BEFORE_UNLOAD_MESSAGE;
|
return Printer.ON_BEFORE_UNLOAD_MESSAGE;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user