diff --git a/notes.md b/notes.md index ddb4e049..f0f6d97d 100644 --- a/notes.md +++ b/notes.md @@ -62,11 +62,11 @@ * `B` clicking on a pop-op should pin it until clicked or [esc] * `B` need to force cut line at synthetic z bottom (midlines, etc) * `B` non-clear-voids duplicates thru-holes -* `B` failure to go *up* when moving between parts? * `B` starting export during animation unleashes chaos * `B` climb vs conventional not fully consistent after refactor * `B` outside cutting direction in roughing mode inverted +* `F` import SVG into a path that can be overlaid onto a 3D mesh (laser?) * `F` intelligently turn circle hole pocket clear into spiral down * `F` trace follow hole that matches endmill should turn into a drill op * `F` add climb/conventional into each operation diff --git a/src/kiri/client.js b/src/kiri/client.js index 9dd2af07..7f6a660b 100644 --- a/src/kiri/client.js +++ b/src/kiri/client.js @@ -70,9 +70,9 @@ KIRI.work = { worker.terminate(); } - for (let key in slicing) { - slicing[key]({error: "cancelled slicing"}); - } + // for (let key in slicing) { + // slicing[key]({error: "cancelled slicing"}); + // } syncd = {}; slicing = {}; @@ -188,6 +188,9 @@ KIRI.work = { if (reply.done) { done(reply.output, reply.maxSpeed); } + if (reply.error) { + done(reply); + } }); }, @@ -199,6 +202,9 @@ KIRI.work = { if (reply.done) { ondone(reply.output); } + if (reply.error) { + ondone(null, reply.error); + } }); }, diff --git a/src/kiri/export.js b/src/kiri/export.js index a2e047e0..ebecd552 100644 --- a/src/kiri/export.js +++ b/src/kiri/export.js @@ -35,9 +35,11 @@ const gcode = []; KIRI.client.export(API.conf.get(), (line) => { gcode.push(line); - }, (output) => { + }, (output, error) => { API.hide.alert(alert); - if (callback) { + if (error) { + API.show.alert(error, 5); + } else if (callback) { callback(gcode.join('\r\n'), output); } else { exportGCodeDialog(gcode.join('\r\n'), output); @@ -48,8 +50,12 @@ function callExportLaser(options) { KIRI.client.export(API.conf.get(), (line) => { console.log({unexpected_line: line}); - }, (output) => { - exportLaserDialog(output); + }, (output, error) => { + if (error) { + API.show.alert(error, 5); + } else { + exportLaserDialog(output); + } }); } @@ -60,9 +66,13 @@ if (line.data) { preview.push(line.data); } - }, (output) => { + }, (output, error) => { API.show.progress(0); - KIRI.driver.SLA.printDownload(preview, output, API); + if (error) { + API.show.alert(error, 5); + } else { + KIRI.driver.SLA.printDownload(preview, output, API); + } }); } diff --git a/src/kiri/main.js b/src/kiri/main.js index faf632e3..faa320a6 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -898,9 +898,22 @@ } API.event.emit('slice', getMode()); } + // handle slicing errors + if (error && !errored) { + errored = true; + setViewMode(VIEWS.ARRANGE); + alert2(error, 5); + API.show.progress(0); + KIRI.client.restart(); + API.event.emit('slice.error', error); + } + // discard remaining errors + if (errored) { + return; + } let alert = null; // on the last exit, update ui and call the callback - if (--countdown === 0 || error || errored) { + if (--countdown === 0) { if (scale === 1 && feature.work_alerts) { alert = API.show.alert("Rendering"); }; @@ -923,12 +936,13 @@ updateSliderMax(true); setVisibleLayer(-1, 0); }); - // mark slicing complete for prep/preview - complete.slice = true; if (scale === 1) { API.show.progress(0); } + // cause visuals to update SPACE.scene.active(); + // mark slicing complete for prep/preview + complete.slice = true; API.event.emit('slice.end', getMode()); // print stats segtimes.total = Date.now() - now; @@ -937,16 +951,6 @@ callback(); } } - // handle slicing errors - if (error && !errored) { - API.show.progress(0); - API.hide.alert(alert); - errored = true; - setViewMode(VIEWS.ARRANGE); - setOpacity(color.model_opacity); - platform.deselect(); - alert2(error, 1); - } }, function(update, msg) { if (msg && msg !== lastMsg) { let mark = Date.now(); @@ -1018,7 +1022,17 @@ startTime = mark; } API.show.progress(offset + progress * scale, message); - }, function (oldout, maxSpeed) { + }, function (reply, maxSpeed) { + // handle worker errors + if (reply && reply.error) { + alert2(reply.error, 5); + setViewMode(VIEWS.ARRANGE); + API.event.emit('preview.error', reply.error); + API.show.progress(0); + SPACE.update(); + return; + } + if (lastMsg) { segtimes[`${segNumber++}_${lastMsg}`] = Date.now() - startTime; } diff --git a/src/kiri/worker.js b/src/kiri/worker.js index da70b9e4..77c363d8 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -159,35 +159,30 @@ KIRI.worker = { last = time(), now; - try { - widget.slice(settings, function(error) { - if (error) { - send.data({error: error}); - } else { - const slices = widget.slices || []; - send.data({send_start: time()}); - send.data({ - stats: widget.stats, - slices: slices.length, - }); - slices.forEach(function(slice,index) { - const state = { zeros: [] }; - send.data({index: index, slice: slice.encode(state)}, state.zeros); - }) - send.data({send_end: time()}); - } - send.done({done: true}); - }, function(update, msg) { - now = time(); - if (now - last < 10 && update < 0.99) return; - // on update - send.data({update: (0.05 + update * 0.95), updateStatus: msg}); - last = now; - }); - } catch (error) { - send.data({error: error.toString()}); - console.log(error); - } + widget.slice(settings, function(error) { + if (error) { + send.data({error: error}); + } else { + const slices = widget.slices || []; + send.data({send_start: time()}); + send.data({ + stats: widget.stats, + slices: slices.length, + }); + slices.forEach(function(slice,index) { + const state = { zeros: [] }; + send.data({index: index, slice: slice.encode(state)}, state.zeros); + }) + send.data({send_end: time()}); + } + send.done({done: true}); + }, function(update, msg) { + now = time(); + if (now - last < 10 && update < 0.99) return; + // on update + send.data({update: (0.05 + update * 0.95), updateStatus: msg}); + last = now; + }); }, prepare: function(data, send) { @@ -593,20 +588,25 @@ self.onmessage = function(e) { }; if (run) { - let time_xfer = (time_recv - msg.time), - output = run(msg.data, send), - time_send = time(), - time_proc = time_send - time_recv; + try { + let time_xfer = (time_recv - msg.time), + output = run(msg.data, send), + time_send = time(), + time_proc = time_send - time_recv; - if (output) self.postMessage({ - seq: msg.seq, - task: msg.task, - time_send: time_xfer, - time_proc: time_proc, - // replaced on reply side - time_recv: time(), - data: output - }); + if (output) self.postMessage({ + seq: msg.seq, + task: msg.task, + time_send: time_xfer, + time_proc: time_proc, + // replaced on reply side + time_recv: time(), + data: output + }); + } catch (wrkerr) { + console.log({wrkerr}); + send.done({error: wrkerr.toString()}); + } } else { console.log({kiri_msg:e}); } diff --git a/src/mode/fdm/prepare.js b/src/mode/fdm/prepare.js index 7382caf2..2366ed00 100644 --- a/src/mode/fdm/prepare.js +++ b/src/mode/fdm/prepare.js @@ -20,7 +20,6 @@ */ FDM.prepare = function(widgets, settings, update) { settings = FDM.fixExtruders(settings); - let render = settings.render !== false, { device, process, controller, bounds, mode } = settings, output = [], diff --git a/web/kiri/index.html b/web/kiri/index.html index ef601e46..502dfc1a 100644 --- a/web/kiri/index.html +++ b/web/kiri/index.html @@ -3,7 +3,7 @@
- +