Professional OPC
Development Tools

logos

OPC development in F#

QuickOPC makes it easy for you to integrate OPC client functionality into your Visual F# solution. Reading a value from OPC Data Access or OPC Unified Architecture 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 F# 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 F# developer in mind, making you feel right at home when referencing and using them.

The components can be used from various environments: Code libraries, ASP.NET pages, console applications, Windows services, etc. are all supported. The F# development tool we have targeted primarily is Visual Studio.

  • New: QuickOPC now also supports OPC UA Alarms&Conditions.

Read More 

Simple OPC-UA F# Example Using QuickOPC

The code below (in F#) reads and displays a monitored item value, using QuickOPC:

// Obtain value of a node and display it
let client = new EasyUAClient()
let value = client.ReadValue(
new UAEndpointDescriptor("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"),
new UANodeDescriptor("nsu=http://test.org/UA/Data/;i=10853"))
Console.WriteLine value

The code below subscribes to changes of a monitored item value, and displays the value with each change:

let easyUAClient = new EasyUAClient()
// The callback is a delegate that displays the value
let handle = easyUAClient.SubscribeDataChange(
new UAEndpointDescriptor("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"),
new UANodeDescriptor("nsu=http://test.org/UA/Data/;i=10853"),
1000,
new EasyUADataChangeNotificationEventHandler(
fun sender eventArgs -> Console.WriteLine(eventArgs.AttributeData.Value:obj)))

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.

let subscriber = new EasyUASubscriber()
let pubSubConnectionDescriptor = new UAPubSubConnectionDescriptor()
pubSubConnectionDescriptor.ResourceAddress.ResourceDescriptor.UrlString <- 
    "opc.udp://239.0.0.1"
// The callback displays information about the dataset message received.
subscriber.SubscribeDataSet(
    pubSubConnectionDescriptor,
    new EasyUADataSetMessageEventHandler(
        fun sender eventArgs -> Console.WriteLine(eventArgs.DataSetData)))

OPC "Classic" Data Access, or Alarms&Events

The code below (in F# language) connects to an OPC server, and reads and displays an item value, using QuickOPC.NET component. It works in multiple versions of Microsoft Visual Studio.

// Read item value and display it
let client = new EasyDAClient()
let value = client.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Ramp")
Console.WriteLine value

No other product can do this in such a clear and concise code! The programming is straightforward, and the developer can focus on getting the work done and not on fighting the intricacies of OPC protocols.

Try It

Useful links: Examples / Knowledge Base

 

Footnote & required disclosure: QuickOPC (including its Options) is a software development kit (SDK) for development of OPC clients and subscribers. Installing QuickOPC or its Options does not change system settings.