Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions asyncua/common/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,46 @@ async def read_raw_history(self, starttime=None, endtime=None, numvalues=0, retu
break

return history

async def read_processed_history(self, aggregate_type, aggregation_configuration, starttime=None, endtime=None, processing_interval=60000):
"""
Read processed history of a node
result code from server is checked and an exception is raised in case of error
exemples of values for the arguments :
aggregate_type = [2000] //with 2000 is the 'average' nodeId in the opc ua server.
aggregation_configuration = 948
"""

details = ua.ReadProcessedDetails()
details.AggregateConfiguration = ua.AggregateConfiguration(aggregation_configuration)
details.ProcessingInterval = processing_interval
d0 = []
for i in aggregate_type :
d0.append(ua.NodeId(i))
details.AggregateType =d0

if starttime:
details.StartTime = starttime
else:
details.StartTime = ua.get_win_epoch()
if endtime:
details.EndTime = endtime
else:
details.EndTime = ua.get_win_epoch()

history = []
continuation_point = None
while True:
result = await self.history_read(details, continuation_point)
result.StatusCode.check()
continuation_point = result.ContinuationPoint
history.extend(result.HistoryData.DataValues)
# No more data available
if continuation_point is None:
break

return history


async def history_read(self, details, continuation_point=None):
"""
Expand Down