AF-Element Relative display with variable number of child elements

Discussion created by JohnJFors on Aug 18, 2011
Latest reply on Nov 3, 2011 by dhollebeek

I'm currently trying to build a better set of AF-Relative displays.  The problem is that any current context element can have a variable number of child elements representing a recuring similiar object.  The live application is a substation (top level element) can have many circuit breakers (child elements). 


The current model to make this work is to have a naming scheme for CBs (Circuit Breakers) where each child element is CB1, CB2, CB3....  Then the PB display has a layer for each set of CB data values to reside on.  On context change fires a VBA script which retrieves a Substation|CBcnt attribute from a value symbol in the display and makes visible, the layers associated with each CB in the Substation.  Each of the Values associated with a particular CB has a context relative column like "E.\CB1|kv", "E.\CB2|kv"  ...  where the kv is an attribute on the CB element which resolves into a PI-Tag.  This works.


My problem with this is that the AF-Model is not generalized enough.  Each Substation in the system doesn't have a CB named CB1, CB2...but each CB is uniquely identified.  To make the Model more useable than for just this set of displays, to actually serve as a way to  resolve any particular kv value the naming path should use the actual CB_id (ex:  SUB390\CB392|kv ). 


My initial thought would be to retrieve the CB element names by an AF-SDK query and then assign each of the names to a separate Context handler.  By adding to the ContextHandlers collection using VBA.


ContextHandler("E") = SUB390


ContextHandler("F") = SUB390\CB392           Value_CB1 Column = F.|kv


ContextHandler("G") = SUB390\CB453          Value_CB2 Column = G.|kv


My initial try seems to fail in that PB doesn't try to substitue the new contexthandler for each value where the context character has been changed.  Of course if I could make this work the next step would be to create a PB addin which would allow me to  query the AF model for child element names and retrieve them into VBA variables. 


I'm looking for alternate ways or ideas to make a better mouse trap for this situation as this could be leveraged in many situations.