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

57 lines
1.8 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 => {
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 18:19:28 -05:00
// widgets[rec.id].sindex = rec.sindex;
2020-11-30 18:46:56 -05:00
});
2020-12-01 20:56:10 -05:00
ondone(ids);
2020-11-30 18:46:56 -05:00
});
};
if (KIRI.worker)
KIRI.worker.traces = function(data, send) {
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));
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-01 18:19:28 -05:00
// sindex: widget.sindex
2020-11-30 18:46:56 -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
})();