Calculation Base Time for Historic Views

The Calculation Base Time makes the historic result set have a start time that begins at the start of a whole time unit (day, hour, and so on). This works in a similar way to an offset, except that it rounds the time down to the nearest whole time unit, for example, the start of a day (00:00).

With Calculation Base Time, only suitable historic result sets are used to provide the value(s) that are read by Geo SCADA Expert or a third-party application.

Take care with End and End Last Historic Algorithms used on clients, or with Geo SCADA Expert features, that run in Local Time with Daylight Saving Time. Ensure that the start and end times specified for the sample interval do not coincide exactly with the time at which the clock jumps backward. Include a small offset in the sample time, to offset the calculation to avoid the sample end or start time exactly matching the time that the clock jumps backward at the transition from Daylight Saving Time to Standard Time. A small offset of 1s or even 1ms should suffice. For more information about Daylight Saving Time, see The Effects of Daylight Saving Time Adjustments.

The example (below) explains how the Calculation Base Time can be used as part of a Historic View.

Example:

A user needs to use a third-party report application to obtain the average daily value of a point named ‘pValve’ for the previous week. The report will then be compared to similar reports for other points. To make the reports cover values for the same time spans, a Historic View is created to represent an average calculation for a 1 week period. The Historic View is named ‘HisWeeklyAverage’ and is configured to have the following settings:

  • Algorithm—Average.
  • Calculation Base Time—D. This means that the algorithm only includes values reported from the start of the first day in the defined historic result set. The Calculation Base Time is applied irrespective of any start times that may be specified in the third-party application’s SQL query.
  • Resample—1D. This means that the algorithm will be used to produce 1 value for each day in the historic result set.
  • Default Start—D-1W. This defines the default start time of the historic result set as 1 week prior to the current day. However, this is ignored if there is a start time defined in the SQL query.
  • Default Length—1W. This defines the duration of the historic result set as being 1 week. However, this value is ignored if there is a length defined in the SQL query.

    The third-party application uses the following SQL Query to request the values from the ‘HisWeeklyAverage’ Historic View:

    SELECT

    CDBPoint."FullName",

    HisWeeklyAverage."Value", HisWeeklyAverage."Time"


    FROM

    "CDBPoint" CDBPoint,

    "HisWeeklyAverage" HisWeeklyAverage


    WHERE

    CDBPoint. "Id" =HisWeeklyAverage. "Id" AND

    HisWeeklyAverage."Time" >={ts '2010-01-25 02:00:00'} AND

    HisWeeklyAverage."Time" <={ts '2010-02-02 02:00:00'} AND

    CDBPoint."FullName" = 'pValve'

    As the SQL Query defines a start time and an end time (in the WHERE clause), the Default Start and Default End settings of the Historic View are not applied. This means that the query will return values from the period 2010-01-25 02:00:00 to 2010-02-02 02:00:00.

    The Historic View’s Calculation Base Time of 1D means that the Geo SCADA Expert performs its calculation (algorithm) using the raw values reported from the start of the first day to the end of the last day in sample. So the calculation is performed using the values reported in the period 2010-01-25 00:00:00 to 2010-02-02 00:00:00.

    The Historic View’s Resample setting defines when the calculation is performed. In this case, the calculation is performed once every day.

    So the result set of the query contains the average value of the ‘pValve’ point at:

    2010-01-26 00:00:00 (midnight after the start time defined in the query)

    2010-01-27 00:00:00

    2010-01-28 00:00:00

    2010-01-29 00:00:00

    2010-01-30 00:00:00

    2010-01-31 00:00:00

    2010-02-01 00:00:00

    2010-02-01 00:00:00

    2010-02-02 00:00:00

    There is no value for 2010-02-03 00:00:00 as this is after the end time that is defined in the query.


Disclaimer

Geo SCADA Expert 2019