QuickOPC User's Guide and Reference
PullItemChangedQueueCapacity Property (IEasyDAClient)
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClient Interface : PullItemChangedQueueCapacity Property
Capacity of the event pull queue for item changes.
Syntax
'Declaration
 
<DataMemberAttribute()>
Property PullItemChangedQueueCapacity As Integer
'Usage
 
Dim instance As IEasyDAClient
Dim value As Integer
 
instance.PullItemChangedQueueCapacity = value
 
value = instance.PullItemChangedQueueCapacity
[DataMember()]
int PullItemChangedQueueCapacity {get; set;}
[DataMember()]
property int PullItemChangedQueueCapacity {
   int get();
   void set (    int value);
}
Example
// This example shows how to subscribe to item changes and obtain the events by pulling them.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    class PullItemChanged
    {
        public static void Main1()
        {
            // Instantiate the client object.
            // In order to use event pull, you must set a non-zero queue capacity upfront.
            var client = new EasyDAClient { PullItemChangedQueueCapacity = 1000 };

            Console.WriteLine("Subscribing item changes...");
            client.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000);

            Console.WriteLine("Processing item changes for 1 minute...");
            int endTick = Environment.TickCount + 60 * 1000;
            do
            {
                EasyDAItemChangedEventArgs eventArgs = client.PullItemChanged(2 * 1000);
                if (!(eventArgs is null))
                    // Handle the notification event
                    Console.WriteLine(eventArgs);
            } while (Environment.TickCount < endTick);

            Console.WriteLine("Unsubscribing item changes...");
            client.UnsubscribeAllItems();

            Console.WriteLine("Finished.");
        }
    }
}
# This example shows how to subscribe to item changes and obtain the events by pulling them.

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.DataAccess

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Assemblies/net47/OpcLabs.EasyOpcClassic.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient
# In order to use event pull, you must set a non-zero queue capacity upfront.
$client.PullItemChangedQueueCapacity = 1000

Write-Host "Subscribing item..."
[IEasyDAClientExtension]::SubscribeItem($client, "", "OPCLabs.KitServer.2", "Simulation.Random", 1000)

Write-Host "Processing item changes for 1 minute..."
$stopwatch =  [System.Diagnostics.Stopwatch]::StartNew() 
while ($stopwatch.Elapsed.TotalSeconds -lt 60) {    
    $eventArgs = [IEasyDAClientExtension]::PullItemChanged($client, 2*1000)
    if ($eventArgs -ne $null) {
        # Handle the notification event
        Write-Host $eventArgs
    }
}

Write-Host "Unsubscribing items..."
$client.UnsubscribeAllItems()

Write-Host "Finished."
Rem This example shows how to get value of multiple OPC properties.
Rem
Rem Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
Rem case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run
Rem IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your
Rem code may also subscribe to the items in order to assure that they remain active.

Private Sub GetMultiplePropertyValues_Main_Command_Click()
    OutputText = ""
    
    ' Get the values of Timestamp and AccessRights properties of two items.

    Dim propertyArguments1 As New DAPropertyArguments
    propertyArguments1.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments1.nodeDescriptor.itemId = "Simulation.Random"
    propertyArguments1.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_Timestamp
    
    Dim propertyArguments2 As New DAPropertyArguments
    propertyArguments2.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments2.nodeDescriptor.itemId = "Simulation.Random"
    propertyArguments2.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_AccessRights
    
    Dim propertyArguments3 As New DAPropertyArguments
    propertyArguments3.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments3.nodeDescriptor.itemId = "Trends.Ramp (1 min)"
    propertyArguments3.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_Timestamp
    
    Dim propertyArguments4 As New DAPropertyArguments
    propertyArguments4.serverDescriptor.ServerClass = "OPCLabs.KitServer.2"
    propertyArguments4.nodeDescriptor.itemId = "Trends.Ramp (1 min)"
    propertyArguments4.PropertyDescriptor.propertyId.NumericalValue = DAPropertyIds_AccessRights
    
    Dim arguments(3) As Variant
    Set arguments(0) = propertyArguments1
    Set arguments(1) = propertyArguments2
    Set arguments(2) = propertyArguments3
    Set arguments(3) = propertyArguments4

    ' Instantiate the client object
    Dim client As New EasyDAClient

    ' Obtain values. By default, the Value attributes of the nodes will be read.
    Dim results() As Variant
    results = client.GetMultiplePropertyValues(arguments)

    ' Display results
    Dim i: For i = LBound(results) To UBound(results)
        Dim valueResult As valueResult: Set valueResult = results(i)
        ' Check if there has been an error getting the property value
        If Not valueResult.Exception Is Nothing Then
            OutputText = OutputText & arguments(i).nodeDescriptor.NodeId & " *** Failure: " & valueResult.Exception.Message & vbCrLf
        Else
            OutputText = OutputText & "results(" & i & ").Value: " & valueResult.value & vbCrLf
        End If
    Next
End Sub
Rem This example shows how to get value of multiple OPC properties, and handle errors.
Rem
Rem Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
Rem case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
Rem IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your 
Rem code may also subscribe to the items in order to assure that they remain active.

Option Explicit

Const Timestamp = 4
Const AccessRights = 5

' Get the values of Timestamp and AccessRights properties of two items.

Dim PropertyArguments1: Set PropertyArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments1.NodeDescriptor.ItemID = "Simulation.Random"
PropertyArguments1.PropertyDescriptor.PropertyID.NumericalValue = Timestamp

Dim PropertyArguments2: Set PropertyArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments2.NodeDescriptor.ItemID = "Simulation.Random"
PropertyArguments2.PropertyDescriptor.PropertyID.NumericalValue = AccessRights

Dim PropertyArguments3: Set PropertyArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments3.NodeDescriptor.ItemID = "Trends.Ramp (1 min)"
PropertyArguments3.PropertyDescriptor.PropertyID.NumericalValue = Timestamp

Dim PropertyArguments4: Set PropertyArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAPropertyArguments")
PropertyArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
PropertyArguments4.NodeDescriptor.ItemID = "Trends.Ramp (1 min)"
PropertyArguments4.PropertyDescriptor.PropertyID.NumericalValue = AccessRights

Dim arguments(3)
Set arguments(0) = PropertyArguments1
Set arguments(1) = PropertyArguments2
Set arguments(2) = PropertyArguments3
Set arguments(3) = PropertyArguments4

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim results: results = Client.GetMultiplePropertyValues(arguments)

Dim i: For i = LBound(results) To UBound(results)
    If results(i).Exception Is Nothing Then 
        WScript.Echo "results(" & i & ").Value: " & results(i).Value
    Else
        WScript.Echo "results(" & i & ").Exception.Message: " & results(i).Exception.Message
    End If
Next
' This example shows how to subscribe to item changes and obtain the events by pulling them.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DocExamples.DataAccess._EasyDAClient
    Partial Friend Class PullItemChanged
        Public Shared Sub Main1()
            Dim client = New EasyDAClient()
            ' In order to use event pull, you must set a non-zero queue capacity upfront.
            client.PullItemChangedQueueCapacity = 1000

            Console.WriteLine("Subscribing item changes...")
            client.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000)

            Console.WriteLine("Processing item changes for 1 minute...")
            Dim endTick As Integer = Environment.TickCount + 60 * 1000
            Do
                Dim eventArgs As EasyDAItemChangedEventArgs = client.PullItemChanged(2 * 1000)
                If Not eventArgs Is Nothing Then
                    ' Handle the notification event
                    Console.WriteLine(eventArgs)
                End If
            Loop While Environment.TickCount < endTick

            Console.WriteLine("Unsubscribing item changes...")
            client.UnsubscribeAllItems()

            Console.WriteLine("Finished.")
        End Sub
    End Class
End Namespace
# This example shows how to subscribe to changes of multiple items and obtain the item changed events by pulling them.

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.DataAccess
using namespace OpcLabs.EasyOpc.DataAccess.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Assemblies/net47/OpcLabs.EasyOpcClassic.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient
# In order to use event pull, you must set a non-zero queue capacity upfront.
$client.PullItemChangedQueueCapacity = 1000

Write-Host "Subscribing item changes..."
$handleArray = [OpcLabs.EasyOpc.DataAccess.IEasyDAClientExtension]::SubscribeMultipleItems($client, @(
    (New-Object DAItemGroupArguments("", "OPCLabs.KitServer.2", "Simulation.Random", 1000, $null)),
    (New-Object DAItemGroupArguments("", "OPCLabs.KitServer.2", "Trends.Ramp (1 min)", 1000, $null)),
    (New-Object DAItemGroupArguments("", "OPCLabs.KitServer.2", "Trends.Sine (1 min)", 1000, $null)),
    # Intentionally specifying an unknown item here, to demonstrate its behavior.
    (New-Object DAItemGroupArguments("", "OPCLabs.KitServer.2", "SomeUnknownItem", 1000, $null))
    ))

Write-Host "Processing item changes for 1 minute..."
$stopwatch =  [System.Diagnostics.Stopwatch]::StartNew() 
while ($stopwatch.Elapsed.TotalSeconds -lt 60) {    
    $eventArgs = [IEasyDAClientExtension]::PullItemChanged($client, 2*1000)
    if ($eventArgs -ne $null) {
        # Handle the notification event
        if ($eventArgs.Succeeded) {
            Write-Host "$($eventArgs.Arguments.ItemDescriptor.ItemId): $($eventArgs.Vtq)"
        }
        else {
            Write-Host "$($eventArgs.Arguments.ItemDescriptor.ItemId) *** Failure: $($eventArgs.ErrorMessageBrief)"
        }
    }
}

Write-Host "Unsubscribing item changes..."
$client.UnsubscribeAllItems()

Write-Host "Finished."
// This example shows how to subscribe to OPC XML-DA item changes and obtain the events by pulling them.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.DataAccess.Xml
{
    class PullItemChanged
    {
        public static void Main1Xml()
        {
            // Instantiate the client object.
            // In order to use event pull, you must set a non-zero queue capacity upfront.
            var client = new EasyDAClient { PullItemChangedQueueCapacity = 1000 };

            Console.WriteLine("Subscribing item changes...");
            client.SubscribeItem(
                "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx",
                "Dynamic/Analog Types/Int",
                1000,
                state: null);

            Console.WriteLine("Processing item changes for 1 minute...");
            int endTick = Environment.TickCount + 60 * 1000;
            do
            {
                EasyDAItemChangedEventArgs eventArgs = client.PullItemChanged(2 * 1000);
                if (!(eventArgs is null))
                    // Handle the notification event
                    Console.WriteLine(eventArgs);
            } while (Environment.TickCount < endTick);

            Console.WriteLine("Unsubscribing item changes...");
            client.UnsubscribeAllItems();

            Console.WriteLine("Finished.");
        }
    }
}
' This example shows how to subscribe to OPC XML-DA item changes and obtain the events by pulling them.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel

Namespace DocExamples.DataAccess.Xml
    Partial Friend Class PullItemChanged
        Public Shared Sub Main1Xml()
            ' In order to use event pull, you must set a non-zero queue capacity upfront.
            Dim client = New EasyDAClient() With {.PullItemChangedQueueCapacity = 1000}

            Console.WriteLine("Subscribing item changes...")
            client.SubscribeItem(
                    "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx",
                    "Dynamic/Analog Types/Int",
                    1000,
                    state:=Nothing)

            Console.WriteLine("Processing item changes for 1 minute...")
            Dim endTick As Integer = Environment.TickCount + 60 * 1000
            Do
                Dim eventArgs As EasyDAItemChangedEventArgs = client.PullItemChanged(2 * 1000)
                If Not eventArgs Is Nothing Then
                    ' Handle the notification event
                    Console.WriteLine(eventArgs)
                End If
            Loop While Environment.TickCount < endTick

            Console.WriteLine("Unsubscribing item changes...")
            client.UnsubscribeAllItems()

            Console.WriteLine("Finished.")
        End Sub
    End Class
End Namespace
Requirements

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

See Also

Reference

IEasyDAClient Interface
IEasyDAClient Members