This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
forked from linuxcnc-probe-screen/probe-screen-ng
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.axisrc
76 lines (58 loc) · 2.66 KB
/
.axisrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright (c) 2020 Probe Screen NG Developers
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.
# This AXIS RC file adds support for an error pin, mirroring the
# gmocappy.error pin's behaviour for AXIS.
def _remaining_error_count(widgets):
""" Returns the count of remaining error messages """
count = 0
for i, item in enumerate(widgets):
frame, icon, text, button, iname = item
if iname == "icon_std_error":
count += 1
return count
def my_add(self, iconname, message):
""" Signal to PSNG that an error has occurred. """
self.original_add(iconname, message)
if iconname == "error":
probe_user_comp["error"] = True
def my_remove(self, widgets):
""" Signal to PSNG when all errors have been cleared. """
self.original_remove(widgets)
if _remaining_error_count(self.widgets) == 0:
probe_user_comp["error"] = False
root_window.tk.call('.toolbar.program_stop','configure','-command','my_task_stop')
def my_task_stop(*event):
#print 'hijacked stop command'
probe_user_comp["abort"] = True
#self.original_task_stop(*event) # bug : self not defined
if s.task_mode == linuxcnc.MODE_AUTO and vars.running_line.get() != 0:
o.set_highlight_line(vars.running_line.get())
c.abort()
c.wait_complete()
time.sleep(0.5)
probe_user_comp["abort"] = False
# Rename the original add/remove method so we can retain the ability to call them
Notification.original_add = Notification.add
Notification.original_remove = Notification.remove
#TclCommands.original_task_stop = TclCommands.task_stop # bug : self not defined
# Replace the add/remove methods with a wrapped version that manages an error pin
Notification.add = my_add
Notification.remove = my_remove
TclCommands.task_stop = my_task_stop
commands = TclCommands(root_window)
if hal_present == 1:
# Add an probe.user.error pin
probe_user_comp = hal.component("axisui.user")
probe_user_comp.newpin("error", hal.HAL_BIT, hal.HAL_OUT)
probe_user_comp.newpin("abort", hal.HAL_BIT, hal.HAL_OUT)
probe_user_comp.ready()