QuickOPC User's Guide and Reference
PullItemChanged Method (IEasyDAClientExtension)
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class : PullItemChanged Method
The client object that will perform the operation.
The number of milliseconds to wait, or System.Threading.Timeout.Infinite (-1) to wait indefinitely.
Attempts to pull an OPC item change subscribed to by the SubscribeMultipleItems or SubscribeItem method.
Syntax
'Declaration
 
<ExtensionAttribute()>
<CanBeNullAttribute()>
Public Shared Function PullItemChanged( _
   ByVal client As IEasyDAClient, _
   ByVal millisecondsTimeout As Integer _
) As EasyDAItemChangedEventArgs
'Usage
 
Dim client As IEasyDAClient
Dim millisecondsTimeout As Integer
Dim value As EasyDAItemChangedEventArgs
 
value = IEasyDAClientExtension.PullItemChanged(client, millisecondsTimeout)
[Extension()]
[CanBeNull()]
public static EasyDAItemChangedEventArgs PullItemChanged( 
   IEasyDAClient client,
   int millisecondsTimeout
)
[Extension()]
[CanBeNull()]
public:
static EasyDAItemChangedEventArgs^ PullItemChanged( 
   IEasyDAClient^ client,
   int millisecondsTimeout
) 

Parameters

client
The client object that will perform the operation.
millisecondsTimeout
The number of milliseconds to wait, or System.Threading.Timeout.Infinite (-1) to wait indefinitely.

Return Value

The event arguments, or null if no event is available within the specified time.
Exceptions
ExceptionDescription
One of the arguments provided to a method is not valid.
The value of an argument is outside the allowable range of values as defined by the invoked method.
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."
' 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

IEasyDAClientExtension Class
IEasyDAClientExtension Members