8 Replies Latest reply on Jul 2, 2018 9:29 PM by Noga

    Is there a way to retrieve events in Bulk

    Noga

      I am interested in using PIDataPipe class in order to retrieve points values updates events from pi server.

      I've been examining the follwoing example for using a PIDataPipe.

       

      How to use the PIDataPipe or the AFDataPipe

       

      As described in this code snapped example, the OnNext(AFDataPipeEvent value) function returns a single event on each call:

       

      1.         /// <summary> 
      2.         /// Provides the observer with new data. 
      3.         /// </summary> 
      4.         /// <param name="value"></param> 
      5.         public void OnNext(AFDataPipeEvent value) 
      6.         { 
      7.             Console.WriteLine("PIDataPipe event - {4} - Tag Name: {0}, Action Type: {1}, Value {2}, TimeStamp: {3}", value.Value.PIPoint.Name, value.Action.ToString(), value.Value.Value, value.Value.Timestamp.ToString(), _dataPipeType); 
      8.         } 

       

      I am interested to know-

      Is there a more efficient way to retrieve events as bulk (group of events at each call), instead of single event?

       

      I am interested on making the process more efficient.

        • Re: Is there a way to retrieve events in Bulk
          gregor

          Hello Noga,

           

          You are using PIDataPipe.GetObserverEvents Method to retrieve PIDataPipe events from the server. The first parameter for this method is an integer you use to limit the amount of events to pull. The second parameter is an out reference to a Boolean variable which will have the information if there are more events to retrieve. Retrieved events are send to the IOBserver<T> Interface you've registered for the PIDataPipe. The OnNext() method is a method of the IOBserver interface. I assume you are suspecting that each OnNext() means a roundtrip to the server. Please be assured that this is not the case.

           

          If I misinterpreted your concern, please let me know.

          1 of 1 people found this helpful
            • Re: Is there a way to retrieve events in Bulk
              Noga

              Hi Gregor,

               

              So the PIDataPipe.GetObserverEvents method retrieves events from the server in bulks and not one by one?

              Do I understand that correctly?

               

              Also, Is there a way for me to not send a parameter that limits the amount of events to pull?  Is there a parameter to send All events in one call? or the only way is to loop this method with "hasMoreEvents" = true?

                • Re: Is there a way to retrieve events in Bulk
                  gregor

                  Noga Avr wrote:

                   

                  Also, Is there a way for me to not send a parameter that limits the amount of events to pull?

                  No. maxEventCountPerServer is a required parameter.

                   

                  Is there a parameter to send All events in one call?

                  No. You can use Int32.MaxValue but this doesn't eliminate the theoretical chance there are more events on the server.

                   

                  or the only way is to loop this method with "hasMoreEvents" = true?

                  Yes.

                  1 of 1 people found this helpful
                    • Re: Is there a way to retrieve events in Bulk
                      Noga

                      And is the PIDataPipe.GetObserverEvents method retrieves events from the server in an efficient manner? or is there a way for me to optimize the process?

                       

                      Thanks Gregor.

                        • Re: Is there a way to retrieve events in Bulk
                          gregor

                          Hello Noga,

                           

                          PIDataPipe.GetObserverEvents using IOBserver pattern is supposed to provide you with very good performance.

                          What AFDataPipeType are you using with your signup? How often do you check for updates? What's the average amount of updates you get and how long does it take to receive those updates?

                           

                          Only because there has been confusion between concepts in the past, are you interested into just the 'news' which arrived since the previous query, or are you interested to retrieve time series data / summaries for certain PI Points over a certain period of time? The more information you can share, the better we will be able to guide you.

                            • Re: Is there a way to retrieve events in Bulk
                              Noga

                              I am using the 'Snapshot' AFDataPipeType, and I am currently checking for updates every 5 seconds. The average amount of updates I get is between 15-20 updates and I receive them in up to 20 second. I am interested to retrieve data for each changed point (point name, timestamp and value).

                               

                              Although at the moment I have few points on my pi server that I monitor, my application should support up to the maximum number of tags possible ( by the pi-server, interface, machine running the application etc), and a high traffic. so therefor I am interested in as good performance as possible.

                                • Re: Is there a way to retrieve events in Bulk
                                  gregor

                                  Hi Noga,

                                   

                                  I understand your concern now. Without testing 20 seconds is factor 10³ beyond my expectations.

                                  Patrice Thivierge created his sample as a class and I believe you are using this class or your own class derived from the example. I suspect that you are instantiating a class object each 5 seconds but that is not the intended way of usage. The idea is to create the signup once (one instance of the class) and keep 'listening' while the object is alive. The class includes a timer already which when it fires takes care to get the updates. Creating the signup is kind of time consuming but once the instance exists, you should get updates in 'real time' meaning if the timer is set to fire each 5 seconds, you should see the updates each 5 seconds, shortly after the timer has fired.

                                  So, please create one instance and keep using it. It is also possible to add and to remove points from the signup - again, no need to create a new instance.

                                  1 of 1 people found this helpful
                                    • Re: Is there a way to retrieve events in Bulk
                                      Noga

                                      Thank you Rick for your guidance.

                                       

                                      My application does uses a class similar to the sample class created by patrice,  and also uses PIserver. FindChangedPiPoints()  method to monitor point changes.

                                      Another issue I will be glad to be clarified about is:

                                      What happens in case of running 10 or 20 instances of my application?  That means 20 listeners for changes on the same source PI Archive Server will register for changes, Is that possible?  If yes, then how does it load the PI Archive Server? Could that be a problem in terms of performance?