system.historian.queryAggregatedPoints
This function is used in Python Scripting.
Description​
Queries aggregated data points for the specified historian.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax​
system.historian.queryAggregatedPoints(paths, startTime, endTime, [aggregates], [fillModes], [columnNames], [returnFormat], [returnSize], [includeBounds], [excludeObservations])
Parameters​
| Type | Parameter | Description |
|---|---|---|
| List | paths | A list of historical paths to query aggregated data points for. |
| Date | startTime | A start time to query aggregated data points for. |
| Date | endTime | An end time to query aggregated data points for. |
| List | aggregates | A list of aggregate functions to apply to the query. [Optional] Available aggregates include:
|
| List | fillModes | A list of fill modes to apply to the query. The fill mode will override the tag's stored interpolation mode at query time. For example, if a tag stores with analog mode (linear), but you want to query as discrete (prev), specify fillModes=['PREV']. This parameter is only functional with the Core Historian and the Internal Historian. [Optional] Available options include:
|
| List | columnNames | A list of alias column names for the returned dataset. [Optional] |
| String | returnFormat | The desired return format for the query. [Optional] Available options include:
|
| Integer | returnSize | The maximum number of results to return. [Optional] |
| Boolean | includeBounds | Whether to include the bounds in the query results. [Optional] |
| Boolean | excludeObservations | Whether to exclude observed aggregated data points in the query results. When applied, observed values, such as periodic samples from Tag Group evaluations will be filtered out, while source values, such as tag changes from devices will remain in the returned dataset. [Optional] |
Returns​
Dataset - A dataset representing the aggregated values for the specified historical paths.
Scope​
Gateway, Vision Client, Perspective Session
Code Examples​
Code Snippet 1
# Query a specified historical simulator tag path and display aggregated data from within the past minute.
end = system.date.now()
start = system.date.addMinutes(end, -1)
myDataset = system.historian.queryAggregatedPoints(["[default]_Simulator_/Random/RandomInteger1"], start, end)
for row in myDataset:
print row[0], row[1]
Code Snippet 2
# Query a specified historical simulator tag path and display the sum of the aggregated data
# from within the past minute in Wide format.
path = ["[default]_Simulator_/Random/RandomInteger1"]
aggregates = ["Sum"]
returnFormat = 'Wide'
fillModes = ['NONE']
returnSize = 1
end = system.date.now()
start = system.date.addMinutes(end, -1)
historyHistorian = system.historian.queryAggregatedPoints(path, start, end, aggregates, returnFormat, returnSize, fillModes)
print(historyHistorian)