Exploring AF 2.5 new AFAttributeList.GetPIPoint

Discussion created by rdavin Employee on Oct 31, 2012
Latest reply on Nov 9, 2012 by rdavin

A few things have coincided recently at work.  One is the eagerly anticipated release of AF 2.5.  Another is a co-worker who was writing code in AF 2.4 to detect attributes using the PIPoint DR but with the tag not found.  The 2nd thing led to a 3rd thing where I reviewed some vCampus postings on the AFAttribute.RawPIPoint and AFAttributeList.GetRawPIPoint methods. 


This eventually lead to a 4th thing, which is the key topic: how would this be coded in AF 2.5 using the new AFAttributeList.GetPIPoint method?


The old GetRawPIPoint method returned an object array with the same ordinality as the input attribute list.  I kind of sense that syncing disjoint collections positionally by index is no longer in vogue and is being supplanted by dictionaries.  The new GetPIPoint doesn't just return a dictionary object.  Instead it returns an AFKeyedResults<AFAttribute, OSIsoft.AF.PI.PIPoint> object that contains 2 dictionaries.  One is the .Results dictionary containing those attributes whose new .PIPoint property did not throw a System.Exception .  The other is the .Errors dictionary of <AFAttribute, System.Exception>.


Just because an attribute didn't throw an exception and can be found in .Results doesn't mean that it's PIPoint is valid.  It most likely means that the attribute isn't a PI Point.  If you only want to work with valid, non-null PIPoint's, you will have to filter the .Results.


For exceptions, one thing that interests many is tags not found.  You can filter on that specific exception (System.Collections.Generic.KeyNotFoundException).  In other cases, there may be a poorly or misconfigured ConfigString for a PI Point attribute.  I intentionally created an attribute using the PIPoint DR that had a server but not a tagname.


{ problems pasting sample C# code.  keeps getting eaten when Inserting Code.  without the code, the post is kind of worthless.  }



Count of input attributes 10
     3 valid PI Points
     4 attributes not a PI Point
     2 Tags not found
     1 Misconfigured