The simplest (although not very realistic) example is on our Web page:
www.opclabs.com/products/quickopc/languages-and-tools/csharp .
Better examples: open the solution with C# Examples (from the Start menu), then look into the Console/DocExamples project. You will find there e.g. following examples:
1.
// This example shows how subscribe to changes of multiple items and display the value of the item with each change,
// using a callback method specified using lambda expression.
using System.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using System;
using System.Threading;
namespace DocExamples
{
namespace _EasyDAClient
{
class SubscribeItem
{
public static void CallbackLambda()
{
// Instantiate the client object
var easyDAClient = new EasyDAClient();
Console.WriteLine("Subscribing...");
// The callback is a lambda expression the displays the value
easyDAClient.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000,
(sender, eventArgs) =>
{
Debug.Assert(eventArgs != null);
if (eventArgs.Exception != null)
Console.WriteLine(eventArgs.Exception.ToString());
else
{
Debug.Assert(eventArgs.Vtq != null);
Console.WriteLine(eventArgs.Vtq.ToString());
}
});
Console.WriteLine("Processing item changed events for 10 seconds...");
Thread.Sleep(10 * 1000);
Console.WriteLine("Unsubscribing...");
easyDAClient.UnsubscribeAllItems();
Console.WriteLine("Waiting for 2 seconds...");
Thread.Sleep(2 * 1000);
}
}
}
}
2.
// This example shows how subscribe to changes of multiple items and display the value of the item with each change.
using JetBrains.Annotations;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;
using System;
using System.Threading;
namespace DocExamples
{
namespace _EasyDAClient
{
partial class SubscribeMultipleItems
{
public static void Main()
{
using (var easyDAClient = new EasyDAClient())
{
easyDAClient.ItemChanged += easyDAClient_ItemChanged;
easyDAClient.SubscribeMultipleItems(
new[] {
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Simulation.Random", 1000, null),
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Trends.Ramp (1 min)", 1000, null),
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Trends.Sine (1 min)", 1000, null),
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 1000, null)
});
Console.WriteLine("Processing item changed events for 1 minute...");
Thread.Sleep(60 * 1000);
}
}
// Item changed event handler
static void easyDAClient_ItemChanged([NotNull] object sender, [NotNull] EasyDAItemChangedEventArgs e)
{
Console.WriteLine("{0}: {1}", e.Arguments.ItemDescriptor.ItemId, e.Vtq);
}
}
}
}
If you are more interested in code in some more specialized environment (such as Windows Forms - showing data as values of texboxes etc.), we have such examples as well - let me know.
Best regards