-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGage_Scanner_Scan_String.py
More file actions
43 lines (34 loc) · 1.88 KB
/
Gage_Scanner_Scan_String.py
File metadata and controls
43 lines (34 loc) · 1.88 KB
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
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
"""
Fired whenever the current value changes in value or quality.
Arguments:
tag: The source tag object. A read-only wrapper for obtaining tag
properties.
tagPath: The full path to the tag (String)
previousValue: The previous value. This is a "qualified value", so it
has value, quality, and timestamp properties.
currentValue: The current value. This is a "qualified value", so it has
value, quality, and timestamp properties.
initialChange: A boolean flag indicating whether this event is due to
the first execution or initial subscription.
missedEvents: A flag indicating that some events have been skipped due
to event overflow.
"""
try:
if currentValue.value is None: # Sometimes currentValue is None, like when the Gage is turned off or perhaps in some other offline-like state
quit()
# =========== WILL'S VANILLA CODE start ==============================================
if currentValue.value[0:3] == "<u>":
system.tag.write("[.]User",currentValue.value[3:7])
elif len(currentValue.value) == 12: # if a WIP Tag was scanned
gageLock = system.tag.readBlocking(['[.]../MES/MES Control Hold'])
gageLock = str(gageLock[0].value)
if gageLock.upper() == 'True'.upper():
quit() # Block or quit() the scanning of a WIP Tag when the Gage is locked
system.tag.write("[.]Active Wip",currentValue.value)
# =========== WILL'S VANILLA CODE end ==============================================
except Exception as e:
eParams = {'msgID':'valueChanged err', # + system.tag.readBlocking(['[.]../Gage/Gage Name'])[0].value,
'message':getattr(e, 'message', repr(e)),
'msgSource':'UDT_Tag/Gage/Scanner/Scan String.valueChanged. . . XTA9ZQ'}
system.db.runNamedQuery("Gages", "Debug/LogMsg", eParams)