6 Replies Latest reply on Aug 24, 2012 6:29 PM by MikeRay

    PI AF Formula Data Reference - Syntax for getting the Attributes an Attribute of type Element. If you follow me...

    MikeRay

      Hi There,

       

      This is a tricky one to explain. So I will just start at the beginning.

       

      I have an attribute, 'ElementRefTest', on an element, 'Root',  and I am using one of the 'Object' value types, specifically the 'Element' type to hold a reference to an other element, in this case 'Element6'.

       

      7271.Img1.jpg

       

      Then I want to make a formula on an attribute, 'ElementValueFormulaTest', on one of Root's children, 'Element1' that will go back up to its parent, get the element from the 'ElementRefTest' attribute and get one of its attributes, 'RollupTest'.

       

      7612.Img2.jpg

       

      The expected value is \\Root\Element3\Element6|RollupTest:

       

      4276.Img3.jpg

       

      I have been trying: A=..\.|ElementRefTest|RollupTest; but this does not seem to work.

       

      So I am wondering what the Formula data reference syntax is to achieve this. I looked in the AF documents but could not find it, if I have missed it please someone point me in the right direction.

       

      Thanks,

       

      Mike.

        • Re: PI AF Formula Data Reference - Syntax for getting the Attributes an Attribute of type Element. If you follow me...
          Asle Frantzen

          Hi Mike

           

          I haven't used any of the object data types, but I have tried creating formula attributes where one of the referenced attributes had a string value type. This of course didn't work very well. It could seem like the formula data reference is very strict on which attribute value types you actually can use.

           

          Maybe someone else knows more about this?

            • Re: PI AF Formula Data Reference - Syntax for getting the Attributes an Attribute of type Element. If you follow me...

              Pretty sure you can't use the navigational path syntax to jump to an AFElement that is set as the value of an AF Attribute.

                • Re: PI AF Formula Data Reference - Syntax for getting the Attributes an Attribute of type Element. If you follow me...
                  mhamel

                  @Michael, @Asle: Formula Data Reference allows showing the value of an element's attribute located elsewhere in the hierarchy (or another attribute of the current element). Although, this data reference does not support any string output. For this purpose, I have created the Alias Data Reference as an example for the PI Application Development Course that does what you want. It supports any type of value (including string). You can make use of the relative and absolute path method to an attribute.

                   

                  For example, you might want to "expose" one information from 2 levels in the hierarchy regarding your current attribute, you can use the following syntax for the configstring property: ..\..\AnotherElement|MyAttribute You can use an absolute path like this: \\MyServer\MyDB\Element1\Line1\Part1|MyAttribute This data reference supports both GetValue and GetValues methods.

                   

                  You can find an excerpt of the project here! The code and information are provided as is without warranty of any kind.

                   

                  Let me know if that helped.

                    • Re: PI AF Formula Data Reference - Syntax for getting the Attributes an Attribute of type Element. If you follow me...
                      Asle Frantzen

                      Mathieu Hamel

                      For this purpose, I have created the Alias Data Reference as an example for the PI Application Development Course that does what you want. It supports any type of value (including string). You can make use of the relative and absolute path method to an attribute.

                       

                       

                      Mathieu, I can definitely use this so this goes in my toolbox. Bit too late now, but we had a project before the summer where we had transformers using the terms HV and MV, which needed to be visible to the ProcessBook users as the ERD values. But the tags followed the AF template, which had the possibility of storing 400 kV, 220 kV and 110 kV voltage level tags. For some transformers the HV level would be 400 and the MV would be 110, for others it could be HV=220 and MV=110, and here we used formula attributes to create these "aliases" with a simple badval check also.

                       

                      But as mentioned, this only worked for number value types.

                • Re: PI AF Formula Data Reference - Syntax for getting the Attributes an Attribute of type Element. If you follow me...

                  Michael Ray

                  I have been trying: A=..\.|ElementRefTest|RollupTest; but this does not seem to work.

                   

                  So I am wondering what the Formula data reference syntax is to achieve this. I looked in the AF documents but could not find it, if I have missed it please someone point me in the right direction.

                   

                   

                  @Mike: This won't work because that is an AF Path that expects the attribute "ElementRefTest" Attribute to have a child Attribute "RollupTest", which is not what you want.  As I already said you cannot do what you want to do to my knowledge, you will need a different approach other than having the Value Type of the Attribute being an Element.

                  • Re: PI AF Formula Data Reference - Syntax for getting the Attributes an Attribute of type Element. If you follow me...
                    MikeRay

                    Thanks all for the replies.

                     

                    I got around the scenario by using the PI Point data reference and copying in the tags I wanted from the element valued attribute rather than using a formula on a template. It would have been more ideal to be able to use the formula to do this as then if the element in the attribute needed to change it would be simple and I would not need to trace through and change multiple PI Point data references.

                     

                    In case anyone was wondering the scenario was that I had an element representing a test separator in an attribute on a well, so that if the well was on test, the formula could go and check what the flow rates were for the current test. In the asset I am modelling its feasible that the test sep could be changed and so I wanted a simple way to manage this scenario.

                     

                    @Mathieu thanks for the code it looks like it might go part way to achieving what I want to do and I will definitely examine it further.

                     

                    Cheers,

                     

                    Mike.