AdvancedHMI Software
General Category => Support Questions => Topic started by: yubish on April 12, 2015, 09:29:13 AM
-
Hi, i'm a newbie and i'm trying to become more familiar with VB.NET
My question is : It is possible to create a component that includes AdvancedHMI controls and drivers and use it after in the project ?
For example, in my situation, i want to create a component that includes 2 Datasubscribers, the Ethernet/IP driver component and a digital panel meter.
Thank you in advance
-
I'm not sure if I am fully understand what you mean.
The DigitalPanelMeter, Datasubscriber, and Ethernet/IP are all components that you add to a form.
-
I mean by component a control. What i want actually is to create my own component (control) using AdvancedHMI controls and drivers,
to mix a number of components (controls and drivers) in one component (one control) and the possibility for the result component (control) to inherit properties from his components (AdvancedHMI controls and drivers).
-
What think what you are looking for is a UserControl.
- Right click the AdvancedHMI project in the Solution Explorer
- Add->User Control
- Add the controls you want to the UserControl
- You can then add many copies of the UserControl to your MainForm
-
Thanks, It works well with the AdvancedHMI controls but i still have a problem, especially, when i add the component EthernetIPforCLXcom driver, i have a message error that indicates "incomplete solution".
In my usercontrol, i need 2 Datasubscribers and the EthernetIPforCLXcom component for the datasbscribers. All the other drivers work when i add them in my usercontrol, the message error appears only when i add the EthernetIPforCLXcom driver.
-
The "Incomplete Solution" usually means it cannot find all of the parts of the AdvancedHMI solution. Such as the drivers being separated from the solution.
-
Thank you Archie.
But, what can i do in this situation to resolve this problem ?
You will find attached the picture of the message error
-
Can you post a screen shot of your Solution Explorer and a screen shot of \AdvancedHMI\bin\Debug directory.
I never tried a driver on a UserControl. I will see if I can test it later this evening.
-
here is it
-
Where do you have your UserControl?
-
After it didn't work in The AdvancedHMI project, I moved it to the AdvancedHMI Controls project.
The problem is that when we put AdvancedHMI controls in a UserControl, we need a driver component included in the UserControl to set it in the properties of each AdvancedHMI control for the communication with the PLC, and the problem 'incomplete solution' appears only with the EthernetIP driver
-
I will have to try this out later this afternoon to figure what it doesn't like.
-
I had to make a fix to the program to make it work. This will be part of the next release that will be available within the next 2 days.
-
Thank you a lot Archie !
-
Hi again Archie ! We're always waiting for the next release, i hope it's going good.
Thank you a lot for your efforts, it's a great work and good luck.
-
Version 3.98f has been posted. I wasn't able to do much testing with User Controls, so there still may be some bugs to work out.
-
Hi Archie !
Thank you so much for your collaboration and for the update, the bugs are fixed (y).
I had another idea, instead of including the ethernet driver in the usecontrol, i thought if it could be possible to insert the driver only in the mainform and have a property in the usercontrol that links the driver with the advancedHMI controls of our usercontrol.
This could help us avoid using the driver in each usercontrol in the mainform. As a newbie in VB, i don't know if it's possible to do this in it.
Thank's in advance.
-
I had another idea, instead of including the ethernet driver in the usecontrol, i thought if it could be possible to insert the driver only in the mainform and have a property in the usercontrol that links the driver with the advancedHMI controls of our usercontrol.
This is starting to get into the area of writing custom controls so it can get complicated. To fully take advantage of this, you would need to understand object oriented programming.
This is an idea of how to go about this. First you need to create a property for your UserControl that hold the driver instance:
- Right click the design surface of the UserControl and select ViewCode
- Enter this code
Private m_CommComponent As AdvancedHMIDrivers.IComComponent
Public Property CommComponent() As AdvancedHMIDrivers.IComComponent
Get
Return m_CommComponent
End Get
Set(ByVal value As AdvancedHMIDrivers.IComComponent)
If m_CommComponent IsNot value Then
m_CommComponent = value
End If
End Set
End Property
Next you will need to initialize each control on the UserControl to tell it where to find it's driver to communicate:
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
If Me.components Is Nothing Then
Me.components = New System.ComponentModel.Container()
End If
'* Set the component to each control that is on the UserControl
DigitalPanelMeter1.CommComponent = m_CommComponent
End Sub
Now when you add the UserControl to an application's form, you will need to set the CommComponent property to a driver that you have on the form.
I do not have access to a PLC right now to fully test this, but it is the framework to do what you want.
-
Thank you Archie. I wrote the code in a similar way by including the initialization in the property :
Public CommComponent As AdvancedHMIDrivers.IComComponent
Public Property CommComponent() As AdvancedHMIDrivers.IComComponent
Get
Return m_CommComponent
End Get
Set(value As AdvancedHMIDrivers.IComComponent)
CommComponent = value
BasicLabel3.CommComponent = value
End Set
End Property
It works well but i don't know if it's right.
-
Your method works just as well and is simpler.
-
It is possible to add driver to a UserControl but the code needs to be adjusted to use that driver only and not to look for the presence of any other driver.
Check the attached picture for a simple UserControl with TrendChart, BasicLabel and BasicButton (at Runtime, left picture is before subscriptions are enabled and right picture after).
This control has a tendency of using the driver as soon as it is created in the DesignMode and that was the reason I included the button to Enable/Disable Subscriptions (the driver subscriptions are also disabled in the code = Constructor Region - Public Sub New()).
Could possibly be adjusted to behave differently.