mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 01:07:56 +01:00
fixed isRemote mode. Pressing stop button brings interface directly in IDLE mode.
This commit is contained in:
parent
b13f9f541b
commit
96e14615c8
128
js/Printer.js
128
js/Printer.js
@ -1,6 +1,7 @@
|
|||||||
function Printer() {
|
function Printer() {
|
||||||
this.temperature = 0;
|
this.temperature = 0;
|
||||||
this.targetTemperature = 0;
|
this.targetTemperature = 0;
|
||||||
|
this.printing;
|
||||||
|
|
||||||
this.wifiboxURL;
|
this.wifiboxURL;
|
||||||
|
|
||||||
@ -45,24 +46,28 @@ function Printer() {
|
|||||||
console.log("Printer:preheat");
|
console.log("Printer:preheat");
|
||||||
var postData = { id: 0 };
|
var postData = { id: 0 };
|
||||||
var self = this;
|
var self = this;
|
||||||
$.ajax({
|
if (communicateWithWifibox) {
|
||||||
url: this.wifiboxURL + "/printer/heatup",
|
$.ajax({
|
||||||
type: "POST",
|
url: this.wifiboxURL + "/printer/heatup",
|
||||||
data: postData,
|
type: "POST",
|
||||||
dataType: 'json',
|
data: postData,
|
||||||
timeout: this.timeoutTime,
|
dataType: 'json',
|
||||||
success: function(data){
|
timeout: this.timeoutTime,
|
||||||
console.log("Printer:preheat response: ",data);
|
success: function(data){
|
||||||
if(data.status == "error") {
|
console.log("Printer:preheat response: ",data);
|
||||||
clearTimeout(self.retryPreheatDelay);
|
if(data.status == "error") {
|
||||||
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
clearTimeout(self.retryPreheatDelay);
|
||||||
}
|
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}
|
||||||
console.log("Printer:preheat: failed");
|
}).fail(function() {
|
||||||
clearTimeout(self.retryPreheatDelay);
|
console.log("Printer:preheat: failed");
|
||||||
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
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) {
|
this.print = function(gcode) {
|
||||||
@ -106,29 +111,33 @@ function Printer() {
|
|||||||
|
|
||||||
var postData = { id: 0, gcode: gcodePart.join("\n"), first: firstOne, last: lastOne};
|
var postData = { id: 0, gcode: gcodePart.join("\n"), first: firstOne, last: lastOne};
|
||||||
var self = this;
|
var self = this;
|
||||||
$.ajax({
|
if (communicateWithWifibox) {
|
||||||
url: this.wifiboxURL + "/printer/print",
|
$.ajax({
|
||||||
type: "POST",
|
url: this.wifiboxURL + "/printer/print",
|
||||||
data: postData,
|
type: "POST",
|
||||||
dataType: 'json',
|
data: postData,
|
||||||
timeout: this.timeoutTime,
|
dataType: 'json',
|
||||||
success: function(data){
|
timeout: this.timeoutTime,
|
||||||
console.log("Printer:sendPrintPart response: ",data);
|
success: function(data){
|
||||||
|
console.log("Printer:sendPrintPart response: ",data);
|
||||||
if(data.status == "success") {
|
|
||||||
if (lastOne) {
|
if(data.status == "success") {
|
||||||
console.log("Printer:sendPrintPart:gcode sending completed");
|
if (lastOne) {
|
||||||
this.gcode = [];
|
console.log("Printer:sendPrintPart:gcode sending completed");
|
||||||
} else {
|
this.gcode = [];
|
||||||
self.sendPrintPart(sendIndex + sendLength, sendLength);
|
} else {
|
||||||
}
|
self.sendPrintPart(sendIndex + sendLength, sendLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}
|
||||||
console.log("Printer:sendPrintPart: failed");
|
}).fail(function() {
|
||||||
clearTimeout(self.retrySendPrintPartDelay);
|
console.log("Printer:sendPrintPart: failed");
|
||||||
self.retrySendPrintPartDelay = setTimeout(function() { self.sendPrintPart(sendIndex, sendLength) },self.retryDelay); // retry after delay
|
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,23 +145,26 @@ function Printer() {
|
|||||||
console.log("Printer:stop");
|
console.log("Printer:stop");
|
||||||
var postData = { id: 0 };
|
var postData = { id: 0 };
|
||||||
var self = this;
|
var self = this;
|
||||||
$.ajax({
|
if (communicateWithWifibox) {
|
||||||
url: this.wifiboxURL + "/printer/stop",
|
$.ajax({
|
||||||
type: "POST",
|
url: this.wifiboxURL + "/printer/stop",
|
||||||
data: postData,
|
type: "POST",
|
||||||
dataType: 'json',
|
data: postData,
|
||||||
timeout: this.timeoutTime,
|
dataType: 'json',
|
||||||
success: function(data){
|
timeout: this.timeoutTime,
|
||||||
console.log("Printer:stop response: ", data);
|
success: function(data){
|
||||||
|
console.log("Printer:stop response: ", data);
|
||||||
setTimeout(function() { console.log("send: ",gcodeEnd); self.print(gcodeEnd) },self.sendStopGCodeDelay);
|
|
||||||
}
|
setTimeout(function() { console.log("send: ",gcodeEnd); self.print(gcodeEnd) },self.sendStopGCodeDelay);
|
||||||
}).fail(function() {
|
}
|
||||||
console.log("Printer:stop: failed");
|
}).fail(function() {
|
||||||
clearTimeout(self.retryStopDelay);
|
console.log("Printer:stop: failed");
|
||||||
self.retryStopDelay = setTimeout(function() { self.stop() },self.retryDelay); // retry after delay
|
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() {
|
this.checkTemperature = function() {
|
||||||
|
@ -229,6 +229,7 @@ function initButtonBehavior() {
|
|||||||
function stopPrint() {
|
function stopPrint() {
|
||||||
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
||||||
if (sendPrintCommands) printer.stop();
|
if (sendPrintCommands) printer.stop();
|
||||||
|
setState(IDLE_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
12
js/main.js
12
js/main.js
@ -13,10 +13,14 @@ $(function() {
|
|||||||
if (getURLParameter("c") != "null") communicateWithWifibox = (getURLParameter("c") == "1");
|
if (getURLParameter("c") != "null") communicateWithWifibox = (getURLParameter("c") == "1");
|
||||||
if (getURLParameter("r") != "null") wifiboxIsRemote = (getURLParameter("r") == "1");
|
if (getURLParameter("r") != "null") wifiboxIsRemote = (getURLParameter("r") == "1");
|
||||||
|
|
||||||
if (communicateWithWifibox) {
|
|
||||||
wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
|
if (wifiboxIsRemote) {
|
||||||
} else {
|
wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
|
||||||
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
|
sendPrintCommands = false; // 'communicateWithWifibox = false' implies this
|
||||||
}
|
}
|
||||||
console.log("debugMode: " + debugMode);
|
console.log("debugMode: " + debugMode);
|
||||||
|
Loading…
Reference in New Issue
Block a user