1 Reply Latest reply on Nov 16, 2011 12:10 PM by andreas

    Reading compressed values on an AF PI Point Reference

    lchaylian

      Hi,

       

      Is it possible to read an array of compressed data in a time range usign a PI Point Reference in AF?

       

      regards,

       

      Luis

        • Re: Reading compressed values on an AF PI Point Reference
          andreas

          You should be able to get this with the AFAttribute.GetValues method:

           
                      // The available AF Servers
                      OSIsoft.AF.PISystems _PISystems = new OSIsoft.AF.PISystems();
                      // The Default AF Server
                      OSIsoft.AF.PISystem _PISystem = _PISystems.DefaultPISystem;
                      // The NuGreen Database
                      OSIsoft.AF.AFDatabase _AFDatabase = _PISystem.Databases["NuGreen"];
                      // The B-210 Element
                      OSIsoft.AF.Asset.AFElement _AFElement = _AFDatabase.Elements["NuGreen\\Houston\\Cracking Process\\Equipment\\B-210"];
                      // This Attribute is SINUSOID
                      OSIsoft.AF.Asset.AFAttribute _AFAttribute = _AFElement.Attributes["Fuel Gas Flow"];
                      // An AFTimeRange
                      OSIsoft.AF.Time.AFTimeRange _AFTimeRange = new OSIsoft.AF.Time.AFTimeRange();
                      // 1 Day
                      _AFTimeRange.StartTime = DateTime.Now.AddDays(-1);
                      _AFTimeRange.EndTime = DateTime.Now;
                      // Get the recorded Values (numberOfValues = 0)
                      OSIsoft.AF.Asset.AFValues _AFValues = _AFAttribute.GetValues(_AFTimeRange, 0, _AFAttribute.DefaultUOM);
                      // print out the values
                      foreach (OSIsoft.AF.Asset.AFValue _AFValue in _AFValues)
                      {
                          Console.WriteLine(_AFValue.Timestamp.LocalTime 
                                            + " " 
                                            + _AFValue.Value.ToString());
                      }