Private Function strGetPLCData(ByVal strAddress As String) As String
Dim OpcServer As New RsiOPCAuto.OPCServer
Dim OpcGroup As RsiOPCAuto.OPCGroup
Dim OpcItem As RsiOPCAuto.OPCItem
Dim vItem As String = ""
Try
OpcServer.Connect("RSLinx OPC Server")
' Add this group to the shared topic
OpcGroup = OpcServer.OPCGroups.Add(MY_GROUP)
OpcGroup.IsSubscribed = False
OpcGroup.IsActive = False
OpcGroup.UpdateRate = 250
OpcGroup.OPCItems.DefaultAccessPath = OPC_SHARE
OpcGroup.OPCItems.AddItem(strAddress, 1)
OpcItem = OpcGroup.OPCItems.Item(1)
OpcItem.Read(2, vItem)
OpcItem = Nothing
OpcServer.OPCGroups.RemoveAll()
OpcGroup = Nothing
OpcServer.Disconnect()
OpcServer = Nothing
'Add and Error the list box
Catch ex As PlatformNotSupportedException
MsgBox("Error In Get Plc Data: " & ex.Message)
End Try
Return vItem
End Function