11 Replies Latest reply on Jan 26, 2017 9:36 AM by gregor

    Why getting two events from DataPipe?

    ChaoXu

      Hello,

      I am using DataPipe GetObserverEvents() to listen DataPipe and retrieving events at OnNext() in IObserver<AFDataPipeEvent>.  Line Sensor fires event every 15 minutes.  I assume we will always get latest event in DataPipe every 15 minutes. But I got two events every 15 minutes(30 seconds between the two events) with different TimeStamp and different values. I am wondering it is configuration issue or my code issue.

      Thank you!

        • Re: Why getting two events from DataPipe?
          rsun

          Have you take a look at the examples from Patrice Thivierge How to use the PIDataPipe or the AFDataPipe ?

          You might be able to idenity if it is your code issue.

          Please let us know your result.

          Thanks.

          Ricky

          • Re: Why getting two events from DataPipe?
            Roger Palmen

            If you could post a bit more information on the data incoming to PI, the data you receive and the code used.

             

            If you get different datapoints i would suspect the code to register for signups to different points, or that the incoming data is different than expected.

            1 of 1 people found this helpful
            • Re: Why getting two events from DataPipe?
              pthivierge

              Hello Chao,

               

              As Roger suggested it can be caused by either your datapipe configuration that contains multiple tags or by the data patterns in the data collection, It could be that the system is sending two events this really depends on the data collection. 

               

              On top of this, if the values are very similar but have a different timestamps, it could be that from the time you collect the data, the second event always get compressed.

              Is compression enabled on the tag?

               

              Let us know how it goes!

                • Re: Why getting two events from DataPipe?
                  ChaoXu

                  Thanks everyone!

                  Yes The compression is on.

                  Here is snippet code:

                   

                  class AFDataService

                  {

                      void DataPipeSignup(IList<AFAttribute> attributesForSignUp)

                      {

                          dataPipes.AddSignup(attributesForSignUp);

                          dataPipes.StartListening(TimeSpan.FromSeconds(0.001));

                      }

                  }

                   

                   

                  class AFDataPipeListener : IDisposable

                  {

                      private readonly AFDataPipe _afDataPipe = new AFDataPipe();

                      public AFDataPipeListener()

                      {

                          _afDataPipe.Subscribe(new AFDataReceiver());

                      }

                      public void StartListening(TimeSpan checkIntervall)

                      {

                          _timer = new Timer(CheckForData, null, 0, (int)checkIntervall.TotalMilliseconds);

                      }

                      public void AddSignup(IList<AFAttribute> attributes)

                      {

                          AFErrors<AFAttribute> errors = _afDataPipe.AddSignups(attributes);

                      }

                   

                      private void CheckForData(object o)

                      {

                          _afDataPipe.GetObserverEvents();

                      }

                   

                      public void Dispose()

                      {

                          StopListening();

                          _afDataPipe.Dispose();

                      }

                  }

                   

                   

                  class AFDataReceiver : IObserver<AFDataPipeEvent>

                  {

                      public void OnNext(AFDataPipeEvent dataPipeEvent)

                      {

                          //todo

                      }

                      public void OnError(Exception error)

                      {

                          //todo

                      }

                      public void OnCompleted()

                      {

                          //todo

                      }

                  }

                    • Re: Why getting two events from DataPipe?
                      ChaoXu

                      Anyone has any idea?

                      If the second one is compression data, how can I get rid of it?

                      Thanks

                        • Re: Why getting two events from DataPipe?
                          Roger Palmen

                          Can you post the exact details of the two datapipe events you receive? DataPipeAction, PreviousAction,SpecificUpdatedValue , AFvalue, etc.

                            • Re: Why getting two events from DataPipe?
                              ChaoXu

                              Roger,

                              Action, PreviousEventAction, SpecificUpdatedValue have following data combination:

                              Insert, None, empty

                              Add, PreviousEventArchived, empty

                              Add, PreviousEventDiscarded, empty

                                • Re: Why getting two events from DataPipe?
                                  Roger Palmen

                                  Without knowing the timestamps, i assume these are in sequence. It looks like that two events are received from the data source: the first is archived, the second is NOT archived due to compression?

                                  AFDataPipePreviousEventAction Enumeration

                                  Not 100% sure if i interpret this behaviour correctly.

                                   

                                  How sure are you that we only receive one event from the interface / sensor?

                                    • Re: Why getting two events from DataPipe?
                                      ChaoXu

                                      Roger.

                                      The admin said it is configured only one event every 15 minutes. So I am wondering it is my code issue or the server configuration issue.

                                        • Re: Why getting two events from DataPipe?
                                          Roger Palmen

                                          The simple solution would be to decide which of the events is the 'correct one' and just ignore the other events. You could decide on the Action / PreviousAction combination. That does leave an unsatisfactory feeling of a workaround, so digging further is an option if time and resources permitted.

                                           

                                          You could call techsupport to have a look together with you where the second event is coming from. There is a lot to trace, but digging through debug logging of the various components takes time and skill to setup.

                                           

                                          PS: i also noted you indicated 3 lines received: one insert and two add events, while previously you indicated 2 events?

                                          2 of 2 people found this helpful
                                            • Re: Why getting two events from DataPipe?
                                              gregor

                                              Hello Chao,

                                               

                                              Are the effected PI Points serviced by an OSIsoft Interface? Which one? Let me guess it's the PI OPC DA Interface and data is acquired in advise mode. Please confirm.

                                              Can you verify if the point attribute excmax is set to 900 (15 minutes)?

                                               

                                              OPC advise mode is also referred to as unsolicited scans. When the interface connects to the OPC Server, it requests the OPC Server to check on new values at the scan rate defined with the scan class. The OPC Server sends updates for configured data items. The interface is not actively scanning. Because of this scan mode, it happens that single data items do not become updated for longer periods. Trending such a tag may give the impression that the value was constantly changing over the period between 2 updates which is not true. A stepped plot would be closer to reality. To address this, the PI OPC DA Interface has a specific excmax behavior. When the period specified with excmax has expired, the interface repeats the previous (current) value with an updated timestamp (previous timestamp + excmax). If excmax is equal to the update (scan) rate, it happens that the OPC Server sends a new update right after the interface has send its update because of excmax.

                                               

                                              It's just a theory about what might be causing your observation but the issue is not uncommon. With 15 minutes scans, I would suggest to stick with excmax but to change the scan rate to either each 10 or 5 minutes.

                                              1 of 1 people found this helpful