OPCDA.NET Client Component
Data Binding Subscriptions
OPCDA.NET version 4 added support for Data Binding Subscriptions that transfer item values directly into properties of application objects. If an object is a Windows control then the item values are displayed without need for any user callback handlers. Server items bound to a property of any class cause the property Set accessor to be executed as the callback handler.
The application shown below in code and in a screenshot displays and updates the OPC server item values, with only the few lines of VB.NET code. No other OPC related code is required.
This simplicity does not come at the cost of performance or flexibilty. OPCDA.NET is structured into layers and the multi-threaded implementation allows the user application to access all layers. While the data binding subscriptions handle some items, the application can access these or other items synchronously or asynchronously and execute any other OPC server functions. Multiple OPC servers can be simultanously accessed by instantiating multiple access objects.
|
Private Sub btnConnect_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnConnect.Click
ListView1.Items.Clear()
ListView1.Items.Add("")
ListView1.Items.Add("")
Try
tbStatus.Text = "Connected"
OpcBind = New OpcDataBind(Me, cbOPCServers.Text)
OpcBind.Subscribe("SimulatedData.Signal", CheckBox1)
OpcBind.Subscribe("SimulatedData.Ramp", ProgressBar1)
OpcBind.Subscribe("Dynamic.Analog Types.Double[]", _
ListView1.Items(1).SubItems, 0)
Catch ex As OPCException
tbStatus.Text = ex.Message
End Try
End Sub
Private Sub btnDisconnect_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDisconnect.Click
OpcBind.Disconnect()
tbStatus.Text = "Disconnected"
End Sub |
The OPCDA.NET DataBind Subscriptions handle data type conversions, value transformations and formatting according the property data type and the subscription definitions. Properties of data type DataBindEventData get all callback item data including quality and timestamp.
The following Windows control objects are handled specially to even further simplify usage:
The following screenshot shows the provided sample application that updates simple and array item values in many different types of controls.
The user can control how the items values are displayed by assigning a formatting object to the subscription. Formatting includes features such as:
|