AdvancedHMI Software
General Category => Support Questions => Topic started by: TimWilborne on January 03, 2016, 09:45:25 AM
-
I started playing with the AdvancedHMI last night and have been very impressed so far. It was very easy to get started on and functioned very well with a PLC I was accessing over a cell modem.
One thing I'm sure it is capable of that has eluded me is how to have common text use the same variable. For example "output 1" on that system is the "Trash Pump" It is used on the HOA text, the output states text, etc.
So to start with we use a color coded MessageDisplayByValue for our HOAs with different text for each value as follows.
0 = Trash pump auto off
1 = Trash pump auto on
2 = Trash pump off
3 = Trash pump hand
4 = Trash pump faulted
What I would like to do is have a variable textoutput01 so that the text assignment would be something like...
0 = textoutput01 & "auto off"
1 = textoutput01 & "auto on"
2 = textoutput01 & "off"
3 = textoutput01 & "hand"
4 = textoutput01 & "faulted"
Then be able to change one instance of the text of textoutput01 and have it change everywhere.
Thoughts? Thanks, TW
-
I was trying to come up with an easy way to do this, but one I came up involves a lot of code and the other involves modifying the MessageDisplayByValue which can seem complicated if you are new to .NET, so I will explain both methods.
This is a method using the DataSubscriber:
- From the All Windows Forms group in the ToolBox, add a Label to the form (in my expample, the name for it is Label2)
- Add a DataSubscriber to the form
- Set PLCAddressValue property
- Double click the DataSubscriber to get to the ValueChanged event handler
- Add this code:
Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
Select Case e.Values(0)
Case "0"
Label2.Text = textoutput01 & "auto off"
Case "1"
Label2.Text = textoutput01 & "auto on"
Case "2"
Label2.Text = textoutput01 & "off"
Case "3"
Label2.Text = textoutput01 & "hand"
Case Else
Label2.Text = "Unknown Message " & e.Values(0)
End Select
End Sub
I know this won't get you completely where you wanted to go, but I wanted to keep it simple enough to be able to understand the concept. If you want to pursue this technique, I can elaborate further.
I will make another post explaining another technique.
-
In the method, I will explain how to add a MessagePrefix property to the MessageDisplayByValue.
- Since you are modifying a control, be sure to close all of your forms open in Design view in order to prevent VS from getting messed up
-In Solution Explorer under the AdvancedHMIControls project, right click \Controls\MessageDisplayByValue.vb and click View Code
- Near the top your will see a Region of "Properties", expand that down if not already
- Go to the bottom of the Region which is about line 100
- Insert this code just above the line "#End Region":
Private m_MessagePrefix As String
Public Property MessagePrefix As String
Get
Return m_MessagePrefix
End Get
Set(value As String)
m_MessagePrefix = value
End Set
End Property
- Go to the bottom of the Events region and add this code:
Protected Overrides Sub OnTextChanged(e As EventArgs)
MyBase.OnTextChanged(e)
Text = m_MessagePrefix & Text
End Sub
- Build the project
You should now have a property of MessagePrefix
-
Thanks Archie
I think I want to expand this further but I'm about 10 years behind on Visual. Let me brush up a little bit and continue converting one of my screens so I can fully identify these points. Because we reuse much of our HMI code most of the text is dynamic. I'll get back with you. Thanks again.