TestCenter Reference
NotificationCounter.py
Go to the documentation of this file.
1
#
2
# Copyright 2021, MeVis Medical Solutions AG
3
#
4
# The user may use this file in accordance with the license agreement provided with
5
# the Software or, alternatively, in accordance with the terms contained in a
6
# written agreement between the user and MeVis Medical Solutions AG.
7
#
8
# For further information use the contact form at https://www.mevislab.de/contact
9
#
10
11
12
class
NotificationCounter
:
13
def
__init__
(self, ctx, fieldName):
14
self.
counter
= 0
15
self.
validCounter
= 0
16
self.
fieldListener
=
None
17
18
self.
setField
(ctx, fieldName)
19
20
def
reset
(self):
21
self.
counter
= 0
22
self.
validCounter
= 0
23
24
def
setField
(self, ctx, fieldName):
25
if
not
ctx.hasField(fieldName):
26
ctx.log(
"Error: Field '"
+ fieldName +
"' not found in parent network."
)
27
else
:
28
if
self.
fieldListener
is
not
None
:
29
ctx.removeFieldListener(self.
fieldListener
)
30
self.
fieldListener
= ctx.addFieldListener(ctx.field(fieldName), self.
updateCounter
,
False
)
31
32
def
updateCounter
(self, field):
33
self.
counter
+= 1
34
if
callable(getattr(field,
"isValid"
,
None
))
and
field.isValid():
35
self.
validCounter
+= 1
36
37
def
notifications
(self):
38
return
self.
counter
39
40
def
validNotifications
(self):
41
return
self.
validCounter
TestSupport.NotificationCounter.NotificationCounter
Definition
NotificationCounter.py:12
TestSupport.NotificationCounter.NotificationCounter.notifications
notifications(self)
Definition
NotificationCounter.py:37
TestSupport.NotificationCounter.NotificationCounter.validCounter
validCounter
Definition
NotificationCounter.py:15
TestSupport.NotificationCounter.NotificationCounter.updateCounter
updateCounter(self, field)
Definition
NotificationCounter.py:32
TestSupport.NotificationCounter.NotificationCounter.__init__
__init__(self, ctx, fieldName)
Definition
NotificationCounter.py:13
TestSupport.NotificationCounter.NotificationCounter.setField
setField(self, ctx, fieldName)
Definition
NotificationCounter.py:24
TestSupport.NotificationCounter.NotificationCounter.validNotifications
validNotifications(self)
Definition
NotificationCounter.py:40
TestSupport.NotificationCounter.NotificationCounter.reset
reset(self)
Definition
NotificationCounter.py:20
TestSupport.NotificationCounter.NotificationCounter.fieldListener
fieldListener
Definition
NotificationCounter.py:16
TestSupport.NotificationCounter.NotificationCounter.counter
counter
Definition
NotificationCounter.py:14
MeVisLab
Standard
Modules
Scripts
python
TestSupport
NotificationCounter.py
Generated by
1.10.0