Skip to content

Commit afcc6c8

Browse files
AXIS: Add [DISPLAY] PREVIEW_TIMEOUT setting.
Previously AXIS would freeze when loading a G-code file that takes very long to execute and/or never terminates. This commit adds an optional timeout that stops the loading of preview and shows a notice. Retains old behavior if the .ini file setting is not specified.
1 parent bbc2214 commit afcc6c8

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

docs/src/config/ini-config.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ User Manual.
305305
If the update time is not set right the screen can become unresponsive or very jerky.
306306
A value of 100ms (0.1 seconds) is a common setting though a range of 50 - 200ms (.05 - .2 seconds) may be useable.
307307
An under powered CPU may see improvement with a longer setting. Usually the default is fine.
308+
* 'PREVIEW_TIMEOUT = 5' - Timeout (in seconds) for loading graphical preview of G-code. Currently AXIS only.
308309

309310
[NOTE]
310311
The following [DISPLAY] items are used by GladeVCP, see the

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,15 @@ def __init__(self, widget, text, linecount, progress, arcdivision):
10691069
self.progress = progress
10701070
self.aborted = False
10711071
self.arcdivision = arcdivision
1072+
self.timeout_time = None
1073+
1074+
def set_timeout(self, timeout):
1075+
'''Abort loading of G-code if it takes more than timeout seconds from
1076+
the time this method was called. Set timeout to None to disable.'''
1077+
if timeout is None or timeout <= 0:
1078+
self.timeout_time = None
1079+
else:
1080+
self.timeout_time = time.time() + timeout
10721081

10731082
def change_tool(self, pocket):
10741083
GLCanon.change_tool(self, pocket)
@@ -1081,6 +1090,11 @@ def do_cancel(self, event):
10811090

10821091
def check_abort(self):
10831092
root_window.update()
1093+
1094+
if self.timeout_time is not None and self.timeout_time < time.time():
1095+
notifications.add("info", _("G-code preview loading timed out"))
1096+
self.aborted = True
1097+
10841098
if self.aborted: raise KeyboardInterrupt
10851099

10861100
def next_line(self, st):
@@ -1217,6 +1231,10 @@ def open_file_guts(f, filtered=False, addrecent=True):
12171231
shutil.copy(parameter, temp_parameter)
12181232
canon.parameter_file = temp_parameter
12191233

1234+
timeout = inifile.find("DISPLAY", "PREVIEW_TIMEOUT") or ""
1235+
if timeout:
1236+
canon.set_timeout(float(timeout))
1237+
12201238
initcode = inifile.find("EMC", "RS274NGC_STARTUP_CODE") or ""
12211239
if initcode == "":
12221240
initcode = inifile.find("RS274NGC", "RS274NGC_STARTUP_CODE") or ""

0 commit comments

Comments
 (0)