Compare commits

...

2 Commits
master ... RC

Author SHA1 Message Date
Simon Voordouw a32a778538 add supportedPrinters api call 2017-05-18 14:55:42 +02:00
Simon Voordouw c838625a86 implement gcode server support 2017-05-12 16:33:48 +02:00
3 changed files with 28 additions and 0 deletions

View File

@ -13,4 +13,7 @@ export default class Config {
set(data) {
return rest.post(`${ this.api }config`, data);
}
supportedPrinters() {
return rest.get(`${ this.api }config/supportedprinters`);
}
}

View File

@ -25,6 +25,14 @@ export default class Printer {
stop(gcode = '') {
return rest.post(`${ this.api }printer/stop`, { gcode });
}
fetch(gcode = '') {
rest.post(`https://tranquil-meadow-94621.herokuapp.com/upload`, { gcode })
.then(response => {
rest.post(`${ this.api }printer/fetch`, { id: response.id });
}).catch(err => {
console.log(err);
});
}
async _sendBatch(gcode, start, index) {
try {
const response = await this.print(gcode, start, start);

View File

@ -51,6 +51,23 @@ export default class Doodle3DBox extends EventDispatcher {
this.alive = alive;
return alive;
}
async startLargePrint(gcode) {
try {
const printerState = await this.printer.state();
if (printerState.state !== 'idle') {
throw `Cannot print, print state is ${ printerState.state }`;
}
if (!gcode.endsWith('\n')) {
gcode += '\n';
}
this.printer.fetch(gcode);
} catch (e) {
console.log(e);
}
}
async sendGCode(gcode) {
const printerState = await this.printer.state();
if (printerState.state !== 'idle') {