OPC Studio User's Guide and Reference
MaximumAge Property (_UAReadParameters)
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.ComTypes Namespace > _UAReadParameters Interface : MaximumAge Property
Maximum age of the value to be read (in milliseconds). Use OpcLabs.EasyOpc.UA.UAReadParameters.CacheMaximumAge to read from the cache.
Syntax
'Declaration
 
Property MaximumAge As Double
'Usage
 
Dim instance As _UAReadParameters
Dim value As Double
 
instance.MaximumAge = value
 
value = instance.MaximumAge
double MaximumAge {get; set;}
property double MaximumAge {
   double get();
   void set (    double value);
}

Property Value

Unit of measurement is ms.

The default value of this property is 2147483647.

Returns the maximum age (in milliseconds).
Exceptions
ExceptionDescription

The value of an argument is outside the allowable range of values as defined by the invoked method.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

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 (OpcLabs.EasyOpc.UA.UAReadParameters.CacheMaximumAge constant).

This member or type is for use from COM. It is not meant to be used from .NET or Python. Refer to the corresponding .NET member or type instead, if you are developing in .NET or Python.

Example
Rem This example shows how to read 3 values (without status or timestamps) at once, from the device (data source).
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

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