I only looked at UpdateOEETag_Script here is what I see.
Don't do this:
sys.exit()
You can unpack pyDataSets so your for loop can be written as:
for machineName,zoneName,lineId,facilityName,attachedTo in allShifts:
If you do that, then there is no need for the if statement prior to the loop, if allShifts is empty, it just wont run. So remove:
if(len(allShifts) > 0):
What is the point of the try: except:
block in the for loop if you're not going to log an issue? Also, I really don't think that you need it here, but since you're calling external functions perhaps you do?
This:
if (len(result) > 0):
Should be written as
if result:
You've already set count to 0 so there is not need for the else in this if statement, but meh...
I don't know what you're doing in the HistorianData
functions but you are calling getOeewithZone()
and getUnattendedDT()
multiple times, perhaps seeing the code for those functions we could provide some more insight.
I would certainly combine all of your tag writes into a single function call, and remove the unneeded string conversions.
Something like:
tags = ['OEE','Availablity','Downtime','GoodCount','Performance','Quality','Runtime','Scrap','UnattendedDT','IsHoliday','Department']
tagPaths = ['{0}{1}/{2}/{3}'.format(machineOEEPath,facilityName,machineName,tag) for tag in tags]
tagValues = [oee,availability,totalDownTime,goodCount,performance,quality,runTime,scrapCount,count,Holiday,attachedTo]
system.tag.writeAsync(tagPaths,tagValues)
You're collecting error info to log, but then not actually logging it in you're final except block.
There is also potentially a typo in one of your tag paths. You have 'UnattendentDT'
but I think you might mean 'UnattendedDT'
?