4 Replies Latest reply on Apr 18, 2017 7:50 PM by TrentHuhn

    Write forecast values to tags on both members of a collective using AF SDK

    TrentHuhn

      We have a couple future PI tags that we write forecast values to. These values are input into a form on a web application and then stored via AF SDK code running on the web server. The issue we're running into is that the values only get written to the primary member of the PI collective. However, when these values get used in AF Analytics calculations down the line, the analysis service sometimes connects to the secondary collective member and is unable to see the user-input values.

       

      My question is what is the best method to fan these data values to both members of the collective? Is this something that needs to be done in the code or can we somehow set up buffering on the web server to take care of this fanning?

       

      Here is a rough outline of the code being used:

                  AFDatabase afDatabase = tools.AFDatabase; 
                  AFElement capacityGroup = AFElement.FindElement(tools.PISystem, new Guid(AssetID));
                  AFAttribute capacityForecastAttribute = AFAttribute.FindElementAttributes(afDatabase, capacityGroup, null, null, null, AFElementType.Any, null, afDatabase.AttributeCategories["CapacityForecast"], TypeCode.Empty, false, AFSortField.Name, AFSortOrder.Ascending, int.MaxValue).FirstOrDefault();
      
                  // availableCapacityValues is an AFValues() object that gets populated with the appropriate values
                   capacityForecastAttribute.Data.UpdateValues(availableCapacityValues, OSIsoft.AF.Data.AFUpdateOption.Replace);
      

       

      Code used to construct the tools.AFDatabase object:

                  PISystems availablePISystems = new PISystems();
                  _piSystem = availablePISystems[_config.PISystem.Name];
                  _piSystem.Connect();
                  _afDatabase = _piSystem.Databases[_config.PISystem.Database];
                  _afDatabase.Refresh();
      

       

      where _config.PISystem.Name and _config.PISystem.Database are set from the Web.config file for the application.

       

      We are running PI Data Archive 2015 R2, PI AF Client 2016 R2, PI AF Server 2015 R2, and PI Analysis Service 2016 R2.

       

      Thanks,

      Trent Huhn