OPC client and subscriber development in C#
QuickOPC makes it easy for you to integrate OPC client functionality into your Visual C# solution. Reading a value from OPC Unified Architecture or OPC Data Access server, or writing a data value can be achieved in just one or two lines of code. You can also set up subscriptions and receive event notifications about data changes. What's more, in your OPC C# program, connections to OPC servers do not have to be created and recreated in case of a network failure or similar problems - QuickOPC handles this automatically, behind the scenes.
Component interfaces hide the complexities of OPC, are designed specifically with Microsoft .NET and C# developer in mind, making you feel right at home when referencing and using them.
The components can be used from various environments: Windows Forms, ASP.NET pages, console applications, Windows services, and WPF applications are all supported. The C# development tools we have targeted primarily is Visual Studio or VS Code.
- QuickOPC also supports OPC UA Alarms&Conditions.
Note: For OPC server development in C#, see OPC Wizard instead.
Simple OPC UA C# Example Using QuickOPC
The code below (in C#) reads and displays a monitored item value, using QuickOPC:
// Obtain value of a node and display it in a message box
MessageBox.Show(EasyUAClient.SharedInstance.ReadValue(
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
"nsu=http://test.org/UA/Data/;i=10853").ToString());
The code below subscribes to changes of a monitored item value, and displays the value with each change:
// The callback is a lambda expression that displays the value
EasyUAClient.SharedInstance.SubscribeDataChange(
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853", 1000,
(_, args) => Console.WriteLine(args.AttributeData.Value));
OPC UA PubSub
The PubSub variety of OPC UA (as opposed to client-server) uses message-oriented middleware to deliver the data. QuickOPC supports it as well, as shown in the example below.
// The callback displays information about the dataset message received.
EasyUASubscriber.SharedInstance.SubscribeDataSet(
"opc.udp://239.0.0.1",
(_, args) => Console.WriteLine(args.DataSetData));
OPC Data Access "Classic"
The code below (in C# language) connects to an OPC server, and reads and displays an item value, using the QuickOPC component.
// Read item value and display it in a message box
MessageBox.Show(EasyDAClient.SharedInstance.ReadItemValue(
"", "OPCLabs.KitServer.2", "Demo.Single").ToString());
The code below subscribes to changes of an item, and displays the value with each change:
// The callback is a lambda expression that displays the value
EasyDAClient.SharedInstance.SubscribeItem(
"", "OPCLabs.KitServer.2", "Demo.Single", 1000,
(_, args) => Console.WriteLine(args.Vtq.Value));
No other product can do this in such a clear and concise code, in a single statement! The programming is straightforward, and the developer can focus on getting the work done and not on fighting the intricacies of OPC protocols.
The same code simplicity is maintained in other programming languages. Here are the corresponding examples in Visual Basic (VB.NET).
Useful links: C# Examples / C# in Knowledge Base / C# examples GitHub repository
Testimonial
I came across QuickOPC.net when undertaking a c# project that needed to access data in a Siemens PLC using OPC. Having used the free trial version, it quickly became clear that QuickOPC.net would remove the need for an in-depth knowledge of OPC client to server protocols and would allow me to concentrate on the application itself. It is very robust, easy to integrate into a .net project and the response to my questions by email was excellent. I'd certain only recommend the product and the company.
Peter Thomas, Control Specialists Ltd
