11 Replies Latest reply on Mar 26, 2012 5:50 PM by mhamel

    Trace highlighting problem

    moacircaetano

      Hi everybody,

       

      I am developing a C# ProcessBook Add-in to manipulate tag data in memory. In my add-in, I can use a tag to create data copies and execute some operations like average and data replacements. The main purpose of the add-in is to allow the user to eliminate undesirable values, using implemented functions, without to change the real data of the tags. After that, the user can save the data in other tag or export data as a file.

       

      To use the plugin, the user creates a data copy of some tag, AF attribute or imports data from a file. The add-in implements the IdataProvider3 interface to provide the data like a ProcessBook Dataset. The figure below shows this step.

       

      8154.vcmapus.bmp

       

      TagSim.cdt158 is the dataset provided by the add-in. The problem is when I move the mouse over the tag name in trend, ProcessBook stops to work for a long time. For example, if I have 30-day data in memory, PB locks the screen for almost 30 seconds. The add-in executes many data operations and the process is very fast, but this ProcessBook feature is disturbing my development.  But this lazy behavior doesn´t happen when I move the mouve over a tag or AF attribute.

       

      Is there a way to intercept the PB event (I think could be a Trend event) responsble for highlighting the trend ? Or is there a way to programmatically disable this feature? I think if is a way to disable this feauture, I could use LineWidth property to programmatically "highlighting" the trace. Has somebody another options ? I have tried to investigate Trend events and methods, but I didn´t find anything to undesrtand and debug what is happening.

       

      Thanks a lot!

        • Re: Trace highlighting problem
          mhamel

          Your add-in assembly should contain a class (thereafter called TagSim to follow you example) implementing The IDataProvider3 interface. This class should implements a GetData method that make use of a DataPoint class. The DataPoint class represents a use of a DataSet in a symbol in a display. Did you define the GetData method to use a DataPoint class?

            • Re: Trace highlighting problem
              moacircaetano

              Mathieu. Thanks for your reply.

               

              My add-in assembly contains a class implementing the IDataProvider3 interface and a method GetData. I also use a DataPoint class to represent symbols in displays. This add-in implementation is working and PB calls GetData method and others IDataProvider3 methods. The problem is I don´t know the method or event is called when the user moves the mouse over the trend name in a display because PB trend highlighting doesn´t call any method of my IDataProvider3 implementation class. I think trend highlighting can be an event of Trend Object but It doesn´t expose this event or something else.

               

              Thanks Moacir.

                • Re: Trace highlighting problem
                  mhamel

                  @Moacir: The highlighting behavior is handled by the trend symbol itself and you cannot modify in any way. Although, I was wondering as you make a copy of the data coming from either the PI Server of PI AF, how many events (I mean here values to be added to the trend symbol) were you handling in the 30 day time range? Just to give you a hint, if you use a PI Point or a PI AF data point the values returned will be optimized with the size of the trend symbol to avoid heavy calls for nothing. A method exist for either the PI SDK and AF SDK to return a set of values over a time period that will produce the most accurate plot while minimizing the amount of data returned.

                   

                  I suspect that if you allow the end-user to eliminate undesirable values on the fly, you bring all the data for a given time-range into the trend symbol to avoid the cost of calling either PI Server or PI AF Server multiple times. Can you describe better your data set behavior for the copy process?

                   

                  The process of highlighting traces on a trend symbol probably involves reading all events contained to draw a "ticker" curve around the standard curve. The more data you have the longer it should take. Do you have the same problem if you load a short time range of data? Is it faster?

                   

                  On your other question, there is no way to intercept an event from the trend that would prevent highlighting the trace.

                    • Re: Trace highlighting problem
                      dhollebeek

                      Check if IDP3.Refresh is being called in your addin when the trend highlights.  That method is actually called more that IDP3.GetData.

                        • Re: Trace highlighting problem
                          moacircaetano

                          @Mathieu: In 30 day time range, we are handling about 70.000 values. You are right when you said we want to allow the end-user to eliminate undesirable values on the fly. The dataset behavior is the following:

                           

                          1. User creates a PB trend and inserts a PI tag or AF attribute;

                           

                          2. Besides add-in menu, user can to create a data copy in memory. What does it mean? Using trend start and end time, we uses PI SDK or AF SDK to get data into PI archive. The result is a collection of PIValue or AFValue. We translate this collection into a collection of add-in internal types (because PIValue and AFValue are read-only). Each time when the IDataProvider3 GetData method is executed, the values between start and end time parameters are selected and returned to the PB. Before returning data to PB, the internal types are translate again into a collection of PIValue or AFValue.

                           

                          3. After to create a data copy, user can to select an interval using trend cursors and to replace data between two cursors or to apply customized average functions. The main purpose isn´t change data into archive and because of that, we create copies from the data.

                           

                          We have the problem with trend highlighting only when we have more data. We don´t have this problem when we have a short time range of data. Although add-in IDataProvider3 GetData doesn't take longer, trend highlighting process takes longer too much in the other hand for the same time range.

                           

                          @David: In my tests, IDataProvider3.Refresh is not called when the trend highlights.

                           

                          Thanks Moacir

                            • Re: Trace highlighting problem
                              moacircaetano

                              @Mathieu...I saw there are trend events you can provide a handler, such as ETrend_MouseOutEventHandler, ETrend_MouseOverEventHandler and ETrend_DataRefreshEventHandler. Does ProcessBook expose the trace highlight event or other event responsible for that? If it does that, I could to provide a customized handler.

                               

                              Let me know if you see another option to solve the problem, because, in my point of view, I am facing with a ProcessBook black box feature.

                               

                              Thanks Moacir

                                • Re: Trace highlighting problem
                                  mhamel

                                  @Moacir: As you pointed, you can provide custom handlers to respond to MouseOut, MouseOver and DataRefresh events within a PI ProcessBook add-in by setting a function pointer to the handler. At this point, PI ProcessBook does not expose any trace highlight event. This is part of another event. I have escalated the question to development to see if it exists a way to shut off the highlight event. I'll come back to you soon.

                                    • Re: Trace highlighting problem
                                      ssaad

                                      Moacir, I think we could explore Mathieu´s suggestion regarding the number of values in deeper detail. We should mimic the behavior of PISDK´s PlotValue method in our Dataset. When you debug the GetData method, what is the value of the maxValues parameter being received?

                                        • Re: Trace highlighting problem
                                          mhamel

                                          @Moacir: After verification, the trace highlight event is not exposed via automation. One workaround for you can be to deactivate the legend on the trend to prevent the trace highlighting event to trigger when the mouse is hovering on the trend symbol.

                                           

                                          You can easily deactivate the legend programmatically by manipulating a TrendFormat object that you pass to the SetFormat method of Trend object.

                                           

                                          Let me know if that workaround helped you.

                                            • Re: Trace highlighting problem
                                              moacircaetano

                                              @Mathieu. Thanks for your reply..

                                               

                                              I think this workaround can't be used in our case because could be difficulty to identify all traces in the same trend.

                                               

                                              We are thinking about Sergio Saad question (PlotValue behavior). When I debug my code, IDataProvider3 GetDSData method is called by ProcessBook all the time to get data to plot. This method has a maxValues parameter that I'm not using it. For example, for 30-day timerange, maxValues is about 3000, but we have 30000 points in dataset.

                                               

                                              According to PIDSK documentation, "the PlotValues method is designed to return a set of values over a time period that will produce the most accurate plot while minimizing the amount of data returned. For each timerange, PB returns only significant values and each interval can produce up to 5 values if they are unique, the value at the beginning of the interval, the value at the end of the interval, the highest value, the lowest value and at most one exceptional point (digital state)."  

                                               

                                              We are thinking to mimic this behavior. That is, we will store all data in memory, but when PB to call the GetDSData method, our code will divide the timerange in many intervals and, for each interval, it will be returned four values (the value at the beginning of the interval, the value at the end of the interval, the highest value, the lowest value).

                                               

                                              The number of interval will identified using maxValues, starttime and endtime parameters of the method IDataProvider3 GetDSData, like that:

                                               

                                              nInterval = (endtime - startime) / maxValues.

                                               

                                              What do you think about ? I have one doubt about PlotValues documentation. It follows below:.

                                               

                                              "The caller specifies a time range and a number of intervals.  For each interval, the data available is examined and significant values are returned.  Each interval can produce up to 5 values if they are unique, the value at the beginning of the interval, the value at the end of the interval, the highest value, the lowest value and at most one exceptional point (digital state)." What does it mean (at most one exceptional point)? Is this only for Digital state?

                                               

                                              Thank you

                                               

                                              Moacir

                                                • Re: Trace highlighting problem
                                                  mhamel
                                                  @Moacir: The PlotValues is intended to return an efficient number of events for a given number of intervals. You must see an interval as a slice of time where up to 5 events will be returned. For example, if you want to use a maximum number of 3000 events to show the sensor signal and your time range is equal to 30 days (43200 minutes) it means each interval is 72 minutes in length (3000 events / 5 events/interval = 600 intervals; and 43200 minutes / 600 intervals = 72 minutes/interval). You can see the question with a different angle: "Do I get more than 5 significant changes within 72 minutes?". If the answer is yes, this will tell that you are under evaluating the number of intervals. Each interval can produce up to 5 events if they are unique, the event at the beginning of the interval, the event at the end of the interval, the highest event value, the lowest event value and at most one exceptional event. The exceptional point will be a discrete event such as No Data or Bad (defined by the System Digital State). So, it applies to analog and digital state points.