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.