________________________________________________________________________________________
www.kepware.com 7 ClientAce: Creating a Simple Windows Form
Note: The VB .NET code is displayed below.
'initialize the client subscription handle
clientSubscriptionHandle = 1
'Parameter to specify if the subscription will be added as active or not
Dim active As Boolean = False
' The updateRate parameter is used to tell the server how fast we
' would like to see data updates.
Dim updateRate As Integer = 1000
' The deadband parameter specifies the minimum deviation needed
' to be considered a change of value. 0 is disabled
Dim deadBand As Single = 0
' The revisedUpdateRate parameter is the actual update rate that the
' server will be using.
Dim revisedUpdateRate As Integer
'initialize the itemIdentifier values
itemIdentifiers(0) = New Kepware.ClientAce.OpcDaClient.ItemIdentifier
itemIdentifiers(0).ItemName = "Channel1.Device1.Bool1"
itemIdentifiers(0).ClientHandle = 0
itemIdentifiers(0).DataType = Nothing
itemIdentifiers(1) = New Kepware.ClientAce.OpcDaClient.ItemIdentifier
itemIdentifiers(1).ItemName = "Channel1.Device1.Bool2"
itemIdentifiers(1).ClientHandle = 1
itemIdentifiers(1).DataType = Nothing
itemIdentifiers(2) = New Kepware.ClientAce.OpcDaClient.ItemIdentifier
itemIdentifiers(2).ItemName = "Channel1.Device1.Short1"
itemIdentifiers(2).ClientHandle = 2
itemIdentifiers(2).DataType = Nothing
itemIdentifiers(3) = New Kepware.ClientAce.OpcDaClient.ItemIdentifier
itemIdentifiers(3).ItemName = "Channel1.Device1.Short2"
itemIdentifiers(3).ClientHandle = 3
itemIdentifiers(3).DataType = Nothing
itemIdentifiers(4) = New Kepware.ClientAce.OpcDaClient.ItemIdentifier
itemIdentifiers(4).ItemName = "Channel1.Device1.Long5"
itemIdentifiers(4).ClientHandle = 4
itemIdentifiers(4).DataType = Nothing
'Call the Subscribe API method:
Try
daServerMgt.Subscribe(clientSubscriptionHandle, active, updateRate,
revisedUpdateRate, deadBand, itemIdentifiers, activeServerSubscriptionHandle)
' Check item result ID:
If itemIdentifiers(0).ResultID.Succeeded = False Then
' Show a message box if an item could not be added to subscription.
' You would probably use some other means to alert
' the user to failed item enrollments in an actual application.
MsgBox("Failed to add item " & itemIdentifiers(0).ItemName & " to
subscription")
End If
Catch ex As Exception
MsgBox("Handled Subscribe exception. Reason: " & ex.Message)
End Try
End Sub