Skip to content

Commit f41e482

Browse files
committed
axis: warn when run_warn used a truncated preview
run_warn() checks program extents from the preview parse. An aborted parse (PREVIEW_TIMEOUT or cancel) skips calc_extents(), leaving init extents, so run_warn() gives a false all-clear. Compute partial extents on abort and flag the preview incomplete so run_warn() reports it.
1 parent 60d6f0b commit f41e482

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

lib/python/rs274/glcanon.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def __init__(self, colors, geometry, is_foam=0, foam_w=1.5, foam_z=0.0):
129129
self.min_extents_notool_zero_rxy = [9e99,9e99,9e99]
130130
self.max_extents_notool_zero_rxy = [-9e99,-9e99,-9e99]
131131
self.colors = colors
132+
# Set if the parse was aborted, so the extents above are only partial.
133+
self.preview_incomplete = False
132134
self.in_arc = 0
133135
self.xo = self.yo = self.zo = self.ao = self.bo = self.co = self.uo = self.vo = self.wo = 0
134136
self.dwell_time = 0
@@ -2016,7 +2018,15 @@ def make_main_list(self, unused=None):
20162018
def load_preview(self, f, canon, *args):
20172019
self.set_canon(canon)
20182020
self.preview_too_large = False
2019-
result, seq = gcode.parse(f, canon, *args)
2021+
canon.preview_incomplete = False
2022+
try:
2023+
result, seq = gcode.parse(f, canon, *args)
2024+
except KeyboardInterrupt:
2025+
# Aborted parse: extents cover only the parsed portion. Flag it so
2026+
# callers do not treat the partial check as complete.
2027+
canon.preview_incomplete = True
2028+
canon.calc_extents()
2029+
raise
20202030

20212031
if result <= gcode.MIN_ERROR:
20222032
self.canon.progress.nextphase(1)

src/emc/usr_intf/axis/scripts/axis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,11 @@ def run_warn():
19011901
if o.canon.max_extents_notool[i] > machine_limit_max[i]:
19021902
warnings.append(_("Program exceeds machine maximum on axis %s")
19031903
% "XYZABCUVW"[i])
1904+
# A truncated preview only checked part of the program; warn rather
1905+
# than imply a clean all-clear.
1906+
if getattr(o.canon, "preview_incomplete", False):
1907+
warnings.append(_("G-code preview was truncated before completion; "
1908+
"machine limits could not be fully checked."))
19041909
if warnings:
19051910
text = "\n".join(warnings)
19061911
return int(root_window.tk.call("nf_dialog", ".error",

0 commit comments

Comments
 (0)