Skip to content

Archiving ​

About 6 min read

2WinScada stores the past values of a tag only if a log definition has been made for that tag. A tag without a log definition has only a current value; it cannot be used in reports, consumption calculations or snapshots. The definition steps are on the Log (Archive) Definitions page.

Log Definition ​

Every log definition is a separate record series of one tag and answers these questions:

QuestionSetting
When is a record taken?Log Type, Interval[s], Trigger Tag
Which value is recorded?Log Value Type
How long is the record kept?Data Retention [Months]
How is consumption calculated?Consumption Value Type and Total Value Conversion[Factor/Divisor] in the Consumption & Run/Stop step
  • A tag can have more than one log definition; for example, one with a one-minute average and one that records every value change. Log definition names are unique in the system.
  • Only numeric and Bool tags are archived. No records are taken for text (String) tags.

When a Record Is Taken ​

Log TypeRecord time
Cyclic (Cycled)Each time the Interval[s] elapses.
On Change (Changed)Each time the tag's value changes.
On Trigger Change (TriggerChanged)When the value of the Trigger Tag changes.
Trigger Rising Edge (TriggerRisingEdge)When the trigger tag's value increases (e.g. from 0 to 1).
Trigger Falling Edge (TriggerFallingEdge)When the trigger tag's value decreases (e.g. from 1 to 0).
Cyclic While Triggered (CycledWhenTriggered)Each time the Interval[s] elapses while the trigger tag is greater than 0. A record is also taken when the trigger changes to a value greater than 0.
  • Interval[s] is used only for Cyclic and Cyclic While Triggered; it can be between 0.1 seconds and 2,073,600 seconds (24 days).
  • Timed and triggered records are not taken while the tag's quality is not Good. For triggered types, the trigger tag's quality must also be Good. A communication outage therefore appears as a gap in the archive.
  • For advanced tags, whether a record is taken while the quality is bad depends on the advanced tag's Bad Quality Behavior setting (see Data Model).

Day Boundary Records ​

For timed logs with an interval of at least 60 seconds whose Consumption Value Type is Instant or Cumulative, one extra record is taken at the start (00:00) and one at the end (23:59) of the day in the server's local time, even if the interval has not elapsed. This way daily consumption is split correctly at the day boundary.

Recorded Value ​

Log Value Type decides which value is written at record time:

Log Value TypeRecorded value
CurrentThe value at record time.
AverageThe average of the values the tag took since the previous record.
Median (Mean)The middle value (median) of the values the tag took since the previous record, sorted from smallest to largest.
SumThe sum of the values the tag took since the previous record.

For Average, Median and Sum, values are accumulated each time the tag's value changes. Protocols update a tag only when its value changes; reads where the value stays the same are not counted again. Therefore:

  • The average is not time-weighted; a value that stays constant for a long time has the same weight as a value that lasts a short time.
  • If the value did not change at all during the record interval, Average and Median write the value at record time, and Sum writes 0.

Minimum and Maximum

The Minimum and Maximum log value types are not supported in this version; select Current, Average, Median or Sum instead. The smallest and largest values can be obtained with the aggregation methods on the Reporting screen.

Where History Is Stored ​

Definitions (channels, tags, log and alarm definitions, users) are kept in the configuration database on SQL Server. History is kept in a separate time-series database, the archive database:

  • Tag history: The records of the log definitions.
  • Alarm history: The times alarms were raised and cleared (see Alarms).
  • Operation history: Records of user actions.

Consequences of this separation:

  • The configuration backup does not contain history data. The archive database must be backed up separately (see Backup and Restore and Upgrading).
  • All projects on a server use the same archive database (see Project Profiles (in the help installed with the product)).
  • If the archive database temporarily cannot be written to, records wait in server memory for a limited time and are written when the connection returns. If the outage goes on, the oldest records are dropped; if the service is restarted in the meantime, the waiting records are lost. In both cases a data gap appears in the archive.

Retention Period ​

Every log definition has its own Data Retention [Months] value. Records whose retention has expired are deleted automatically by the archive database in monthly partitions; deleted records cannot be recovered.

  • The default for a new log definition is 48 months. The server applies at most 60 months; a larger value is saved as 60 months.
  • Shortening the retention can delete old records. Therefore, when you shorten it, you are asked to check I understand the risk of reducing the data retention period and I want to apply this change.
  • Since projects share the archive database, a retention change can also affect other projects that use the same archive records.

Consumption Calculation ​

Consumption such as energy, water or gas is calculated from archive records. The calculation method is selected with Consumption Value Type in the Consumption & Run/Stop step of the log definition:

Consumption Value TypeSuitable dataConsumption for a period
CumulativeA continuously increasing counter (kWh, m³)The increase of the counter within the period.
InstantData where each record is an amount itselfThe sum of the records within the period.

The result is multiplied and divided with Total Value Conversion[Factor/Divisor] and shown with the Unit; for example, to report a Wh counter in kWh, set the divisor to 1000.

Consumption depends on records being continuous. If records are missing in a period, consumption can come out lower than it really is. From 2.10 on, consumption values mark this case as a data gap, and periods that have not ended yet as a partial period. Data gaps can be detected only for logs with the Cyclic log type; for logs that record on value change or on a trigger, missing records are considered normal.

Binding consumption values to pages, the data gap rules and the indicators are described on the Consumption and Snapshots page.

Reviewing History ​

Archive records are reviewed as charts and tables on the Reporting screens. Wide time ranges produce many points; in charts you can use downsampling to reduce the points while keeping the shape (see Data Downsampling (LTTB)).

2WinScada 2.10