7 Replies Latest reply on May 24, 2018 3:03 PM by cmanhard

    AFSDK PlotValues Issue - Returns too much data

    mark.omeara

      Hello

       

      I may be missing something very obvious, but it seems the PlotValues method is returning too much data.

      I have an AFListData where I want to plot the values of a collection of attributes in a trend over a time range, hence the 'PlotValues' method of that class seems appropriate. I will use one of these attributes as an example, a pressure reading.

       

      Lets say the chart is 500px wide which I shall hard code for demonstration sake in the code below:

       

                      var pg = new PIPagingConfiguration(PIPageType.TagCount, 100);

                      var tr = new AFTimeRange(new AFTime(StartDate), new AFTime(EndDate));

                      var listResults = afList.Data.PlotValues(tr, 500, pg);

       

      If I look at the returned AFValues for the pressure reading attribute it has returned about 1200 values - more than can be reasonably displayed on a 500 pixel area.

      What am I doing wrong here?

       

      Using Osisoft.AFSDK.dll ver 2.9.5.8352

       

      Below is a comparison between the PlotValues call and the PI System Explorer trend (note I have set the intervals to 500 there). The PI Point is the same one, but different results.

      Chart from PlotValues callExpected result from same PI Point as displayed in System Explorer
      AFSDK - Chart with 500 intervals.JPGPI Explorer - Chart with 500 intervals.JPG
        • Re: AFSDK PlotValues Issue - Returns too much data
          dmoler

          Hi Mark,

           

          This is expected. PlotValues can return up to 5 events per interval as specified in the documentation here:

          For each interval, the data available is examined and significant values are returned. Each interval can produce up to 5 values if they are unique, the first value in the interval, the last value, the highest value, the lowest value and at most one exceptional point (bad status or digital state).

           

          I'm not sure how the plot is implemented, but in one pixel width the plot could show the range from min to max for example.

            • Re: AFSDK PlotValues Issue - Returns too much data
              mark.omeara

              David

               

              Thanks, yes that does make sense. So I assume one has to select one from the first four values, then look at the 5th value, if it is a digital state, then it is the 5th value of the current interval, otherwise it is the 1st value of the next interval.

               

              Thanks again.

                • Re: AFSDK PlotValues Issue - Returns too much data
                  dmoler

                  The values will be returned in timestamp order, so a digital value won't necessarily be the 5th value. You should be able to divide the requested time range into the specified number of intervals and have at most 5 data points per interval.

                    • Re: AFSDK PlotValues Issue - Returns too much data
                      mark.omeara

                      David

                      Not certain I understand this, if one divides the requested time range into the specified number of intervals, then one ends up with x seconds per interval. Lets say a 4 hour trend with a plot width of 1024 pixels = 4 x60x60 / 1024 = ~14 second intervals. But if this was the case I may as well just issued an interpolation api call instead of PlotValues and avoid the complexity. Further I do not think PlotValues returns data so evenly, it may concentrate data points around interesting peaks and troughs and leave linear sections with sparse results.

                       

                      So I am still a little confused as to how to identify which set of AFValues map to a specific 'interval'. There does not appear to be a helpful 'interval' id in the AFValues results.

                       

                      Again I imagine I am missing something obvious, please illuminate.

                      Thanks.

                • Re: AFSDK PlotValues Issue - Returns too much data
                  Eugene Lee

                  Hi Mark,

                   

                  From visual inspection, I see that the trend for Location A from both the PlotValues call and in PSE are similar in shape. Not sure what you mean by they are different. The trend in the PlotValues call only starts a bit earlier than the trend in PSE.

                  • Re: AFSDK PlotValues Issue - Returns too much data
                    cmanhard

                    The AFValues themselves are not mapped to a specific interval in the return set.  The idea is that if you plot the values as returned, there will be no loss of information on any vertical pixel.  That is, the entry point, exit point, and range of the data, along with an error, is plotted.  The difference between this and interpolation is that interpolation will provide only a single value for the value - so - you will miss the range (max and min), as well as the entry and exit point if the data preceding or following the interval is sparse.  If the interval contains no data, PlotValues will not return any data for that interval.  If the interval contains a single record, only a single record is returned for the interval.