Author Topic: BarLevel Value Alignment question and position click keypad  (Read 2781 times)

Phrog30

  • Guest
Re: BarLevel Value Alignment question and position click keypad
« Reply #15 on: December 17, 2018, 09:53:35 PM »
Yes, you create properties. Why are you hard coding stuff? What is the point to any of this? Who labels stuff aaaaa?

Godra

  • Hero Member
  • *****
  • Posts: 1446
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #16 on: December 18, 2018, 12:26:15 AM »
This is what works for me (with 2 BarLevelEx controls on the form):

Code: [Select]
    Public BLSender As String = ""

    '***********************************************************
    '* If label is clicked, pop up a keypad for data entry
    '***********************************************************
    Protected Overrides Sub OnClick(e As System.EventArgs)
        MyBase.OnClick(e)

        If BLSender <> "" Then
            Dim ex As MouseEventArgs = e
            Dim kordinatax = ex.X

            If kordinatax < (Me.Size.Width / 2) Then
                If BLSender = "BarLevelEx1" Then
                    KeypadText = "xxxxxx"
                    PLCAddressKeypad = "400001"
                ElseIf BLSender = "BarLevelEx2" Then
                    KeypadText = "aaaaaa"
                    PLCAddressKeypad = "400011"
                End If

            ElseIf kordinatax > (Me.Size.Width / 2) Then
                If BLSender = "BarLevelEx1" Then
                    KeypadText = "yyyyyy"
                    PLCAddressKeypad = "400002"
                ElseIf BLSender = "BarLevelEx2" Then
                    KeypadText = "bbbbbb"
                    PLCAddressKeypad = "400012"
                End If
            End If
        End If

        ActivateKeypad()

    End Sub

    Public Sub ActivateKeypad()
        If KeypadPopUp Is Nothing Then
            If m_KeypadAlphanumeric Then
                KeypadPopUp = New MfgControl.AdvancedHMI.Controls.AlphaKeyboard3(m_KeypadWidth)
            Else
                KeypadPopUp = New MfgControl.AdvancedHMI.Controls.KeypadV2(m_KeypadWidth)
            End If
            KeypadPopUp.StartPosition = Windows.Forms.FormStartPosition.CenterScreen
            KeypadPopUp.TopMost = True
        End If

        '***************************
        '*Set the font and forecolor
        '****************************
        If m_KeypadFont IsNot Nothing Then KeypadPopUp.Font = m_KeypadFont
        KeypadPopUp.ForeColor = m_KeypadForeColor
        KeypadPopUp.Text = m_KeypadText

        If m_KeypadShowCurrentValue Then
            Try
                Dim CurrentValue As String = m_ComComponent.Read(m_PLCAddressKeypad, 1)(0)
                '* v3.99p - added scaling
                If m_ValueScaleFactor = 1 Then
                    KeypadPopUp.Value = CurrentValue
                Else
                    Try
                        Dim ScaledValue As Double = CDbl(CurrentValue) * m_ValueScaleFactor
                        KeypadPopUp.Value = ScaledValue
                    Catch ex As Exception
                        System.Windows.Forms.MessageBox.Show("Failed to Scale current value of " & CurrentValue)
                    End Try
                End If

            Catch ex As Exception
                System.Windows.Forms.MessageBox.Show("Failed to read current value of " & m_PLCAddressKeypad)
            End Try
        Else
            KeypadPopUp.Value = ""
        End If
        KeypadPopUp.Visible = True
    End Sub

And in the MainForm.vb:

Code: [Select]
    Private Sub BarLevelEx_Click(sender As Object, e As MouseEventArgs) Handles BarLevelEx1.Click, BarLevelEx2.Click
        DirectCast(sender, AdvancedHMIControls.BarLevelEx).BLSender = DirectCast(sender, AdvancedHMIControls.BarLevelEx).Name
    End Sub

The code allows for either the Keypad or the AlphaKeyboard to be selected.

The attached BarLevelEx control is the standalone version which I used. It might have bugs.

You are customizing everything which requires lots of time to figure out so try to figure out and use what's provided here.

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #17 on: December 18, 2018, 01:35:42 AM »
The label stuff is only for explaining purpose, not the real text. Im more of  a LAD programming PLC person, so i dont know much about visual basic language and its structure, so maybe that looks easy to you guys who are experts of doing with .vb , but im learning things that way .

Btw thanks for support


Phrog30

  • Guest
Re: BarLevel Value Alignment question and position click keypad
« Reply #18 on: December 18, 2018, 07:56:27 AM »
Im more of  a LAD programming PLC person,
OK, so what you are doing now is the equivalent of hard coding values inside an AOI, assuming you deal with RA and AOIs.  You just don't do it.  They aren't reusable anymore.

Clicking on a bar in the first place isn't common, it's not intuitive.  Most operators will not think to click there, especially to click on separate sides.  It would be better to simply place two buttons, then it's obvious.

However, if you want to the functionality...
You have properties for KeypadText & PLCAddressKeypad.  You basically need to create two more and relabel the existing ones.  So, something like, KeypadTextRight, KeypadTextLeft, PLCAddressKeypadRight, PLCAddressKeypadLeft.  Now your control is resuable. 

Godra

  • Hero Member
  • *****
  • Posts: 1446
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #19 on: December 18, 2018, 05:36:22 PM »
The code you posted in the reply #7 might work as you originally intended, just change MouseClick to Click.
Ignore all suggestions posted afterwards and try to revert everything to the point you had at that time.

If this works then you can create separate subs for each bar level.
« Last Edit: December 18, 2018, 05:41:41 PM by Godra »

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #20 on: December 20, 2018, 03:30:11 AM »
Just need to change from MouseClick to Click, now it works. Tnx
Phrog i know that in most cases when barlevel is used its for displaying value (graphic) of gas tank etc. ,and clicking on a bar has no meaning. But i actually draw a time diagrams for traffic lights at intersections, and if operator wants to change time for green light, if clicked on left he shorten that time, clicked on right he can extand that time. 

bachphi

  • Hero Member
  • *****
  • Posts: 653
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #21 on: December 20, 2018, 09:49:00 AM »
That's interesting!

It sounded like in the movie, guys robbed the bank, then use their escape car and turn all traffic lights to red after they passed intersections. Godra and James could be implicated as his accomplice in the future :=)

Happy Holidays everyone!
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: BarLevel Value Alignment question and position click keypad
« Reply #22 on: December 21, 2018, 09:57:20 AM »
Not my intention, but could simply be done 😁. Ill deny any connection to AHMI if comes that far.

On what principe can be done to write to register with resizing object and lenght of object will be value to write? Any idea?