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)
|
2020-12-14 12:52:08 -05:00
|
|
|
CAM.traces = function(ondone) {
|
2020-11-30 18:01:32 -05:00
|
|
|
KIRI.client.sync();
|
2020-11-30 18:46:56 -05:00
|
|
|
let settings = API.conf.get();
|
|
|
|
|
let widgets = API.widgets.map();
|
2021-01-01 11:14:07 -05:00
|
|
|
KIRI.client.send("cam_traces", { settings }, output => {
|
2020-12-01 20:56:10 -05:00
|
|
|
let ids = [];
|
2020-11-30 18:46:56 -05:00
|
|
|
KIRI.codec.decode(output).forEach(rec => {
|
2020-12-01 20:56:10 -05:00
|
|
|
ids.push(rec.id);
|
2020-11-30 18:46:56 -05:00
|
|
|
widgets[rec.id].traces = rec.traces;
|
|
|
|
|
});
|
2020-12-01 20:56:10 -05:00
|
|
|
ondone(ids);
|
2020-11-30 18:46:56 -05:00
|
|
|
});
|
2020-11-30 18:01:32 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (KIRI.worker)
|
2020-12-14 12:52:08 -05:00
|
|
|
KIRI.worker.cam_traces = function(data, send) {
|
2020-11-30 18:01:32 -05:00
|
|
|
const { settings } = data;
|
|
|
|
|
const widgets = Object.values(cache);
|
2020-12-01 19:54:54 -05:00
|
|
|
const fresh = widgets.filter(widget => CAM.traces(settings, widget));
|
2020-12-14 14:28:14 -05:00
|
|
|
send.done(KIRI.codec.encode(fresh.map(widget => { return {
|
2020-11-30 18:46:56 -05:00
|
|
|
id: widget.id,
|
2020-12-01 14:22:19 -05:00
|
|
|
traces: widget.traces,
|
2020-12-14 14:28:14 -05:00
|
|
|
} } )));
|
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
|
|
|
})();
|