mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-25 18:47:57 +01:00
Handling new print3d driver (using new api, printer states)
This commit is contained in:
parent
d417a7454f
commit
abc9841bc7
@ -31,3 +31,13 @@
|
|||||||
.agentInfoToggle {
|
.agentInfoToggle {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#debug_display {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: none;
|
||||||
|
background-color: #fff;
|
||||||
|
opacity: .7;
|
||||||
|
color: #000;
|
||||||
|
}
|
@ -78,6 +78,8 @@
|
|||||||
<div id="debug_textArea">
|
<div id="debug_textArea">
|
||||||
<textarea rows="5" cols="115" id="textdump"></textarea>
|
<textarea rows="5" cols="115" id="textdump"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="debug_display">
|
||||||
|
</div>
|
||||||
<div id="contentOverlay">
|
<div id="contentOverlay">
|
||||||
<div id="settings" class="popup">
|
<div id="settings" class="popup">
|
||||||
<header>
|
<header>
|
||||||
|
155
js/Printer.js
155
js/Printer.js
@ -11,37 +11,45 @@ function setPrintprogress(val) {
|
|||||||
//*/
|
//*/
|
||||||
|
|
||||||
function Printer() {
|
function Printer() {
|
||||||
|
|
||||||
|
Printer.UNKNOWN_STATE = "unknown";
|
||||||
|
Printer.DISCONNECTED_STATE = "disconnected";
|
||||||
|
Printer.IDLE_STATE = "idle"; // printer found, but idle
|
||||||
|
Printer.BUFFERING_STATE = "buffering"; // printer is buffering (recieving) data, but not yet printing
|
||||||
|
Printer.PRINTING_STATE = "printing";
|
||||||
|
Printer.STOPPING_STATE = "stopping"; // when you stop (abort) a print it prints the endcode
|
||||||
|
|
||||||
this.temperature = 0;
|
this.temperature = 0;
|
||||||
this.targetTemperature = 0;
|
this.targetTemperature = 0;
|
||||||
this.printing;
|
this.currentLine = 0;
|
||||||
|
this.totalLines = 0;
|
||||||
|
this.bufferedLines = 0;
|
||||||
|
this.state = Printer.UNKNOWN_STATE;
|
||||||
|
this.hasControl = true; // whether this client has control access
|
||||||
|
|
||||||
this.wifiboxURL;
|
this.wifiboxURL;
|
||||||
|
|
||||||
this.maxTempLastMod = 7; // max time (seconds) since the last temp info modification before the printer connection is considered lost
|
this.checkStatusInterval = 3000;
|
||||||
|
this.checkStatusDelay;
|
||||||
this.checkTemperatureInterval = 6000;
|
|
||||||
this.checkTemperatureDelay;
|
|
||||||
this.checkProgressInterval = 6000;
|
|
||||||
this.checkProgressDelay;
|
|
||||||
this.timeoutTime = 3000;
|
this.timeoutTime = 3000;
|
||||||
|
this.sendPrintPartTimeoutTime = 5000;
|
||||||
|
|
||||||
this.gcode; // gcode to be printed
|
this.gcode; // gcode to be printed
|
||||||
this.sendLength = 6000; // 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)
|
||||||
|
|
||||||
this.retryDelay = 2000; // retry setTimout delay
|
this.retryDelay = 2000; // retry setTimout delay
|
||||||
this.retrySendPrintPartDelay; // retry setTimout instance
|
this.retrySendPrintPartDelay; // retry setTimout instance
|
||||||
this.retryCheckTemperatureDelay; // retry setTimout instance
|
this.retryCheckStatusDelay; // retry setTimout instance
|
||||||
this.retryCheckProgressDelay; // 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.sendStopGCodeDelay = 1000;
|
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
Printer.UPDATE = "update";
|
Printer.UPDATE = "update";
|
||||||
|
|
||||||
|
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";
|
||||||
@ -51,20 +59,17 @@ function Printer() {
|
|||||||
console.log(" wifiboxURL: ",this.wifiboxURL);
|
console.log(" wifiboxURL: ",this.wifiboxURL);
|
||||||
|
|
||||||
if(autoUpdate) {
|
if(autoUpdate) {
|
||||||
this.checkTemperature();
|
this.checkStatus();
|
||||||
this.checkProgress();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preheat = function() {
|
this.preheat = function() {
|
||||||
console.log("Printer:preheat");
|
console.log("Printer:preheat");
|
||||||
var postData = { id: 0 };
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.wifiboxURL + "/printer/heatup",
|
url: this.wifiboxURL + "/printer/heatup",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: postData,
|
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
@ -109,8 +114,6 @@ 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;
|
||||||
@ -127,7 +130,7 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength);
|
var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength);
|
||||||
|
|
||||||
var postData = { id: 0, gcode: gcodePart.join("\n"), first: firstOne, last: lastOne};
|
var postData = { gcode: gcodePart.join("\n"), first: firstOne, last: lastOne};
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -135,7 +138,7 @@ function Printer() {
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
data: postData,
|
data: postData,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.sendPrintPartTimeoutTime,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
console.log("Printer:sendPrintPart response: ",data);
|
console.log("Printer:sendPrintPart response: ",data);
|
||||||
|
|
||||||
@ -161,13 +164,11 @@ function Printer() {
|
|||||||
|
|
||||||
this.stop = function() {
|
this.stop = function() {
|
||||||
console.log("Printer:stop");
|
console.log("Printer:stop");
|
||||||
var postData = { id: 0 };
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.wifiboxURL + "/printer/stop",
|
url: this.wifiboxURL + "/printer/stop",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: postData,
|
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
@ -183,94 +184,60 @@ 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.checkStatus = function() {
|
||||||
//console.log("Printer:checkTemperature");
|
//console.log("Printer:checkStatus");
|
||||||
var getData = { id: 0 };
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.wifiboxURL + "/printer/temperature",
|
url: this.wifiboxURL + "/info/status",
|
||||||
data: getData,
|
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(data){
|
success: function(response){
|
||||||
//console.log("Printer:temperature response: ",data);
|
console.log("Printer:status: ",response.data.state," response: ",response);
|
||||||
if(data.status == "success") {
|
|
||||||
//console.log("temp: ",response.data.hotend+"/"+response.data.hotend_target+" ("+response.data.last_mod+")");
|
|
||||||
self.temperature = data.data.hotend;
|
|
||||||
if(data.data.hotend_target != undefined) {
|
|
||||||
if(state == PRINTING_STATE) { // HACK
|
|
||||||
self.targetTemperature = settings["printer.temperature"];
|
|
||||||
} else {
|
|
||||||
self.targetTemperature = data.data.hotend_target;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.alive = (data.data.last_mod < self.maxTempLastMod);
|
|
||||||
} else {
|
|
||||||
self.alive = false;
|
|
||||||
}
|
|
||||||
//console.log(" this.alive: ",self.alive);
|
|
||||||
$(document).trigger(Printer.UPDATE);
|
|
||||||
|
|
||||||
self.checkTemperatureDelay = setTimeout(function() { self.checkTemperature() }, self.checkTemperatureInterval);
|
self.handleStatusUpdate(response);
|
||||||
|
|
||||||
|
clearTimeout(self.checkStatusDelay);
|
||||||
|
clearTimeout(self.retryCheckStatusDelay);
|
||||||
|
self.checkStatusDelay = setTimeout(function() { self.checkStatus() }, self.checkStatusInterval);
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Printer:checkTemperature: failed");
|
console.log("Printer:checkStatus: failed");
|
||||||
clearTimeout(self.retryCheckTemperatureDelay);
|
self.state = Printer.UNKNOWN_STATE;
|
||||||
self.retryCheckTemperatureDelay = setTimeout(function() { self.checkTemperature() },self.retryDelay); // retry after delay
|
clearTimeout(self.checkStatusDelay);
|
||||||
|
clearTimeout(self.retryCheckStatusDelay);
|
||||||
|
self.retryCheckStatusDelay = setTimeout(function() { self.checkStatus() },self.retryDelay); // retry after delay
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log ("Printer >> f:checkTemperature() >> communicateWithWifibox is false, so not executing this function");
|
console.log ("Printer >> f:checkStatus() >> communicateWithWifibox is false, so not executing this function");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.checkProgress = function() {
|
this.handleStatusUpdate = function(response) {
|
||||||
//console.log("Printer:checkProgress");
|
var data = response.data;
|
||||||
var getData = { id: 0 };
|
if(response.status != "success") {
|
||||||
var self = this;
|
self.state = Printer.UNKNOWN_STATE;
|
||||||
if (communicateWithWifibox) {
|
|
||||||
$.ajax({
|
|
||||||
url: this.wifiboxURL + "/printer/progress",
|
|
||||||
data: getData,
|
|
||||||
dataType: 'json',
|
|
||||||
timeout: this.timeoutTime,
|
|
||||||
success: function(data){
|
|
||||||
if(data.status == "success") {
|
|
||||||
|
|
||||||
self.printing = data.data.printing;
|
|
||||||
self.currentLine = data.data.current_line;
|
|
||||||
self.num_lines = data.data.num_lines;
|
|
||||||
|
|
||||||
if(self.printing) {
|
|
||||||
console.log("progress: ",data.data.current_line+"/"+data.data.num_lines+" ("+data.data.last_mod+")");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.printing = false;
|
// state
|
||||||
|
self.state = data.state;
|
||||||
|
|
||||||
|
// temperature
|
||||||
|
self.temperature = data.hotend;
|
||||||
|
self.targetTemperature = data.hotend_target;
|
||||||
|
|
||||||
|
// progress
|
||||||
|
self.currentLine = data.current_line;
|
||||||
|
self.totalLines = data.total_lines;
|
||||||
|
self.bufferedLines = data.buffered_lines
|
||||||
|
|
||||||
|
// access
|
||||||
|
self.hasControl = data.has_control;
|
||||||
|
|
||||||
|
if(self.state == Printer.PRINTING_STATE || self.state == Printer.STOPPING_STATE) {
|
||||||
|
console.log("progress: ",self.currentLine+"/"+self.totalLines+" ("+self.bufferedLines+") ("+self.state+")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//console.log(" this.alive: ",self.alive);
|
|
||||||
$(document).trigger(Printer.UPDATE);
|
$(document).trigger(Printer.UPDATE);
|
||||||
|
|
||||||
self.checkProgressDelay = setTimeout(function() { self.checkProgress() },self.checkProgressInterval);
|
|
||||||
}
|
|
||||||
}).fail(function() {
|
|
||||||
console.log("Printer:checkProgress: failed");
|
|
||||||
clearTimeout(self.retryCheckProgressDelay);
|
|
||||||
self.retryCheckProgressDelay = setTimeout(function() { self.checkProgress() },self.retryDelay); // retry after delay
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,3 @@
|
|||||||
var $displayThermometer;
|
|
||||||
|
|
||||||
function Thermometer() {
|
function Thermometer() {
|
||||||
this.currentTemperature = 0; // default val
|
this.currentTemperature = 0; // default val
|
||||||
this.targetTemperature = 180; // default val
|
this.targetTemperature = 180; // default val
|
||||||
@ -13,9 +11,12 @@ function Thermometer() {
|
|||||||
this.$canvas;
|
this.$canvas;
|
||||||
this.canvas;
|
this.canvas;
|
||||||
this.context;
|
this.context;
|
||||||
|
this.$container;
|
||||||
|
|
||||||
this.isInitted = false;
|
this.isInitted = false;
|
||||||
|
|
||||||
|
this.enabled = true;
|
||||||
|
|
||||||
this.thermoColors = [
|
this.thermoColors = [
|
||||||
[50, 200, 244], // 'cold'
|
[50, 200, 244], // 'cold'
|
||||||
[244, 190, 10], // 'warming up'
|
[244, 190, 10], // 'warming up'
|
||||||
@ -25,7 +26,7 @@ function Thermometer() {
|
|||||||
this.init = function(targCanvas, targCanvasContainer) {
|
this.init = function(targCanvas, targCanvasContainer) {
|
||||||
console.log("Thermometer.init()");
|
console.log("Thermometer.init()");
|
||||||
|
|
||||||
$displayThermometer = targCanvasContainer;
|
this.$container = targCanvasContainer;
|
||||||
|
|
||||||
this.$canvas = targCanvas;
|
this.$canvas = targCanvas;
|
||||||
this.canvas = this.$canvas[0];
|
this.canvas = this.$canvas[0];
|
||||||
@ -45,6 +46,7 @@ function Thermometer() {
|
|||||||
// console.log("Thermometer.update(" + curr + "," + targ + ")");
|
// console.log("Thermometer.update(" + curr + "," + targ + ")");
|
||||||
|
|
||||||
if (this.isInitted) {
|
if (this.isInitted) {
|
||||||
|
if(!this.enabled) return;
|
||||||
if (curr == undefined) curr = 0;
|
if (curr == undefined) curr = 0;
|
||||||
if (targ== undefined) targ = 180; // prevent divide by zero
|
if (targ== undefined) targ = 180; // prevent divide by zero
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ function Thermometer() {
|
|||||||
// rect will be clipped by the thermometer outlines
|
// rect will be clipped by the thermometer outlines
|
||||||
this.context.beginPath();
|
this.context.beginPath();
|
||||||
this.context.rect(20, h - paddingUnder - p, 60, p + paddingUnder);
|
this.context.rect(20, h - paddingUnder - p, 60, p + paddingUnder);
|
||||||
console.log(" currColor: " + currColor);
|
//console.log(" currColor: " + currColor);
|
||||||
//todo Math.floor??
|
//todo Math.floor??
|
||||||
this.context.fillStyle = "rgb(" + currColor[0] + "," + currColor[1] + "," + currColor[2] + ")";
|
this.context.fillStyle = "rgb(" + currColor[0] + "," + currColor[1] + "," + currColor[2] + ")";
|
||||||
this.context.fill();
|
this.context.fill();
|
||||||
@ -116,4 +118,12 @@ function Thermometer() {
|
|||||||
console.log("Thermometer.setTemperature() -> thermometer not initialized!");
|
console.log("Thermometer.setTemperature() -> thermometer not initialized!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.show = function() {
|
||||||
|
this.$container.show();
|
||||||
|
this.enabled = true;
|
||||||
|
}
|
||||||
|
this.hide = function() {
|
||||||
|
this.$container.hide();
|
||||||
|
this.enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,10 @@ var btnOops, btnStop, btnClear;
|
|||||||
var btnMoveUp, btnMoveDown, btnTwistLeft, btnTwistRight;
|
var btnMoveUp, btnMoveDown, btnTwistLeft, btnTwistRight;
|
||||||
var btnInfo, btnSettings;
|
var btnInfo, btnSettings;
|
||||||
var btnDebug; // debug
|
var btnDebug; // debug
|
||||||
var displayTemp, displayProgress;
|
var displayProgress;
|
||||||
|
|
||||||
var displayTempEnabled = false;
|
var state;
|
||||||
|
var prevState;
|
||||||
var IDLE_STATE = "idle";
|
|
||||||
var PRINTING_STATE = "printing";
|
|
||||||
|
|
||||||
var state = IDLE_STATE;
|
|
||||||
var prevState = state;
|
|
||||||
|
|
||||||
function initButtonBehavior() {
|
function initButtonBehavior() {
|
||||||
console.log("f:initButtonBehavior >> btnNew = " + btnNew);
|
console.log("f:initButtonBehavior >> btnNew = " + btnNew);
|
||||||
@ -36,7 +31,6 @@ function initButtonBehavior() {
|
|||||||
btnNew = $("#btnNew");
|
btnNew = $("#btnNew");
|
||||||
btnPrint= $("#btnPrint");
|
btnPrint= $("#btnPrint");
|
||||||
btnStop = $("#btnStop");
|
btnStop = $("#btnStop");
|
||||||
displayTemp = $("#displayTemp");
|
|
||||||
displayProgress = $("#printProgressContainer");
|
displayProgress = $("#printProgressContainer");
|
||||||
|
|
||||||
// btnPrevious = $("#btnPrevious");
|
// btnPrevious = $("#btnPrevious");
|
||||||
@ -192,7 +186,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);
|
setState(Printer.STOPPING_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,7 +204,7 @@ function print(e) {
|
|||||||
$("#textdump").text("");
|
$("#textdump").text("");
|
||||||
if (_points.length > 2) {
|
if (_points.length > 2) {
|
||||||
|
|
||||||
setState(PRINTING_STATE);
|
setState(Printer.BUFFERING_STATE);
|
||||||
var gcode = generate_gcode();
|
var gcode = generate_gcode();
|
||||||
//startPrint(gencode);
|
//startPrint(gencode);
|
||||||
|
|
||||||
@ -296,52 +290,61 @@ function previewTwistRight(redrawLess) {
|
|||||||
|
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
if(!displayTempEnabled && printer.alive) {
|
setState(printer.state);
|
||||||
displayTemp.show();
|
|
||||||
$displayThermometer.show();
|
|
||||||
displayTempEnabled = true;
|
|
||||||
} else if(displayTempEnabled && !printer.alive) {
|
|
||||||
displayTemp.hide();
|
|
||||||
$displayThermometer.hide();
|
|
||||||
displayTempEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(displayTempEnabled) {
|
|
||||||
displayTemp.text(printer.temperature+"/"+printer.targetTemperature);
|
|
||||||
thermometer.update(printer.temperature, printer.targetTemperature);
|
thermometer.update(printer.temperature, printer.targetTemperature);
|
||||||
}
|
//TODO: update progress
|
||||||
|
|
||||||
//setPrintprogress(printer.currentLine/printer.num_lines);
|
|
||||||
|
|
||||||
var btnPrint= $("#btnPrint");
|
|
||||||
|
|
||||||
setState(printer.printing? PRINTING_STATE : IDLE_STATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setState(newState) { //TODO add hasControl
|
||||||
function setState(newState) {
|
|
||||||
if(newState == state) return;
|
if(newState == state) return;
|
||||||
|
|
||||||
|
console.log("setState: ",state," > ",newState);
|
||||||
|
setDebugText("State: "+newState);
|
||||||
|
|
||||||
|
// print button
|
||||||
switch(newState) {
|
switch(newState) {
|
||||||
case IDLE_STATE:
|
case Printer.IDLE_STATE:
|
||||||
|
|
||||||
btnPrint.removeClass("disabled"); // enable print button
|
btnPrint.removeClass("disabled"); // enable print button
|
||||||
btnStop.addClass("disabled"); // disable stop button
|
|
||||||
btnPrint.bind('touchstart mousedown',print);
|
btnPrint.bind('touchstart mousedown',print);
|
||||||
displayProgress.hide();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PRINTING_STATE:
|
default:
|
||||||
|
|
||||||
btnPrint.addClass("disabled"); // disable print button
|
btnPrint.addClass("disabled"); // disable print button
|
||||||
btnStop.removeClass("disabled"); // enable stop button
|
|
||||||
btnPrint.unbind('touchstart mousedown');
|
btnPrint.unbind('touchstart mousedown');
|
||||||
displayProgress.show();
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop button
|
||||||
|
switch(newState) {
|
||||||
|
case Printer.PRINTING_STATE:
|
||||||
|
case Printer.BUFFERING_STATE:
|
||||||
|
btnStop.removeClass("disabled");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
btnStop.addClass("disabled");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// thermometer
|
||||||
|
switch(newState) {
|
||||||
|
case Printer.UNKNOWN_STATE:
|
||||||
|
case Printer.DISCONNECTED_STATE:
|
||||||
|
thermometer.hide();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
thermometer.show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// progress indicator
|
||||||
|
switch(newState) {
|
||||||
|
case Printer.PRINTING_STATE:
|
||||||
|
displayProgress.show(); // TODO: Show progress
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
displayProgress.hide(); // TODO: hide progress
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
prevState = state;
|
prevState = state;
|
||||||
state = newState;
|
state = newState;
|
||||||
|
|
||||||
}
|
}
|
12
js/main.js
12
js/main.js
@ -8,7 +8,7 @@ var printer = new Printer();
|
|||||||
var thermometer = new Thermometer();
|
var thermometer = new Thermometer();
|
||||||
var settingsWindow = new SettingsWindow();
|
var settingsWindow = new SettingsWindow();
|
||||||
|
|
||||||
var firstTimesettingsLoaded = true;
|
var firstTimeSettingsLoaded = true;
|
||||||
|
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
@ -55,6 +55,8 @@ $(function() {
|
|||||||
$("#debug_textArea").css("display", "block");
|
$("#debug_textArea").css("display", "block");
|
||||||
$("#preview_tmp").css("display", "block");
|
$("#preview_tmp").css("display", "block");
|
||||||
|
|
||||||
|
$("#debug_display").css("display", "block");
|
||||||
|
|
||||||
/* TEMP CODE!! -> artificially populates the startgcode and endgcode textareas in the settings window */
|
/* TEMP CODE!! -> artificially populates the startgcode and endgcode textareas in the settings window */
|
||||||
// todo remove this temporary code...
|
// todo remove this temporary code...
|
||||||
/*
|
/*
|
||||||
@ -85,9 +87,13 @@ function settingsLoaded() {
|
|||||||
console.log("settingsLoaded");
|
console.log("settingsLoaded");
|
||||||
console.log("autoHeatup: ",settings["printer.heatup.enabled"]);
|
console.log("autoHeatup: ",settings["printer.heatup.enabled"]);
|
||||||
if(settings["printer.heatup.enabled"]) {
|
if(settings["printer.heatup.enabled"]) {
|
||||||
if(firstTimesettingsLoaded) {
|
if(firstTimeSettingsLoaded) {
|
||||||
printer.preheat();
|
printer.preheat();
|
||||||
firstTimesettingsLoaded = false;
|
firstTimeSettingsLoaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setDebugText(text) {
|
||||||
|
$("#debug_display").text(text);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user