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-11-08 13:04:54 -05:00
|
|
|
const KIRI = self.kiri,
|
2017-04-18 17:09:33 -04:00
|
|
|
CAM = KIRI.driver.CAM = {
|
2020-11-05 18:29:04 -05:00
|
|
|
// init, // src/mode/cam/client.js
|
2020-11-05 15:41:52 -05:00
|
|
|
// slice, // src/mode/cam/slice.js
|
2020-11-08 16:44:32 -05:00
|
|
|
// prepare, // src/mode/cam/prepare.js
|
2020-11-08 18:39:21 -05:00
|
|
|
// export // src/mode/cam/export.js
|
2017-04-18 17:09:33 -04:00
|
|
|
},
|
|
|
|
|
CPRO = CAM.process = {
|
2020-06-29 13:48:52 -04:00
|
|
|
LEVEL: 1,
|
|
|
|
|
ROUGH: 2,
|
|
|
|
|
OUTLINE: 3,
|
|
|
|
|
CONTOUR_X: 4,
|
|
|
|
|
CONTOUR_Y: 5,
|
|
|
|
|
TRACE: 6,
|
|
|
|
|
DRILL: 7
|
2020-11-05 18:29:04 -05:00
|
|
|
};
|
2017-04-18 17:09:33 -04:00
|
|
|
|
2020-11-30 18:01:32 -05:00
|
|
|
// defer loading until KIRI.client and KIRI.worker exist
|
|
|
|
|
KIRI.loader.push(function(API) {
|
|
|
|
|
|
|
|
|
|
if (KIRI.client)
|
|
|
|
|
KIRI.client.traces = function(ondone) {
|
|
|
|
|
KIRI.client.sync();
|
2020-11-30 18:46:56 -05:00
|
|
|
let settings = API.conf.get();
|
|
|
|
|
let widgets = API.widgets.map();
|
|
|
|
|
send("traces", { settings }, output => {
|
|
|
|
|
KIRI.codec.decode(output).forEach(rec => {
|
|
|
|
|
widgets[rec.id].traces = rec.traces;
|
|
|
|
|
});
|
|
|
|
|
ondone(true);
|
|
|
|
|
});
|
2020-11-30 18:01:32 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (KIRI.worker)
|
|
|
|
|
KIRI.worker.traces = function(data, send) {
|
|
|
|
|
const { settings } = data;
|
|
|
|
|
const widgets = Object.values(cache);
|
|
|
|
|
widgets.forEach(widget => CAM.traces(settings, widget));
|
2020-11-30 18:46:56 -05:00
|
|
|
send.done(KIRI.codec.encode(widgets.map(widget => {return {
|
|
|
|
|
id: widget.id,
|
|
|
|
|
traces: widget.traces
|
|
|
|
|
}})));
|
2020-11-30 18:01:32 -05:00
|
|
|
};
|
|
|
|
|
|
2017-04-18 17:09:33 -04:00
|
|
|
});
|
2020-06-09 18:12:59 -04:00
|
|
|
|
2017-04-18 17:09:33 -04:00
|
|
|
})();
|