mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 11:33:49 +01:00
sending gcode now in array
This commit is contained in:
parent
20e80b390e
commit
173e723656
@ -44,7 +44,6 @@ var printer = new D3D.Printer({
|
||||
"printer.heatup.enabled": true,
|
||||
"printer.heatup.temperature": 180,
|
||||
"printer.retraction.amount": 3,
|
||||
"printer.retraction.enabled": false,
|
||||
"printer.retraction.minDistance": 5,
|
||||
"printer.retraction.speed": 50,
|
||||
"printer.screenToMillimeterScale": 0.3, //????
|
||||
@ -54,6 +53,7 @@ var printer = new D3D.Printer({
|
||||
"printer.type": "ultimaker",
|
||||
"printer.useSubLayers": true, //wat is dit?
|
||||
|
||||
"printer.retraction.enabled": true,
|
||||
"printer.speed": 50,
|
||||
"printer.wallThickness": 0.4, //nozzle
|
||||
"printer.layerHeight": 0.3,
|
||||
|
16
src/box.js
16
src/box.js
@ -16,9 +16,8 @@ D3D.Box = function (localIp) {
|
||||
"use strict";
|
||||
var self = this;
|
||||
|
||||
this.batchSize = 1024 * 10; //10kb
|
||||
this.maxBufferSize = 1024 * 1024 * 2; //2mb
|
||||
this.bytesSend = 0;
|
||||
this.batchSize = 512;
|
||||
this.maxBufferedLines = 4096;
|
||||
|
||||
this.localIp = localIp;
|
||||
this.api = "http://" + localIp + "/d3dapi/";
|
||||
@ -61,7 +60,7 @@ D3D.Box.prototype.update = function () {
|
||||
//Bij error wordt gelijk zelfde data opnieuw gestuurd
|
||||
//Als DoodleBox ontkoppeld wordt komt er een error in de loop waardoor pagina breekt en ververst moet worden
|
||||
|
||||
if (this.printBatches.length > 0 && (this.status["buffered_lines"]*30 + this.batchSize) <= this.maxBufferSize) {
|
||||
if (this.printBatches.length > 0 && (this.status["buffered_lines"] + this.batchSize) <= this.maxBufferedLines) {
|
||||
//if (this.printBatches.length > 0 ) {
|
||||
this.printBatch();
|
||||
}
|
||||
@ -89,9 +88,12 @@ D3D.Box.prototype.print = function (gcode) {
|
||||
|
||||
this.currentBatch = 0;
|
||||
|
||||
//clone gcode to remove array links
|
||||
gcode = gcode.clone();
|
||||
|
||||
//gcode split in batches
|
||||
for (var i = 0; i < gcode.length; i += this.batchSize) {
|
||||
var gcodeBatch = gcode.substring(i, Math.min(i + this.batchSize, gcode.length));
|
||||
while (gcode.length > 0) {
|
||||
var gcodeBatch = gcode.splice(0, Math.min(this.batchSize, gcode.length));
|
||||
this.printBatches.push(gcodeBatch);
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ D3D.Box.prototype.printBatch = function () {
|
||||
this.setPrinterPrint({
|
||||
"start": ((this.currentBatch === 0) ? true : false),
|
||||
"first": ((this.currentBatch === 0) ? true : false),
|
||||
"gcode": gcode
|
||||
"gcode": gcode.join("\n")
|
||||
}, function (data) {
|
||||
console.log("batch sent: " + self.currentBatch, data);
|
||||
|
||||
|
@ -29,7 +29,7 @@ D3D.Printer.prototype.getStartCode = function () {
|
||||
var gcode = this.config["printer.startcode"];
|
||||
gcode = this.subsituteVariables(gcode);
|
||||
|
||||
return gcode;
|
||||
return gcode.split("\n");
|
||||
};
|
||||
D3D.Printer.prototype.getEndCode = function () {
|
||||
"use strict";
|
||||
@ -37,7 +37,7 @@ D3D.Printer.prototype.getEndCode = function () {
|
||||
var gcode = this.config["printer.endcode"];
|
||||
gcode = this.subsituteVariables(gcode);
|
||||
|
||||
return gcode;
|
||||
return gcode.split("\n");
|
||||
};
|
||||
D3D.Printer.prototype.subsituteVariables = function (gcode) {
|
||||
"use strict";
|
||||
|
@ -431,8 +431,8 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var a = new THREE.Vector2().set(point.X, point.Y);
|
||||
var b = new THREE.Vector2().set(previousPoint.X, previousPoint.Y);
|
||||
var a = new THREE.Vector2(point.X, point.Y);
|
||||
var b = new THREE.Vector2(previousPoint.X, previousPoint.Y);
|
||||
var lineLength = a.distanceTo(b);
|
||||
|
||||
extruder += lineLength * wallThickness * layerHeight / filamentSurfaceArea * flowRate;
|
||||
@ -452,7 +452,7 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
|
||||
return gcode;
|
||||
}
|
||||
|
||||
var gcode = printer.getStartCode().split("\n");
|
||||
var gcode = printer.getStartCode();
|
||||
|
||||
var extruder = 0.0;
|
||||
var speed = firstLayerSlow ? (bottomSpeed*60).toFixed(3) : (normalSpeed*60).toFixed(3);
|
||||
@ -480,7 +480,9 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
|
||||
}
|
||||
}
|
||||
|
||||
return gcode.join("\n") + "\n" + printer.getEndCode();
|
||||
gcode = gcode.concat(printer.getEndCode());
|
||||
|
||||
return gcode;
|
||||
};
|
||||
//only for debug purposes
|
||||
D3D.Slicer.prototype.drawPaths = function (printer, min, max) {
|
||||
|
11
src/utils.js
11
src/utils.js
@ -68,4 +68,15 @@ function downloadFile (file, data) {
|
||||
button.download = file;
|
||||
button.href = window.URL.createObjectURL(blob);
|
||||
button.click();
|
||||
}
|
||||
|
||||
Array.prototype.clone = function () {
|
||||
"use strict";
|
||||
var array = [];
|
||||
|
||||
for (var i = 0; i < this.length; i ++) {
|
||||
array[i] = this[i];
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
Loading…
Reference in New Issue
Block a user