improved code for splitting code into batches

This commit is contained in:
casperlamboo 2015-07-27 17:13:23 +02:00
parent b686f36856
commit 65d61dd492
4 changed files with 10 additions and 38067 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
jspm_packages/*
jspm_packages/*
example/test.gcode

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@ export default class extends EventDispatcher {
wifiboxid: 'Node JS Server',
localip: '127.0.0.1:2000'
}];
this.checkNonServerBoxes = true;
this.api = 'http://connect.doodle3d.com/api/';
}
@ -78,8 +79,10 @@ export default class extends EventDispatcher {
var request = rest.get(this.api + 'list.php');
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);
for (var boxData of boxes) {

View File

@ -40,10 +40,10 @@ export default class {
this._currentBatch = 0;
var lastIndex = 0;
while (lastIndex !== (gcode.length - 1)) {
while (lastIndex !== gcode.length) {
var index = gcode.lastIndexOf('\n', lastIndex + this.maxBatchSize);
var batch = gcode.substring(lastIndex, index);
lastIndex = index;
lastIndex = index + 1; //skip next return
this._printBatches.push(batch);
}
@ -68,7 +68,7 @@ export default class {
if (this._printBatches.length > 0) {
if (progress['buffered_lines'] + this.maxBatchSize < this.maxBufferedLines) {
this._currentBatch ++;
_sendBatch();
this._sendBatch();
}
else {
setTimeout(() => {