Author Topic: Dynamically assign PLCAddress to number displayer, SevenSegment2 and Odometer  (Read 1733 times)

halosome

  • Newbie
  • *
  • Posts: 31
    • View Profile
Is it possible to assign the PLCAddress on those displayers in programming? I tried use to integers or strings ("41001") and they all failed.

I am trying to use a group of displayers to show several groups of devices by selecting different ModbusTCP Addresses.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile

halosome

  • Newbie
  • *
  • Posts: 31
    • View Profile
I try to make it simple so I directly drag the controls in the form, but when I change the controls' PLCaddress, the value not changed, it sticks to the one from the address in the form designer.

Dim addr1 as integer = 40001
Dim addr2 as integer = 40011
If DeviceID=1 then
Odometer1.PLCAddressValue.PLCAddress = addr1.ToString
Odometer2.PLCAddressValue.PLCAddress = (addr1+1).ToString
Else
Odometer1.PLCAddressValue.PLCAddress = addr2.ToString
Odometer2.PLCAddressValue.PLCAddress = (addr2+1.ToString
End If

halosome

  • Newbie
  • *
  • Posts: 31
    • View Profile
Hello Godra and Archie, please help.

It seems most of the problems are solved except this one, I really need help in solving this issue because I would like to create one page for several same devices (their Modbus addresses are the only difference). Once I select a device, the device base address plus offsets will be applied to all the display components. But currently they all stick to the address at the form designer.


Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Code: [Select]
        Dim addr1 As Integer = 40001
        Dim addr2 As Integer = 40011
        If DeviceID = 1 Then
            Odometer1.PLCAddressValue = New Drivers.PLCAddressItem(addr1.ToString)
            Odometer2.PLCAddressValue = New Drivers.PLCAddressItem((addr1 + 1).ToString)
        Else
            Odometer1.PLCAddressValue = New Drivers.PLCAddressItem(addr2.ToString)
            Odometer2.PLCAddressValue = New Drivers.PLCAddressItem((addr2 + 1).ToString)
        End If

halosome

  • Newbie
  • *
  • Posts: 31
    • View Profile
It seems working! I will test it tomorrow.

Thank you!