7 Replies Latest reply on Aug 6, 2013 6:19 AM by pt030

    PI Datalink Calculated Data




      In Datalink, Calculated Data option.  e.g for Caculation = average and Time Interval being 30m, I noticed that it calculates the values as TimeWeighted.  Is there a way to get the values as TimeWeightedDiscrete instead?  Thanks.





        • Re: PI Datalink Calculated Data

          Hi Peter,


          I don't think that is a supported option in DataLink, as the available options are only time and event weighted. It would seem like using the option would only make sense if you want to treat a tag with continuous data as if it is a tag with discrete data (Step attribute = 1) when performing the calculation. Is that what you are trying to do?

            • Re: PI Datalink Calculated Data

              Hi Han,


              Well I'm trying to replace an old system that was not using PI.  


              The old system seemed to calculate half hourly averages on cbTimeWeightedDiscrete.   In my new client which uses PI SDK, by using cbTimeWeightedDiscrete, the values returned matches exactly like the old system.


              However users will also use DataLink but the half hourly averages don't match to what the old system and my new client are showing.

                • Re: PI Datalink Calculated Data

                  I've also read vcampus.osisoft.com/.../10340.aspx and Daniel Tanaka explained quite well the timeweighted calculation in a diagram.  


                  I read the PI SDK and now I'm not sure about cbTimeWeightedDiscrete and cbTimeWeighted


                  according to SDK documenttation cbTimeWeightedDiscrete:


                  "Apply weighting as in cbTimeWeighted but interpolation between values is performed as if they represent discrete, unrelated values (stair step plot) regardless of the step attribute of the point."


                  Is it possible for someone to draw a graph and show which area is being calculated under timeweighteddiscrete?

                    • Re: PI Datalink Calculated Data

                      The difference would really need to go down to the difference between a continuous data and discrete data, Here's something that illustrate this:




                      Assume that the circles are represents the points where data is stored (value vs time). A continuous data would give a trend that is joined by a slope line (blue). Whereas the same set of data defined as discrete would give a step trend (red). This behaviour is determined by the Step attribute of the PI Point. What this would affect would be

                      1. The result of time weighted total
                        As you mentioned, this is the same as the area under the graph, and very obviously the result would be different for a step graph compared to a line graph even for the same set of data
                      2. the values of interpolating data at a specific time
                        Interpolating data at a time where there is no data, a continuous trend will find the value based on linear interpolation whereas for a discrete trend, the value will be the same as the last value before the specified time.
                      The difference between cbTimeWeighted and cbTimeWeightedDiscrete is that cbTimeWeighted will look at the point's Step attribute and determine how it should handle it, but cbTimeWeightedDiscrete will ignore the Step attribute and always regard the tag as having discrete data (Step graph). Thus if your tag is actually a set of continuous data and you are calculating with the mode cbTimeWeightedDiscrete, the end result could be different from cbTimeWeighted.
                        • Re: PI Datalink Calculated Data

                          Thanks a lot.   I have another question.  


                          According to the documentation, cbTimeWeighted - Weight the values in the calculation by the time over which they apply. Interpolation is based on the step attribute of the point. Interpolated events are generated at the boundaries if necessary.


                          So in a half hourly period it will try to get the interpolated values at the boundary.  What if there is no values outside the boundary?  What values does it take at the boundary to do an average within that 30mins?

                            • Re: PI Datalink Calculated Data

                              That would depends on the situation. At the end time boundary, if there are not values after the end time (meaning the last data before the boundary is the snapshot value). Then it is assumed that the value is constant from the last value, hence interpolation will give the same value as the last value.


                              At the start time boundary, usually if there are no values earlier than the start time, it usually means that it will return some system state values (Bad Values) like "Shutdown", "Arc Off-line". These values is not taken into account for summary calculation. One thing to note for calculating Time-Weighted Total mentioned in the PI SDK Programming Reference


                              PI SDK Programming Reference

                              If some of the data are bad in the time range, the calculated total is divided by the fraction of the time period for which there are good values. Mathematically, this approach is equivalent to assuming that during the period of bad data, the tag takes on the average values for the entire calculation time range. It is important for the user of the data to check the percentGood attribute to determine if the calculation result is suitable for the application's purposes.