Skip to content

Commit

Permalink
Add Filter Result property to monitored item status (#2219)
Browse files Browse the repository at this point in the history
Adds a property to the monitored item status to expose the filter result returned from the server.
  • Loading branch information
marcschier committed Jul 14, 2023
1 parent 17d4f04 commit d99c4bc
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Libraries/Opc.Ua.Client/MonitoredItemStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
Expand All @@ -11,7 +11,7 @@
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Expand Down Expand Up @@ -56,6 +56,7 @@ private void Initialize()
m_clientHandle = 0;
m_samplingInterval = 0;
m_filter = null;
m_filterResult = null;
m_queueSize = 0;
m_discardOldest = true;
}
Expand Down Expand Up @@ -117,6 +118,11 @@ private void Initialize()
/// </summary>
public MonitoringFilter Filter => m_filter;

/// <summary>
/// The result of applying the filter
/// </summary>
public MonitoringFilterResult FilterResult => m_filterResult;

/// <summary>
/// The length of the queue used to buffer values.
/// </summary>
Expand Down Expand Up @@ -168,6 +174,7 @@ public void SetMonitoringMode(MonitoringMode monitoringMode)
m_queueSize = request.RequestedParameters.QueueSize;
m_discardOldest = request.RequestedParameters.DiscardOldest;
m_filter = null;
m_filterResult = null;
m_error = error;

if (request.RequestedParameters.Filter != null)
Expand All @@ -180,6 +187,11 @@ public void SetMonitoringMode(MonitoringMode monitoringMode)
m_id = result.MonitoredItemId;
m_samplingInterval = result.RevisedSamplingInterval;
m_queueSize = result.RevisedQueueSize;

if (result.FilterResult != null)
{
m_filterResult = Utils.Clone(result.FilterResult.Body) as MonitoringFilterResult;
}
}
}

Expand All @@ -200,6 +212,7 @@ internal void SetTransferResult(MonitoredItem monitoredItem)
m_queueSize = monitoredItem.QueueSize;
m_discardOldest = monitoredItem.DiscardOldest;
m_filter = null;
m_filterResult = null;

if (monitoredItem.Filter != null)
{
Expand Down Expand Up @@ -227,6 +240,7 @@ internal void SetTransferResult(MonitoredItem monitoredItem)
m_queueSize = request.RequestedParameters.QueueSize;
m_discardOldest = request.RequestedParameters.DiscardOldest;
m_filter = null;
m_filterResult = null;

if (request.RequestedParameters.Filter != null)
{
Expand All @@ -235,6 +249,11 @@ internal void SetTransferResult(MonitoredItem monitoredItem)

m_samplingInterval = result.RevisedSamplingInterval;
m_queueSize = result.RevisedQueueSize;

if (result.FilterResult != null)
{
m_filterResult = Utils.Clone(result.FilterResult.Body) as MonitoringFilterResult;
}
}
}

Expand Down Expand Up @@ -267,6 +286,7 @@ internal void SetError(ServiceResult error)
private uint m_clientHandle;
private double m_samplingInterval;
private MonitoringFilter m_filter;
private MonitoringFilterResult m_filterResult;
private uint m_queueSize;
private bool m_discardOldest;
#endregion
Expand Down

0 comments on commit d99c4bc

Please sign in to comment.