// This example shows how change the update rate of an existing subscription.
using System;
using System.Threading;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;
namespace DocExamples.DataAccess._EasyDAClient
{
partial class ChangeItemSubscription
{
public static void Main1()
{
// Instantiate the client object.
using (var client = new EasyDAClient())
{
client.ItemChanged += client_ItemChanged;
Console.WriteLine("Subscribing...");
int handle = client.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000);
Console.WriteLine("Waiting for 10 seconds...");
Thread.Sleep(10 * 1000);
Console.WriteLine("Changing subscription...");
client.ChangeItemSubscription(handle, new DAGroupParameters(100));
Console.WriteLine("Waiting for 10 seconds...");
Thread.Sleep(10 * 1000);
Console.WriteLine("Unsubscribing...");
client.UnsubscribeAllItems();
Console.WriteLine("Waiting for 10 seconds...");
Thread.Sleep(10 * 1000);
}
}
// Item changed event handler
static void client_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
{
if (e.Succeeded)
Console.WriteLine(e.Vtq);
else
Console.WriteLine("*** Failure: {0}", e.ErrorMessageBrief);
}
}
}
' This example shows how change the update rate of an existing subscription.
Imports System.Threading
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel
Namespace DocExamples.DataAccess._EasyDAClient
Partial Friend Class ChangeItemSubscription
Public Shared Sub Main1()
Using client = New EasyDAClient()
AddHandler client.ItemChanged, AddressOf client_ItemChanged
Console.WriteLine("Subscribing...")
Dim handle As Integer = client.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000)
Console.WriteLine("Waiting for 10 seconds...")
Thread.Sleep(10 * 1000)
Console.WriteLine("Changing subscription...")
client.ChangeItemSubscription(handle, New DAGroupParameters(100))
Console.WriteLine("Waiting for 10 seconds...")
Thread.Sleep(10 * 1000)
Console.WriteLine("Unsubscribing...")
client.UnsubscribeAllItems()
Console.WriteLine("Waiting for 10 seconds...")
Thread.Sleep(10 * 1000)
End Using
End Sub
' Item changed event handler
Private Shared Sub client_ItemChanged(ByVal sender As Object, ByVal e As EasyDAItemChangedEventArgs)
If e.Succeeded Then
Console.WriteLine(e.Vtq)
Else
Console.WriteLine("*** Failure: {0}", e.ErrorMessageBrief)
End If
End Sub
End Class
End Namespace