46
Support Questions / Re: InvalidOperationException OnDataReceived ModbusBase
« on: January 28, 2015, 11:04:49 PM »Your timer may be firing before the form is fully loaded. I would add a DataSubscriber, set PLCAddressValue to 414940, double click the DataSubscriber to get to the DataChanged event handler.
Add your code there and use e.values(0) in place of ModbusTCPCom1.Read(414940)
I use DataSubscriber then it is okay.
In 3.97e release note, there is additional features:
DataSubscriber - Can subscribe to multiple values by putting comma separated values in PLCAddressValue
So, I have tried to put 2 address by using comma as separation.
Then, parse the PLCAddressValue to be stored in separate variable.
Code: [Select]
Private Sub DataSubscriber2_DataChanged_1(ByVal sender As System.Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs) Handles DataSubscriber2.DataChanged
' temp = 414940
Dim temp As Integer = Integer.Parse(ModbusTCPCom1.Read(Me.DataSubscriber2.PLCAddressValue.Substring(0, 6)))
' temp2 = 414942
Dim temp2 As Integer = Integer.Parse(ModbusTCPCom1.Read(Me.DataSubscriber2.PLCAddressValue.Substring(7, 6)))
End Sub
This works really well.
However, besides manually parsing PLCAddressValue, do you have special function to get those address (by index maybe)?
Please advise the trick, Thank you.
Best regards,
Andrew