<< Click to Display Table of Contents >> Manual > Server Creation Guide > Interface > IPLink-Interface > IPLinkClient Library > IPLinkClient Library Sample Collection > Loading data |
overview
This sample is a sample program that reads tag values using the four methods explained in "Client Cache and Server Cache".
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.
▪ValueChanged event
The
ValueChanged event occurs when the tag value changes. The return value "Value" contains the value when communication is successful, so it is a reliable value.
'------------------------------------------ ' Event - ValueChanged '------------------------------------------ Private Sub AxIPLink1_ValueChanged(sender As Object, e As AxIPLINKLib6._DClientIPLinkEvents_ValueChangedEvent) Handles AxIPLink1.ValueChanged Select Case e.tagPath Case "U01.F01.T01" txtRead1.Text = CStr(e.value) End Select End Sub
▪ReadVal(DataSource=0)
The value of the client cache is obtained by setting the third argument DataSource of the
ReadVal method to 0. This method is the fastest way to obtain data, so use this method when quick response of ReadVal is required.
If Not AxIPLink1.ReadVal("U01.F01.T02", a, 0) Then txtError.Text = AxIPLink1.ErrMessage Exit Sub End If
▪ReadVal(DataSource=1)
If you set the third argument DataSource of the
ReadVal method to 1, the value in the server cache will be obtained. Since the value obtained is updated on the server side, there is no need for periodic automatic updates between the client and server, which has the effect of reducing the load between them. For this reason, this method is used when the network bandwidth is narrow.
If Not AxIPLink1.ReadVal("U01.F01.T03", a, 1) Then txtError.Text = AxIPLink1.ErrMessage Exit Sub End If
▪ReadVal(DataSource=2)
Setting the third argument DataSource of the
ReadVal method to 2 will retrieve the device value. This method requires the longest processing time and has the highest load, as it forcibly requests communication with the PLC. However, since the results of actual communication with the PLC are returned each time a request is made, it is possible to retrieve the most recent device value. This method is optimal when synchronization with PLC is required or when low-frequency data retrieval is not required, and processing is performed at regular intervals like batch processing.
If Not AxIPLink1.ReadVal("U01.F01.T04", a, 2) Then txtError.Text = AxIPLink1.ErrMessage Exit Sub End If
Operation check
After going online, run the Visual Basic application. Check that the tag lights "T01" to "T03" are red, and "T04" is yellow.
Once you have confirmed that the communication connection is correct, click each read button to verify that the tag values are read correctly.
"T04" was registered in an inactive state with "AddTag", so automatic updates will not occur between the server and the PLC. Inactive tags will have a yellow light.
IPLink1.AddTag "U01.F01.T04", False |