3 Replies Latest reply on Nov 4, 2015 10:39 AM by pthivierge

    Efficient method for writing back values to AF Attribute using AFSDK

    chaof

      Is there a more efficient method for writing back values generated by a custom calculation to a PI Point behind an AF Attribute on a templated element than simply looping through a collection of elements searched up with a template name?

       

      AFElementTemplate template = afdb.ElementTemplates["Template"];
      AFNamedCollectionList<AFBaseElement> Elements = template.FindInstantiatedElements(true, AFSortField.Name, AFSortOrder.Ascending, 100000);
      
      
      foreach (AFElement e in Elements)
      {
        try
        {
        ... // custom calculation code
        afAttribute.PIPoint.UpdateValue(afValue, OSIsoft.AF.Data.AFUpdateOption.Replace);
        ...
        }
        catch (Exception ex)
        {
        ...
        }
      }
      

       

      Basically, looking for a more efficient way to do the above.