mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
More robust state override
This commit is contained in:
parent
07fa1f62e8
commit
9fb9ee2bc4
@ -45,6 +45,8 @@ function Printer() {
|
|||||||
|
|
||||||
this.maxGCodeSize = 10; // max size of gcode in MB's (estimation)
|
this.maxGCodeSize = 10; // max size of gcode in MB's (estimation)
|
||||||
|
|
||||||
|
this.stateOverruled = false;
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
Printer.UPDATE = "update";
|
Printer.UPDATE = "update";
|
||||||
|
|
||||||
@ -152,8 +154,10 @@ function Printer() {
|
|||||||
//self.targetTemperature = settings["printer.temperature"]; // slight hack
|
//self.targetTemperature = settings["printer.temperature"]; // slight hack
|
||||||
} else {
|
} else {
|
||||||
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode
|
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode
|
||||||
if(self.state == Printer.STATE_PRINTING || self.state == Printer.STATE_BUFFERING) {
|
|
||||||
console.log("sending next part");
|
console.log("Printer:sendPrintPart:gcode part received (state: ",self.state,")");
|
||||||
|
if(self.state == Printer.PRINTING_STATE || self.state == Printer.BUFFERING_STATE) {
|
||||||
|
console.log("Printer:sendPrintPart:sending next part");
|
||||||
self.sendPrintPart(sendIndex + sendLength, sendLength);
|
self.sendPrintPart(sendIndex + sendLength, sendLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,7 +199,9 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.checkStatus = function() {
|
this.checkStatus = function() {
|
||||||
//console.log("Printer:checkStatus");
|
console.log("Printer:checkStatus");
|
||||||
|
this.stateOverruled = false;
|
||||||
|
console.log(" stateOverruled: ",this.stateOverruled);
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -203,7 +209,7 @@ function Printer() {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
console.log("Printer:status: ",response.data.state," response: ",response);
|
console.log(" Printer:status: ",response.data.state); //," response: ",response);
|
||||||
|
|
||||||
self.handleStatusUpdate(response);
|
self.handleStatusUpdate(response);
|
||||||
|
|
||||||
@ -223,12 +229,17 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.handleStatusUpdate = function(response) {
|
this.handleStatusUpdate = function(response) {
|
||||||
|
console.log("Printer:handleStatusUpdate");
|
||||||
var data = response.data;
|
var data = response.data;
|
||||||
if(response.status != "success") {
|
if(response.status != "success") {
|
||||||
self.state = Printer.UNKNOWN_STATE;
|
self.state = Printer.UNKNOWN_STATE;
|
||||||
} else {
|
} else {
|
||||||
// state
|
// state
|
||||||
|
console.log(" stateOverruled: ",this.stateOverruled);
|
||||||
|
if(!this.stateOverruled) {
|
||||||
self.state = data.state;
|
self.state = data.state;
|
||||||
|
console.log(" state > ",self.state);
|
||||||
|
}
|
||||||
|
|
||||||
// temperature
|
// temperature
|
||||||
self.temperature = data.hotend;
|
self.temperature = data.hotend;
|
||||||
@ -248,4 +259,12 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
$(document).trigger(Printer.UPDATE);
|
$(document).trigger(Printer.UPDATE);
|
||||||
}
|
}
|
||||||
|
this.overruleState = function(newState) {
|
||||||
|
this.stateOverruled = true;
|
||||||
|
console.log(" stateOverruled: ",this.stateOverruled);
|
||||||
|
|
||||||
|
self.state = newState;
|
||||||
|
|
||||||
|
$(document).trigger(Printer.UPDATE);
|
||||||
|
}
|
||||||
}
|
}
|
@ -191,7 +191,8 @@ function stopPrint() {
|
|||||||
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands);
|
||||||
if (!confirm("Weet je zeker dat je de huidige print wilt stoppen?")) return;
|
if (!confirm("Weet je zeker dat je de huidige print wilt stoppen?")) return;
|
||||||
if (sendPrintCommands) printer.stop();
|
if (sendPrintCommands) printer.stop();
|
||||||
setState(Printer.STOPPING_STATE,printer.hasControl);
|
//setState(Printer.STOPPING_STATE,printer.hasControl);
|
||||||
|
printer.overruleState(Printer.STOPPING_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -209,7 +210,8 @@ function print(e) {
|
|||||||
$("#textdump").text("");
|
$("#textdump").text("");
|
||||||
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);
|
||||||
var gcode = generate_gcode();
|
var gcode = generate_gcode();
|
||||||
//startPrint(gencode);
|
//startPrint(gencode);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
<legend>Access point settings</legend>
|
<legend>Access point settings</legend>
|
||||||
<label for="ssid">Wi-Fi box ssid*:</label><input type="text" class="large" name="network.ap.ssid" id="ssid"> <br>
|
<label for="ssid">Wi-Fi box ssid*:</label><input type="text" class="large" name="network.ap.ssid" id="ssid"> <br>
|
||||||
<small>* The text <em>%%MAC_ADDR_TAIL%%</em> will be replaced by the last 6 digits of your Doodle3D Wi-Fi box's MAC address.</small>
|
<small>* The text <em>%%MAC_ADDR_TAIL%%</em> will be replaced by the last 6 digits of your Doodle3D Wi-Fi box's MAC address.</small>
|
||||||
<label for="ssid">Password:</label><input type="text" class="large" name="network.ap.key" id="ssid"> <br>
|
<label for="apKey">Password:</label><input type="text" class="large" name="network.ap.key" id="apKey"> <br>
|
||||||
<label for="ipaddress">Wi-Fi box IP address:</label><input type="text" name="network.ap.address" id="ipaddress"><br>
|
<label for="ipaddress">Wi-Fi box IP address:</label><input type="text" name="network.ap.address" id="ipaddress"><br>
|
||||||
<label for="netmask">Wi-Fi box netmask:</label><input type="text" name="network.ap.netmask" id="netmask"><br>
|
<label for="netmask">Wi-Fi box netmask:</label><input type="text" name="network.ap.netmask" id="netmask"><br>
|
||||||
<input type="button" name="create" value="Create" class="button" id="createAP"/>
|
<input type="button" name="create" value="Create" class="button" id="createAP"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user