Calculations
Calculations are measurements that are produced by evaluating custom scripts, written in the Tengo scripting language. They can take other measurements and calculations as input fields and derive new values from these inputs.
Auto-pausing calculations
Available from version 8.2 and later.
A calculation written with a faulty script can produce significant additional load on the system. To counter this, calculations automatically pause themselves if they have produced too many errors in a row. By default, this happens after 3 errors, but this can be changed or disabled in the calculation collector's settings via the Auto pause threshold setting.
Inputs
A calculation reads its inputs through an alias, such as _A. Which input types a calculation takes depends on its type:
A calculation on an asset prototype can also take an Asset property prototype input. LookupTable inputs are available from version 8.3 and read a lookup table.
From version 8.3, saving, testing, recalculating or resuming a calculation, and reading or updating its context, needs the READ_LOOKUP_TABLES privilege on top of MANAGE_MEASUREMENTS, whether or not the script has a lookup table input. Without it, the request gets a 403. See Privileges.
Held calculations
Available from version 8.3 and later.
An active calculation that cannot start is held. It does not run, and it does not need to be resumed by hand. A calculation is held when:
- An input is an asset property without a measurement. The calculation starts once a measurement is linked to the asset property again.
- An input references a measurement or asset property that no longer exists. The calculation starts once the input exists again, or once you replace the input.
The detail panel of a held calculation shows This calculation is not running. Expand it to see the reason, which names the aliases of the inputs, for example inputs _B reference an asset property without a linked measurement. Held calculations are also listed under Calculations with errors in the issues panel on the homepage.
The calculation editor warns about these inputs before you save:
- An asset property input without a measurement shows This asset property has no linked measurement. The calculation will not run until a measurement is linked. In the list of inputs, such an asset property has an unlink icon.
- An input that references a deleted measurement, asset property or lookup table shows Measurement not found, Asset property not found or Lookup table not found.
Calculation load
Available from version 8.3 and later.
The heading of the Calculations page holds a Calculation load button with two bars:
- Total: the script time of all running calculations, as a share of the cores of the server. Only shown to users with the READ_STATISTICS privilege.
- Heaviest: the script time of the heaviest calculation, as a share of one core.
Click the button to open the calculation load view. It refreshes every 10 seconds, and its rates and averages cover the last minute.
The top of the view shows three cards:
- Script time: seconds of script time per second, added up over all running calculations. This is wall clock time, not CPU time: a script waiting for a core keeps counting.
- Historian process CPU: the CPU the whole Historian process uses, not only calculations. Only shown to users with the READ_STATISTICS privilege.
- Heaviest calculation: the calculation ranked first, with its mean evaluation time and how often it runs.
Below, a table lists the running calculations, heaviest first, up to the 250 heaviest:
- Relative load: a score against the heaviest calculation, on script time and retained memory together. The heaviest reads 100.
- Script time: seconds of script time per second for this calculation. One calculation evaluates one run at a time, so it cannot pass 1.00.
- Mean evaluation: the average duration of one script evaluation.
- Evaluations/s: how often the calculation ran its script.
- Retained memory: the encoded size of the script context, plus the fixed memory every running calculation costs. This is an estimate, not the live heap size.
- Mean query: the average duration of a time series query, including the wait for a query slot.
- Failed evaluations: script runs that ended in an error since the calculation last started. Editing, pausing or restarting a calculation resets it.
The view needs the READ_MEASUREMENTS privilege.