6 Replies Latest reply on Jan 25, 2013 11:07 PM by santiago_pet

    Processbook Button Controls and AF Navigation


      I have 2 Process book displays (PDI's).


      - One PDI ('office.PDI') contains a camera view of an office with computer equipment in it. Each equipment has a button control labeled '"detail" under each.
      - The 2nd PDI is a single detailed page ('equipment_detail.pdi) which contains information like name, make, model, price, location..etc. This PDI is AF driven with an AF list (containing all the equipement) exposed.


      The idea is to have the person click on the button on the global.pdi and take them to the 'equipment_details.pdi' with information for that equipment pre-populated in the display. From there the user can toggle back to the 'office.pdi' or select other equipment from the AF menu for viewing.


      I'm thinking that this would require VB coding for the button to pass AF parameters to the 'equipment_details.pdi' to prepopulate it. I guess my question is if there is an example where I can pass an AF string (via an _onClick function) to my AF driven pdi and have that information appear pre-populated. This would save on the user have to 'fish' for equipment through a huge AF tree when clicking on an image (or button) in the preceding PDI could essentially guide them to particular element or attribute in the tree.

        • Re: Processbook Button Controls and AF Navigation

          Hi Peter, is your equipment_detail.pdi display an element relative display? If so you can change the context via VBA based on the equipment the user selects. I did this by having a hidden text symbol on the detail display that is updated from the "overview" display and then the detail display_dataupdate event would then change the "E" context to that equipment's path. Works a treat. On my overview display I used labels instead of buttons, where the labels were named accordingly to be picked up by the SelectionChange event logic I had.

            • Re: Processbook Button Controls and AF Navigation

              Hello Rhys,


              I really appreciate the immediate response to this. Thanks a million. Your solution is exactly what I am looking for to complete the loop. I'm assuming that with this in place I could hide the AF pane to the left of the target display to make it look clean or clutter free. Are you at libery to post the snippet of what the code would look like from the label or vb_button control?

                • Re: Processbook Button Controls and AF Navigation

                  I found this VBA snippet which changes ERD's dynamically onclick.

                  Private Sub Text5_Click(ByVal lvarX As Long, ByVal lvarY As Long)
                      Dim myLocalDevice As String
                      Dim myDevice As String
                      myLocalDevice = "\\PI-SYSTEM-2010\Training Sample\OSIsoft Enterprises\Geography\Houston\Chemicals Division\02 - Production\Production Line 1\2 - Reactor Train\HOU Reactor 102" 'Watch out for word wrap error--this is 1 line in VBA
                          Dim myContextHandler As ContextHandler
                          Dim myNamedValues As PBNamedValues
                          Dim myAFContextString As String
                          Set myContextHandler = ThisDisplay.Application.ContextHandlers("E")
                          Set myNamedValues = myContextHandler.ContextData(ThisDisplay)
                          While myNamedValues.Count > 0
                              myNamedValues.Remove (1)
                          myAFContextString = myLocalDevice 'This should be full path, not relative path.
                          myNamedValues.Add "ERD.Context1", myAFContextString
                          myContextHandler.ContextData(ThisDisplay) = myNamedValues
                          myContextHandler.CurrentContext(ThisDisplay) = myAFContextString
                          myContextHandler.ContextUpdated ThisDisplay
                          myDevice = myLocalDevice
                  End Sub

                   The above code snippet i believe can help me toggle between assets while im on the 'target_detail.pdi'. I can hide the AF pane now. What I'm looking for is somewhat the same but I'm coming from a 'main.pdi' to the 'target_detail.pdi', of which this relative information should be prepopulated.


                  use case


                  - user clicks on label (or button) "some_asset"  underdeath an image of the asset on "main.pdi"
                  - "target_detail.pdi" opens up with element relative information pre-populated.
                  - user can toggle to information about other assets on the 'target_detail.pdi' (I think the above code snippet helps me here)


                    • Re: Processbook Button Controls and AF Navigation

                      Peter, see below.


                      In the "overview" I would do:

                      Private Sub Display_SelectionChange()
                      If ThisDisplay.SelectedSymbols.Count = 0 Then Exit Sub
                      If Application.RunMode = False Then Exit Sub
                      Dim s As Symbol
                      Set s = ThisDisplay.SelectedSymbols(ThisDisplay.SelectedSymbols.Count)
                      If Left(LCase(s.Name), Len("myprefix")) = "myprefix" Then
                          Dim d As Display
                          Set d = ThisDisplay.Application.Displays.Open(Replace(ThisDisplay.Path, Split(ThisDisplay.Path, "\")(UBound(Split(ThisDisplay.Path, "\"))), "") & "OVERVIEW.pdi", True)
                              d.Symbols("HIDDEN_CONTEXT").Contents = s.Contents
                              d.Modified = False
                          Set d = Nothing
                      End If
                      Set s = Nothing
                      End Sub



                      where the symbol named "HIDDEN_CONTEXT" is a Label on the detail ERD.


                      The on the "detail" ERD I do the following:

                      Private Sub Display_DataUpdate()
                      If Application.RunMode = False Then Exit Sub
                      Dim sContext As String
                      sContext = Application.ContextHandlers("E").CurrentContext(ThisDisplay)
                      If Not LCase(Split(sContext, "\")(UBound(Split(sContext, "\")))) = LCase(Symbols("HIDDEN_CONTEXT").Contents) Then
                          Application.ContextHandlers("E").CurrentContext(ThisDisplay) = Replace(sContext, Split(sContext, "\")(UBound(Split(sContext, "\"))), "") & Symbols("HIDDEN_CONTEXT").Contents
                      End If
                      End Sub



                      Hope this helps.



                        • Re: Processbook Button Controls and AF Navigation

                          Hi Rhys,


                          Maybe I'm missing something here. I was more looking for a VBA label_onclick that passes the context FROM the overview.pdi, opens and passes this to the detail.pdi.


                          navigation from 'overview.pdi' to 'detail.pdi' via _onclick VBA context pass.


                          I have label "serverA" in the 'overview.pdi' and _onclick it opens detail.pdi with element relative values for serverA populated.
                          similarly if I click on the label titled "serverB" in the 'overview.pdi' it opens (or refreshes) the 'detail.pdi' with element relative values for serverB...etc
                          users can click on the 'home' label to go back to the 'overview.pdi', or they can remain in the 'detail.pdi' and change the ERD through the labels there with the same context functionality


                          Hopefully this makes sense

                            • Re: Processbook Button Controls and AF Navigation

                              Figured it out (after stepping away from the keyboard for a spell) and in basically came up with 2 lines of code.



                              Private Sub SomeLabelA_Click(ByVal lvarX As Long, ByVal lvarY As Long)
                              Dim myDisplay As Display
                              Set myDisplay = Application.Displays.Open("C:\AssetDisplays\detail.pdi", True)
                              myDisplay.ContextHandlers("E").CurrentContext(myDisplay) = "\\MYAFSERVER\MyAssets\ServerA"
                              End Sub
                              Private Sub SomeLabelA_Click(ByVal lvarX As Long, ByVal lvarY As Long)
                              ThisDisplay.ContextHandlers("E").CurrentContext(ThisDisplay) = "\\MYAFSERVER\MyAssets\ServerB"
                              End Sub

                              Problem solved. Now I can navigate between my overview.pdi and detail.pdi as well :)