4 Replies Latest reply on Mar 17, 2015 2:23 PM by Steve Boyko

    RecordedValuesByCount Including the Snapshot?

    Steve Boyko

      I am calling the PI-SDK function RecordedValuesByCount from ProcessBook VBA. I am calling it like this:

         Set sSrv = PISDK.Servers(sServer)

         Set pt = sSrv.PIPoints(sTag)

         Set pivals = pt.Data.RecordedValuesByCount("*", 5, dReverse, btAuto)   ' load last 5 values

         lstLast5Values.Clear

         For Each pival In pivals

            If (pival.IsGood) Or (pival.Value <> "No Data") Then

               lstLast5Values.AddItem

               lstLast5Values.List(lstLast5Values.ListCount - 1, 0) = pival.TimeStamp.LocalDate

               lstLast5Values.List(lstLast5Values.ListCount - 1, 1) = pival.Value

            End If

         Next

       

      The PI data for this tag, as shown by the the Archive Editor plugin of PI-SMT, has a Pt Created event at 2015/3/11 4:53:42 PM and nothing else. However, the PIValues collection returned by RecordedValuesByCount contains two events: that Pt Created event and another Pt Created event at the current time. What gives?

       

      I tried using btInside or btOutside instead, and both of them return what I expect (just one value), but why does btAuto invent an event?

       

      Thanks in advance for any help you can provide.

        • Re: RecordedValuesByCount Including the Snapshot?
          bpayne

          Hi Steve,

             Looks like btAuto returns interpolated values, so you may get back 2 values at start/current based on the Step attribute. If Step is ON, only a single value is returned.

            • Re: RecordedValuesByCount Including the Snapshot?
              Steve Boyko

              I agree, that's what it looks like, but that's not what the documentation says.

               

              btAuto: For points with the Step attribute set (Step=1) use btInside, otherwise use btInterp.

                • Re: RecordedValuesByCount Including the Snapshot?
                  stang

                  Hi Steve,

                   

                  The documentation says that if step is on, you will get inside behavior (one value), but if it is off, you will get interpolation (two values).

                   

                  By default, step is off. So if you have not changed that, then as per the documentation, seeing two values would be the expected behavior.

                    • Re: RecordedValuesByCount Including the Snapshot?
                      Steve Boyko

                      I see that now in the Remarks section of the documentation.

                       

                      PI3 systems, when queried over a time range which includes the current server time and where the snapshot value for the PIPoint in question is before the current time, will return an event containing a DigitalState with the value "NO_DATA" one second past the current server time for boundary types btInterp and btOutside.  This event is manufactured by the server to indicate the time range over which the snapshot value is considered valid.  This is provided to assist the caller in further interpolation of the results.  Specifying btInside, indicates that no interpolation is desired and this manufactured value is not provided for that case.

                       

                      Thanks!