General Category > Application Showcase

Embedded variables

<< < (4/5) > >>

Godra:
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: ---    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

--- End code ---


Arvanoss:
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: ---                    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

--- End code ---

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


--- Code: ---                        If FinalString = "" Then FinalString = " "

--- End code ---

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

Godra:
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.

jimtech1967:
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

MajorFault:
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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version