2 Replies Latest reply on Mar 1, 2016 2:43 PM by pthivierge

    PI WEB API GetValues query




      I've been exercising the PI WEB API GetValues method (https://techsupport.osisoft.com/Documentation/PI-Web-API/help/controllers/streamset/actions/getvalues.html ) against the dummy data which gets supplied with the PI Server install.

      When I formulate a query with no time parameter specified, the result appears to be the values with the closest prior timestamp to now.

      For example, if I execute a query at 12:30, I might get the values:


      Tag name: BA:TEMP.1


      {UnitsAbbreviation=, Substituted=false, Value=18.5690861, Good=true, Timestamp=2016-02-05T12:28:50Z, Questionable=false}


      Tag name: SINUSOID


      {UnitsAbbreviation=, Substituted=false, Value=62.8774452, Good=true, Timestamp=2016-02-05T12:29:51Z, Questionable=false}


      However, if I specify the time to be e.g. 'Yesterday', I will get (note the returned timestamp):


      Tag name: BA:TEMP.1


      {UnitsAbbreviation=, Substituted=false, Value=21.131424, Good=true, Timestamp=2016-02-04T00:00:00Z, Questionable=false}


      Tag name: SINUSOID


      {UnitsAbbreviation=, Substituted=false, Value=29.765192, Good=true, Timestamp=2016-02-04T00:00:00Z, Questionable=false}


      In the first case (no time specified) I appear to be getting the closest actual recording.

      In the second, I assume I am getting an interpolated value.


      Is this correct and is this the expected behaviour?

      I note that there is also a GetInterpolated action (https://techsupport.osisoft.com/Documentation/PI-Web-API/help/controllers/streamset/actions/getinterpolated.html ) - shouldn't getting interpolated data be reserved for that action?


      Many thanks,


        • Re: PI WEB API GetValues query

          Hi James,


          What you're seeing is expected behavior.


          All of our client tools ( DataLink, SMT, WebAPI, etc) when querying the current value give you the snapshot value and the timestamp when we received it from the data source. This is meant to prevent extrapolation. If the server hasn't received a value in the last few minutes, then all the PI server can report is the most recent value, not necessarily the correct value of right now.


          As for the other time queries, we do interpolation (unless that specific tag is set to Step = On) because there's a value on both sides of your query timestamp, and because that's how our data structure was built. This video does a great job of visually explaining how data is received and stored by the PI server: OSIsoft: Exception and Compression Full Details - YouTube


          The WebAPI interpolated values is actually a call that returns a set of values. If you look at the valid URL parameters, you'll see a start time and end time for the interpolated values, but not for the Get Values. The reason you have to specify interpolated here is that you could also use recordedvalues: https://techsupport.osisoft.com/Documentation/PI-Web-API/help/controllers/streamset/actions/getrecorded.html


          Recorded values will only return the values explicitly stored in the archive files, but the interpolated values will give you values on a set frequency (15m for example) across a time range. If you're familiar with DataLink, you can think of this as Compressed Data versus Timed Data, respectively.


          Is this making sense? The way our archive files work can be complicated so I strongly recommend starting with the exception and compression youtube video.



          2 of 2 people found this helpful
          • Re: PI WEB API GetValues query

            Hello James,


            I have marked Kelsey's answer as correct as I assume he answered your question correctly, this is something you may consider doing once you get used to PI Square


            Thanks for coming and see you soon!