Author Topic: OPC server IP as a variable?  (Read 843 times)

Hank

  • Newbie
  • *
  • Posts: 4
    • View Profile
OPC server IP as a variable?
« on: February 16, 2022, 09:14:24 AM »
I have a simple HMI project done, and working, but I'd like to be able to make the IP address of the remote server I'm connecting to a variable that I can edit in an .ini file, rather than having to set it in the driver.   I'm using the OpcDACom driver.

Is this possible?    After searching the forum it appears it is possible for some drivers (like EthernetIPforCLX..).

I'm very new to AdvancedHMI and not much of a VB programmer, so I apologize if there is an obvious answer that I'm missing.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC server IP as a variable?
« Reply #1 on: February 16, 2022, 09:34:15 AM »
The OPCDaCom driver was not given the capability for using an INI file, however, it is not too difficult to add it.

- In the AdvancedHMIDrivers project, right click EthernetIPForCLXCom.vb and select View Code
- Scroll to the bottom and look for #Region "IniFileHandling"
- Copy all the code in that region
- In AdvancedHMIDrivers project, right click OpcDaCom.vb file and select View Code
- Scroll down to the line just before End Class and paste the code
- Rebuild Solution

You should now have the properties IniFileName and IniFileSection

Hank

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: OPC server IP as a variable?
« Reply #2 on: February 16, 2022, 09:58:43 AM »
Thank you.

I did that, and I get these errors when rebuilding:


Hank

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: OPC server IP as a variable?
« Reply #3 on: February 16, 2022, 10:48:50 AM »
OK, I added this line to the beginning of OpcDACom.vb and made progress

Implements System.ComponentModel.ISupportInitialize

Hank

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: OPC server IP as a variable?
« Reply #4 on: February 16, 2022, 01:03:14 PM »
Its working, thank you for the help!