AdvancedHMI Software
General Category => Support Questions => Topic started 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?
-
http://advancedhmi.com/documentation/index.php?title=INI_File_Usage
-
does it work for multi modbuses
like this
[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 ?
-
does it work for multi modbuses
Yes, yo just have to specify which INIFileSection to use for each driver
-
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?
-
look at the photo in the attachment
how to use these?
-
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:
[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
-
is this good?
-
ok it worked great
now can i change the ini file path?
-
ok it worked great
now can i change the ini file path?
can anyone help me change the ini path?
-
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.
-
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.
-
Darn tootin', I was wrong.
-
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?
-
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.
-
I DON`T KNOW HOW TO MAKE THE PROPERTY MAKE THE INI READ IT AS THE PLAYLIST
THIS IS THE CODE
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
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
-
Dim p As New AdvancedHMIDrivers.IniParser(iniFileName)
AxVLCPlugin22.playlist.add(p.GetSetting(MysectionName, MySettingName))
-
IT GIVES AN ERROR
THIS IS THE INSIDE OF THE INI
[door1cam]
url=rtsp://admin:admin1234@192.168.1.64:554/Streaming/Channels/101/
AND THIS IS THE NAME OF THE FILE
ipcamurl
AND THIS IS THE CODE WHEN I TRIED I
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
-
BY THE WAY I WORK ON visual studio 2017 enterprise
-
The values are strings, they need quotes
Dim p As New AdvancedHMIDrivers.IniParser("ipcamurl.ini")
AxVLCPlugin22.playlist.add(p.GetSetting("door1cam", "URL"))
-
IT WORKED LIKE A CHARM
THANK U VERY MUCH
YOU GUYS ARE THE BEST
-
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
-
am trying to read the sitting from the ini file
but it is not working
the code
Dim pnnn As New AdvancedHMIDrivers.IniParser("ipcamurL.INI")
phwo2.Text = pnnn.GetSetting("meare", "typem")
the inside of the ini file
[meare]
typem = Flo1
i don`t know how to do it
-
Are your names correct: is it "ipcamurl.ini" or "ipcamurL.INI"?
You also have spaces: typem = Flo1, which should be typem=Flo1.
-
am trying to read the sitting from the ini file
but it is not working
the code
Dim pnnn As New AdvancedHMIDrivers.IniParser("ipcamurL.INI")
phwo2.Text = pnnn.GetSetting("meare", "typem")
the inside of the ini file
[meare]
typem = Flo1
i don`t know how to do it
What error do you get?
-
the error in the attachment
and the code is in the form load
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
-
I did get the same error if spaces were used: typem = Flo1, which should be typem=Flo1.
-
thanks it worked i did not notice it lol
thanks again