Doodle3D-API/src/api/printer.js

33 lines
723 B
JavaScript
Raw Normal View History

2016-04-21 15:32:11 +02:00
import * as rest from '../rest.js';
2015-07-15 15:06:18 +02:00
2016-04-21 15:44:20 +02:00
export default class Printer {
constructor(api) {
this.api = api;
2015-07-15 15:06:18 +02:00
}
2016-04-21 15:44:20 +02:00
temperature() {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/temperature`);
2015-07-15 15:06:18 +02:00
}
2016-04-21 15:44:20 +02:00
progress() {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/progress`);
2015-07-15 15:06:18 +02:00
}
2016-04-21 15:44:20 +02:00
state() {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/state`);
2015-07-15 15:06:18 +02:00
}
2016-04-21 15:44:20 +02:00
listAll() {
2016-04-21 15:09:49 +02:00
return rest.get(`${ this.api }printer/listall`);
2015-07-15 15:06:18 +02:00
}
2016-04-21 15:44:20 +02:00
heatup() {
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }printer/heatup`, {});
}
2016-04-21 15:44:20 +02:00
print(gcode = '', first = false, start = false, last) {
2016-04-16 18:05:15 +02:00
const data = { gcode, first, start, last };
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }printer/print`, data);
2015-07-15 15:06:18 +02:00
}
2016-04-21 15:44:20 +02:00
stop(gcode = '') {
2016-04-16 18:05:15 +02:00
const data = { gcode };
2016-04-21 15:09:49 +02:00
return rest.post(`${ this.api }printer/stop`, data);
2015-07-15 15:06:18 +02:00
}
}