mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 01:07:56 +01:00
Add connecting state.
This commit is contained in:
parent
2457ce656e
commit
e050c8e080
@ -23,13 +23,14 @@ 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
|
||||||
Printer.IDLE_STATE = "idle"; // printer found, but idle
|
Printer.CONNECTING_STATE = "connecting"; // printer connecting (printer found, but driver has not yet finished setting up the connection)
|
||||||
|
Printer.IDLE_STATE = "idle"; // printer found and ready to use, but idle
|
||||||
Printer.BUFFERING_STATE = "buffering"; // printer is buffering (recieving) data, but not yet printing
|
Printer.BUFFERING_STATE = "buffering"; // printer is buffering (recieving) data, but not yet printing
|
||||||
Printer.PRINTING_STATE = "printing";
|
Printer.PRINTING_STATE = "printing";
|
||||||
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.TOUR_STATE = "tour"; // when in joyride mode
|
Printer.TOUR_STATE = "tour"; // when in joyride mode
|
||||||
|
|
||||||
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 sent to the printer, leaving will result in a incomplete 3D print";
|
||||||
|
|
||||||
this.temperature = 0;
|
this.temperature = 0;
|
||||||
this.targetTemperature = 0;
|
this.targetTemperature = 0;
|
||||||
@ -47,7 +48,7 @@ function Printer() {
|
|||||||
this.sendPrintPartTimeoutTime = 5000;
|
this.sendPrintPartTimeoutTime = 5000;
|
||||||
|
|
||||||
this.gcode; // gcode to be printed
|
this.gcode; // gcode to be printed
|
||||||
this.sendLength = 500; // max amount of gcode lines per post (limited because WiFi box can't handle to much)
|
this.sendLength = 500; // max amount of gcode lines per post (limited because WiFi box can't handle too much)
|
||||||
|
|
||||||
this.retryDelay = 2000; // retry setTimout delay
|
this.retryDelay = 2000; // retry setTimout delay
|
||||||
this.retrySendPrintPartDelay; // retry setTimout instance
|
this.retrySendPrintPartDelay; // retry setTimout instance
|
||||||
@ -80,11 +81,7 @@ function Printer() {
|
|||||||
this.preheat = function() {
|
this.preheat = function() {
|
||||||
console.log("Printer:preheat");
|
console.log("Printer:preheat");
|
||||||
|
|
||||||
if( this.state == Printer.BUFFERING_STATE ||
|
if (this.state != Printer.IDLE_STATE) return;
|
||||||
this.state == Printer.PRINTING_STATE ||
|
|
||||||
this.state == Printer.STOPPING_STATE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
@ -131,8 +128,9 @@ function Printer() {
|
|||||||
console.log(" gcodeSize: ",gcodeSize);
|
console.log(" gcodeSize: ",gcodeSize);
|
||||||
|
|
||||||
if(gcodeSize > Printer.MAX_GCODE_SIZE) {
|
if(gcodeSize > Printer.MAX_GCODE_SIZE) {
|
||||||
alert("Error: Printer:print: gcode file is probably too big ("+gcodeSize+"MB) (max: "+Printer.MAX_GCODE_SIZE+"MB)");
|
var msg = "Error: Printer:print: gcode file is probably too big ("+gcodeSize+"MB) (max: "+Printer.MAX_GCODE_SIZE+"MB)";
|
||||||
console.log("Error: Printer:print: gcode file is probably too big ("+gcodeSize+"MB) (max: "+Printer.MAX_GCODE_SIZE+"MB)");
|
alert(msg);
|
||||||
|
console.log(msg);
|
||||||
|
|
||||||
this.overruleState(Printer.IDLE_STATE);
|
this.overruleState(Printer.IDLE_STATE);
|
||||||
this.startStatusCheckInterval();
|
this.startStatusCheckInterval();
|
||||||
@ -191,7 +189,7 @@ function Printer() {
|
|||||||
message.set("Doodle has been 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 been 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) {
|
||||||
@ -257,7 +255,7 @@ function Printer() {
|
|||||||
self.startStatusCheckInterval();
|
self.startStatusCheckInterval();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log ("Printer >> f:communicateWithWifibox() >> communicateWithWifibox is false, so not executing this function");
|
console.log ("Printer >> f:stop() >> communicateWithWifibox is false, so not executing this function");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,6 @@ 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 (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);
|
||||||
@ -248,10 +247,6 @@ function print(e) {
|
|||||||
console.log("f:print >> not enough points!");
|
console.log("f:print >> not enough points!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//alert("Je tekening zal nu geprint worden");
|
|
||||||
//$(".btnPrint").css("display","block");
|
|
||||||
|
|
||||||
|
|
||||||
// $.post("/doodle3d.of", { data:output }, function(data) {
|
// $.post("/doodle3d.of", { data:output }, function(data) {
|
||||||
// btnPrint.disabled = false;
|
// btnPrint.disabled = false;
|
||||||
// });
|
// });
|
||||||
@ -393,6 +388,7 @@ function setState(newState,newHasControl) {
|
|||||||
|
|
||||||
/* settings button */
|
/* settings button */
|
||||||
switch(newState) {
|
switch(newState) {
|
||||||
|
case Printer.CONNECTING_STATE: /* fall-through */
|
||||||
case Printer.IDLE_STATE:
|
case Printer.IDLE_STATE:
|
||||||
btnSettings.enable();
|
btnSettings.enable();
|
||||||
break;
|
break;
|
||||||
@ -426,12 +422,15 @@ function setState(newState,newHasControl) {
|
|||||||
message.set("Connected to WiFi box",Message.INFO,true);
|
message.set("Connected to WiFi box",Message.INFO,true);
|
||||||
} else if(newState == Printer.DISCONNECTED_STATE) {
|
} else if(newState == Printer.DISCONNECTED_STATE) {
|
||||||
message.set("Printer disconnected",Message.WARNING,true);
|
message.set("Printer disconnected",Message.WARNING,true);
|
||||||
|
} else if(newState == Printer.CONNECTING_STATE) {
|
||||||
|
message.set("Printer connecting",Message.INFO,false);
|
||||||
} else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE ||
|
} else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE ||
|
||||||
prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE) {
|
prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE ||
|
||||||
|
prevState == Printer.CONNECTING_STATE && newState == Printer.IDLE_STATE) {
|
||||||
message.set("Printer connected",Message.INFO,true);
|
message.set("Printer connected",Message.INFO,true);
|
||||||
console.log(" preheat: ",settings["printer.heatup.enabled"]);
|
console.log(" preheat: ",settings["printer.heatup.enabled"]);
|
||||||
if(settings["printer.heatup.enabled"]) {
|
if(settings["printer.heatup.enabled"]) {
|
||||||
// HACK: we delay the preheat because the driver needs time to connect
|
// HACK: we delay the preheat because the makerbot driver needs time to connect
|
||||||
clearTimeout(preheatDelay);
|
clearTimeout(preheatDelay);
|
||||||
preheatDelay = setTimeout(printer.preheat,preheatDelayTime); // retry after delay
|
preheatDelay = setTimeout(printer.preheat,preheatDelayTime); // retry after delay
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user