mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-12-03 13:34:56 +01:00
Fix stopping while sending
Fixes https://github.com/Doodle3D/WiFi-Box/issues/9
This commit is contained in:
parent
28ce8ff479
commit
d2bc62b092
@ -168,6 +168,11 @@ function Printer() {
|
||||
}
|
||||
|
||||
this.sendPrintPart = function(sendIndex,sendLength) {
|
||||
var self = this;
|
||||
// Abort if stopping
|
||||
// sendPrintPart can be called by delayed retry after request timeout for example
|
||||
if (self.state === Printer.STOPPING_STATE) return;
|
||||
|
||||
var completed = false;
|
||||
if (this.gcode.length < (sendIndex + sendLength)) {
|
||||
sendLength = this.gcode.length - sendIndex;
|
||||
@ -200,8 +205,6 @@ function Printer() {
|
||||
|
||||
|
||||
/* send data */
|
||||
|
||||
var self = this;
|
||||
if (communicateWithWifibox) {
|
||||
$.ajax({
|
||||
url: this.wifiboxURL + "/printer/print",
|
||||
@ -296,7 +299,7 @@ function Printer() {
|
||||
console.log("Printer:waitForBufferSpace: waiting until gcode buffer load ratio is below " +
|
||||
(Printer.GCODE_BUFFER_WAIT_LOAD_RATIO * 100) + "% (current: " + fillPercent + "% of " +
|
||||
(self.maxBufferSize / 1024) + "KiB)");
|
||||
setTimeout(function() { self.waitForBufferSpace(sendIndex, sendLength); }, Printer.BUFFER_SPACE_WAIT_TIMEOUT);
|
||||
self.waitForBufferSpaceDelay = setTimeout(function() { self.waitForBufferSpace(sendIndex, sendLength); }, Printer.BUFFER_SPACE_WAIT_TIMEOUT);
|
||||
} else {
|
||||
if(self.state == Printer.PRINTING_STATE || self.state == Printer.BUFFERING_STATE) {
|
||||
console.log("Printer:waitForBufferSpace: load ratio dropped below " + (Printer.GCODE_BUFFER_WAIT_LOAD_RATIO * 100) + "%, calling sendPrintPart...");
|
||||
@ -309,10 +312,17 @@ function Printer() {
|
||||
|
||||
this.stop = function() {
|
||||
console.log("Printer:stop");
|
||||
var self = this;
|
||||
if (self.retrySendPrintPartDelay !== undefined) {
|
||||
clearTimeout(self.retrySendPrintPartDelay);
|
||||
}
|
||||
if (self.waitForBufferSpaceDelay !== undefined) {
|
||||
clearTimeout(self.waitForBufferSpaceDelay);
|
||||
}
|
||||
|
||||
endCode = generateEndCode();
|
||||
console.log(" endCode: ",endCode);
|
||||
var postData = { gcode: endCode.join("\n")};
|
||||
var self = this;
|
||||
if (communicateWithWifibox) {
|
||||
$.ajax({
|
||||
url: this.wifiboxURL + "/printer/stop",
|
||||
|
Loading…
Reference in New Issue
Block a user