AdvancedHMI Software

General Category => Application Showcase => Topic started by: Phrog30 on October 21, 2017, 07:16:08 PM

Title: Embedded variables
Post by: Phrog30 on October 21, 2017, 07:16:08 PM
I spent some time today working on getting embedded variables to work.  Right now it's rather rough, but I think it should work out nicely.  It works like placeholders in RA software ({#1} - is a pointer to PLC address 1 in the collection).  Right now I have the PLC addresses hard coded, but when it's said and done, it will be a collection that can be edited in the control.  All of this will work without writing a single line of code.  My example has 4 states in a multistate indicator.  Just showing off the potential of AdvancedHMI.

James

Title: Re: Embedded variables
Post by: timryder on November 07, 2017, 07:51:19 AM
Again this looks REALLY good james.  These controls you're coming up with should be added to the AHMI libraries for sure.
Title: Re: Embedded variables
Post by: Phrog30 on November 07, 2017, 09:50:49 AM
Thanks, I think Archie is working on several things that should really make things better.  I believe he has been on some projects so time has been hard to come by for him.

James
Title: Re: Embedded variables
Post by: Phrog30 on April 04, 2018, 09:26:26 AM
I added this control to a base app and added some examples if anyone is interested.

See later link....

James

Edit: updated, added observable collections
Title: Re: Embedded variables
Post by: Phrog30 on April 05, 2018, 03:01:37 PM
Updated, found a few issues:
See later link....

I found an issue I think is CLX driver related.  If I have datasubscriptions to the same string non-82 character the driver will stop working.  I can also duplicate if I drop two basic labels and point to the same string non-82 character.  Hopefully Archie can duplicate and issue a fix.  (The Beta version seems to have addressed this issue!)

James
Title: Re: Embedded variables
Post by: Phrog30 on April 09, 2018, 01:35:25 PM
I think I have all bugs fixed.  I added INI for messages and embedded variables.
Here's the app: https://drive.google.com/file/d/1GqH4FxCVq8GCQGnNjzITB7D-E_7L0I2W/view?usp=sharing (https://drive.google.com/file/d/1GqH4FxCVq8GCQGnNjzITB7D-E_7L0I2W/view?usp=sharing)

If anyone needs a write up on this control, please let me know.  I don't want to spend time on something that won't get used, but I can make one if it will help someone.  The basic premise is you have state collections and embedded collections.  If you want to use a PLC value in a state, like time, pressure, temperature, etc., you add this address to the embedded collection.  You only need to add the name.  You never need to worry about the value.  The data type only becomes an issue when dealing with custom length strings in CpLX/CLX.  If you need to use a custom length string, which is basically anything other than 82 characters, you will select partial string.  All other times you can enter any data type, as of right now I'm only looking for partials.  The order in which you enter embedded variables is how you reference them in the states, starting at 0.  So, the first embedded variable is referenced by typing {#0}.  The next variable is {#1}, and so on.  It needs entered exact.  This, { #1} will not work.  You can reference these variables many times in the same state, or other states.  For example,  the first state message can be, "Step 1 on wash cycle, water temp = {#0}, time remaining = {#1} seconds".  I could also enter, "Step 1 on wash cycle, water temp = {#0}, time remaining = {#1}, by the way water temp = {#0}".  If you want to use the value of the control itself, you can enter {#Me}.  There are slight differences between the multistate and analog, the main difference being one allows an entry.

James
Title: Re: Embedded variables
Post by: Godra on April 29, 2018, 02:55:36 PM
I tried it and it seems to be a neat control (as the attached picture shows).
Title: Re: Embedded variables
Post by: Arvanoss on August 16, 2018, 11:30:16 AM
Gentlemen,

I would like to use Embedded Variables in my project.  I have looked over your example and tried to figure out how to make it work but I am stuck.

Background:
I have a "Screen" that I need to display the data from 64 (Identical) stations on the plant floor based on the selection from a dropdown box. 
I can build all of the "pop-up screens" and overlay them but thought it would be better to use Embedded Variables.

The Multistate used in your example allows for connection to a .txt file with all the states listed but in the Beta12 release that function is not available.  How can I use the Embedded Variables in my project?
There will be as many as 18 Embedded Analog data points and digital indicators related to the 64 stations.

Thanks
Randy

Title: Re: Embedded variables
Post by: Phrog30 on August 17, 2018, 01:03:40 PM
What exactly do you need help with? Have you been able to add the control to your project?
Title: Re: Embedded variables
Post by: Arvanoss on August 20, 2018, 01:00:10 PM
I have not added the control to my project, sorry to say I don't know how to include the control.

Edit:  I did figure it out...I looked around forum and found how to add the controls to my project.

Thanks
Randy
Title: Re: Embedded variables
Post by: Phrog30 on August 21, 2018, 02:09:00 PM
There is info on this forum on how to add controls.

Can anyone assist on this, I'm on a start-up.
Title: Re: Embedded variables
Post by: Godra on August 21, 2018, 05:19:39 PM
He already figured it out.
Title: Re: Embedded variables
Post by: Phrog30 on August 21, 2018, 11:59:19 PM
He already figured it out.
Good to hear
Title: Re: Embedded variables
Post by: Arvanoss on August 23, 2018, 10:39:02 AM
Gentlemen,

I have installed, configured and tested several Multistate Indicators with Embedded Variables....These are GREAT.

I have one issue, using the FullString Data Type, when the value is blank or empty the Message is displayed with the placeholder number rather than just a blank space i.e. Job ID 3 for value of 3 in the PLCAddressValue.  I've not used the PartialString yet but I assume it reacts the same.
Is there anything I can do to just display a blank field when the tag data is empty??

Thanks
Title: Re: Embedded variables
Post by: Phrog30 on August 23, 2018, 11:00:23 AM
That's interesting, I don't think I ever tested empty strings. I'm not sure I will have time to look into it.

Godra, any chance you could look into this please?
Title: Re: Embedded variables
Post by: Godra on August 23, 2018, 10:05:41 PM
I am not completely sure about this one but the code below might be working.

Add the "Else" part to the Private Sub PLCDS_DataChanged inside the ctrlMultiState control:

Code: [Select]
    Private Sub PLCDS_DataChanged(sender As Object, e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)

        If Not Me.DesignMode Then

            For i = 0 To m_EmbeddedVariables.Count - 1
                If m_EmbeddedVariables.Count > 0 Then
                    If e.PlcAddress = m_EmbeddedVariables(i).Name Then

                        If e.Values(0) IsNot Nothing Then

                            If m_EmbeddedVariables(i).Type = AHMI_v1.PLCItems.DataType.PartialString Then
                                m_EmbeddedVariables(i).Value = ExtractString(e.Values(0))
                            Else
                                m_EmbeddedVariables(i).Value = e.Values(0)
                            End If

                        Else

                            If m_EmbeddedVariables(i).Type = AHMI_v1.PLCItems.DataType.PartialString OrElse m_EmbeddedVariables(i).Type = AHMI_v1.PLCItems.DataType.FullString Then
                                m_EmbeddedVariables(i).Value = " "
                            End If

                        End If
                    End If
                    Update_Embedded_Variables()
                End If
            Next

        End If

    End Sub


Title: Re: Embedded variables
Post by: Arvanoss on August 27, 2018, 08:46:44 AM
Godra,

Thanks for looking at this, I added the Else statement then put a breakpoint in the routine.  Looking at the Code the Else statement would never be seen as I believe that the "e.Values(0) IsNot Nothing" is never nothing even if the value is a blank field.

I single stepped through more of the program and found in the "Update_Embedded_Variables()" is where what gets displayed is updated per the data from the field.  I single stepped around in this loop until I was able to catch what was happening.
In the following code the FinalString does get set to the Blank data as expected but on the next loop is set back to the OriginalString because it is Blank.

Code: [Select]
                    If FinalString = "" Then
                        FinalString = OriginalString.Replace("{#" & i & "}", m_EmbeddedVariables(i).Value)
                    Else
                        FinalString = FinalString.Replace("{#" & i & "}", m_EmbeddedVariables(i).Value)
                    End If
                    MessageStrings(index) = FinalString

To fix the issue I added this code to the Else portion of the statement. 

Code: [Select]
                        If FinalString = "" Then FinalString = " "

So far it appears to be working, I used a few characters for the testing but the " " is the end result I needed.

Thanks
Randy
Title: Re: Embedded variables
Post by: Godra on August 29, 2018, 12:00:21 AM
Cool.

I didn't test it properly so my code probably isn't working.
At least it got you started and, with the smart stepping through the code, find a proper solution.
Title: Re: Embedded variables
Post by: jimtech1967 on November 30, 2020, 09:20:24 AM
I am looking to display values from a SLC500 and embed in in my MessageDisplayByValue message collection
Registers like N7:1, N7:2 Etc..
How do i set up the .ini file and where do I put it ??
I am electrician that works with PLCs Not Visual Studio.
I have the AdvancedHMI working and communicating to my plcs but would like to
embed variables in the MessageDisplayByValue
Title: Re: Embedded variables
Post by: MajorFault on November 30, 2020, 01:22:23 PM
The MessageDisplayByValue can't do what you want.  You will either need to use a custom control, which already exist and are on this forum, or will need to just use a label and create your own text using subscriptions and lookup tables.  If you don't have experience with VS this may be a tough one.
Title: Re: Embedded variables
Post by: Godra on November 30, 2020, 01:37:04 PM
jimtech1967,

Each of the messages is displayed depending on the predetermined value so since you know what the value is then just include it in the message itself.
It is the easiest approach and doesn't require any special knowledge of Visual Studio.
Title: Re: Embedded variables
Post by: MajorFault on November 30, 2020, 04:02:57 PM
One of us is confused. 😁

An embedded variable is not predetermined and changes so you can't enter ahead of time. So I guess the question is does the value you want to enter change constantly?
Title: Re: Embedded variables
Post by: Godra on November 30, 2020, 06:23:11 PM
It could be me but let's wait for jimtech1967 to confirm what he wants exactly.