0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-12-04 22:04:55 +01:00

disable wifibox communication in progress

This commit is contained in:
Rick Companje 2017-12-30 02:36:43 +01:00
parent f8032d7411
commit d27ac15f15
6 changed files with 176 additions and 163 deletions

View File

@ -83,7 +83,7 @@ function Printer() {
var self = this;
this.init = function() {
//console.log("Printer:init");
console.log("Printer:init");
//this.wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
//this.wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
this.wifiboxURL = wifiboxURL;

View File

@ -94,7 +94,7 @@ function initButtonBehavior() {
btnRotate.on("onButtonHold", onBtnRotate);
//getSavedSketchStatus();
listSketches();
// listSketches();
// setSketchModified(false);
// updateSketchButtonStates();
@ -202,62 +202,64 @@ function initButtonBehavior() {
buttonGroupAdd.fadeOut();
}
btnSettings.on("onButtonClick", openSettingsWindow);
// btnSettings.on("onButtonClick", openSettingsWindow);
// 29-okt-2013 - we're not doing help for smartphones at the moment
if (clientInfo.isSmartphone) {
btnInfo.disable();
} else {
btnInfo.on("onButtonClick", function(e) {
helpTours.startTour(helpTours.WELCOMETOUR);
});
}
// if (clientInfo.isSmartphone) {
// btnInfo.disable();
// } else {
// btnInfo.on("onButtonClick", function(e) {
// helpTours.startTour(helpTours.WELCOMETOUR);
// });
// }
}
function stopPrint() {
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
if (sendPrintCommands) printer.stop();
//setState(Printer.STOPPING_STATE,printer.hasControl);
printer.overruleState(Printer.STOPPING_STATE);
console.log("stop");
// console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
// if (sendPrintCommands) printer.stop();
// //setState(Printer.STOPPING_STATE,printer.hasControl);
// printer.overruleState(Printer.STOPPING_STATE);
}
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);
printer.overruleState(Printer.BUFFERING_STATE);
// //setState(Printer.BUFFERING_STATE,printer.hasControl);
// printer.overruleState(Printer.BUFFERING_STATE);
// we put the gcode generation in a little delay
// so that for example the print button is disabled right away
clearTimeout(gcodeGenerateDelayer);
gcodeGenerateDelayer = setTimeout(function() {
// // we put the gcode generation in a little delay
// // so that for example the print button is disabled right away
// clearTimeout(gcodeGenerateDelayer);
// gcodeGenerateDelayer = setTimeout(function() {
var gcode = generate_gcode();
if (sendPrintCommands) {
if(gcode.length > 0) {
printer.print(gcode);
} else {
printer.overruleState(Printer.IDLE_STATE);
printer.startStatusCheckInterval();
}
} else {
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
}
// var gcode = generate_gcode();
// if (sendPrintCommands) {
// if(gcode.length > 0) {
// printer.print(gcode);
// } else {
// printer.overruleState(Printer.IDLE_STATE);
// printer.startStatusCheckInterval();
// }
// } else {
// console.log("sendPrintCommands is false: not sending print command to 3dprinter");
// }
// if (debugMode) {
// $("#textdump").text("");
// $("#textdump").text(gcode.join("\n"));
// }
// // if (debugMode) {
// // $("#textdump").text("");
// // $("#textdump").text(gcode.join("\n"));
// // }
}, gcodeGenerateDelay);
} else {
console.log("f:print >> not enough points!");
}
// }, gcodeGenerateDelay);
// } else {
// console.log("f:print >> not enough points!");
// }
// $.post("/doodle3d.of", { data:output }, function(data) {
// btnPrint.disabled = false;
@ -415,57 +417,62 @@ function setState(newState,newHasControl) {
break;
}
/* save, next and prev buttons */
switch(newState) {
case Printer.WIFIBOX_DISCONNECTED_STATE:
btnPrevious.disable();
btnNext.disable()
btnSave.disable();
break;
default:
// updatePrevNextButtonState();
updateSketchButtonStates();
if (isModified) btnSave.enable();
break;
}
btnPrevious.disable();
btnNext.disable()
btnSave.disable();
if(connectingHintDelay && newState != Printer.CONNECTING_STATE) {
clearTimeout(connectingHintDelay);
connectingHintDelay = null;
}
// /* save, next and prev buttons */
// switch(newState) {
// case Printer.WIFIBOX_DISCONNECTED_STATE:
// btnPrevious.disable();
// btnNext.disable()
// btnSave.disable();
// break;
// default:
// // updatePrevNextButtonState();
// updateSketchButtonStates();
// if (isModified) btnSave.enable();
// break;
// }
if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) {
message.set("Lost connection to WiFi box",Message.ERROR);
} else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) {
message.set("Connected to WiFi box",Message.INFO,true);
} else if(newState == Printer.DISCONNECTED_STATE) {
message.set("Printer disconnected",Message.WARNING,true);
} else if(newState == Printer.CONNECTING_STATE) {
message.set("Printer connecting...",Message.INFO,false);
if (prevState != Printer.CONNECTING_STATE) { //enable 'watchdog' if we entered from a different state
clearTimeout(connectingHintDelay);
connectingHintDelay = setTimeout(function() {
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();
}
// if(connectingHintDelay && newState != Printer.CONNECTING_STATE) {
// clearTimeout(connectingHintDelay);
// connectingHintDelay = null;
// }
// if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) {
// message.set("Lost connection to WiFi box",Message.ERROR);
// } else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) {
// message.set("Connected to WiFi box",Message.INFO,true);
// } else if(newState == Printer.DISCONNECTED_STATE) {
// message.set("Printer disconnected",Message.WARNING,true);
// } else if(newState == Printer.CONNECTING_STATE) {
// message.set("Printer connecting...",Message.INFO,false);
// if (prevState != Printer.CONNECTING_STATE) { //enable 'watchdog' if we entered from a different state
// clearTimeout(connectingHintDelay);
// connectingHintDelay = setTimeout(function() {
// 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;
hasControl = newHasControl;

View File

@ -89,27 +89,27 @@ $(function() {
initScanDialog();
disableDragging();
if (!clientInfo.isSmartphone) initHelp();
// if (!clientInfo.isSmartphone) initHelp();
thermometer.init($("#thermometerCanvas"), $("#thermometerContainer"));
progressbar.init($("#progressbarCanvas"), $("#progressbarCanvasContainer"));
message.init($("#message"));
printer.init();
$(document).on(Printer.UPDATE,update);
// printer.init();
// $(document).on(Printer.UPDATE,update);
settingsWindow.init(wifiboxURL,wifiboxCGIBinURL);
$(document).on(SettingsWindow.SETTINGS_LOADED, settingsLoaded);
// settingsWindow.init(wifiboxURL,wifiboxCGIBinURL);
// $(document).on(SettingsWindow.SETTINGS_LOADED, settingsLoaded);
if(debugMode) {
console.log("debug mode is true");
$("body").css("overflow", "auto");
$("#debug_textArea").css("display", "block");
//$("#preview_tmp").css("display", "block");
// if(debugMode) {
// console.log("debug mode is true");
// $("body").css("overflow", "auto");
// $("#debug_textArea").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
//showhideInterval = setInterval(showOrHideThermo, 2500);
@ -138,8 +138,8 @@ $(function() {
$("#endgcode").append("M84 (disable axes) \n");
console.log("$('#endgcode'): " + $("#endgcode").val());
}, 1000);
//*/
}
// //*/
// }
});
function disableDragging() {
@ -162,24 +162,24 @@ function showOrHideThermo() {
showOrHide = !showOrHide;
}
function settingsLoaded() {
console.log("settingsLoaded");
// function settingsLoaded() {
// console.log("settingsLoaded");
if(firstTimeSettingsLoaded) {
console.log(" preheat: ",settings["printer.heatup.enabled"]);
console.log(" state: ",state);
if(state == Printer.IDLE_STATE && settings["printer.heatup.enabled"]) {
printer.preheat();
}
console.log("doodle3d.tour.enabled: ",settings["doodle3d.tour.enabled"]);
if(settings["doodle3d.tour.enabled"] && !clientInfo.isSmartphone) {
console.log("show tour");
initHelp();
}
firstTimeSettingsLoaded = false;
}
// if(firstTimeSettingsLoaded) {
// console.log(" preheat: ",settings["printer.heatup.enabled"]);
// console.log(" state: ",state);
// if(state == Printer.IDLE_STATE && settings["printer.heatup.enabled"]) {
// printer.preheat();
// }
// console.log("doodle3d.tour.enabled: ",settings["doodle3d.tour.enabled"]);
// if(settings["doodle3d.tour.enabled"] && !clientInfo.isSmartphone) {
// console.log("show tour");
// initHelp();
// }
// firstTimeSettingsLoaded = false;
// }
}
// }
function setDebugText(text) {
$("#debug_display").text(text);

View File

@ -41,7 +41,8 @@ function initPreviewRendering() {
previewCtx_tmp = preview_tmp.getContext('2d');
// doodleImageCapture = new Image();
doodleImageCapture = new Image();
calcPreviewCanvasProperties();
redrawPreview();
@ -252,8 +253,11 @@ function redrawRenderedPreview(redrawLess) {
var y = 0;
var r = 0;
// console.log("doodleImageCapture",doodleImageCapture);
// return;
// 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++) {

View File

@ -41,60 +41,61 @@ function setSketchModified(_isModified) {
}
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) {
btnSave.enable();
}
else {
btnSave.disable();
}
// if (isModified) {
// btnSave.enable();
// }
// else {
// btnSave.disable();
// }
if (curSketch<sketches.length-1) {
btnNext.enable();
} else {
btnNext.disable();
}
// if (curSketch<sketches.length-1) {
// btnNext.enable();
// } else {
// btnNext.disable();
// }
if (curSketch>0) {
btnPrevious.enable();
} else {
btnPrevious.disable();
}
// if (curSketch>0) {
// btnPrevious.enable();
// } else {
// btnPrevious.disable();
// }
}
function loadSketch(_curSketch) {
curSketch = _curSketch;
// curSketch = _curSketch;
if (curSketch<0) curSketch=0;
if (curSketch>sketches.length-1) curSketch=sketches.length-1;
// if (curSketch<0) curSketch=0;
// 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) {
if (response.status=='success') {
console.log('sketch: loaded',response);
var svgData = response.data.data;
loadFromSvg(svgData);
setSketchModified(false);
} else {
console.log('error loading sketch: ',response);
listSketches();
}
// $.get(wifiboxURL + "/sketch", {id:id}, function(response) {
// if (response.status=='success') {
// console.log('sketch: loaded',response);
// var svgData = response.data.data;
// loadFromSvg(svgData);
// setSketchModified(false);
// } else {
// console.log('error loading sketch: ',response);
// listSketches();
// }
})
// })
}
function saveSketch() {
console.log("sketch: saveSketch");
var svgData = saveToSvg();
// console.log("sketch: saveSketch");
// var svgData = saveToSvg();
$.post(wifiboxURL + "/sketch", {data: svgData}, function(response) {
console.log("sketch: saveSketch: response",response);
listSketches();
})
// $.post(wifiboxURL + "/sketch", {data: svgData}, function(response) {
// console.log("sketch: saveSketch: response",response);
// listSketches();
// })
}

View File

@ -182,7 +182,8 @@
<script src="js/libs/jquery-coolfieldset.min.js"></script>
<script src="js/libs/FileSaver.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>
</html>