Author Topic: how to put the ModbusTCPCom info in a file  (Read 5668 times)

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
how to put the ModbusTCPCom info in a file
« on: May 20, 2017, 07:57:27 AM »
hello

i want to make the ModbusTCPCom read the propartys from a file

ip
port
unitid

how can i do that?


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #2 on: May 20, 2017, 08:37:55 AM »
does it work for multi modbuses

like this

Code: [Select]

[Com2]
IPAddress=192.168.0.5
TcpipPort=502
UnitId=1

[Com1]
IPAddress=192.168.0.6
TcpipPort=502
UnitId=1



and if i do this it the ModbusTCPCom will automatically use it ?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: how to put the ModbusTCPCom info in a file
« Reply #3 on: May 20, 2017, 09:19:55 AM »
does it work for multi modbuses
Yes, yo just have to specify which INIFileSection to use for each driver

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #4 on: May 20, 2017, 09:53:23 AM »
can u explain it more i never used ini or any files

what i have

first ModbusTCPCom   name is com1

ip: 192.168.0.5
port: 502
unitid: 1
----------------------
second name is com2
ip: 192.168.0.6
port: 503
unitid: 1

what should i write exactly in the ini file

and can i use the same file for more than one ModbusTCPCom?
« Last Edit: May 20, 2017, 10:02:01 AM by oqapsking »

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #5 on: May 20, 2017, 10:05:30 AM »
look at the photo in  the attachment
how to use these?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: how to put the ModbusTCPCom info in a file
« Reply #6 on: May 20, 2017, 10:12:21 AM »
1) In Solution Explorer, right click the AdvancedHMI project
2) Select Add->New Item
3) In the pop up window, select the Text File
4) Give it the name PLCConfig.ini, then click the Add button
5) In Solution Explorer click once on the new file (PLCConfig.ini) to select it
6) In the Properties Window, set Copy To Output Directory to Copy if newer
7) In Solution Explorer, double click the new ini file to open in the text editor
8) Add this to the file:
Code: [Select]
[Driver1]
IPAddress=192.168.0.5

[Driver2]
IPAddress=192.168.0.6
9) Save the file

10) Go to the Form design view that has your driver instance
11) Select the first driver
12) In the Properties window, set the property INIFileName to PLCConfig.ini
13) Set the INIFileSection to Driver1
14) Select the second driver on the form
15) In the Properties window, set the property INIFileName to PLCConfig.ini
16) Set the INIFileSection to Driver2

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #7 on: May 20, 2017, 10:34:54 AM »
is this good?

Code: [Select]









oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #8 on: May 20, 2017, 10:49:09 AM »
ok it worked great

now can i change the ini file path?

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #9 on: May 26, 2018, 04:41:09 PM »
ok it worked great

now can i change the ini file path?

can anyone help me change the ini path?

Godra

  • Hero Member
  • *****
  • Posts: 1449
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #10 on: May 26, 2018, 05:55:09 PM »
That doesn't seem to be an option.

You should be able to add your ini file to the project, where ever that file might be located.
« Last Edit: May 26, 2018, 05:58:25 PM by Godra »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: how to put the ModbusTCPCom info in a file
« Reply #11 on: May 26, 2018, 06:47:03 PM »
The original design was intended to have your ini file added to your project in Solution Explorer, then set the CopyToOutputDirectory property of the file to CopyIfNewer.


But I would expect that if you want it in another place, you can specify the full path in the IniFileName Property such as :


C:\MyDirectory\MyIniFile.ini

The file is opened and parsed in the IniParser.vb file found in the AdvancedHMIDrivers project under the Common folder.
« Last Edit: May 27, 2018, 06:58:49 AM by Archie »

Godra

  • Hero Member
  • *****
  • Posts: 1449
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #12 on: May 26, 2018, 10:57:55 PM »
Darn tootin', I was wrong.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: how to put the ModbusTCPCom info in a file
« Reply #13 on: May 21, 2019, 04:46:14 PM »
HELLO
CAN I USE THIS METHOD FOR SOMETHING ELSE

WHAT I MEAN IN MY PROJECT THERE IS A BUTTON WHEN I CLICK IT I OPEN A WEBPAGE
WHAT IS THE CODE I SHOULD WRITE IN THE BUTTON CLICK CODE TO READ THE URL FROM THE INI FILE?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5324
    • View Profile
    • AdvancedHMI
Re: how to put the ModbusTCPCom info in a file
« Reply #14 on: May 21, 2019, 04:54:14 PM »
Look in the file EthernetIPForCLXCom.vb and you will see a region named IniFileHandling. Copy that whole region of code into the BasicButton.vb file and that should get you mostly there for using an INIFile to set property values.