5 Replies Latest reply on Jul 8, 2011 4:23 AM by hanyong

    How to prevent the last value to be repeated?

    philco

      I’m retrieving values using the GetPIArchiveDataAsync method. Fixed dates are sent in parameter (same start and end date) since the sought values are entered manually at... fixed dates. Everything’s fine except if I’m asking for values that have not been entered yet. Instead of receiving nothing, PI returns the closer value (the last available).

       

       

       

      Here’s the context. This is for a page where users have to manually enter values at fixed intervals, one value per quarter, thus four values per year. The page is displaying the values that have been entered for the past 3 quarters plus the current quarter. This one should be empty until it is filled by the user.

       

       

       

      I’m building multiple requests, one for each quarter in this case. The RetrievalType is set to compressed and the Boundaries is set to inside, both being the default values. The returned values are fine except for the current quarter if it’s still empty. In that case PI repeats the previous quarter value so instead of showing a blank value the page is repeating the previous value, which is very bad in this case. So the question is, is there a way to prevent that behaviour?

       

       

       

      Thanks

       

       

        • Re: How to prevent the last value to be repeated?
          philco

          This excerpt from the PI Web Services Programming Reference should be clearer:

           

          "The behavior during retrieval of Compressed values depends entirely on the existence of events in the PI Archive. If the time range specified in the request does not include any events, you will receive a TimeSeries (page 78) object that has no events; that is, an empty TimedValue (page 80) array. This is important when querying paths containing stale data since you will retrieve data only if the time range includes the time of the most recent snapshot."

           

          This is exaclty what I'm expecting; an empty Timedvalue array but that's not what I got. Any ideas?

            • Re: How to prevent the last value to be repeated?
              hanyong

              Hi Philippe,

               

              Like you, when I set a request's start time and end time to the same timestamp, I am getting a single value, which is an interpolated value at the specified timestamp. I am guessing the underlying implementation of the GetPIArchiveData call will always try to return a single value if the start time and end time is set to the same timestamp.

               

              A workaround that I can think of, is to add a small offset to the end time from the start time, like 1s or 0.1s. GetPIArchiveData call will interpret this as a query for a timerange instead of a single timestamp, and not return any value if there is no archive data at that time.