6 Replies Latest reply on Mar 6, 2014 9:05 PM by mark.omeara

    PI ACE Calc and waiting for the Buffer to flush

    mark.omeara

      Hello

       

       

       

      I have an ACE calculation that takes the last recorded data point from the archive (or snapshot I suppose) manipulates it then saves it back to PI as a new value at the timestamp of ACE execution. So as an illustrative example:

       

      1) The current snapshot value is 40.00 at 9:15am

       

      2) Ace runs and grabs that value (40) and adds 10 to it, so now 50

       

      3) Ace wites the value back (either point.Value = 50 or point.PutValue(9:20, 50) - whichever)  at 9:20

       

      4) Repeats steps 2 and 3 forever

       

       

       

      My concern is when Buffering is enabled - to fan out to a collective.

       

      If the calculation runs again soon after and the buffer has not flushed (in the above example the 9:20 data write is still in the buffer and not in the PI snapshot yet) then the calculation will pick up the previous value (at 9:15) and perform the calculation on that.

       

      My question: Is there a way for an ACE calc to determine whether the buffer has been flushed for a specif point before embarking on the calculation?

       

       

       

      Thanks

       

      Mark

        • Re: PI ACE Calc and waiting for the Buffer to flush
          Rhys Kirk

          There is no read-back from PIBufss.

           

          Default send rate of PIBufss is 100ms, so unless your data is being rejected via PIBufss, or you have a large buffer queue that is back filling, then you'll most likely not suffer with this as your ACE schedule won't be faster than PIBufss send rate + network latency. You could run into an issue if the calculation cycles of dependent calculations (another ACE context) are using that same snapshot as an input, but you'd be in that boat anyway with writing directly to the PI Server.

           

          To help you sleep at night, you could run PI Interface for Performance Monitor to keep an eye on how PIBufss is performing on your ACE server to flag up times where you may have an issue (size of buffer queue, drain time, etc).

          • Re: PI ACE Calc and waiting for the Buffer to flush

            Hello Mark,

             

            I might be mistaken, but believe the issue you are seeing is because of this:

             

            Mark OMeara

            4) Repeats steps 2 and 3 forever

             

            Is my suspicion correct that you intend to run this PI ACE Module continuously? Depending on your use case you shouldn't see the issue when using natural scheduling.

             

            What you describe looks as if you like to create a kind of heartbeat signal that is using a single PI Point as input and output. Is this the case here or is this PI Point also supposed being updated by another data source e.g. an interface?

             

            When your intention is to create a counter / heartbeat that updates every 5 seconds, you may want to set up your ACE Module for clock scheduling.

             

            If your intention is to "correct" a PI Points value that is usually fed by a different data source you will run into trouble when using PI Buffer Subsystem because PI Buffer Subsystem will lock this point causing no updates from other data sources will be accepted - buffered or not. The log file of your PI Data Archive (PI Server log) would show "buffered point does not accept new events" with reference to the points ID.

             

            Can you possibly give us a better idea of what you would like to achieve?   

             

             

              • Re: PI ACE Calc and waiting for the Buffer to flush
                mark.omeara

                Gregor

                 

                No, not run continuously. This issue can be seen in two areas, one where a recalc is occurring (this has been replicated by Osisoft support) and another where the code may have multiple adjustments to the same point values over its operation.

                 

                I think the example I gave is reasonably clear. I simply want to know when the buffer has been flushed before doing a calculation that is based on the most recent archived value (such as a positive delta). The obvious workaround is to put a sleep in (particularly if IsRecalculating) however that is not exactly deterministic.

                 

                Mark

                  • Re: PI ACE Calc and waiting for the Buffer to flush
                    mark.omeara

                    Rhys

                     

                    Thanks for that, I might just log the buffer subsystem to what the flush time is likely to be.

                     

                    Mark

                      • Re: PI ACE Calc and waiting for the Buffer to flush

                        Hello Mark,

                         

                        I doubt the issue you are seeing is caused by PI Buffer Subsystem flushing too lazy. I haven't seen events sitting in buffer queues for long time except there's either an issue with a corrupted buffer queue or the queue is filled faster than it is able to forward data. The latter may be because of different reasons like e.g. a bad network, small bandwidth a busy PI Data Archive (PI Server).

                         

                        However, there are ways to monitor the buffer queue like e.g. pibufss -qs command (see KB00831 for details). Collecting PI Buffer Subsystem performance counters using the PI Interface for Performance Monitor is also a good approach. Looking at the "Total Queued Events" gives you an idea about how many events are sitting in the queue at a certain time. Together with "Total Events Sent/sec" one gets an idea about the PI Buffer Subsystem performance.

                         

                        I suggesting trying something totally different first. You suspect PI Buffer Subsystem flushing its queue too lazy. Let's try to proof this by taking PI Buffer Subsystem out of the scope. When doing so and still observing the same behavior, we should discuss other possible reasons.

                         

                        To me the example you provided gives me an idea what you are trying to accomplish but even you would have provided the PI ACE code, there would still be a chance for different behavior depending on how your PI ACE context is scheduled. Please note that not every update you send to a PI tag causes a snapshot update. This only happens if the timestamp of the update is more recent than the one of the event currently sitting in the snapshot. Also for event triggered calculations (natural scheduling) the requirement is a snapshot update.  

                          • Re: PI ACE Calc and waiting for the Buffer to flush
                            mark.omeara

                            Hi Gregor

                             

                            I do not think I have conveyed any impression that the buffer system is lazy, just that there are scenarios where a calculation may be performed before the last point write has been flushed. I have replicated the issue on a development PI server and a production one, and as mentioned tech support has also replicated the issue (see OSIsoft TechSupport Call # 480570 if you are interested). In this case the issue was not replicated when buffering was disabled, hence buffering has an extremely high likelihood of being a contributory factor.

                             

                            My intention here was not to replicate the afore mentioned techsupport case (which incidentally I have not had any feedback from for over half a year), rather to see whether there was some way to determine whether the buffer status for a point can be examined. I now have my answer (that being 'no') and am happy with that.

                             

                            Thanks

                             

                            Mark