system.tag.queryTagCalculations problem

Hi Guys,

I Have a problem using this command.

In script console i have it working properly.

Using a gateway timer script it fails and says cannot multiply nonetype and float. i have done it right in there plus with the project scoped scripts and changed alot of other things to see if it was not returning any data. it is returning a row but the get value at is not returning a float like it does in the script console so im sure im missing something with the scoping?

Its meant to average the flow rate time weighted so i can calculate a rough strokes count for each day.

it errors out at "e = b * mult" saying it cant multiply nonetype and float in the gloabal timer script but it works in script console.

Blockquote
def yday(fldr, s):
pathx = str(fldr + "/PUMP" + s + "FLOWRATE")
pathy = str(fldr + "/VOL_PER_STROKE
" + s)
pathz = str(fldr + "/PUMP" + s + "_STROKE_YD")
mult = 1000.0
b = 0.0
d = 0.0
a = system.tag.queryTagCalculations(paths=[pathx], calculations=['Average'], rangeHours=24)
if a.rowCount > 0:
b = a.getValueAt(0,1)
e = b * mult
c = system.tag.queryTagCalculations(paths=[pathy], calculations=['Average'], rangeHours=24, noInterpolation=True, ignoreBadQuality=True)
d = c.getValueAt(0,1)
if d < 0.76418:
d = system.tag.read(pathy).value
if d < 0.76418:
d = 0.76418
f = e / d
system.tag.write(pathz, f)

You probably need to add the provider to the tag path when running your script on the gateway. It should be something like [nameOfHistoryProviderHere] added to the beginning of the tag path.

Also, format your code with triple backquotes ``` one set on a line before, and one set on a line after, to preserve the formatting.

2 Likes