move send batch to printer api

This commit is contained in:
casperlamboo 2016-08-02 17:59:39 +02:00
parent 721c968341
commit ce6824ab8b
2 changed files with 14 additions and 14 deletions

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}