Tag monitoring with IPLink

<< Click to Display Table of Contents >>

Manual > Server Creation Guide > Interface > IPLink-Interface > IPLinkClient Library > IPLinkClient Library Sample Collection >

Tag monitoring with IPLink

overview

This is a sample program that monitors 32 points of data in real time. By registering the tag as active and setting the Update property to True, an event will occur when the value changes. The StateChanged event is used to display each item, and the connection status with the IPLink server is displayed. In addition, the ValueStateChanged event is used to automatically update the display of each tag value when the tag value or quality changes.

 

c_interface_0128

 

 

Download the sample

The creation examples shown on this page are provided with samples.

 

The sample can be downloaded from below.

 

Samples and detailed explanations will be provided in VB.NET2010.

 

 

Program Highlights

We will explain the main points of the program.

 

Form Load Process
When the form is loaded, the NetworkParam property is set to connect to the IPLink server. At the same time, initial processing such as registering tags for communication with AddTag is performed.
 

'IPlink Setting
AxIPLink1.Visible = False
AxIPLink1.AddTags(32, TagPaths, Actives, Results)
AxIPLink1.NetworkParam = ",3000,1000"
AxIPLink1.Online = True
AxIPLink1.CtlUpdate = True

 

hint

The update cycle between the client and server is set in NetworkParam. The update cycle between the server and PLC is set in the folder properties of each PLC.

 

 

StateChanged event
StateChanged occurs when the connection state of the IPLink server changes. If you are connected, you can get "True", and if you are not connected, you can get "False". Here, the obtained connection state is displayed in the edit box.
 

'------------------------------------------
' Event - StateChanged
'------------------------------------------
Private Sub AxIPLink1_StateChanged(sender As Object, e As AxIPLINKLib6._DClientIPLinkEvents_StateChangedEvent) Handles AxIPLink1.StateChanged
    txtState.Text = CStr(e.state)
End Sub

 
 

ValueStateChanged event
ValueStateChanged occurs when the value and quality of a tag on the IPLink server change. In this example, if the tag quality is normal (True), it is displayed in the value edit box. If the quality becomes abnormal, "Error!" is displayed.
 

'------------------------------------------
' Event - ValueStateChanged
'------------------------------------------
Private Sub AxIPLink1_ValueStateChanged(sender As Object, e As AxIPLINKLib6._DClientIPLinkEvents_ValueStateChangedEvent) Handles AxIPLink1.ValueStateChanged
    If e.state Then
        txtVal(Integer.Parse(e.tagPath.Substring(e.tagPath.Length - 2))).Text = CStr(e.value)
    Else
        txtVal(Integer.Parse(e.tagPath.Substring(e.tagPath.Length - 2))).Text = "Error!"
    End If
End Sub

 

 

Verifying communication loss

The causes of communication interruptions can be broadly divided into two categories:

 

c_interface_0129

 

 

When a communication failure occurs, the two events used in this sample behave as follows:

 

ValueStateChanged(ByVal TagPath As String, ByVal Value As Variant, ByVal State As Boolean)
The "ValueStateChanged" event has three arguments, and the third argument, "State", indicates the quality of the value. If the value cannot be obtained for some reason, the State argument is set to False. This occurs in both cases, whether there is a failure between the client and server, or between the server and PLC.
 

StateChanged(ByVal State As Boolean)
The "StateChanged" event occurs when the communication state between the client and server changes. It does not occur when communication between the server and PLC is no longer possible. In the event of an error, the "State" argument is set to False.

 

 

This sample will be used to verify operation during communication failure.

 

1.Communication failure between client and server
 
To simulate a communication failure between the client and the server, take the application offline during normal communication. Then, StateChanged and ValueStateChanged will occur. On the form, confirm that the value becomes "Error!" and the state is displayed as "False".
 

  c_interface_0131

c_interface_0130

 

 

2.Communication failure between server and PLC
 
To simulate a communication failure between the server and PLC, right-click on the U01 unit during normal communication and select "Unit Operations" and "Disconnect". The disconnect operation will simulate a state where communication with PLC is not possible. In this case, only ValueStateChanged will occur. On the form, the value will be "Error!", but the state will still be displayed as "True". Since the state is disconnected, the quality of all tags on the server side will be BAD.
 

  c_interface_0132

c_interface_0133