mirror of
https://github.com/Doodle3D/Doodle3D-API
synced 2025-01-03 10:03:48 +01:00
implement gcode server support
This commit is contained in:
parent
7aecffb876
commit
c838625a86
@ -25,6 +25,15 @@ export default class Printer {
|
|||||||
stop(gcode = '') {
|
stop(gcode = '') {
|
||||||
return rest.post(`${ this.api }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 => {
|
||||||
|
console.log(`gcode file id: ${ response }`);
|
||||||
|
rest.post(`${ this.api }printer/fetch`, { id: response.id });
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
async _sendBatch(gcode, start, index) {
|
async _sendBatch(gcode, start, index) {
|
||||||
try {
|
try {
|
||||||
const response = await this.print(gcode, start, start);
|
const response = await this.print(gcode, start, start);
|
||||||
|
@ -51,6 +51,23 @@ export default class Doodle3DBox extends EventDispatcher {
|
|||||||
this.alive = alive;
|
this.alive = alive;
|
||||||
return 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) {
|
async sendGCode(gcode) {
|
||||||
const printerState = await this.printer.state();
|
const printerState = await this.printer.state();
|
||||||
if (printerState.state !== 'idle') {
|
if (printerState.state !== 'idle') {
|
||||||
|
Loading…
Reference in New Issue
Block a user