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

Sequence numbering + stop button:

- send sequence numbers along with gcode to wifibox;
- remove 'disable stop button hack';
- show error to user in case of sequencing errors, except when in stopping state.

Should fix #226.
This commit is contained in:
Wouter R 2016-02-14 17:13:13 +01:00
parent bca548def5
commit 578fba4f63
2 changed files with 15 additions and 6 deletions

View File

@ -63,7 +63,8 @@ function Printer() {
this.timeoutTime = 3000; this.timeoutTime = 3000;
this.sendPrintPartTimeoutTime = 5000; this.sendPrintPartTimeoutTime = 5000;
this.gcode; // gcode to be printed this.gcode = []; // gcode to be printed
this.gcodeNumChunks = 0; //number of chunks to be sent (used for sequence numbering)
this.retryDelay = 2000; // retry setTimout delay this.retryDelay = 2000; // retry setTimout delay
this.retrySendPrintPartDelay; // retry setTimout instance this.retrySendPrintPartDelay; // retry setTimout instance
@ -133,6 +134,7 @@ function Printer() {
this.sendIndex = 0; this.sendIndex = 0;
this.gcode = gcode; this.gcode = gcode;
this.gcodeNumChunks = Math.ceil(this.gcode.length / Printer.MAX_LINES_PER_POST);
//console.log(" gcode[20]: ",gcode[20]); //console.log(" gcode[20]: ",gcode[20]);
var gcodeLineSize = this.byteSize(gcode[20]); var gcodeLineSize = this.byteSize(gcode[20]);
@ -188,7 +190,12 @@ function Printer() {
var gcodePart = this.gcode.slice(sendIndex, sendIndex + sendLength); var gcodePart = this.gcode.slice(sendIndex, sendIndex + sendLength);
var firstOne = (sendIndex == 0) ? true : false; var firstOne = (sendIndex == 0) ? true : false;
var start = firstOne; // start printing right away var start = firstOne; // start printing right away
var postData = { gcode: gcodePart.join("\n"), total_lines: this.gcode.length, clear: firstOne, start: start}; var seqNum = Math.floor(sendIndex / Printer.MAX_LINES_PER_POST);
var postData = {
gcode: gcodePart.join("\n"), total_lines: this.gcode.length,
clear: firstOne, start: start,
seq_number: seqNum, seq_total: this.gcodeNumChunks
};
/* send data */ /* send data */
@ -208,7 +215,7 @@ function Printer() {
if (completed) { if (completed) {
console.log("Printer:sendPrintPart: gcode sending completed"); console.log("Printer:sendPrintPart: gcode sending completed");
this.gcode = []; this.gcode = [];
btnStop.css("display","block"); // hack this.gcodeNumChunks = 0;
self.removeLeaveWarning(); self.removeLeaveWarning();
message.set("Doodle has been sent to printer...",Message.INFO,true); message.set("Doodle has been sent to printer...",Message.INFO,true);
//self.targetTemperature = settings["printer.temperature"]; // slight hack //self.targetTemperature = settings["printer.temperature"]; // slight hack
@ -229,6 +236,10 @@ function Printer() {
//Note: apart from logging an error here, we ignore these errors as they all have to do //Note: apart from logging an error here, we ignore these errors as they all have to do
//with chunk sequencing, which we do not use, except for the source parameter which is set internally. //with chunk sequencing, which we do not use, except for the source parameter which is set internally.
console.error("Printer:sendPrintPart: unexpected failure response for API endpoint printer/print (" + data.data.status + ")"); console.error("Printer:sendPrintPart: unexpected failure response for API endpoint printer/print (" + data.data.status + ")");
//sequence errors should not occur, except perhaps when 'stop' was clicked while still sending (https://github.com/Doodle3D/doodle3d-client/issues/226).
if (self.state != Printer.STOPPING_STATE) {
message.set("Unexpected error sending doodle to printer (" + data.data.status + "), please retry", Message.ERROR, false, true);
}
} }
} }

View File

@ -232,8 +232,6 @@ function print(e) {
//setState(Printer.BUFFERING_STATE,printer.hasControl); //setState(Printer.BUFFERING_STATE,printer.hasControl);
printer.overruleState(Printer.BUFFERING_STATE); printer.overruleState(Printer.BUFFERING_STATE);
btnStop.css("display","none"); // hack
// 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);