mirror of
https://github.com/Doodle3D/Doodle3D-API
synced 2025-01-03 10:03:48 +01:00
improved code for splitting code into batches
This commit is contained in:
parent
b686f36856
commit
65d61dd492
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
|
|
||||||
jspm_packages/*
|
jspm_packages/*
|
||||||
|
example/test.gcode
|
||||||
|
38061
example/test.gcode
38061
example/test.gcode
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@ export default class extends EventDispatcher {
|
|||||||
wifiboxid: 'Node JS Server',
|
wifiboxid: 'Node JS Server',
|
||||||
localip: '127.0.0.1:2000'
|
localip: '127.0.0.1:2000'
|
||||||
}];
|
}];
|
||||||
|
this.checkNonServerBoxes = true;
|
||||||
this.api = 'http://connect.doodle3d.com/api/';
|
this.api = 'http://connect.doodle3d.com/api/';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +79,10 @@ export default class extends EventDispatcher {
|
|||||||
var request = rest.get(this.api + 'list.php');
|
var request = rest.get(this.api + 'list.php');
|
||||||
request.then((boxes) => {
|
request.then((boxes) => {
|
||||||
|
|
||||||
boxes = boxes.concat(this.nonServerBoxes);
|
if (this.checkNonServerBoxes) {
|
||||||
|
boxes = boxes.concat(this.nonServerBoxes);
|
||||||
|
}
|
||||||
|
|
||||||
var knownIPs = this.boxes.map((box) => box.boxData.localip);
|
var knownIPs = this.boxes.map((box) => box.boxData.localip);
|
||||||
|
|
||||||
for (var boxData of boxes) {
|
for (var boxData of boxes) {
|
||||||
|
@ -40,10 +40,10 @@ export default class {
|
|||||||
this._currentBatch = 0;
|
this._currentBatch = 0;
|
||||||
|
|
||||||
var lastIndex = 0;
|
var lastIndex = 0;
|
||||||
while (lastIndex !== (gcode.length - 1)) {
|
while (lastIndex !== gcode.length) {
|
||||||
var index = gcode.lastIndexOf('\n', lastIndex + this.maxBatchSize);
|
var index = gcode.lastIndexOf('\n', lastIndex + this.maxBatchSize);
|
||||||
var batch = gcode.substring(lastIndex, index);
|
var batch = gcode.substring(lastIndex, index);
|
||||||
lastIndex = index;
|
lastIndex = index + 1; //skip next return
|
||||||
|
|
||||||
this._printBatches.push(batch);
|
this._printBatches.push(batch);
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ export default class {
|
|||||||
if (this._printBatches.length > 0) {
|
if (this._printBatches.length > 0) {
|
||||||
if (progress['buffered_lines'] + this.maxBatchSize < this.maxBufferedLines) {
|
if (progress['buffered_lines'] + this.maxBatchSize < this.maxBufferedLines) {
|
||||||
this._currentBatch ++;
|
this._currentBatch ++;
|
||||||
_sendBatch();
|
this._sendBatch();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user