store fdm and cam gcode output
This commit is contained in:
parent
2cfd612b86
commit
c78fedfbdc
7 changed files with 68 additions and 91 deletions
|
|
@ -171,22 +171,22 @@ KIRI.work = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
printExport : function(settings, online, ondone) {
|
export : function(settings, online, ondone) {
|
||||||
let lines = [];
|
let lines = [];
|
||||||
send("printExport", {settings:settings}, function(reply) {
|
send("export", {settings:settings}, function(reply) {
|
||||||
if (reply.line) {
|
if (reply.line) {
|
||||||
online(reply.line);
|
online(reply.line);
|
||||||
}
|
}
|
||||||
if (reply.done) {
|
if (reply.done) {
|
||||||
ondone(reply.done);
|
ondone(reply.output);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
printGCode : function(callback) {
|
gcode : function(callback) {
|
||||||
let gcode = [];
|
let gcode = [];
|
||||||
let start = BASE.util.time();
|
let start = BASE.util.time();
|
||||||
send("printGCode", {}, function(reply) {
|
send("gcode", {}, function(reply) {
|
||||||
if (reply.line) {
|
if (reply.line) {
|
||||||
gcode.push(reply.line);
|
gcode.push(reply.line);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -195,19 +195,6 @@ KIRI.work = {
|
||||||
callback(reply);
|
callback(reply);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
|
|
||||||
sliceToGCode : function(settings, vertices, callback) {
|
|
||||||
vertices = widget.getGeoVertices().buffer.slice(0);
|
|
||||||
let wid = new Date().toString(36);
|
|
||||||
send("slice", {settings:settings, id:wiwd, vertices:vertices, position:{x:0,y:0,z:0}}, function(reply) {
|
|
||||||
send("printSetup", {settings:settings}, function(reply) {
|
|
||||||
send("printGCode", {}, function(reply) {
|
|
||||||
callback(reply);
|
|
||||||
});
|
|
||||||
}, [vertices]);
|
|
||||||
callback(reply);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,27 +15,45 @@
|
||||||
STATS = API.stats,
|
STATS = API.stats,
|
||||||
MODES = API.const.MODES;
|
MODES = API.const.MODES;
|
||||||
|
|
||||||
KIRI.export = exportPrint;
|
KIRI.export = exportFile;
|
||||||
|
|
||||||
let printSeq = parseInt(SDB['kiri-print-seq'] || SDB['print-seq'] || "0") + 1;
|
let printSeq = parseInt(SDB['kiri-print-seq'] || SDB['print-seq'] || "0") + 1;
|
||||||
|
|
||||||
function exportPrint(options) {
|
function isPrepared() {
|
||||||
let currentPrint = API.print.get();
|
return API.view.get() === API.const.VIEWS.PREVIEW;
|
||||||
if (currentPrint) {
|
}
|
||||||
|
|
||||||
|
function exportFile(options) {
|
||||||
|
if (isPrepared()) {
|
||||||
API.event.emit('export', API.mode.get());
|
API.event.emit('export', API.mode.get());
|
||||||
switch (API.mode.get()) {
|
switch (API.mode.get()) {
|
||||||
case 'LASER': return exportPrintLaser(currentPrint);
|
case 'LASER': return callExport();
|
||||||
case 'FDM': return exportPrintGCODE(currentPrint, options);
|
case 'FDM': return callExport(options);
|
||||||
case 'CAM': return exportPrintGCODE(currentPrint, options);
|
case 'CAM': return callExport(options);
|
||||||
case 'SLA': return exportPrintSLA(currentPrint);
|
case 'SLA': return exportSLA();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
API.function.print(function() { exportPrint(options) });
|
API.function.prepare(function() {
|
||||||
|
exportFile(options)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportPrintSLA(currentPrint) {
|
function callExport(options) {
|
||||||
if (currentPrint) {
|
if (isPrepared()) {
|
||||||
|
const gcode = [];
|
||||||
|
KIRI.client.export(API.conf.get(), (line) => {
|
||||||
|
gcode.push(line);
|
||||||
|
}, (output) => {
|
||||||
|
exportGCodeDialog(gcode.join('\n'), output);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
API.function.prepare(function() { exportPrint(options) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportSLADialog(currentPrint) {
|
||||||
|
if (isPrepared()) {
|
||||||
if (currentPrint.exported) {
|
if (currentPrint.exported) {
|
||||||
KIRI.driver.SLA.printDownload(currentPrint);
|
KIRI.driver.SLA.printDownload(currentPrint);
|
||||||
return;
|
return;
|
||||||
|
|
@ -69,27 +87,13 @@
|
||||||
KIRI.driver.SLA.printDownload(currentPrint);
|
KIRI.driver.SLA.printDownload(currentPrint);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
API.function.print(exportPrintSLA);
|
API.function.prepare(exportSLA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportPrintGCODE(currentPrint, options) {
|
function exportLaserDialog(currentPrint) {
|
||||||
if (currentPrint) {
|
if (!isPrepared()) {
|
||||||
currentPrint.exportGCode(true, function(gcode) {
|
return API.function.prepare(exportLaser);
|
||||||
if (typeof(options) === 'function') {
|
|
||||||
options(gcode, currentPrint);
|
|
||||||
} else {
|
|
||||||
exportGCode(gcode, currentPrint);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
API.function.print(function() { exportPrint(options) });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportPrintLaser(currentPrint) {
|
|
||||||
if (!currentPrint) {
|
|
||||||
return API.function.print(exportPrintLaser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let filename = "laser-"+(new Date().getTime().toString(36));
|
let filename = "laser-"+(new Date().getTime().toString(36));
|
||||||
|
|
@ -128,7 +132,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportGCode(gcode, currentPrint) {
|
function exportGCodeDialog(gcode, currentPrint) {
|
||||||
SDB['kiri-print-seq'] = printSeq++;
|
SDB['kiri-print-seq'] = printSeq++;
|
||||||
|
|
||||||
let settings = API.conf.get(),
|
let settings = API.conf.get(),
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@
|
||||||
STACKS = KIRI.stacks,
|
STACKS = KIRI.stacks,
|
||||||
DRIVER = undefined,
|
DRIVER = undefined,
|
||||||
onEvent = {},
|
onEvent = {},
|
||||||
currentPrint = null,
|
|
||||||
selectedMeshes = [],
|
selectedMeshes = [],
|
||||||
localFilterKey ='kiri-gcode-filters',
|
localFilterKey ='kiri-gcode-filters',
|
||||||
localFilters = js2o(SDB.getItem(localFilterKey)) || [],
|
localFilters = js2o(SDB.getItem(localFilterKey)) || [],
|
||||||
|
|
@ -229,9 +228,10 @@
|
||||||
function: {
|
function: {
|
||||||
slice: prepareSlices,
|
slice: prepareSlices,
|
||||||
print: preparePrint,
|
print: preparePrint,
|
||||||
|
prepare: preparePrint,
|
||||||
export: function() { KIRI.export(...arguments) },
|
export: function() { KIRI.export(...arguments) },
|
||||||
cancel: cancelWorker,
|
cancel: cancelWorker,
|
||||||
clear: clearWidgetCache
|
clear: () => { console.log("api.function.clear unimplemented") }
|
||||||
},
|
},
|
||||||
hide: {
|
hide: {
|
||||||
alert: function(rec) { alert2cancel(rec) },
|
alert: function(rec) { alert2cancel(rec) },
|
||||||
|
|
@ -252,10 +252,6 @@
|
||||||
switch: switchMode,
|
switch: switchMode,
|
||||||
set_expert: setExpert
|
set_expert: setExpert
|
||||||
},
|
},
|
||||||
print: {
|
|
||||||
get: function() { return currentPrint },
|
|
||||||
clear: clearPrint
|
|
||||||
},
|
|
||||||
probe: {
|
probe: {
|
||||||
live : "https://live.grid.space",
|
live : "https://live.grid.space",
|
||||||
grid : function() { return false },
|
grid : function() { return false },
|
||||||
|
|
@ -580,13 +576,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideSlices() {
|
function hideSlices() {
|
||||||
let showing = false;
|
|
||||||
setOpacity(color.model_opacity);
|
|
||||||
STACKS.clear();
|
STACKS.clear();
|
||||||
|
setOpacity(color.model_opacity);
|
||||||
forAllWidgets(function(widget) {
|
forAllWidgets(function(widget) {
|
||||||
widget.setWireframe(false);
|
widget.setWireframe(false);
|
||||||
});
|
});
|
||||||
return showing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWidgetVisibility(bool) {
|
function setWidgetVisibility(bool) {
|
||||||
|
|
@ -634,8 +628,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadCode(code, type) {
|
function loadCode(code, type) {
|
||||||
|
return alert2('currently unavailable');
|
||||||
|
|
||||||
setViewMode(VIEWS.PREVIEW);
|
setViewMode(VIEWS.PREVIEW);
|
||||||
clearPrint();
|
|
||||||
setOpacity(0);
|
setOpacity(0);
|
||||||
currentPrint = kiri.newPrint(settings, []);
|
currentPrint = kiri.newPrint(settings, []);
|
||||||
let center = settings.process.outputOriginCenter;
|
let center = settings.process.outputOriginCenter;
|
||||||
|
|
@ -682,7 +677,6 @@
|
||||||
|
|
||||||
if (feature.preview) {
|
if (feature.preview) {
|
||||||
setViewMode(VIEWS.PREVIEW);
|
setViewMode(VIEWS.PREVIEW);
|
||||||
clearPrint();
|
|
||||||
}
|
}
|
||||||
API.conf.save();
|
API.conf.save();
|
||||||
API.event.emit('preview.begin', pMode);
|
API.event.emit('preview.begin', pMode);
|
||||||
|
|
@ -730,25 +724,6 @@
|
||||||
if (KIRI.work.isSlicing()) KIRI.work.restart();
|
if (KIRI.work.isSlicing()) KIRI.work.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearWidgetCache() {
|
|
||||||
hideSlices();
|
|
||||||
clearSlices();
|
|
||||||
clearPrint();
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearPrint() {
|
|
||||||
if (currentPrint) {
|
|
||||||
SPACE.platform.remove(currentPrint.group);
|
|
||||||
currentPrint = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearSlices() {
|
|
||||||
forAllWidgets(function(widget) {
|
|
||||||
widget.slices = null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showSlider() {
|
function showSlider() {
|
||||||
UI.layers.style.display = 'flex';
|
UI.layers.style.display = 'flex';
|
||||||
UI.slider.style.display = 'flex';
|
UI.slider.style.display = 'flex';
|
||||||
|
|
@ -777,7 +752,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
hideSlider(true);
|
hideSlider(true);
|
||||||
clearPrint();
|
|
||||||
platform.deselect();
|
platform.deselect();
|
||||||
setViewMode(VIEWS.SLICE);
|
setViewMode(VIEWS.SLICE);
|
||||||
|
|
||||||
|
|
@ -1954,10 +1928,11 @@
|
||||||
case VIEWS.ARRANGE:
|
case VIEWS.ARRANGE:
|
||||||
$('lt-back').style.display = '';
|
$('lt-back').style.display = '';
|
||||||
KIRI.work.clear();
|
KIRI.work.clear();
|
||||||
|
STACKS.clear();
|
||||||
hideSlider();
|
hideSlider();
|
||||||
clearWidgetCache();
|
|
||||||
updateSliderMax();
|
updateSliderMax();
|
||||||
setWidgetVisibility(true);
|
setWidgetVisibility(true);
|
||||||
|
setOpacity(1);
|
||||||
break;
|
break;
|
||||||
case VIEWS.SLICE:
|
case VIEWS.SLICE:
|
||||||
$('lt-back').style.display = 'flex';
|
$('lt-back').style.display = 'flex';
|
||||||
|
|
@ -2028,7 +2003,6 @@
|
||||||
API.conf.load();
|
API.conf.load();
|
||||||
API.conf.save();
|
API.conf.save();
|
||||||
// other housekeeping
|
// other housekeeping
|
||||||
clearWidgetCache();
|
|
||||||
triggerSettingsEvent();
|
triggerSettingsEvent();
|
||||||
platformUpdateSelected();
|
platformUpdateSelected();
|
||||||
updateFields();
|
updateFields();
|
||||||
|
|
|
||||||
|
|
@ -220,9 +220,9 @@
|
||||||
|
|
||||||
if (KIRI.client) {
|
if (KIRI.client) {
|
||||||
// executed from kiri.js
|
// executed from kiri.js
|
||||||
KIRI.client.printExport(this.settings, online, ondone);
|
KIRI.client.export(this.settings, online, ondone);
|
||||||
} else {
|
} else {
|
||||||
if (!(driver && driver.printExport)) {
|
if (!(driver && driver.export)) {
|
||||||
console.log({missing_export_driver: mode});
|
console.log({missing_export_driver: mode});
|
||||||
ondone(null);
|
ondone(null);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -129,15 +129,27 @@ KIRI.worker = {
|
||||||
send.done({ done: true, output: KIRI.codec.encode(layers) });
|
send.done({ done: true, output: KIRI.codec.encode(layers) });
|
||||||
},
|
},
|
||||||
|
|
||||||
printExport: function(data, send) {
|
export: function(data, send) {
|
||||||
current.print.export(false, function(line, direct) {
|
const mode = data.settings.mode;
|
||||||
send.data({line}, direct);
|
const driver = KIRI.driver[mode];
|
||||||
}, function(done, direct) {
|
|
||||||
send.done({done}, direct);
|
if (!(driver && driver.export)) {
|
||||||
|
console.log({missing_export_driver: mode});
|
||||||
|
return send.done()
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = driver.export(current.print, function(line) {
|
||||||
|
send.data({line});
|
||||||
|
});
|
||||||
|
const { time, lines, bytes, bounds } = current.print;
|
||||||
|
|
||||||
|
send.done({
|
||||||
|
done: true,
|
||||||
|
output: { time, lines, bytes, bounds }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
printGCode: function(data, send) {
|
gcode: function(data, send) {
|
||||||
current.print.exportGCode(false, function(gcode) {
|
current.print.exportGCode(false, function(gcode) {
|
||||||
send.done({
|
send.done({
|
||||||
gcode: gcode,
|
gcode: gcode,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
/**
|
/**
|
||||||
* @returns {Array} gcode lines
|
* @returns {Array} gcode lines
|
||||||
*/
|
*/
|
||||||
CAM.printExport = function printExport(print, online) {
|
CAM.export = function printExport(print, online) {
|
||||||
let widget = print.widgets[0];
|
let widget = print.widgets[0];
|
||||||
|
|
||||||
if (!widget) return;
|
if (!widget) return;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
/**
|
/**
|
||||||
* @returns {Array} gcode lines
|
* @returns {Array} gcode lines
|
||||||
*/
|
*/
|
||||||
FDM.printExport = function(print, online) {
|
FDM.export = function(print, online) {
|
||||||
let layers = print.output,
|
let layers = print.output,
|
||||||
settings = FDM.fixExtruders(print.settings),
|
settings = FDM.fixExtruders(print.settings),
|
||||||
device = settings.device,
|
device = settings.device,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue