COPC DLL : Detect if specified OPC tag’s value changed

You can detecting if specified OPC tag’s value changed by ‘tagIndex’ in event ‘datChange’.  Event ‘datChange’ will retun index number of OPC tag that having value changed. We  can use this in our code for comparision.

Code show below is example of ‘datChange’ event(VB.Net, C# is similar). Your code will be processed when OPC tag index no 1 has value changed.

Private Sub copc1_datChange(tagIndex As Integer) Handles copc1.datChang

       If tagIndex = 1 Then

…Your code here

       End If

   End Sub

 

or

 

Private Sub copc1_datChange(tagIndex As Integer) Handles copc1.datChange

        Select Case tagIndex
            Case 0
                … Your Code

            Case 1
               
… Your Code

            Case 2
               
… Your Code

        End Select

End Sub

 

It is better to use Timer for general data reading and keeping in variables. Above case is for conditional process.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s