2 Replies Latest reply on Apr 9, 2018 2:01 PM by Rick Davin

    getting values from system explorer in .net


      I'm retrieving data from PI in vb.net using the AFSDK. Recently I'm started to use the AF and made a lot of attributes in my elements. Some of them are based on PI database tags some are made by formula in the attributes. For instance a lookup table.


      I'm using this snippet to get the data from the AF.



      Works great. PiAFelementPAth is the long path like you use in de AF framework to identify a tag. "E" finally gets all the values,timestamps and flags from the desired tag. However this only works when the tag is based on a PI database tag. If the tag is e.g. based on a lookup table or other formula then the "findobject" returns nothing. I realize that "tag" in this sample is probably the underlying tag from the element but in the case of a formula it does not have a tag.

      Is there a way to get data from attributes from elements that are based on not-tags? A snippet a code would be very appreciated.




        • Re: getting values from system explorer in .net
          David Hearn

          Instead of using the attribute's 'PIPoint' property directly, try using the attribute's 'Data' property which gives you access to all the AFData methods like the Summaries method.

          1 of 1 people found this helpful
          • Re: getting values from system explorer in .net
            Rick Davin

            Hi Benny,


            Let's clarify some things.  PI System Explorer is a configuration tool used to inspect AFDatabases.  Your code is not querying or touching PSE.  It is querying an AFDatabase, just like PSE does.


            I would suggest more meaningful names, which add clarity to your code. Also, the biggest problem you see, not working for Formulas or Table Lookups, is because you switch from an AFAttribute to a PIPoint by virtue of calling tagAtt.PIPoint.  If you have an AFDatabase, I urge you to only work with AFAttributes in your code if the attribute can be something other than a PIPoint.


            Dim assetServer As PISystem = New PISystems().Item("your AFServer name")
            Dim database As AFDatabase = assetServer.Databases("your AFDatabase name")
            Dim element As AFElement = database.Elements("your AFElement path")
            Dim attribute As AFAttribute = element.Attributes("your AFAttribute path")
            Dim summaries As IDictionary(Of AFSummaryTypes, AFValues) = attribute.Data.Summaries( -- lots of parameters -- );



            The above code should work for PIPoints, Formulas, and Table Lookups for attributes with a numeric type.

            1 of 1 people found this helpful