Here is the error that is displayed
Error_ScriptEval
Property
root/Chart.series[0].data
Description
Traceback (most recent call last): File "<transform>", line 24, in transform at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source) at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source) at java.base/java.util.Objects.checkIndex(Unknown Source) at java.base/java.util.ArrayList.get(Unknown Source) at com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset.getValueAt(BasicStreamingDataset.java:161) at jdk.internal.reflect.GeneratedMethodAccessor54.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IndexOutOfBoundsException: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
Voici le code
# If timeSelection is 0, set minutes equal to minutes param.
if value['timeSelection'] == 0:
minutes = value['minutes']
else:
# Otherwise, get the amount of minutes based on the
# timeSelection. 1M=1min,1H=60min,1D=1440min,1W=10080min.
minuteMap = {1:1,2:60,3:1440,4:10080}
minutes = minuteMap[value['timeSelection']]
# Query the historical data using now() as the endTime and
# 0 - minutes (figured out minutes above) as the startTime,
# and then put the data in a format expected by the chart
# and return it.
data = []
if value['tag'] != '':
path = value['tag']
system.perspective.print('querying data for: ' + str(path))
endTime = system.date.now()
startTime = system.date.addMinutes(endTime,(0-minutes))
history = system.tag.queryTagHistory(paths=[path],startDate=startTime,endDate=endTime,aggregationMode='LastValue',returnSize=300,noInterpolation=0)
#return history.getValueAt(0,1)
if history.getValueAt(0,1) == None:
return data
else:
for x in range(0,history.getRowCount()):
data.append({'time':system.date.toMillis(history.getValueAt(x,0)),'value':history.getValueAt(x,1)})
return data
I would like this error not to appear when there is no historical data recorded in the database