OPC Controls Read Values

Refer to the WinForm Example Code installed with OPC Systems.NET for a full example on how to read data from OPC Systems.NET Tags and DirectOPC Items.

To read values from the OPC Systems involves one simple method to let the OPC Systems Services which Tags you wish to read and one simple event receive all changes and updates to the Tags you wish to read.

Use the AddTag or AddTags as many times as you desire to subscribe to both local and remote OPC Systems Services.

        Dim Tags(2) As String

        Tags(0) = "Ramp.Value"

        Tags(1) = "Sine.Value"

        Tags(2) = "Random.Value"

        OpcControlsData.AddTags(Tags)

Use the ValuesChangedAll Event to receive the requested values continuously any time the values are requested or the values change.

Private Sub OpcControlsData_ValuesChangedAll(ByVal Tags() As String, ByVal Values() As Object, ByVal Qualities() As Boolean, ByVal TimeStamps() As Date) Handles OpcControlsData.ValuesChangedAll

Use the RemoveTag or RemoveTags as many times as you desire to unsubscribe to both local and remote OPC Systems Services.

        Dim Tags(2) As String

        Tags(0) = "Ramp.Value"

        Tags(1) = "Sine.Value"

        Tags(2) = "Random.Value"

        OpcControlsData.RemoveTags(Tags)