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

hasControl feedback

This commit is contained in:
peteruithoven 2013-10-11 16:17:58 +02:00
parent d61b9cb0d8
commit 253561210d

View File

@ -16,6 +16,7 @@ var displayTemp, displayProgress;
var state; var state;
var prevState; var prevState;
var hasControl;
function initButtonBehavior() { function initButtonBehavior() {
console.log("f:initButtonBehavior"); console.log("f:initButtonBehavior");
@ -189,7 +190,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(Printer.STOPPING_STATE); setState(Printer.STOPPING_STATE,printer.hasControl);
} }
@ -207,7 +208,7 @@ function print(e) {
$("#textdump").text(""); $("#textdump").text("");
if (_points.length > 2) { if (_points.length > 2) {
setState(Printer.BUFFERING_STATE); setState(Printer.BUFFERING_STATE,printer.hasControl);
var gcode = generate_gcode(); var gcode = generate_gcode();
//startPrint(gencode); //startPrint(gencode);
@ -293,40 +294,35 @@ function previewTwistRight(redrawLess) {
function update() { function update() {
setState(printer.state); setState(printer.state,printer.hasControl);
thermometer.update(printer.temperature, printer.targetTemperature); thermometer.update(printer.temperature, printer.targetTemperature);
//TODO: update progress //TODO: update progress
} }
function setState(newState) { //TODO add hasControl function setState(newState,newHasControl) { //TODO add hasControl
if(newState == state) return; if(newState == state && newHasControl == hasControl) return;
console.log("setState: ",state," > ",newState); console.log("setState: ",state," > ",newState," ( ",newHasControl,")");
setDebugText("State: "+newState); setDebugText("State: "+newState);
// print button // print button
switch(newState) { var printEnabled = (newState == Printer.IDLE_STATE && newHasControl);
case Printer.IDLE_STATE: if(printEnabled) {
btnPrint.removeClass("disabled"); // enable print button btnPrint.removeClass("disabled"); // enable print button
btnPrint.unbind('touchstart mousedown'); btnPrint.unbind('touchstart mousedown');
btnPrint.bind('touchstart mousedown',print); btnPrint.bind('touchstart mousedown',print);
break; } else {
default:
btnPrint.addClass("disabled"); // disable print button btnPrint.addClass("disabled"); // disable print button
btnPrint.unbind('touchstart mousedown'); btnPrint.unbind('touchstart mousedown');
break;
} }
// stop button // stop button
switch(newState) { var stopEnabled = ((newState == Printer.PRINTING_STATE || newState == Printer.BUFFERING_STATE) && newHasControl);
case Printer.PRINTING_STATE: if(stopEnabled) {
case Printer.BUFFERING_STATE:
btnStop.removeClass("disabled"); btnStop.removeClass("disabled");
break; } else {
default:
btnStop.addClass("disabled"); btnStop.addClass("disabled");
break;
} }
// thermometer // thermometer
@ -339,6 +335,7 @@ function setState(newState) { //TODO add hasControl
thermometer.show(); thermometer.show();
break; break;
} }
// progress indicator // progress indicator
switch(newState) { switch(newState) {
case Printer.PRINTING_STATE: case Printer.PRINTING_STATE:
@ -351,4 +348,5 @@ function setState(newState) { //TODO add hasControl
prevState = state; prevState = state;
state = newState; state = newState;
hasControl = newHasControl;
} }