0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-22 01:07:56 +01:00

update timing hacks

This commit is contained in:
peteruithoven 2013-09-18 18:55:37 +02:00
parent d610e802f5
commit 6c7b832a30

View File

@ -19,9 +19,9 @@ function Printer() {
this.maxTempLastMod = 5; // max time (seconds) since the last temp info modification before the printer connection is considered lost this.maxTempLastMod = 5; // max time (seconds) since the last temp info modification before the printer connection is considered lost
this.checkTemperatureInterval = 3000; this.checkTemperatureInterval = 6000;
this.checkTemperatureDelay; this.checkTemperatureDelay;
this.checkProgressInterval = 3000; this.checkProgressInterval = 6000;
this.checkProgressDelay; this.checkProgressDelay;
this.timeoutTime = 3000; this.timeoutTime = 3000;
@ -109,6 +109,8 @@ function Printer() {
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.restartIntervals(); // slight hack
} }
this.byteSize = function(s){ this.byteSize = function(s){
return~-encodeURI(s).split(/%..|./).length; return~-encodeURI(s).split(/%..|./).length;
@ -157,7 +159,6 @@ function Printer() {
} }
} }
this.stop = function() { this.stop = function() {
console.log("Printer:stop"); console.log("Printer:stop");
var postData = { id: 0 }; var postData = { id: 0 };
@ -182,6 +183,8 @@ function Printer() {
} else { } else {
console.log ("Printer >> f:communicateWithWifibox() >> communicateWithWifibox is false, so not executing this function"); console.log ("Printer >> f:communicateWithWifibox() >> communicateWithWifibox is false, so not executing this function");
} }
this.restartIntervals(); // slight hack
} }
this.checkTemperature = function() { this.checkTemperature = function() {
@ -200,7 +203,10 @@ function Printer() {
//console.log("temp: ",response.data.hotend+"/"+response.data.hotend_target+" ("+response.data.last_mod+")"); //console.log("temp: ",response.data.hotend+"/"+response.data.hotend_target+" ("+response.data.last_mod+")");
self.temperature = data.data.hotend; self.temperature = data.data.hotend;
if(data.data.hotend_target != undefined) { if(data.data.hotend_target != undefined) {
if(self.@@@@)
self.targetTemperature = data.data.hotend_target; self.targetTemperature = data.data.hotend_target;
self.targetTemperature = settings["printer.temperature"]; // hack
} }
self.alive = (data.data.last_mod < self.maxTempLastMod); self.alive = (data.data.last_mod < self.maxTempLastMod);
} else { } else {
@ -257,4 +263,13 @@ function Printer() {
console.log ("Printer >> f:checkProgress() >> communicateWithWifibox is false, so not executing this function"); console.log ("Printer >> f:checkProgress() >> communicateWithWifibox is false, so not executing this function");
} }
} }
this.restartIntervals = function() {
var self = this;
clearTimeout(self.checkProgressDelay);
self.checkProgressDelay = setTimeout(function() { self.checkProgress() },self.checkProgressInterval);
clearTimeout(self.checkTemperatureDelay);
self.checkTemperatureDelay = setTimeout(function() { self.checkTemperature() }, self.checkTemperatureInterval);
}
} }