2020-06-03 22:39:30 -04:00
|
|
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
2017-04-18 17:09:33 -04:00
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
|
2020-06-03 22:39:30 -04:00
|
|
|
const KIRI = self.kiri,
|
2017-04-18 17:09:33 -04:00
|
|
|
BASE = self.base,
|
2017-12-15 08:54:39 -05:00
|
|
|
DBUG = BASE.debug,
|
2017-04-18 17:09:33 -04:00
|
|
|
UTIL = BASE.util,
|
|
|
|
|
POLY = BASE.polygons,
|
2020-03-11 20:28:28 -04:00
|
|
|
FDM = KIRI.driver.FDM = {
|
2020-11-05 18:29:04 -05:00
|
|
|
// init, // src/mode/fdm/client.js
|
|
|
|
|
// slice, // src/mode/fdm/slice.js
|
2020-11-08 16:44:32 -05:00
|
|
|
// prepare, // src/mode/fdm/prepare.js
|
2020-11-08 18:39:21 -05:00
|
|
|
// export, // src/mode/fdm/export.js
|
2020-11-05 18:29:04 -05:00
|
|
|
fixExtruders
|
|
|
|
|
};
|
2020-04-11 16:33:10 -04:00
|
|
|
|
2020-04-12 22:25:00 -04:00
|
|
|
function fixExtruders(settings) {
|
|
|
|
|
Object.entries(settings.widget).forEach(arr => {
|
|
|
|
|
let [wid,val] = arr;
|
|
|
|
|
let dext = settings.device.extruders[val.extruder];
|
|
|
|
|
if (!dext) {
|
|
|
|
|
settings.widget[wid].extruder = 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 18:29:04 -05:00
|
|
|
// customer gcode post function for XYZ daVinci Mini W
|
|
|
|
|
self.kiri_fdm_xyz_mini_w = function(gcode, options) {
|
|
|
|
|
return btoa("; filename = kirimoto.gcode\n; machine = dv1MW0A000\n" + gcode);
|
2017-04-18 17:09:33 -04:00
|
|
|
};
|
|
|
|
|
|
2020-12-14 12:52:08 -05:00
|
|
|
// defer loading until KIRI.client and KIRI.worker exist
|
|
|
|
|
KIRI.loader.push(function(API) {
|
|
|
|
|
|
|
|
|
|
if (KIRI.client)
|
|
|
|
|
// FDM.support_generate = KIRI.client.fdm_support_generate = function(ondone) {
|
|
|
|
|
FDM.support_generate = function(ondone) {
|
2020-12-14 14:28:14 -05:00
|
|
|
KIRI.client.sync();
|
|
|
|
|
let settings = API.conf.get();
|
|
|
|
|
let widgets = API.widgets.map();
|
2020-12-14 14:51:36 -05:00
|
|
|
send('fdm_support_generate', { settings }, (gen) => {
|
2020-12-14 14:28:14 -05:00
|
|
|
for (let g of gen) g.widget = widgets[g.id];
|
|
|
|
|
ondone(gen);
|
|
|
|
|
});
|
2020-12-14 12:52:08 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (KIRI.worker)
|
|
|
|
|
KIRI.worker.fdm_support_generate = function(data, send) {
|
2020-12-14 14:28:14 -05:00
|
|
|
const { settings } = data;
|
|
|
|
|
const widgets = Object.values(cache);
|
|
|
|
|
const fresh = widgets.filter(widget => FDM.supports(settings, widget));
|
|
|
|
|
send.done(KIRI.codec.encode(fresh.map(widget => { return {
|
|
|
|
|
id: widget.id,
|
|
|
|
|
supports: widget.supports,
|
|
|
|
|
} } )));
|
2020-12-14 12:52:08 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2017-04-18 17:09:33 -04:00
|
|
|
})();
|