Author Topic: Analog Value Display  (Read 3271 times)

Phrog30

  • Guest
Analog Value Display
« on: May 12, 2017, 12:23:31 PM »
There are two PLC properties for min and max, I don't see these doing anything in the code.  Am I missing something on this?  I would expect that the values for the PLC min/max would supersede the keypad min/max.  Can someone point me in the right direction please?

James

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Analog Value Display
« Reply #1 on: May 13, 2017, 10:39:01 AM »
What are the property names.... the only min and max I know of are the KeypadMinValue and KeypadMaxValue, which will not let you enter a value on the keypad outside of those limits.

Phrog30

  • Guest
Re: Analog Value Display
« Reply #2 on: May 13, 2017, 01:11:13 PM »
See attached.  I just downloaded the latest to ensure the properties I have are the same as you.

If these two properties are used, and valid, then the keypad values should be ignored and these used instead.  Right now, I don't think they do anything.  These are two important properties for the component.  Static settings are just not the way to go.

James

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Analog Value Display
« Reply #3 on: May 13, 2017, 05:44:20 PM »
If you are referring to the ValueUpperLimit and ValueLowerLimit, those are used to change the color of the text. You can see a detailed explanation here:

http://advancedhmi.com/documentation/index.php?title=AnalogValueDisplay

Those properties would have been more appropriately named ForeColorChangeThreshold1 and ForeColorChangeThreshold2

Phrog30

  • Guest
Re: Analog Value Display
« Reply #4 on: May 13, 2017, 05:58:31 PM »
Ok, you need to consider adding PLC min/max limits. It's a feature that is highly needed. I will add it myself, but you should add it for other users.

You really need to start adding comments on these properties. It might eliminate a bunch of questions. Users shouldn't have to dig in code to figure things out.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Analog Value Display
« Reply #5 on: May 13, 2017, 07:15:07 PM »
There already is a Min and Max associated with the Keypad. A Min and max not associated with any kind of input would not be able to do anything because you wouldn't want a control writing to the implicitly.

The documentation wiki is there for the purpose of anyone adding to the documentation. The details of the software are fully covered in the training classes.

Phrog30

  • Guest
Re: Analog Value Display
« Reply #6 on: May 13, 2017, 09:21:45 PM »
Archie, those are static min/max settings.  I guess you haven't had a need for those functions before.  Personally, I use them all of the time.

As for documentation, I was referring to the description for the properties.  When you are adding a property it literally takes 10 seconds, why wouldn't you do that?  For us, it will take the time to open the code, figure out the code, then add the description.  Then we have to fumble through updates and correlating your code and ours.  I really appreciate all that you do, but I'm really not understanding why you don't do the easy stuff.

Code: [Select]
Private m_Maximum As Integer = 100
    <System.ComponentModel.Description("Blah blah blah blah")>
    Public Property Maximum As Integer
        Get
            Return m_Maximum
        End Get
        Set(ByVal value As Integer)
            m_Maximum = value
            Invalidate()
        End Set
    End Property

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Analog Value Display
« Reply #7 on: May 13, 2017, 09:33:43 PM »
those are static min/max settings.  I guess you haven't had a need for those functions before.  Personally, I use them all of the time.
If you mean static as in they are not linked to a PLC tag, any atomic value property can be linked to a PLC with the addition of a single line of code to the class:

Public Property PLCAddressKeypadMaxValue as String

As long as the property name and casing matches exactly, it will automatically link. This happens in the underlying code by finding the PLCAddress* properties and checking for a matching property name to what comes after PLCAddress.

Not trying to sound smart or negative, but the top level of the software has always been left open for user contributions. You are free to add those descriptions and submit the code back to be included in the general release.

« Last Edit: May 13, 2017, 09:38:19 PM by Archie »

Phrog30

  • Guest
Re: Analog Value Display
« Reply #8 on: May 15, 2017, 02:55:32 PM »
Archie, can you share a quick example of adding this property? I'm not completely following you on it. It sounds like you are saying all I have to do is add the property, but surely there is more to it than that, right?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Analog Value Display
« Reply #9 on: May 15, 2017, 03:08:25 PM »
Here is a detailed step by step because I am sure others will want to try this:

- In Solution Explorer, expand down the AdvancedHMIControls project
- Expand down the Controls folder
- Right click AnalogValueDisplay.vb and select View Code
- Scroll down to line 284 and look for #Region "PLC Related Properties"
- Just below that at line 285, insert this line of code:
Code: [Select]
Public Property PLCAddressKeypadMaxValue as String
- It is case sensitive and must match exactly
- Rebuild the solution

Now when you add an AnalogValueDisplay to the form, you will have a property named PLCAddressKeypadMaxValue. If you put a valid PLC tag name in that property, during run time the value will be retrieved form the PLC and put into KeypadMaxValue.

Phrog30

  • Guest
Re: Analog Value Display
« Reply #10 on: May 15, 2017, 03:37:42 PM »
Ok, so it is that easy. :)
Thanks.

Phrog30

  • Guest
Re: Analog Value Display
« Reply #11 on: May 15, 2017, 06:31:05 PM »
Quick question, will this line of code work in a new component? For example I create a new component which inherits a textbox. Will adding a property and then PLC property be all I need?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Analog Value Display
« Reply #12 on: May 15, 2017, 06:47:48 PM »
Quick question, will this line of code work in a new component? For example I create a new component which inherits a textbox. Will adding a property and then PLC property be all I need?
No. There is a lot of supporting code around it that makes it work. If you look at line 463 of the AnalogValueDisplay:

            SubScriptions.SubscribeAutoProperties()

That is one of the key pieces that makes it work, but not the only.

Phrog30

  • Guest
Re: Analog Value Display
« Reply #13 on: May 15, 2017, 09:18:02 PM »
Thanks Archie.  I guess that was my original question, what all is involved.  Can you check me on this, I just created a textbox that is populated by a PLC value.  This works, but curious if I'm not in keeping with good .NET practice:

Code: [Select]
Public Class textbox_PLC

    Inherits TextBox

#Region "Constructor"
    Public Sub New()
        MyBase.New()

    End Sub

    '****************************************************************
    '* UserControl overrides dispose to clean up the component list.
    '****************************************************************
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing Then
                If SubScriptions IsNot Nothing Then
                    SubScriptions.dispose()
                End If
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
#End Region

#Region "Basic Properties"

#End Region

#Region "Private Methods"

#End Region

#Region "PLC Related Properties"
    '*****************************************************
    '* Property - Component to communicate to PLC through
    '*****************************************************
    Private m_ComComponent As MfgControl.AdvancedHMI.Drivers.IComComponent
    <System.ComponentModel.Category("PLC Properties")>
    Public Property ComComponent() As MfgControl.AdvancedHMI.Drivers.IComComponent
        Get
            Return m_ComComponent
        End Get
        Set(ByVal value As MfgControl.AdvancedHMI.Drivers.IComComponent)
            If m_ComComponent IsNot value Then
                If SubScriptions IsNot Nothing Then
                    SubScriptions.UnsubscribeAll()
                    SubScriptions.ComComponent = value
                End If

                m_ComComponent = value

                SubscribeToComDriver()
            End If
        End Set
    End Property

    Private m_PLCAddressText As MfgControl.AdvancedHMI.Drivers.PLCAddressItem
    <System.ComponentModel.DefaultValue("")>
    <System.ComponentModel.Category("PLC Properties")>
    Public Property PLCAddressText() As MfgControl.AdvancedHMI.Drivers.PLCAddressItem
        Get
            Try
                Return m_PLCAddressText
            Catch ex As Exception
                Return Nothing
            End Try

        End Get
        Set(ByVal value As MfgControl.AdvancedHMI.Drivers.PLCAddressItem)
            If ((value Is Nothing Or m_PLCAddressText Is Nothing) OrElse ((value.GetType) Is (m_PLCAddressText.GetType))) Then
                Try
                    If m_PLCAddressText IsNot value Then
                        m_PLCAddressText = value
                    End If
                    Try
                        '* When address is changed, re-subscribe to new address
                        SubscribeToComDriver()
                    Catch
                    End Try
                Catch
                End Try
            End If

        End Set
    End Property

#End Region

#Region "Events"
    '********************************************************************
    '* When an instance is added to the form, set the comm component
    '* property. If a comm component does not exist, add one to the form
    '********************************************************************
    Protected Overrides Sub OnCreateControl()
        MyBase.OnCreateControl()

        If Me.DesignMode Then
            '********************************************************
            '* Search for AdvancedHMIDrivers.IComComponent component in parent form
            '* If one exists, set the client of this component to it
            '********************************************************
            Dim i As Integer = 0
            While m_ComComponent Is Nothing And i < Me.Site.Container.Components.Count
                If Me.Site.Container.Components(i).GetType.GetInterface("IComComponent") IsNot Nothing Then m_ComComponent = Me.Site.Container.Components(i)
                i += 1
            End While

            '************************************************
            '* If no comm component was found, then add one and
            '* point the ComComponent property to it
            '*********************************************
            If m_ComComponent Is Nothing Then
                m_ComComponent = New AdvancedHMIDrivers.EthernetIPforCLXCom(Me.Site.Container)
            End If
        Else
            SubscribeToComDriver()
        End If
    End Sub

#End Region

#Region "Subscribing and PLC data receiving"
    Private SubScriptions As SubscriptionHandler
    '**************************************************
    '* Subscribe to addresses in the Comm(PLC) Driver
    '**************************************************
    Private Sub SubscribeToComDriver()
        If Not DesignMode And IsHandleCreated Then
            '* Create a subscription handler object
            If SubScriptions Is Nothing Then
                SubScriptions = New SubscriptionHandler
                SubScriptions.Parent = Me
                AddHandler SubScriptions.DisplayError, AddressOf DisplaySubscribeError
            End If
            SubScriptions.ComComponent = m_ComComponent

            SubScriptions.SubscribeAutoProperties()
        End If
    End Sub

    '***************************************
    '* Call backs for returned data
    '***************************************
    Private OriginalText As String
    Private Sub PolledDataReturned(ByVal sender As Object, ByVal e As SubscriptionHandlerEventArgs)
    End Sub

    Private Sub DisplaySubscribeError(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        'DisplayError(e.ErrorMessage)
    End Sub
#End Region

End Class