AdvancedHMI Software

General Category => Support Questions => Topic started by: oqapsking on May 20, 2017, 07:57:27 AM

Title: how to put the ModbusTCPCom info in a file
Post by: oqapsking 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?

Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie on May 20, 2017, 08:03:24 AM
http://advancedhmi.com/documentation/index.php?title=INI_File_Usage
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking 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 ?
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie 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
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking 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?
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 20, 2017, 10:05:30 AM
look at the photo in  the attachment
how to use these?
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie 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
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 20, 2017, 10:34:54 AM
is this good?

Code: [Select]








Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 20, 2017, 10:49:09 AM
ok it worked great

now can i change the ini file path?
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking 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?
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Godra 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.
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie 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.
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Godra on May 26, 2018, 10:57:55 PM
Darn tootin', I was wrong.
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking 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?
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie 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.
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 21, 2019, 05:10:43 PM
I DON`T KNOW HOW TO MAKE THE PROPERTY MAKE THE INI READ IT AS THE PLAYLIST

THIS IS THE CODE

Code: [Select]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles cam1Btn.Click


        If AxVLCPlugin22.Visible = False Then

            AxVLCPlugin22.playlist.add("rtsp://admin:admin1234@192.168.1.64:554/Streaming/Channels/101/")
            AxVLCPlugin22.playlist.play()
            AxVLCPlugin22.Visible = True
            AxVLCPlugin22.Enabled = True
        Else
            AxVLCPlugin22.playlist.stop()
            AxVLCPlugin22.Visible = False
            AxVLCPlugin22.Enabled = False


        End If


    End Sub

I NEED TO EDIT IT TO READ
Code: [Select]
rtsp://admin:admin1234@192.168.1.64:554/Streaming/Channels/101
FROM THE INI FILE

AND I NEED THAT WORK INSIDE THE FORM1.VB I DON`T PREFER TO EDIT BUTTON VB

Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie on May 21, 2019, 05:30:44 PM
         Dim p As New AdvancedHMIDrivers.IniParser(iniFileName)
        AxVLCPlugin22.playlist.add(p.GetSetting(MysectionName, MySettingName))
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 21, 2019, 05:50:58 PM
IT GIVES AN ERROR

THIS IS THE INSIDE OF THE INI

Code: [Select]
[door1cam]
url=rtsp://admin:admin1234@192.168.1.64:554/Streaming/Channels/101/

AND THIS IS THE NAME OF THE FILE

Code: [Select]
ipcamurl
AND THIS IS THE CODE WHEN I TRIED I

Code: [Select]
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles cam1Btn.Click


        If AxVLCPlugin22.Visible = False Then
            Dim p As New AdvancedHMIDrivers.IniParser(ipcamurl.ini)
            AxVLCPlugin22.playlist.add(p.GetSetting(door1cam, URL))

            AxVLCPlugin22.playlist.play()
            AxVLCPlugin22.Visible = True
            AxVLCPlugin22.Enabled = True
        Else
            AxVLCPlugin22.playlist.stop()
            AxVLCPlugin22.Visible = False
            AxVLCPlugin22.Enabled = False


        End If


    End Sub

AND THE ERROR IN THE ATTACHMENTS
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 21, 2019, 05:53:49 PM
BY THE WAY I WORK ON visual studio 2017 enterprise
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie on May 21, 2019, 05:56:16 PM
The values are strings, they need quotes

 Dim p As New AdvancedHMIDrivers.IniParser("ipcamurl.ini")
 AxVLCPlugin22.playlist.add(p.GetSetting("door1cam", "URL"))
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 21, 2019, 06:01:04 PM
IT WORKED LIKE A CHARM

THANK U VERY MUCH

YOU GUYS ARE THE BEST
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 23, 2019, 05:03:47 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.


i can`t change the path it is locked

Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 26, 2019, 12:33:20 AM
am trying to read the sitting from the ini file

but it is not working
the code
Code: [Select]
Dim pnnn As New AdvancedHMIDrivers.IniParser("ipcamurL.INI")

        phwo2.Text = pnnn.GetSetting("meare", "typem")

the inside of the ini file

Code: [Select]
[meare]
typem = Flo1

i don`t know how to do it

Title: Re: how to put the ModbusTCPCom info in a file
Post by: Godra on May 26, 2019, 01:16:28 AM
Are your names correct: is it "ipcamurl.ini" or "ipcamurL.INI"?

You also have spaces: typem = Flo1, which should be typem=Flo1.
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Archie on May 26, 2019, 07:06:16 AM
am trying to read the sitting from the ini file

but it is not working
the code
Code: [Select]
Dim pnnn As New AdvancedHMIDrivers.IniParser("ipcamurL.INI")

        phwo2.Text = pnnn.GetSetting("meare", "typem")

the inside of the ini file

Code: [Select]
[meare]
typem = Flo1

i don`t know how to do it
What error do you get?
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 27, 2019, 03:43:39 PM
the error in the attachment

and the code is in the form load

Code: [Select]

Dim pnnn As New AdvancedHMIDrivers.IniParser("ipcamurL.INI")
  phwo2.Text = pnnn.GetSetting("meare", "typem")



        If phwo2.Text = "Flo1" Then

            ToolStripStatusLabel.Text = "الطابق الاول"

            ActiveMdiChild.Dispose()

            Dim ChildForm As New floor1

            ChildForm.MdiParent = Me
            ChildForm.WindowState = FormWindowState.Maximized
            ChildForm.FormBorderStyle = FormBorderStyle.None
            ChildForm.ControlBox = False
            ChildForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
            ChildForm.MaximizeBox = False
            ChildForm.MinimizeBox = False
            ChildForm.ControlBox = False
            ChildForm.WindowState = System.Windows.Forms.FormWindowState.Normal
            ChildForm.Dock = DockStyle.Fill
            ChildForm.AutoScroll = True

            Cursor = Cursors.Default
            ResumeLayout()
            ChildForm.Show()
            Grbtn.ForeColor = System.Drawing.Color.DodgerBlue
            F2btn.ForeColor = System.Drawing.Color.DodgerBlue
            F1btn.ForeColor = System.Drawing.Color.Red
            Outbtn.ForeColor = System.Drawing.Color.DodgerBlue
            F1btn.FlatStyle = System.Windows.Forms.FlatStyle.Flat
            Grbtn.FlatStyle = System.Windows.Forms.FlatStyle.Standard
            F2btn.FlatStyle = System.Windows.Forms.FlatStyle.Standard

            Outbtn.FlatStyle = System.Windows.Forms.FlatStyle.Standard

        End If
        If phwo2.Text = "2" Then

            ToolStripStatusLabel.Text = "OutSide"
            Dim ChildForm As New OUT

            ChildForm.MdiParent = Me
            ChildForm.WindowState = FormWindowState.Maximized
            ChildForm.FormBorderStyle = FormBorderStyle.None
            ChildForm.ControlBox = False
            ChildForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
            ChildForm.MaximizeBox = False
            ChildForm.MinimizeBox = False
            ChildForm.ControlBox = False
            ChildForm.WindowState = System.Windows.Forms.FormWindowState.Normal
            ChildForm.Dock = DockStyle.Fill
            ChildForm.AutoScroll = True

            Cursor = Cursors.Default


            ChildForm.Show()
            Grbtn.ForeColor = System.Drawing.Color.DodgerBlue
            F2btn.ForeColor = System.Drawing.Color.DodgerBlue
            F1btn.ForeColor = System.Drawing.Color.DodgerBlue
            Outbtn.ForeColor = System.Drawing.Color.Red
            F1btn.FlatStyle = System.Windows.Forms.FlatStyle.Standard
            Grbtn.FlatStyle = System.Windows.Forms.FlatStyle.Standard
            F2btn.FlatStyle = System.Windows.Forms.FlatStyle.Standard

            Outbtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        End If
Title: Re: how to put the ModbusTCPCom info in a file
Post by: Godra on May 27, 2019, 05:55:09 PM
I did get the same error if spaces were used: typem = Flo1, which should be typem=Flo1.
Title: Re: how to put the ModbusTCPCom info in a file
Post by: oqapsking on May 27, 2019, 06:06:39 PM
thanks it worked i did not notice it  lol

thanks again