From 8081ce3a88aa86227e4212a617bf028c1e3a550e Mon Sep 17 00:00:00 2001 From: Kawtar Youssefi Date: Thu, 3 Aug 2023 16:01:49 +0200 Subject: [PATCH 1/4] first commit --- asyncua/common/node.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/asyncua/common/node.py b/asyncua/common/node.py index b8c647620..424445309 100644 --- a/asyncua/common/node.py +++ b/asyncua/common/node.py @@ -553,6 +553,44 @@ async def read_raw_history(self, starttime=None, endtime=None, numvalues=0, retu break return history + + async def read_processed_history(aggregtype, aggregconfig, 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 + """ + + details = ua.ReadProcessedDetails() + details.AggregateConfiguration = ua.AggregateConfiguration(aggregconfig) #depends de l'aggregat à invoquer + details.ProcessingInterval = processing_interval #predefined + d0 = [] + for i in aggregtype : + 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 myvar.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): """ From 6caf8dbda0376698c8c09ec08043b466a5210ead Mon Sep 17 00:00:00 2001 From: kawkawa99 <56658438+kawkawa99@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:23:30 +0200 Subject: [PATCH 2/4] Update node.py --- asyncua/common/node.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/asyncua/common/node.py b/asyncua/common/node.py index 424445309..01648c8a8 100644 --- a/asyncua/common/node.py +++ b/asyncua/common/node.py @@ -554,20 +554,19 @@ async def read_raw_history(self, starttime=None, endtime=None, numvalues=0, retu return history - async def read_processed_history(aggregtype, aggregconfig, starttime=None, endtime=None, processing_interval=60000): + 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(aggregconfig) #depends de l'aggregat à invoquer - details.ProcessingInterval = processing_interval #predefined - d0 = [] - for i in aggregtype : - d0.append(ua.NodeId(i)) - - details.AggregateType =d0 + details.AggregateConfiguration = ua.AggregateConfiguration(aggregation_configuration) + details.ProcessingInterval = processing_interval + details.AggregateType = ua.NodeId(aggregate_type) if starttime: details.StartTime = starttime @@ -581,7 +580,7 @@ async def read_processed_history(aggregtype, aggregconfig, starttime=None, endti history = [] continuation_point = None while True: - result = await myvar.history_read(details, continuation_point) + result = await self.history_read(details, continuation_point) result.StatusCode.check() continuation_point = result.ContinuationPoint history.extend(result.HistoryData.DataValues) From 43f933948222a3925d51ead6145194b8a1028f8c Mon Sep 17 00:00:00 2001 From: kawkawa99 <56658438+kawkawa99@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:33:47 +0200 Subject: [PATCH 3/4] Update node.py --- asyncua/common/node.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/asyncua/common/node.py b/asyncua/common/node.py index 01648c8a8..bbda9e54d 100644 --- a/asyncua/common/node.py +++ b/asyncua/common/node.py @@ -566,7 +566,10 @@ async def read_processed_history(self, aggregate_type, aggregation_configuration details = ua.ReadProcessedDetails() details.AggregateConfiguration = ua.AggregateConfiguration(aggregation_configuration) details.ProcessingInterval = processing_interval - details.AggregateType = ua.NodeId(aggregate_type) + d0 = [] + for i in aggregtype : + d0.append(ua.NodeId(i)) + details.AggregateType =d0 if starttime: details.StartTime = starttime From 1a78dcd418e93058585b494a39031357c6b8c3d8 Mon Sep 17 00:00:00 2001 From: kawkawa99 <56658438+kawkawa99@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:34:33 +0200 Subject: [PATCH 4/4] Update node.py --- asyncua/common/node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asyncua/common/node.py b/asyncua/common/node.py index bbda9e54d..4123f61f7 100644 --- a/asyncua/common/node.py +++ b/asyncua/common/node.py @@ -567,7 +567,7 @@ async def read_processed_history(self, aggregate_type, aggregation_configuration details.AggregateConfiguration = ua.AggregateConfiguration(aggregation_configuration) details.ProcessingInterval = processing_interval d0 = [] - for i in aggregtype : + for i in aggregate_type : d0.append(ua.NodeId(i)) details.AggregateType =d0