How to specify a deadband (VBA, OPC UA)
From OPC Labs Knowledge Base
Below is a piece of code that shows how to specify an absolute deadband within MonitoringParameters (if you like, you can create different MonitoringParameters objects with different deadband for each item, too). Note that you can also specify UADeadbandType_Percent; we haven’t shown that in our example, because the sample server we are connecting to it does not support it, at least not on the nodes used in the example.
Private Sub SubscribeCommandButton_Click()
' Create the EasyOPC-UA component
Set Client = New EasyUAClient
Dim MonitoringParameters As New UAMonitoringParameters
MonitoringParameters.SamplingInterval = 1000
' Filter numerical data changes using an absolute deadband of 5.0
Dim DataChangeFilter As New UADataChangeFilter
DataChangeFilter.DeadbandType = UADeadbandType_Absolute
DataChangeFilter.DeadbandValue = 5#
Set MonitoringParameters.DataChangeFilter = DataChangeFilter
' Define OPC node IDs
' For "states", we use names of cells where the values should be updated
Dim MonitoredItemArguments1: Set MonitoredItemArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments")
MonitoredItemArguments1.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
MonitoredItemArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/;i=10845"
Set MonitoredItemArguments1.MonitoringParameters = MonitoringParameters
MonitoredItemArguments1.State = "D2"
Dim MonitoredItemArguments2: Set MonitoredItemArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments")
MonitoredItemArguments2.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
MonitoredItemArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/;i=10853"
Set MonitoredItemArguments2.MonitoringParameters = MonitoringParameters
MonitoredItemArguments2.State = "D3"
Dim MonitoredItemArguments3: Set MonitoredItemArguments3 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments")
MonitoredItemArguments3.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
MonitoredItemArguments3.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/;i=10855"
Set MonitoredItemArguments3.MonitoringParameters = MonitoringParameters
MonitoredItemArguments3.State = "D4"
Dim arguments(2)
Set arguments(0) = MonitoredItemArguments1
Set arguments(1) = MonitoredItemArguments2
Set arguments(2) = MonitoredItemArguments3
' Subscribe to OPC monitored items
Call Client.SubscribeMultipleMonitoredItems(arguments)
End Sub