If I modify your code to use ModbusTCP driver instead, and look like this:
Private MyModbusTCPCom As AdvancedHMIDrivers.ModbusTCPCom = New AdvancedHMIDrivers.ModbusTCPCom
Private SubscriptionID As Integer
Private LastValue As String
Public Sub New()
InitializeComponent()
MyModbusTCPCom.IPAddress = "127.0.0.1"
End Sub
Private Sub fm_sis_opc_test_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MyModbusTCPCom.Subscribe("400001", 10, 500, AddressOf DataReturned)
End Sub
Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
Dim PlcIp As String
Dim PlcTag As String
Dim PlcValue As String
Try
Dim DriverComm As AdvancedHMIDrivers.ModbusTCPCom = CType(sender, AdvancedHMIDrivers.ModbusTCPCom)
PlcIp = DriverComm.IPAddress
PlcTag = e.PlcAddress
PlcValue = e.Values(0).ToString()
Label1.Text = PlcValue.ToString
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub
Private Sub MainFormX_FormClosing(sender As Object, e As Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
MyModbusTCPCom.Unsubscribe(SubscriptionID)
End Sub
The DataRetuned is fired continuously and 10 values are returned but only the first value is shown on the label.
if I modify the DataReturned to this:
Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
If e.Values IsNot Nothing Then
Me.Label1.Text = ""
For i = 0 To 9
Me.Label1.Text &= (e.PlcAddress + i) & " = " & e.Values(i).ToString & Environment.NewLine
Next
End If
End Sub
I do get to see all 10 values on the label.
So, I am not currently sure what EthernetIPforSLCMicroCom driver might require in addition to your code to make it work.