grid-apps-cmms/src/mode/cam/driver.js

53 lines
1.6 KiB
JavaScript
Raw Normal View History

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
// slice, // src/mode/cam/slice.js
// 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 = {
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
// 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);
});
};
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
}})));
};
2017-04-18 17:09:33 -04:00
});
2020-06-09 18:12:59 -04:00
2017-04-18 17:09:33 -04:00
})();