3 Replies Latest reply on Mar 16, 2010 5:25 AM by hanyong

    SQC Charts, right-mouse-click on an Alarm

    zglenskij

      When right-mouse-clicking an SQC Alarm, I have added a menu option 'Enter SQC Comment' underneath 'Show Details and Annotations'.

       

      Question #1:  Upon selecting the menu option 'Enter SQC Comment', I want to call a subroutine.  How do I monitor for the selection and know when it happens? 

       

      Question #2:  How do I know the tag and the timestamp of the Alarm selected?

        • Re: SQC Charts, right-mouse-click on an Alarm
          hanyong

          Hi Jennifer

           

          I like to get some clarifications here

          Jennifer Zglenski

          I have added a menu option 'Enter SQC Comment' underneath 'Show Details and Annotations'

          Are you using the PI SQC Automation Interface Example on "Alarm and Comments"? or you are adding a new menu option yourself?

           

          Jennifer Zglenski

          Question #2:  How do I know the tag and the timestamp of the Alarm selected?

          "Alarm selected" meaning the value the mouse pointer is pointing to before you go into the right-click menu?

           

          The SQC Alarm Source tag can be retrieved in VBA using the SQCSymbol.GetTagname(1) method.

           

          I have moved this thread into the ProcessBook/ActiveView and Microsoft Office Development forum, since it seems to be more related to VBA and ProcessBook Environment, rather than PI SDK =)

            • Re: SQC Charts, right-mouse-click on an Alarm
              zglenskij

              To answer your first question:  I have added a new menu option.  I am not using the PI SQC Automation Interface Example.

               

              To answer your second question:  Yes, the pointer is pointing to an SQC Alarm value.  I will try SQCSymbol.GetTagname(1) to retrieve the tag.  How do I retrieve the timestamp?  SQCSymbol.GetTimestamp(1)?

                • Re: SQC Charts, right-mouse-click on an Alarm
                  hanyong

                  We can attach events handler to a new menu item programmatically. I'm not too sure you are doing this in VBA or writing an Add-in to do this, but here's a sample for VBA:

                  Dim WithEvents cbtn As PBCommandBarButton

                  ' insert custom option to Context Display Menu (right-click menu) when display opens
                  Private Sub Display_Open()
                      Dim contextmenubar As PBCommandBar
                      Set contextmenubar = Application.CommandBars("Context Display Menu")
                      Dim m_contextbtn As PBCommandBarButton
                     
                      ' reset Context Display Menu to default
                      contextmenubar.Reset
                     
                      ' add in new button on menu '
                      Set m_contextbtn = contextmenubar.Controls.Add(pbControlType.pbControlButton, 1, Null, Null, False)
                      m_contextbtn.Caption = "Add SQC Comments"
                     
                      ' attach an event to the button
                      Set cbtn = m_contextbtn

                  End Sub

                  ' task to execute when button_click event is captured.
                  Sub cbtn_click(ByVal btn As PBCommandBarButton, ByRef b As Boolean)
                      MsgBox "Add SQC Comment"
                  End Sub

                  I haven't been able to figure out a way to find the time on a trend or an SQC chart based on the mouse pointer position, a quick workaround would be to insert a cursor onto the SQC chart and you can do something like the following to get the time, value and alarm status (true or false only)

                  Private Sub SQCSymbol1_Click(ByVal lvarX As Long, ByVal lvarY As Long)
                      MsgBox SQCSymbol1.Cursors(1).Time
                      MsgBox SQCSymbol1.Cursors(1).Alarm
                      MsgBox SQCSymbol1.Cursors(1).Value
                  End Sub

                  I'll check out with the developer and see if they have any suggestion for getting the time according to the mouse pointer position as well