From ce6824ab8b1c40aa86ede97d7d1c68901f11adf1 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Tue, 2 Aug 2016 17:59:39 +0200 Subject: [PATCH] move send batch to printer api --- src/api/printer.js | 13 +++++++++++++ src/doodle3dbox.js | 15 +-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api/printer.js b/src/api/printer.js index a01e4bf..47bf979 100644 --- a/src/api/printer.js +++ b/src/api/printer.js @@ -25,4 +25,17 @@ export default class Printer { stop(gcode = '') { return rest.post(`${ this.api }printer/stop`, { gcode }); } + async _sendBatch(gcode, start, index) { + try { + const response = await this.print(gcode, start, start); + + console.log(`batch sent: ${ index }`); + } catch(error) { + console.log(`failed sending batch: ${ index }`); + + await sleep(1000); + + await this._sendBatch(gcode, index); + } + } } diff --git a/src/doodle3dbox.js b/src/doodle3dbox.js index 76117ec..fb85173 100644 --- a/src/doodle3dbox.js +++ b/src/doodle3dbox.js @@ -69,7 +69,7 @@ export default class Doodle3DBox extends EventDispatcher { // const progress = await this.printer.progress(); - await this._sendBatch(batch, start, index); + await this.printer._sendBatch(batch, start, index); start = false; lastIndex = index + 1; //skip next \n @@ -92,17 +92,4 @@ export default class Doodle3DBox extends EventDispatcher { await sleep(this.updateInterval); } } - async _sendBatch(gcode, start, index) { - try { - const response = await this.printer.print(gcode, start, start); - - console.log(`batch sent: ${ index }`); - } catch(error) { - console.log(`failed sending batch: ${ index }`); - - await sleep(1000); - - await this._sendBatch(gcode, index); - } - } }