19 Replies Latest reply on Mar 25, 2010 10:20 PM by spilon

    Ensure that ProcBook Details Pane is visible

    cjrancur

      I built a Process Book that includes 2 listboxes, one with a list of process areas, and one with a list of key PI tags within those process areas.  When an item in the process area listbox is selected, the related list of PI tags is shown in the second list box.  When a PI tag is selected from the second listbox, an SQC plot and a trend plot are shown in the same ProcBook display for the selected PI tag.  The SQC control limits are defined via custom PI point attributes, which are set programmatically in another program that uses PI OLEDB based upon specs for products currently running.

       

      I want to ensure that the Details pane will always be visible to show tabular data in this Process Book display. I can't find a vba object reference in the online manual for the Details pane. What is the object name for the details pane?  Is there a method that can be called to ensure that the details pane is visible?

        • Re: Ensure that ProcBook Details Pane is visible
          cjrancur

          There is another issue I am dealing with.  My first question still holds from the previous post, " How do I ensure that the View Pane is visible." I'm still looking for an answer to that one. But then there's an additional, related question that I also need to answer.

           

          The second question is how to select a data object for display in the view pane.  To show details, a data object must be selected.  I find that if I click on the trend and then on the SQC plot, or do the same in reverse order, click on SQC plot and then on the trend, the Details pane will usually populate with data.  A single click on only one of the trends does not seem to populate data into the Details pane.

           

          I tried to program an equivalent to the mouse clicks.  I used the following commands, but the ProcBook display did not populate the data to the Details pane.  What commands do I need to use, instead of the ones below, to get this to behave the same way via vba programming as it does via mouse clicks?

          Trend1.Selected = True
          Application.Redraw = True

          SQCSymbol1.Selected = True
          Application.Redraw = True

            • Re: Ensure that ProcBook Details Pane is visible
              hanyong

              Hi Carrie,

               

              Details and Annotations is an addin to ProcessBook, I was able to access the Dock window of the addin through the Application.DockWindows object in VBA.

               

              Something like:

              Dim i As Integer
              For i = 1 To ThisDisplay.Application.DockWindows.Count
                  If ThisDisplay.Application.DockWindows.Item(i).Title = "Details" Then
                      ThisDisplay.Application.DockWindows.Item(i).Visible = True        
                  End If
              Next
               

               

              I haven't looked into your second question yet. I'll take a look at it again in the later part of the day 

                • Re: Ensure that ProcBook Details Pane is visible
                  dhollebeek

                  To select a symbol it's something like:

                  ThisDisplay.SelectedSymbols.Add(Trend1)
                    • Re: Ensure that ProcBook Details Pane is visible
                      cjrancur

                      David Hollebeek

                      To select a symbol it's something like:
                      ThisDisplay.SelectedSymbols.Add(Trend1)

                       

                      I built a private subroutine into "This Display" as follows, but the "selectedsymbols.add" method, gave an error saying that the object does not support this method.

                      Private Sub SelectTrendToShowDetailsPaneData()
                        ThisDisplay.SelectedSymbols.RemoveAll
                        ThisDisplay.SelectedSymbols.Add (Trend1)
                      End Sub

                      Then I varied the subroutine as follows.

                      Private Sub SelectValue1ToShowDetailsPaneData()
                        ThisDisplay.SelectedSymbols.RemoveAll
                        Value1.Selected = True
                        Application.Restore = True
                      End Sub

                      I also tried application.Refresh and Application.Redraw instead of Application.Restore.  I don't know the difference between these.  Nothing so far has worked to populate data into the details pane, except for a mouse click. 

                       

                      Until I can get this working, I'll just tell the users to click on the Value, the SQC chart or the Trend within this display if there are no details appearing in the details pane.  I haven't succeeded in doing this programmatically.

                        • Re: Ensure that ProcBook Details Pane is visible
                          dhollebeek

                          I just looked it up.  It's ThisDisplay.SelectedSymbols.Add("Trend1").

                           

                          (Notice the quotes).

                            • Re: Ensure that ProcBook Details Pane is visible
                              cjrancur

                              David Hollebeek

                              I just looked it up.  It's ThisDisplay.SelectedSymbols.Add("Trend1").

                               

                              (Notice the quotes).

                               

                               

                               

                               

                              Thanks David, that got rid of the error.

                               

                              But, I still haven't succeeded in my overall task.  The screen showed the red outlines to show that the value was selected, However, this programmatic selection did not duplicate the results of a mouse click selection.   Unfortunately, my main goal wasn't met.  The details pane stayed blank.  Programmatic selection of the data object did not populate data into the details pane as a mouse click does.

                                • Re: Ensure that ProcBook Details Pane is visible

                                  Hi Carrie,

                                   

                                  Let me jump in here as I looked in to this a while ago and had a "dirty" solution for the problem I had at the time.

                                   

                                  The SelectedSymbols.Add method will, to my understanding, only set the "Selected" property of a symbol to True.  It won't trigger the "SelectionChange" event of a display or the "Click" event of a symbol. The Detals addin will be hooked in to the "Display_SelectionChange" event and look at the last symbol added to the SelectedSymbols collection, so you need to generate this event.

                                   

                                  I had to turn to Win32 API to simulate the mouse clicks on symbols, below is briefly what I did but OSI or others may have a better method..?

                                   

                                  - Get the screen width in pixels. (Win32 GetsystemMetrics)
                                  - Set the coordinates for the centre of the screen.
                                  - Set the cursor position to centre coordinates. (Win32 SetCursorPos)
                                  - Set the viewport of the display to that of the symbols dimensions (ThisDisplay.SetViewPort)
                                  - Simulate mouse left button click. (Win32 mouse_event)
                                  - Revert the viewport back to what it was before.

                                  
                                  

                                  Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
                                  Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
                                  Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

                                  Sub test()
                                  Call ClickThisSymbol(Symbols("Trend1"))
                                  End Sub
                                  Public Sub ClickThisSymbol(ByVal TheSymbol As Symbol)

                                  Dim XVal As Long, YVal As Long

                                  Const SM_CXSCREEN = 0 ' Width of screen
                                  Const SM_CYSCREEN = 1 ' Height of screen

                                  Const MOUSEEVENTF_LEFTUP = &H4
                                  Const MOUSEEVENTF_LEFTDOWN = &H2

                                  XVal = GetSystemMetrics(SM_CXSCREEN)
                                  YVal = GetSystemMetrics(SM_CYSCREEN)

                                  Dim vWidth As Long: vWidth = ThisDisplay.ViewWidth
                                  Dim vHeight As Long: vHeight = ThisDisplay.ViewHeight
                                  Dim vLeft As Long: vLeft = ThisDisplay.ViewLeft
                                  Dim vTop As Long: vTop = ThisDisplay.ViewTop

                                  ThisDisplay.SetViewPort TheSymbol.Top, TheSymbol.Left, TheSymbol.Height, TheSymbol.Width

                                  SetCursorPos XVal / 2, YVal / 2
                                  mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0

                                  SetCursorPos XVal / 2, YVal / 2
                                  mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

                                  ThisDisplay.SetViewPort vTop, vLeft, vHeight, vWidth

                                  End Sub

                                   

                                  Obviously there are potential flaws (another symbol on top of another symbol, docked window blocking symbol, the scale for a symbol is too small to be displayed etc) but it served a purpose at the time so might be useful.  I was tempted to do more work on this but the effort vs benefit wasn't very favourable - OSI just need to stick a trigger for the SelectionChange event from the SelectedSymbols.Add method.

                                    • Re: Ensure that ProcBook Details Pane is visible
                                      hanyong

                                      Wow, seems like I'm too slow to get back before everyone else does. It's nice to see people jumping in actively

                                      • Re: Ensure that ProcBook Details Pane is visible

                                        As Rhys pointed out, simulating a mouse click is typically more of a Windows API thing - that's not only true for PI ProcessBook, but for a good number of applications/objects that support automation. It all depends on the internal implementation of the methods like "Select", and whether they take this extra step of simulating the mouse click themselves... they usually do not

                                         

                                        @Rhys: Thanks for going the extra mile kilometer and putting together this code snippet!! One could simply have said "go use the "Win32 API"...

                                        • Re: Ensure that ProcBook Details Pane is visible
                                          cjrancur

                                          Thanks Rhys,

                                           

                                          I am not versed in Win32 API, so I appreciate the example. The inclusion of the code snippet is helpful.  I found an MSDN reference to the windows user interface for mouse inputs at: http://msdn.microsoft.com/en-us/library/ms645533(VS.85).aspx.  The reference mentions that the "mouse_event" method used in this older code snippet has since been superceded by a similar, upgraded method.

                                           

                                          For me, that just emphasizes a question I've been grappling with.  How much custom code should be written, since custom code will eventually require re-write and maintenance due to OS upgrades, PB version changes, and other changes in general software usage?  In this case, I'd like to be able to access an object built by OSIsoft, not by me, to ensure that the details pane will be populated.  I'd rather have OSIsoft bear the responsibility and risks for ensuring consistent upgrades across future OS's and PB versions, rather than me.  That's been a piece of the logic I've used to sell OSIsoft interfaces to my management, rather than continuing to write home-built, custom interfaces to PI.

                                           

                                          I wonder if there is a way to request an OSIsoft change such as you suggested, using vCampus.  Or do such requests always need to be submitted via tech support?  Your suggestion was that OSIsoft could:

                                           

                                          Rhys @ RJK Solutions

                                          stick a trigger for the SelectionChange event from the SelectedSymbols.Add method.

                                           

                                          After looking over the options presented on vCampus, my plan is to see if our users will accept the blank screen sometimes, without just closing the application, as long as I work hard to train them to make mouse clicks so that they can see the data via the details pane.  That will be my first approach, since doing this programmatically has proven more complex initially, and potentially more problematic for long term maintenance, than I had hoped. 

                                           

                                          Thanks again for sharing your knowledge and programming tips and snippets, Rhys,

                                           

                                          Carrie

                                            • Re: Ensure that ProcBook Details Pane is visible
                                              dhollebeek

                                              This does seem like a bug.  I'll write it up.  The fix probably won't make it into PB 2010 though.

                                                • Re: Ensure that ProcBook Details Pane is visible
                                                  cjrancur

                                                  Thanks to all who have contributed.  David, thanks also for writing this up as a software improvement for future releases.

                                                    • Re: Ensure that ProcBook Details Pane is visible

                                                      Carrie Rancuret

                                                      I wonder if there is a way to request an OSIsoft change such as you suggested, using vCampus.  Or do such requests always need to be submitted via tech support?
                                                      In this case we already had a ProcessBook developer involved in the discussion thread (thanks David!), but your best bet for submitting enhancement requests or bugs is definitely our regular Technical Support. They have the right to file, organize, escalate, etc.  these.

                                                       

                                                      Who knows, maybe at some point in the future we will have a button on the vCampus Discussion Forums, to "File this as an bug/enhancement request", with direct connection to our bugs/enhancement tracking system

                                                        • Re: Ensure that ProcBook Details Pane is visible

                                                          Steve Pilon

                                                          Who knows, maybe at some point in the future we will have a button on the vCampus Discussion Forums, to "File this as an bug/enhancement request", with direct connection to our bugs/enhancement tracking system

                                                           

                                                           

                                                          That would be nice.  As there is so much programming related chat on here, a lot of bugs (feature limitations ) will likely originate from such chat.  Maybe at the weekly vCampus meetings you summarise any bugs/issues that have been raised during the week and submit to Tech Support on the commuintys behalf..?

                                                            • Re: Ensure that ProcBook Details Pane is visible

                                                              Rhys @ RJK Solutions

                                                              Maybe at the weekly vCampus meetings you summarise any bugs/issues that have been raised during the week and submit to Tech Support on the commuintys behalf..?
                                                              Rest assured we do communicate a good number of requests over to the Product Management and Development teams. Also, as you could see in various posts, the Product Managers are involved in vCampus and definitely use it as a platform to gather feedback.

                                                               

                                                              With that said, reporting something to tech support is still a very good way to capture data around particular requests. Doing so will either result a new PunchList Item (PLI) being created, or in more and more calls being added to a given PLI. And you probably guessed it by now... the more calls assigned to a PLI, the more weight it's got Especially when it comes from customers and partners, as opposed to us (the vCampus team) reporting those.

                                          • Re: Ensure that ProcBook Details Pane is visible
                                            cjrancur

                                            Thanks Han,

                                             

                                            Your answer leads me to wonder about a more general question about building programs that are efficient.  I'll start with this case and then work out to the more general case.  If I want to set a parameter to "True", is it more efficient to first check to see if it is true, and then set it true only if so, or is it more efficient to avoid the extra "if" statement and just set the parameter to "True", even if it may already be set to "True".

                                             

                                            Once the object is obtained, is Statement 1) more efficient:

                                             

                                                   Statement 1)  ThisDisplay.Application.DockWindows.Item(i).Visible = True    

                                             

                                            or is Statement 2) more efficient:

                                             

                                                  Statement 2) If ThisDisplay.Application.DockWindows.Item(i).Visible <> True then ThisDisplay.Application.DockWindows.Item(i).Visible = True    

                                             

                                            Can a general rule be stated for the answer to the above?  For instance, does this hold true in vba, vb6, vb.net in all varieties, and for a variety of objects, or is this something that differs depending on both the compiler (or line reader for non-compiled code) and the object properties?  Is this worth considering, or is the difference so small that I've already wasted more time writing the question than could be gained by any operational efficiency at run time?  Is a profiler (or a debug timer) needed to answer this question in the specific, or can a reasonable generalization be made for certain compilers or systems?  I assume that the compiler that takes care of statement 1) may have an implicit test that includes statement 2) already present behind the scenes for managed code like vb.net or c#.net, so my guess would be that statement 1) may be more efficient in a managed code context, but I really don't know.  I wonder if someone has looked into this and can talk about the basic matters of efficiency for examples like these.

                                             

                                             

                                              • Re: Ensure that ProcBook Details Pane is visible
                                                dhollebeek

                                                In general, statement 1 is faster (it's just a single assembly instruction rather than 2).  In dealing with PB automation, statement 1 is much faster because Item(i) needs to be executed both times along with Visible (which actually calls a method in PB including crossing from managed to unmanaged code which is MUCH more than a single assembly instruction).

                                                  • Re: Ensure that ProcBook Details Pane is visible
                                                    cjrancur

                                                    Thanks David,

                                                     

                                                    I once found a serious Microsoft article about "double thunking".  Made me think of the sound  a pair of tennis shoes might make in a dryer!  

                                                     

                                                    But Microsoft was talking about dipping into unmanaged code repeatedly, and perhaps unintentionally, when it would not really be necessary.  That should be avoided if possible.  Thanks for the explanation.  I would not have guessed that "double thunking" might apply for statement 2) in my previous post.  Sounds like it does.

                                                     

                                                    Carrie