Author Topic: Dynamic Changing of Driver Properties  (Read 359 times)

Automatikai

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Automation Consulting, LLC
Dynamic Changing of Driver Properties
« on: June 04, 2024, 03:40:05 PM »
I have read several of the Support questions about changing IP Addresses at runtime and am somewhat confused. Most of the discussions were from about 2015 and things may have changed since then.

In the topic Changing IP Address at Runtime it appeared someone was able to use a button to set Driver.IPAddress = Textbox.Text. This seems pretty simple and is what I would prefer to do. Instead of using a button I would place the event in Private Sub Form_Load. When I do this the program hangs up and I have to terminate it.

In other topics Using .ini Files for Driver Settings it implies there is much more than simply changing the driver properties, and that it needs to initialize values on startup.

There are three properties I am trying to make dynamic on a Comms Setup screen; OpcDaCom.OPCTopic, EthernetIPforCLXCom.IPAddress, and EthernetIPforCLXCom.ProcessorSlot. I am using the MainMenuDriven controls with a variety of GoTo buttons that open different screens. Two screens have controls that connect to the 5000 Logix Emulate (OPC), these work fine if the driver topic is entered on the properties screen but not when setting OPCTopic to a string variable. There is also not an example ini file, so I assume there may be another way to set it.

For the EthernetIPforCLXCom.IPAddress and EthernetIPforCLXCom.ProcessorSlot variables, I would like to be able to set them on the Comms Setup screen and then have them saved for use on the rest of the screens that connect to real hardware. The hardware may be a ControlLogix processor in slot 0-4 or a CompactLogix (slot 0). IP addresses can vary from Class C 192.168.0.xx to Class A 10.2.4.xx.

Since the Menu closes the other screens when on the Setup Screen, the drivers can be reinitialized every time a new operation screen is opened, either OPC or hardware. If the button works in the Changing IP at Runtime example listed before, it seems like using a TextChanged or FormLoad event would also work. In this case why would the CLX.ini method be necessary?

« Last Edit: June 04, 2024, 03:43:57 PM by Automatikai »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5280
    • View Profile
    • AdvancedHMI
Re: Dynamic Changing of Driver Properties
« Reply #1 on: June 05, 2024, 05:18:51 AM »
In the topic Changing IP Address at Runtime it appeared someone was able to use a button to set Driver.IPAddress = Textbox.Text. This seems pretty simple and is what I would prefer to do. Instead of using a button I would place the event in Private Sub Form_Load. When I do this the program hangs up and I have to terminate it.
Can you run this code in Visual Studio and when it hangs, click the pause button to see exactly where it is hanging.

Automatikai

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Automation Consulting, LLC
Re: Dynamic Changing of Driver Properties
« Reply #2 on: June 05, 2024, 09:00:09 AM »
It stops at OpcDaCom.vb   
ItemResult = SubscriptionOPC.AddItems(OPCSubscriptionItem)

The code in my screen is

    Private Sub ScrOPCMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        OPC_Display.Text = Variables.clxOPCTopic
        OpcDaCom1.OPCTopic = OPC_Display.Text
    End Sub

The OPC_Display.Text is a textbox on the screen to check whether the Topic made it to the screen from the setup screen.
« Last Edit: June 05, 2024, 09:02:24 AM by Automatikai »