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.
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?
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) Wend 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.
- 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)
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.
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.
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
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 :)