1 Reply Latest reply on Jul 14, 2015 10:12 PM by dng

    AF SDK transpose interpolated data



      I'm trying to find a good way to transpose the data that is coming from the interpolated values call. Each iteration of sIdObjVal below gives the tagname and data but we need to build rows. see code below for reference.


      public class VesselData
      public VesselData()
      this.parameterValues = new ObservableCollection<ParameterTag>();
      private DateTime timestamp;
      public DateTime Timestamp
      get { return timestamp; }
      set { timestamp = value; }
      private ObservableCollection<ParameterTag> parameterValues;
      public ObservableCollection<ParameterTag> ParameterValues
      get { return parameterValues; }
      set { parameterValues = value; }
      #region loop through each vessel tag result
      foreach (AFValues sIdObjVal in pointsValues)
      int i = 1;
      foreach (AFValue val in sIdObjVal) // loop through all result values
      if (i > lstVesselTagNmes.Count)
       row = new VesselData();
       i = 1;
       #region Loop through the parameters for that vessel number
      if (val.IsGood)
      double fc = 0;
       row.Timestamp = val.Timestamp;
       fc = (double)Math.Round((double)val.Value * getDecimalPointValue()) / getDecimalPointValue();
      ParameterTag param = new ParameterTag();
       param.ParamName = "Parameter " + i;
       param.ParamValue = fc;
      //increment Analyzer counter as we have another group of SID for the Batch
        • Re: AF SDK transpose interpolated data

          Hi Mike,


          First, let's discuss the structure of the AFValues and AFValue object in PI AF SDK.

          • AFValues: holds a list of AFValue
          • AFValue: contains the following properties
            • Value
            • Timestamp
            • Status
            • etc.


          I am trying to visualize what your requirement is. From the code provided above, it looks like each VesselData should hold all the values for 1 PI tag/AF attribute. Is this correct? If so, what would be the desired structure for VesselData? Right now, I see

          • VesselData:
            • timestamp
            • ParameterValues (which is a collection of ParameterTag)


          One thing I noticed is that since there is only a single timestamp property, you are overwriting the timestamp in each loop through sIdObjVal. Is only the last timestamp important? If not, ideally, would you like a timestamp/value pair? If so, you might want to make changes to your VesselData class and associated code.


          I see that you have a "wrapper" for the AFValue object. If this code will be reused, you can consider putting the logic behind building the new ParameterTag into a constructor for ParameterTag. Regarding looping through the AFValues and AFValue, I don't see a workaround to bypass this based on your current data structure.


          Please let me know if I have sufficiently addressed your concerns. If not, can you let us know the specific questions you have?