mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2025-04-20 11:16:27 +02:00
disable wifibox communication in progress
This commit is contained in:
parent
f8032d7411
commit
d27ac15f15
@ -83,7 +83,7 @@ function Printer() {
|
|||||||
var self = this;
|
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";
|
||||||
//this.wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
|
//this.wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
|
||||||
this.wifiboxURL = wifiboxURL;
|
this.wifiboxURL = wifiboxURL;
|
||||||
|
@ -94,7 +94,7 @@ function initButtonBehavior() {
|
|||||||
btnRotate.on("onButtonHold", onBtnRotate);
|
btnRotate.on("onButtonHold", onBtnRotate);
|
||||||
|
|
||||||
//getSavedSketchStatus();
|
//getSavedSketchStatus();
|
||||||
listSketches();
|
// listSketches();
|
||||||
// setSketchModified(false);
|
// setSketchModified(false);
|
||||||
// updateSketchButtonStates();
|
// updateSketchButtonStates();
|
||||||
|
|
||||||
@ -202,62 +202,64 @@ function initButtonBehavior() {
|
|||||||
buttonGroupAdd.fadeOut();
|
buttonGroupAdd.fadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
btnSettings.on("onButtonClick", openSettingsWindow);
|
// btnSettings.on("onButtonClick", openSettingsWindow);
|
||||||
|
|
||||||
// 29-okt-2013 - we're not doing help for smartphones at the moment
|
// 29-okt-2013 - we're not doing help for smartphones at the moment
|
||||||
if (clientInfo.isSmartphone) {
|
// if (clientInfo.isSmartphone) {
|
||||||
btnInfo.disable();
|
// btnInfo.disable();
|
||||||
} else {
|
// } else {
|
||||||
btnInfo.on("onButtonClick", function(e) {
|
// btnInfo.on("onButtonClick", function(e) {
|
||||||
helpTours.startTour(helpTours.WELCOMETOUR);
|
// helpTours.startTour(helpTours.WELCOMETOUR);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopPrint() {
|
function stopPrint() {
|
||||||
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
console.log("stop");
|
||||||
if (sendPrintCommands) printer.stop();
|
// console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
||||||
//setState(Printer.STOPPING_STATE,printer.hasControl);
|
// if (sendPrintCommands) printer.stop();
|
||||||
printer.overruleState(Printer.STOPPING_STATE);
|
// //setState(Printer.STOPPING_STATE,printer.hasControl);
|
||||||
|
// printer.overruleState(Printer.STOPPING_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function print(e) {
|
function print(e) {
|
||||||
console.log("f:print() >> sendPrintCommands = " + sendPrintCommands);
|
console.log("print");
|
||||||
|
// console.log("f:print() >> sendPrintCommands = " + sendPrintCommands);
|
||||||
|
|
||||||
//$(".btnPrint").css("display","none");
|
// //$(".btnPrint").css("display","none");
|
||||||
|
|
||||||
if (_points.length > 2) {
|
// if (_points.length > 2) {
|
||||||
|
|
||||||
//setState(Printer.BUFFERING_STATE,printer.hasControl);
|
// //setState(Printer.BUFFERING_STATE,printer.hasControl);
|
||||||
printer.overruleState(Printer.BUFFERING_STATE);
|
// printer.overruleState(Printer.BUFFERING_STATE);
|
||||||
|
|
||||||
// we put the gcode generation in a little delay
|
// // we put the gcode generation in a little delay
|
||||||
// so that for example the print button is disabled right away
|
// // so that for example the print button is disabled right away
|
||||||
clearTimeout(gcodeGenerateDelayer);
|
// clearTimeout(gcodeGenerateDelayer);
|
||||||
gcodeGenerateDelayer = setTimeout(function() {
|
// gcodeGenerateDelayer = setTimeout(function() {
|
||||||
|
|
||||||
var gcode = generate_gcode();
|
// var gcode = generate_gcode();
|
||||||
if (sendPrintCommands) {
|
// if (sendPrintCommands) {
|
||||||
if(gcode.length > 0) {
|
// if(gcode.length > 0) {
|
||||||
printer.print(gcode);
|
// printer.print(gcode);
|
||||||
} else {
|
// } else {
|
||||||
printer.overruleState(Printer.IDLE_STATE);
|
// printer.overruleState(Printer.IDLE_STATE);
|
||||||
printer.startStatusCheckInterval();
|
// printer.startStatusCheckInterval();
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
|
// console.log("sendPrintCommands is false: not sending print command to 3dprinter");
|
||||||
}
|
|
||||||
|
|
||||||
// if (debugMode) {
|
|
||||||
// $("#textdump").text("");
|
|
||||||
// $("#textdump").text(gcode.join("\n"));
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}, gcodeGenerateDelay);
|
// // if (debugMode) {
|
||||||
} else {
|
// // $("#textdump").text("");
|
||||||
console.log("f:print >> not enough points!");
|
// // $("#textdump").text(gcode.join("\n"));
|
||||||
}
|
// // }
|
||||||
|
|
||||||
|
// }, gcodeGenerateDelay);
|
||||||
|
// } else {
|
||||||
|
// console.log("f:print >> not enough points!");
|
||||||
|
// }
|
||||||
|
|
||||||
// $.post("/doodle3d.of", { data:output }, function(data) {
|
// $.post("/doodle3d.of", { data:output }, function(data) {
|
||||||
// btnPrint.disabled = false;
|
// btnPrint.disabled = false;
|
||||||
@ -415,57 +417,62 @@ function setState(newState,newHasControl) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save, next and prev buttons */
|
|
||||||
switch(newState) {
|
|
||||||
case Printer.WIFIBOX_DISCONNECTED_STATE:
|
|
||||||
btnPrevious.disable();
|
btnPrevious.disable();
|
||||||
btnNext.disable()
|
btnNext.disable()
|
||||||
btnSave.disable();
|
btnSave.disable();
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// updatePrevNextButtonState();
|
|
||||||
updateSketchButtonStates();
|
|
||||||
if (isModified) btnSave.enable();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(connectingHintDelay && newState != Printer.CONNECTING_STATE) {
|
|
||||||
clearTimeout(connectingHintDelay);
|
|
||||||
connectingHintDelay = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) {
|
// /* save, next and prev buttons */
|
||||||
message.set("Lost connection to WiFi box",Message.ERROR);
|
// switch(newState) {
|
||||||
} else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) {
|
// case Printer.WIFIBOX_DISCONNECTED_STATE:
|
||||||
message.set("Connected to WiFi box",Message.INFO,true);
|
// btnPrevious.disable();
|
||||||
} else if(newState == Printer.DISCONNECTED_STATE) {
|
// btnNext.disable()
|
||||||
message.set("Printer disconnected",Message.WARNING,true);
|
// btnSave.disable();
|
||||||
} else if(newState == Printer.CONNECTING_STATE) {
|
// break;
|
||||||
message.set("Printer connecting...",Message.INFO,false);
|
// default:
|
||||||
if (prevState != Printer.CONNECTING_STATE) { //enable 'watchdog' if we entered from a different state
|
// // updatePrevNextButtonState();
|
||||||
clearTimeout(connectingHintDelay);
|
// updateSketchButtonStates();
|
||||||
connectingHintDelay = setTimeout(function() {
|
// if (isModified) btnSave.enable();
|
||||||
message.set("Printer still not connected, did you<br/>select the correct printer type?", Message.WARNING, false);
|
// break;
|
||||||
connectingHintDelay = null;
|
// }
|
||||||
}, connectingHintDelayTime);
|
|
||||||
}
|
// if(connectingHintDelay && newState != Printer.CONNECTING_STATE) {
|
||||||
} else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE ||
|
// clearTimeout(connectingHintDelay);
|
||||||
prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE ||
|
// connectingHintDelay = null;
|
||||||
prevState == Printer.CONNECTING_STATE && newState == Printer.IDLE_STATE) {
|
// }
|
||||||
message.set("Printer connected",Message.INFO,true);
|
|
||||||
console.log(" preheat: ",settings["printer.heatup.enabled"]);
|
// if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) {
|
||||||
if(settings["printer.heatup.enabled"]) {
|
// message.set("Lost connection to WiFi box",Message.ERROR);
|
||||||
// HACK: we delay the preheat because the makerbot driver needs time to connect
|
// } else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) {
|
||||||
clearTimeout(preheatDelay);
|
// message.set("Connected to WiFi box",Message.INFO,true);
|
||||||
preheatDelay = setTimeout(printer.preheat,preheatDelayTime); // retry after delay
|
// } else if(newState == Printer.DISCONNECTED_STATE) {
|
||||||
}
|
// message.set("Printer disconnected",Message.WARNING,true);
|
||||||
} else if(prevState == Printer.PRINTING_STATE && newState == Printer.STOPPING_STATE) {
|
// } else if(newState == Printer.CONNECTING_STATE) {
|
||||||
console.log("stopmsg show");
|
// message.set("Printer connecting...",Message.INFO,false);
|
||||||
message.set("Printer stopping",Message.INFO,false);
|
// if (prevState != Printer.CONNECTING_STATE) { //enable 'watchdog' if we entered from a different state
|
||||||
} else if(prevState == Printer.STOPPING_STATE && newState == Printer.IDLE_STATE) {
|
// clearTimeout(connectingHintDelay);
|
||||||
console.log("stopmsg hide");
|
// connectingHintDelay = setTimeout(function() {
|
||||||
message.hide();
|
// message.set("Printer still not connected, did you<br/>select the correct printer type?", Message.WARNING, false);
|
||||||
}
|
// connectingHintDelay = null;
|
||||||
|
// }, connectingHintDelayTime);
|
||||||
|
// }
|
||||||
|
// } else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE ||
|
||||||
|
// prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE ||
|
||||||
|
// prevState == Printer.CONNECTING_STATE && newState == Printer.IDLE_STATE) {
|
||||||
|
// message.set("Printer connected",Message.INFO,true);
|
||||||
|
// console.log(" preheat: ",settings["printer.heatup.enabled"]);
|
||||||
|
// if(settings["printer.heatup.enabled"]) {
|
||||||
|
// // HACK: we delay the preheat because the makerbot driver needs time to connect
|
||||||
|
// clearTimeout(preheatDelay);
|
||||||
|
// preheatDelay = setTimeout(printer.preheat,preheatDelayTime); // retry after delay
|
||||||
|
// }
|
||||||
|
// } else if(prevState == Printer.PRINTING_STATE && newState == Printer.STOPPING_STATE) {
|
||||||
|
// console.log("stopmsg show");
|
||||||
|
// message.set("Printer stopping",Message.INFO,false);
|
||||||
|
// } else if(prevState == Printer.STOPPING_STATE && newState == Printer.IDLE_STATE) {
|
||||||
|
// console.log("stopmsg hide");
|
||||||
|
// message.hide();
|
||||||
|
// }
|
||||||
|
|
||||||
state = newState;
|
state = newState;
|
||||||
hasControl = newHasControl;
|
hasControl = newHasControl;
|
||||||
|
58
js/main.js
58
js/main.js
@ -90,26 +90,26 @@ $(function() {
|
|||||||
|
|
||||||
disableDragging();
|
disableDragging();
|
||||||
|
|
||||||
if (!clientInfo.isSmartphone) initHelp();
|
// if (!clientInfo.isSmartphone) initHelp();
|
||||||
|
|
||||||
thermometer.init($("#thermometerCanvas"), $("#thermometerContainer"));
|
thermometer.init($("#thermometerCanvas"), $("#thermometerContainer"));
|
||||||
progressbar.init($("#progressbarCanvas"), $("#progressbarCanvasContainer"));
|
progressbar.init($("#progressbarCanvas"), $("#progressbarCanvasContainer"));
|
||||||
|
|
||||||
message.init($("#message"));
|
message.init($("#message"));
|
||||||
|
|
||||||
printer.init();
|
// printer.init();
|
||||||
$(document).on(Printer.UPDATE,update);
|
// $(document).on(Printer.UPDATE,update);
|
||||||
|
|
||||||
settingsWindow.init(wifiboxURL,wifiboxCGIBinURL);
|
// settingsWindow.init(wifiboxURL,wifiboxCGIBinURL);
|
||||||
$(document).on(SettingsWindow.SETTINGS_LOADED, settingsLoaded);
|
// $(document).on(SettingsWindow.SETTINGS_LOADED, settingsLoaded);
|
||||||
|
|
||||||
if(debugMode) {
|
// if(debugMode) {
|
||||||
console.log("debug mode is true");
|
// console.log("debug mode is true");
|
||||||
$("body").css("overflow", "auto");
|
// $("body").css("overflow", "auto");
|
||||||
$("#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");
|
// $("#debug_display").css("display", "block");
|
||||||
|
|
||||||
// show and hide the progressguage and thermometer
|
// show and hide the progressguage and thermometer
|
||||||
//showhideInterval = setInterval(showOrHideThermo, 2500);
|
//showhideInterval = setInterval(showOrHideThermo, 2500);
|
||||||
@ -138,8 +138,8 @@ $(function() {
|
|||||||
$("#endgcode").append("M84 (disable axes) \n");
|
$("#endgcode").append("M84 (disable axes) \n");
|
||||||
console.log("$('#endgcode'): " + $("#endgcode").val());
|
console.log("$('#endgcode'): " + $("#endgcode").val());
|
||||||
}, 1000);
|
}, 1000);
|
||||||
//*/
|
// //*/
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
function disableDragging() {
|
function disableDragging() {
|
||||||
@ -162,24 +162,24 @@ function showOrHideThermo() {
|
|||||||
showOrHide = !showOrHide;
|
showOrHide = !showOrHide;
|
||||||
}
|
}
|
||||||
|
|
||||||
function settingsLoaded() {
|
// function settingsLoaded() {
|
||||||
console.log("settingsLoaded");
|
// console.log("settingsLoaded");
|
||||||
|
|
||||||
if(firstTimeSettingsLoaded) {
|
// if(firstTimeSettingsLoaded) {
|
||||||
console.log(" preheat: ",settings["printer.heatup.enabled"]);
|
// console.log(" preheat: ",settings["printer.heatup.enabled"]);
|
||||||
console.log(" state: ",state);
|
// console.log(" state: ",state);
|
||||||
if(state == Printer.IDLE_STATE && settings["printer.heatup.enabled"]) {
|
// if(state == Printer.IDLE_STATE && settings["printer.heatup.enabled"]) {
|
||||||
printer.preheat();
|
// printer.preheat();
|
||||||
}
|
// }
|
||||||
console.log("doodle3d.tour.enabled: ",settings["doodle3d.tour.enabled"]);
|
// console.log("doodle3d.tour.enabled: ",settings["doodle3d.tour.enabled"]);
|
||||||
if(settings["doodle3d.tour.enabled"] && !clientInfo.isSmartphone) {
|
// if(settings["doodle3d.tour.enabled"] && !clientInfo.isSmartphone) {
|
||||||
console.log("show tour");
|
// console.log("show tour");
|
||||||
initHelp();
|
// initHelp();
|
||||||
}
|
// }
|
||||||
firstTimeSettingsLoaded = false;
|
// firstTimeSettingsLoaded = false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
function setDebugText(text) {
|
function setDebugText(text) {
|
||||||
$("#debug_display").text(text);
|
$("#debug_display").text(text);
|
||||||
|
@ -41,7 +41,8 @@ function initPreviewRendering() {
|
|||||||
|
|
||||||
previewCtx_tmp = preview_tmp.getContext('2d');
|
previewCtx_tmp = preview_tmp.getContext('2d');
|
||||||
|
|
||||||
// doodleImageCapture = new Image();
|
doodleImageCapture = new Image();
|
||||||
|
|
||||||
|
|
||||||
calcPreviewCanvasProperties();
|
calcPreviewCanvasProperties();
|
||||||
redrawPreview();
|
redrawPreview();
|
||||||
@ -252,8 +253,11 @@ function redrawRenderedPreview(redrawLess) {
|
|||||||
var y = 0;
|
var y = 0;
|
||||||
var r = 0;
|
var r = 0;
|
||||||
|
|
||||||
|
// console.log("doodleImageCapture",doodleImageCapture);
|
||||||
|
// return;
|
||||||
|
|
||||||
// check if there is preview image data that we can use for the layers
|
// check if there is preview image data that we can use for the layers
|
||||||
if(!doodleImageCapture.src || doodleImageCapture.src == "") return;
|
if(!doodleImageCapture || !doodleImageCapture.src || doodleImageCapture.src == "") return;
|
||||||
|
|
||||||
for(var i = 0; i < numLayers; i++) {
|
for(var i = 0; i < numLayers; i++) {
|
||||||
|
|
||||||
|
@ -41,60 +41,61 @@ function setSketchModified(_isModified) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateSketchButtonStates() {
|
function updateSketchButtonStates() {
|
||||||
console.log('sketch: isModified: ' + isModified + ', curSketch: ' + curSketch + ', sketches.length: ' + sketches.length);
|
return;
|
||||||
|
// console.log('sketch: isModified: ' + isModified + ', curSketch: ' + curSketch + ', sketches.length: ' + sketches.length);
|
||||||
|
|
||||||
if (isModified) {
|
// if (isModified) {
|
||||||
btnSave.enable();
|
// btnSave.enable();
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
btnSave.disable();
|
// btnSave.disable();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (curSketch<sketches.length-1) {
|
// if (curSketch<sketches.length-1) {
|
||||||
btnNext.enable();
|
// btnNext.enable();
|
||||||
} else {
|
// } else {
|
||||||
btnNext.disable();
|
// btnNext.disable();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (curSketch>0) {
|
// if (curSketch>0) {
|
||||||
btnPrevious.enable();
|
// btnPrevious.enable();
|
||||||
} else {
|
// } else {
|
||||||
btnPrevious.disable();
|
// btnPrevious.disable();
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSketch(_curSketch) {
|
function loadSketch(_curSketch) {
|
||||||
curSketch = _curSketch;
|
// curSketch = _curSketch;
|
||||||
|
|
||||||
if (curSketch<0) curSketch=0;
|
// if (curSketch<0) curSketch=0;
|
||||||
if (curSketch>sketches.length-1) curSketch=sketches.length-1;
|
// if (curSketch>sketches.length-1) curSketch=sketches.length-1;
|
||||||
|
|
||||||
var id = sketches[curSketch];
|
// var id = sketches[curSketch];
|
||||||
|
|
||||||
console.log('sketch: loadSketch curSketch:' + curSketch + ', id: ' + id);
|
// console.log('sketch: loadSketch curSketch:' + curSketch + ', id: ' + id);
|
||||||
|
|
||||||
$.get(wifiboxURL + "/sketch", {id:id}, function(response) {
|
// $.get(wifiboxURL + "/sketch", {id:id}, function(response) {
|
||||||
if (response.status=='success') {
|
// if (response.status=='success') {
|
||||||
console.log('sketch: loaded',response);
|
// console.log('sketch: loaded',response);
|
||||||
var svgData = response.data.data;
|
// var svgData = response.data.data;
|
||||||
loadFromSvg(svgData);
|
// loadFromSvg(svgData);
|
||||||
setSketchModified(false);
|
// setSketchModified(false);
|
||||||
} else {
|
// } else {
|
||||||
console.log('error loading sketch: ',response);
|
// console.log('error loading sketch: ',response);
|
||||||
listSketches();
|
// listSketches();
|
||||||
}
|
// }
|
||||||
|
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSketch() {
|
function saveSketch() {
|
||||||
console.log("sketch: saveSketch");
|
// console.log("sketch: saveSketch");
|
||||||
var svgData = saveToSvg();
|
// var svgData = saveToSvg();
|
||||||
|
|
||||||
$.post(wifiboxURL + "/sketch", {data: svgData}, function(response) {
|
// $.post(wifiboxURL + "/sketch", {data: svgData}, function(response) {
|
||||||
console.log("sketch: saveSketch: response",response);
|
// console.log("sketch: saveSketch: response",response);
|
||||||
listSketches();
|
// listSketches();
|
||||||
})
|
// })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,8 @@
|
|||||||
<script src="js/libs/jquery-coolfieldset.min.js"></script>
|
<script src="js/libs/jquery-coolfieldset.min.js"></script>
|
||||||
<script src="js/libs/FileSaver.min.js"></script>
|
<script src="js/libs/FileSaver.min.js"></script>
|
||||||
<script src="js/libs/jquery-fastclick.min.js"></script>
|
<script src="js/libs/jquery-fastclick.min.js"></script>
|
||||||
<script src="js/doodle3d-client.min.js"></script>
|
<!-- <script src="js/doodle3d-client.min.js"></script> -->
|
||||||
|
<script src="js/doodle3d-client.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user