Author Topic: Adding ScaleOffset to Keypad  (Read 2161 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Adding ScaleOffset to Keypad
« on: July 13, 2020, 10:51:34 AM »
On some controls the display can use an Offset as well as a ScaleFactor. But the Keypad does not give this same functionality. This can be fairly easily added with the following steps. The edited file is attached that you can download and replace the original in your solution (see below how to use the attached file).

1) In Solution Explorer expand down the AdvancedHMIControls project
2) Expand down the \ControlsFolder
3) Right Click AnalogValueDisplay and select View Code
4) Scroll down to about line 566 until you find:
    Public Property KeypadScaleFactor() As Double
5) Scroll down past the next End Property
6) Insert this code:
Code: [Select]
    Private m_KeypadScaleOffset As Double = 0
    Public Property KeypadScaleOffset() As Double
        Get
            Return m_KeypadScaleOffset
        End Get
        Set(ByVal value As Double)
            m_KeypadScaleOffset = value
        End Set
    End Property

7) Scroll down to about line 639 and look for:
        If m_KeypadScaleFactor = 1 Or m_KeypadScaleFactor = 0 Then

8- Modify the If-Then block of code to this
Code: [Select]
                            If (m_KeypadScaleFactor = 1 Or m_KeypadScaleFactor = 0) And m_KeypadScaleOffset <> 0 Then
                                m_ComComponent.Write(m_PLCAddressKeypad, KeypadPopUp.Value)
                            Else
                                If m_KeypadScaleFactor = 0 Then
                                    m_KeypadScaleFactor = 1
                                End If
                                m_ComComponent.Write(m_PLCAddressKeypad, Convert.ToString(CDbl(KeypadPopUp.Value - m_KeypadScaleOffset) / m_KeypadScaleFactor) + m_KeypadScaleOffset)
                            End If




To insert the attached file into your solution:

1) Windows->Close All Documents
2) In Solution Explorer expand down the AdvancedHMIControls project
3) Right click the \Controls folder and select Add Existing
4) Browse to and select the attached file that was downloaded
5) Select replace
6) Rebuild Solution
« Last Edit: July 13, 2020, 10:55:48 AM by Archie »