-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStopGageRejectToteMaxed.py
More file actions
64 lines (41 loc) · 1.82 KB
/
Copy pathStopGageRejectToteMaxed.py
File metadata and controls
64 lines (41 loc) · 1.82 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def logDebugMsg(msgID, message, msgSource):
params = {'msgID':msgID,
'message':message,
'msgSource':msgSource}
import system
system.db.runNamedQuery('Gages', 'Debug/LogMsg', params)
def GetGageFromPath(path):
# passed value like [default]G11/G11/Gage/Count/Batch Good Count
# returns 'G11'
try:
pth = path.replace('[default]', '')
pathAry = pth.split('/')
return pathAry[0]
except Exception as e:
errParams = {'msgID':'Gateway Script error',
'message':getattr(e, 'message', repr(e)),
'msgSource':'StopGageRejectToteMaxed.GetGageFromPath GFY8OB'}
system.db.runNamedQuery("Gages", "Debug/LogMsg", errParams)
try:
if (initialChange == 1): # 1 means this script may have been 'saved' and that saving it generated the change event
quit()
GageID = GetGageFromPath(str(event.tagPath))
pathGageID = '[default]' + GageID + '/' + GageID
pathToTag = pathGageID + '/Gage/Count/Batch Target' # [default]G11/G11/Gage/Count/Batch Target
currentVal = event.getValue().value
maxVal = system.tag.readBlocking([pathToTag])[0].value # element [0] is the max value, full batch, full tote
if (currentVal is None): quit()
if strFuncs.isInteger(currentVal) == False: quit()
currentVal = int(currentVal)
if (maxVal is None): quit()
if strFuncs.isInteger(maxVal) == False: quit()
maxVal = int(maxVal / 2)
if currentVal >= maxVal:
path = '[default]' + GageID + '/' + GageID + '/MES/MES Control Hold'
system.tag.writeBlocking([path], [True])
# logDebugMsg('~~~~~', GageID, str(maxVal))
except Exception as e:
eParams = {'msgID':'Gateway Script error',
'message':getattr(e, 'message', repr(e)),
'msgSource':'StopGageRejectToteMaxed CC4P71'}
system.db.runNamedQuery("Gages", "Debug/LogMsg", eParams)