QuickOPC User's Guide and Reference
MaximumAge Property (UAReadParameters)
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA Namespace > UAReadParameters Class : MaximumAge Property
Maximum age of the value to be read (in milliseconds). Use CacheMaximumAge to read from the cache.
Syntax
'Declaration
 
<DefaultValueAttribute(2147483647)>
<UnitAttribute("ms")>
Public Property MaximumAge As Double
'Usage
 
Dim instance As UAReadParameters
Dim value As Double
 
instance.MaximumAge = value
 
value = instance.MaximumAge
[DefaultValue(2147483647)]
[Unit("ms")]
public double MaximumAge {get; set;}
[DefaultValue(2147483647)]
[Unit("ms")]
public:
property double MaximumAge {
   double get();
   void set (    double value);
}

Property Value

Returns the maximum age (in milliseconds).
Remarks

This property corresponds to the maxAge parameter in the OPC UA Read Service request.

"Maximum age of the value to be read in milliseconds. The age of the value is based on the difference between the ServerTimestamp and the time when the Server starts processing the request. For example if the Client specifies a maxAge of 500 milliseconds and it takes 100 milliseconds until the Server starts processing the request, the age of the returned value could be 600 milliseconds prior to the time it was requested.
If the Server has one or more values of an Attribute that are within the maximum age, it can return any one of the values or it can read a new value from the data source.The number of values of an Attribute that a Server has depends on the number of MonitoredItems that are defined for the Attribute.In any case, the Client can make no assumption about which copy of the data will be returned.
If the Server does not have a value that is within the maximum age, it shall attempt to read a new value from the data source.
If the Server cannot meet the requested maxAge, it returns its “best effort” value rather than rejecting the request.This may occur when the time it takes the Server to process and return the new data value after it has been accessed is greater than the specified maximum age.
If maxAge is set to 0, the Server shall attempt to read a new value from the data source.
If maxAge is set to the max Int32 value or greater, the Server shall attempt to get a cached value.
Negative values are invalid for maxAge."

As opposed to the OPC UA Read Service, you cannot use values greater than System.Int32.MaxValue. Reading from the cache is specified by using System.Int32.MaxValue precisely (CacheMaximumAge constant).

Example

COM

Rem This example shows how to read 3 values (without status or timestamps) at once, from the device (data source).

Option Explicit

' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")

Dim ReadArguments1: Set ReadArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments1.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845"
ReadArguments1.ReadParameters.MaximumAge = 0.0

Dim ReadArguments2: Set ReadArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments2.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853"
ReadArguments2.ReadParameters.MaximumAge = 0.0

Dim ReadArguments3: Set ReadArguments3 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments3.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments3.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10855"
ReadArguments3.ReadParameters.MaximumAge = 0.0

Dim arguments(2)
Set arguments(0) = ReadArguments1
Set arguments(1) = ReadArguments2
Set arguments(2) = ReadArguments3

' Obtain values. By default, the Value attributes of the nodes will be read.
Dim results: results = Client.ReadMultipleValues(arguments)

' Display results
Dim i: For i = LBound(results) To UBound(results)
    Dim ValueResult: Set ValueResult = results(i)
    If ValueResult.Succeeded Then
        WScript.Echo "Value: " & ValueResult.Value
    Else
        WScript.Echo "*** Failure: " & ValueResult.ErrorMessageBrief
    End If
Next

' Example output:
'
'Value: 8
'Value: -8.06803E+21
'Value: Strawberry Pig Banana Snake Mango Purple Grape Monkey Purple? Blueberry Lemon^            
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also