AdvancedHMI Software
General Category => Feature Request => Topic started by: andrew_pj on May 12, 2015, 01:39:39 AM
-
Dear Archie,
BarLevel component has PLCAddressValue which displays present value of the address.
In some cases, it is required to dynamically change the Bar's maximum value.
Please advise if possible to implement PLCAddressMaxValue.
Thank you.
Best regards,
Andrew
-
It is actually quite easy. You can link existing properties to a PLC address by editing BarLevel.vb in the AdvancedHMIControls project and adding a new property like this:
Public Property PLCAddressMaximum() As String
It must start with PLCAddress and followed by the exact spelling of an existing property.
-
Dear Archie,
Thanks for the tips, it is working with ScaleFactor 1.
In my case, the ScaleFactor is 0.1, so I need to have another property of MaximumScaleFactor.
Please advise, Thank you.
'*****************************************
'* Property - Address in PLC to Link to
'*****************************************
Private m_PLCAddressMaximum As String = ""
Public Property PLCAddressMaximum() As String
Get
Return m_PLCAddressMaximum
End Get
Set(ByVal maximum As String)
If m_PLCAddressMaximum <> maximum Then
m_PLCAddressMaximum = maximum
'* When address is changed, re-subscribe to new address
SubscribeToCommDriver()
End If
End Set
End Property
-
What about something like this:
Public Shadows Property Maximum As Single
Get
Return MyBase.Maximum / m_ValueScaleFactor
End Get
Set(value As Single)
MyBase.Maximum = value * m_ValueScaleFactor
End Set
End Property
-
Dear Archie,
I got an InvalidCastException error after that.
Here is my additional codes in barlevel.vb:
Public Shadows Property Maximum As Single
Get
Return MyBase.Maximum / m_ValueScaleFactor
End Get
Set(value As Single)
MyBase.Maximum = value * m_ValueScaleFactor
End Set
End Property
'*****************************************
'* Property - Address in PLC to Link to
'*****************************************
Private m_PLCAddressMaximum As String = ""
Public Property PLCAddressMaximum() As String
Get
Return m_PLCAddressMaximum
End Get
Set(ByVal maximum As String)
If m_PLCAddressMaximum <> maximum Then
m_PLCAddressMaximum = maximum
'* When address is changed, re-subscribe to new address
SubscribeToCommDriver()
End If
End Set
End Property
-
Modify the code to this:
If m_ValueScaleFactor = 1 Then
MyBase.Text = value
Else
Dim v As Double
If Double.TryParse(value, v) Then
MyBase.Text = value * m_ValueScaleFactor
Else
MyBase.Text = value
End If
End If
-
The InvalidCastException error has gone now.
But with below codes, I get wrong Maximum value (see attachment).
Without below codes, I get correct Maximum value, but no ValueScaleFactor.
Public Shadows Property Maximum As Single
Get
Return MyBase.Maximum / m_ValueScaleFactor
End Get
Set(value As Single)
MyBase.Maximum = value * m_ValueScaleFactor
End Set
End Property
-
In my case, the ScaleFactor is 0.1, so I need to have another property of MaximumScaleFactor.
Please advise, Thank you.