-
Notifications
You must be signed in to change notification settings - Fork 18
/
.axisrc
58 lines (43 loc) · 1.96 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
# 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
# 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
# Replace the add/remove methods with a wrapped version that manages an error pin
Notification.add = my_add
Notification.remove = my_remove
if hal_present == 1:
# Add an probe.user.error pin
probe_user_comp = hal.component("probe.user")
probe_user_comp.newpin("error", hal.HAL_BIT, hal.HAL_OUT)
probe_user_comp.ready()