18 Replies Latest reply on Jun 23, 2015 1:12 PM by JanvanderVen

    Substitution Parameters in AF Analyses

    vwitzel

      Hi,

       

      I am trying to create an AF Analysis on a parent AF Element that uses AF Attributes on child Elements as calculation inputs. I understand that this is possible by using the relative path to the Attribute of the child Element (e.g., '..\..\Meters\EFM Meters\1234|EFM Previous Days Volume'). However, I would like to templatize this Analysis and use a substitution parameter for the child Element name (e.g., replace "1234" in the relative path with a substitution parameter). Is there any way to do this?

       

      Thanks,

      -Vincent

        • Re: Substitution Parameters in AF Analyses
          vwitzel

          Problem resolved through the generous help of Ales at OSI . Through the use of ".\Elements[@Name=A*]|AttributeName" you can filter for the child Element you need. "@Name" is only one of the parameters you can use. The others are listed below.

           

          @Index (starts at 1)

          @Template

          @Category

          @ReferenceType

          @Description

          @Type (e.g., System.Int32)

          @UOM

           

          You can also logically combine (AND condition) these (e.g., .\Elements[@Name=A*][@Template=B*]). Hope this helps others facing similar challenges

          4 of 4 people found this helpful
          • Re: Substitution Parameters in AF Analyses
            JanvanderVen

            Thanks for sharing this.

            How performant is this solution? Is there a way to specify the root element?

              • Re: Substitution Parameters in AF Analyses
                vwitzel

                Hi Jan,

                 

                What do you mean in terms of performant? The short-coming to this approaching is of course that if AF Element names change, the references could break.

                 

                You can use the same syntax to select Elements at the root. Here's an example to select an Element that begins with "E" at the root: '\Elements[@Name=E*]|[AttributeName]'

                 

                Hope that helps!

                  • Re: Substitution Parameters in AF Analyses
                    JanvanderVen

                    I mean that the syntax suggests that AF will search the complete "address space". For a big model this seems inefficient. That's why I asked about performance. One way to increase it would be to specify a root element from which the search would start. That was my second question.

                      • Re: Substitution Parameters in AF Analyses
                        David Hearn

                        It may be counter intuitive, but most searches are actually slower when you specify a search root element. This is because it is more efficient to search the full address space than try to determine if an element is under a root element in the hierarchy. To determine if an element is under a root element, it must search up the hierarchy. In AF Server 2.6 or later, there have been significant improvements with the introduction of an element hierarchy path cache in the server. But it is still normally faster to not specify a root element for the search.

                         

                        The specified syntax of '.\Elements[@Name=E*]' will only search the elements under the current relative object because the path starts with a '.' which means self. The other suggested path of '\Elements[@Name=E*]' will only search the root elements at the database level because it starts with a '\' which means start at the root path of the database.

                          • Re: Substitution Parameters in AF Analyses
                            vwitzel

                            Good to know, thanks David!

                             

                            I have a follow-up question to my original post. I am trying to point an AF Attribute at a parent AF Element to the Attribute of a child Element. Moreover, I need to account for two different ways that this child Element can be called (its name either ends with an "A" or begins with "20"). For that purpose, I created an AF Attribute with the following formula:

                             

                            A=.\Elements[@Name=*A]|EFM Line Pressure;B=.\Elements[@Name=20*]|EFM Line Pressure;[if badval(A) then B else A]

                             

                            In my AF structure, only one of these child AF Elements will ever be in place, not both. Unfortunately, it appears that AF always tries to evaluate the path for both parameters, and when it cannot find one of them, it fails and returns the below value (showing an example where it cannot find a child Element whose name ends with A):

                             

                            Unknown Attribute '.\Elements[@Name=*A]|EFM Line Pressure' in configuration of formula in attribute .....

                             

                            Is there any other way to account for this naming discrepancy (other than creating a unique AF Element Template for each scenario)?

                             

                            Thanks,

                            -Vincent

                              • Re: Substitution Parameters in AF Analyses
                                dng

                                Hi Vincent,

                                 

                                I haven't found a way to do a "OR" condition for the child element names. So I'll suggest a workaround here. Are there other defining characteristics that these child elements share (apart from their names)? E.g. Do both groups use the same element template? Or can you assign the same category to both groups? If so, you can use these secondary defining characteristics to get the attribute:

                                 

                                e.g. .\Elements[@Category=YourCategory]|EFM Line Pressure

                                1 of 1 people found this helpful
                                  • Re: Substitution Parameters in AF Analyses
                                    vwitzel

                                    Daphne, that's a great point, thanks! I should have thought of that . Unfortunately, I cannot use @Template as the search parameter since the Template in question is also used for other child Elements. And when I tried to apply a Category to the Elements, PSE warned me that "Allow Extensions" is not enabled and that I would either have to enable it or apply the Category to the Template as whole, neither of which is ideal.

                                     

                                    However, in theory, I could use @Description to perform the search (all the relevant child Elements end in "Allocation Meter"). Unfortunately, neither of the below succeeded in finding the child Elements. I tried inserting double and single quotes around Allocation Meter, but I could not get it to work. Is there a way to search for a string which includes a space? And is @Description indeed an available search parameter?

                                     

                                    .\Elements[@Description=*Allocation Meter]

                                    .\Elements[@Description=*Allocation*]

                                      • Re: Substitution Parameters in AF Analyses
                                        dng

                                        Hi Vincent,

                                         

                                        @Description is a valid search parameter, but it looks like only exact matches work (similar to Template/Category). I am leaving for the day, but I will keep thinking about this. Hopefully other community members will chime in in the meantime!

                                        • Re: Substitution Parameters in AF Analyses
                                          Eugene Lee

                                          Hi Vincent,

                                           

                                          I used

                                           

                                          .\Elements[@Description=Allocation Meter]|Attribute1

                                           

                                          and it was able to work. Only the @Name filter supports wildcards.

                                          1 of 1 people found this helpful
                                            • Re: Substitution Parameters in AF Analyses
                                              vwitzel

                                              Hi Eugene,

                                               

                                              Unfortunately, the Description of the Elements consists of more than just "Allocation Meter". That's just what all the strings end with. I assume what you tested involved Elements where that was the entire string, correct?

                                                • Re: Substitution Parameters in AF Analyses
                                                  Rhys Kirk

                                                  Vincent...you have to do some tricks with a couple of extra attributes to do what you need. The StringBuilder DR is your friend in this case.

                                                   

                                                  Under your Formula DR create 2 child Attributes, 1=AllocationMeterEndsWithA 2=AllocationMeterStartsWith20, both of which use the StringBuilder DR.

                                                   

                                                  Then configure each accordingly:

                                                  AllocationMeterEndsWithA has a ConfigString of '.\Elements[@Name=*A]|EFM Line Pressure';

                                                  AllocationMeterStartsWith20 has a ConfigString of '.\Elements[@Name=20*]|EFM Line Pressure';

                                                   

                                                  Once you've configured your Child Attributes make sure to set the Value Type to Double (or other numeric) to allow them as inputs for the Formula DR. One of them will fail on conversion and you can catch that.

                                                   

                                                  The beauty is that the StringBuilder won't throw a wobbly but simply set the IsGood property to false for the value so you can wrap a BadVal() function call around those two attributes in your Formula DR. Yes you need two extra Child Attributes but I couldn't see another way to do it by pure configuration.

                                                   

                                                  So your Formula DR would just have Inputs A=AllocationMeterEndsWithA B=AllocationMeterStartsWith20

                                                   

                                                  C=if BadVal(A) then B else A

                                                  if BadVal(C) then 0 else C

                                                  1 of 1 people found this helpful
                                                    • Re: Substitution Parameters in AF Analyses
                                                      vwitzel

                                                      Rhys, thanks for elaborating. I feared this would be the case, but was trying to avoid having one AF Attribute that will always be bad (due to there only being a child AF Element following one of the two naming standards per parent AF Element).

                                                       

                                                      If anybody has any other thoughts, please let me know

                                                        • Re: Substitution Parameters in AF Analyses
                                                          Rhys Kirk

                                                          Short of following up on the suggestion from Daphne Ng of assigning an AF Category, or assigning the correct attribute manually (or automatically via scripting) when building your AF Hierarchy I don't think you can do what you need within the confides of a single AF Attribute. I assume once your hierarchy is built that it is pretty static?

                                                            • Re: Substitution Parameters in AF Analyses
                                                              vwitzel

                                                              Rhys, to answer your question - yes, our hierarchy should be pretty static. I am not sure I follow your second point about manually or automatically assigning the correct attribute during creation of the AF hierarchy. You mean hard-coding the path to the attribute into the config string? At that point, I don't believe the Element could be templatized anymore (unless you allow extensions and make these attributes non-templatized). Indeed, we discussed at length how to proceed, and eventually decided to use two templates to overcome this naming inconsistency. However, we then realized that the related assets function in Coresight would not include all relevant Elements, so we decided to allow extensions on the original template after all, switch back to it, assign two distinct categories to the child Elements, and use .\Element[@Category=...] to find the proper attributes, as Daphne suggested

                                                               

                                                              Thank you all for your help!

                                                              • Re: Substitution Parameters in AF Analyses
                                                                JanvanderVen

                                                                It should not be too hard for OSI to come up with an analysis that creates an element.

                                                          • Re: Substitution Parameters in AF Analyses
                                                            Eugene Lee

                                                            Hey Vincent,

                                                             

                                                            Yes, I was actually addressing this question.

                                                             

                                                            Is there a way to search for a string which includes a space?

                                                             

                                                            Because you were trying with quotes and double quotes. As I have mentioned, only the @Name filter can support wildcards. Perhaps you can contact Techsupport to file an enhancement request to extend this to other filters as well. Thanks!