I am trying to calculate an hourly average from one historical tag (Outlet Temp) and display it with another tag (Outlet Temp Avg). This is the code that I entered in the script console, and it worked:
def HourAverage(x):
endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -60)
dataSet = system.tag.queryTagCalculations(paths=, startDate=startTime, endDate=endTime, returnSize=1, calculations=[“Average”], returnFormat=‘Wide’)
return dataSet.getValueAt(0,1)
HourAverage(“Outlet Temp”)
Now, this is the code I entered into my global script, identical to the script console:
def HourAverage(x):
endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -60)
dataSet = system.tag.queryTagCalculations(paths=, startDate=startTime, endDate=endTime, returnSize=1, calculations=[“Average”,“Maximum”], returnFormat=‘Wide’)
return dataSet.getValueAt(0,1)
And this is the Outlet Temp Average expression binding:
runScript(“shared.HourAverage”,0,“Outlet Temp”)
I am getting confirmation that both the script console and the tag expression are returning 1x2 arrays, and that both of the (0,0) values are the same “Outlet Temp”. However, the script console and tag expression differ in the (0,1) position, where the tag expression returns a null value. Any ideas of what’s going wrong?