XMLDA.NET Sample Application
Visual Basic Windows Forms Application that uses DataBind subscriptions
 |
A CheckBox, a ProgressBar and a ListView are updated with item values from an OPC-DA or XML-DA server. Three DataBind subsriptions are defined. A binary value is assigned to the CheckBox, an integer value to the ProgressBar and an array of double to the ListBox. |
Dim OpcSrv As XmlServer = Nothing
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
If Not OpcSrv Is Nothing Then
Return
End If
tbStatus.Text = ""
ListView1.Items.Clear()
ListView1.Items.Add("")
ListView1.Items.Add("")
Try
OpcSrv = New XmlServer(Me.cbOPCServers.Text)
' build an ArrayList with dataBind definitions
Dim subscr As DataBindSubscription()
ReDim subscr(2)
subscr(0) = New DataBindSubscription("SimulatedData.Signal", Me.CheckBox1)
subscr(1) = New DataBindSubscription("SimulatedData.Ramp", Me.ProgressBar1)
subscr(2) = New DataBindSubscription("Dynamic.Analog Types.Double[]", Me.ListView1.Items(1).SubItems)
Dim err As OPCError()
OpcSrv.DataBindSubscribe(Me, subscr, 1000, Nothing, err)
tbStatus.Text = "Started"
Catch ex As Exception
tbStatus.Text = ex.Message
OpcSrv = Nothing
End Try
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
If Not OpcSrv Is Nothing Then
Dim err As OPCError()
OpcSrv.DataBindCancel(Nothing, Nothing, err)
OpcSrv = Nothing
tbStatus.Text = "Stopped"
End If
End Sub
|
|