fixed isRemote mode. Pressing stop button brings interface directly in IDLE mode.

This commit is contained in:
peteruithoven 2013-08-19 17:55:01 +02:00
parent b13f9f541b
commit 96e14615c8
3 changed files with 79 additions and 62 deletions

View File

@ -1,6 +1,7 @@
function Printer() {
this.temperature = 0;
this.targetTemperature = 0;
this.printing;
this.wifiboxURL;
@ -45,6 +46,7 @@ function Printer() {
console.log("Printer:preheat");
var postData = { id: 0 };
var self = this;
if (communicateWithWifibox) {
$.ajax({
url: this.wifiboxURL + "/printer/heatup",
type: "POST",
@ -63,6 +65,9 @@ function Printer() {
clearTimeout(self.retryPreheatDelay);
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
});
} else {
console.log ("Printer >> f:preheat() >> communicateWithWifibox is false, so not executing this function");
}
}
this.print = function(gcode) {
@ -106,6 +111,7 @@ function Printer() {
var postData = { id: 0, gcode: gcodePart.join("\n"), first: firstOne, last: lastOne};
var self = this;
if (communicateWithWifibox) {
$.ajax({
url: this.wifiboxURL + "/printer/print",
type: "POST",
@ -129,6 +135,9 @@ function Printer() {
clearTimeout(self.retrySendPrintPartDelay);
self.retrySendPrintPartDelay = setTimeout(function() { self.sendPrintPart(sendIndex, sendLength) },self.retryDelay); // retry after delay
});
} else {
console.log ("Printer >> f:sendPrintPart() >> communicateWithWifibox is false, so not executing this function");
}
}
@ -136,6 +145,7 @@ function Printer() {
console.log("Printer:stop");
var postData = { id: 0 };
var self = this;
if (communicateWithWifibox) {
$.ajax({
url: this.wifiboxURL + "/printer/stop",
type: "POST",
@ -152,7 +162,9 @@ function Printer() {
clearTimeout(self.retryStopDelay);
self.retryStopDelay = setTimeout(function() { self.stop() },self.retryDelay); // retry after delay
});
} else {
console.log ("Printer >> f:communicateWithWifibox() >> communicateWithWifibox is false, so not executing this function");
}
}
this.checkTemperature = function() {

View File

@ -229,6 +229,7 @@ function initButtonBehavior() {
function stopPrint() {
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
if (sendPrintCommands) printer.stop();
setState(IDLE_STATE);
}

View File

@ -13,10 +13,14 @@ $(function() {
if (getURLParameter("c") != "null") communicateWithWifibox = (getURLParameter("c") == "1");
if (getURLParameter("r") != "null") wifiboxIsRemote = (getURLParameter("r") == "1");
if (communicateWithWifibox) {
wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
} else {
if (wifiboxIsRemote) {
wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
} else {
wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
}
if (!communicateWithWifibox) {
sendPrintCommands = false; // 'communicateWithWifibox = false' implies this
}
console.log("debugMode: " + debugMode);