Computed Fields

Define derived fields using an expression language that supports arithmetic, group aggregations, windowed temporal functions, and rate-of-change calculations. Computed fields are evaluated every tick and appear alongside raw telemetry fields in all panes.

YAML Definition

YAML
computed_fields:
  - name: temp_delta
    expr: "zone_temp - setpoint_temp"
    unit: "°C"

  - name: avg_group_temp
    expr: "AVG(zone_temp, building_a)"

  - name: temp_rate
    expr: "RATE(zone_temp, 60)"
    unit: "°C/min"

  - name: efficiency_rank
    expr: "RANK(efficiency, fleet, asc)"

  - name: rolling_std
    expr: "STDDEV_WINDOW(pressure, 300)"
    unit: "kPa"

Expression Language

Arithmetic

Standard operators with conventional precedence: + - * /. Division by near-zero (< 1e-12) evaluates to 0.0.

Text
zone_temp - setpoint_temp
(actual_power / rated_power) * 100
altitude_ft * 0.3048

Literals and Field References

TypeSyntaxExample
LiteralNumeric constant42.5, 0.3048
FieldField name from data_schemazone_temp, altitude_ft

Group Aggregations

Aggregate a field across all entities in a named group. Takes 2 arguments: (field, group_name).

FunctionDescriptionExample
MIN(field, group)Minimum valueMIN(zone_temp, floor_3)
MAX(field, group)Maximum valueMAX(pressure, all_zones)
AVG(field, group)Mean valueAVG(zone_temp, building_a)
SUM(field, group)Sum of valuesSUM(power_kw, plant)
COUNT(field, group)Count of entitiesCOUNT(id, active_fleet)

Ranking

Rank the current entity within its group. Takes 3 arguments: (field, group, asc|desc).

Text
RANK(efficiency, fleet, asc)    // 1 = lowest efficiency
RANK(speed, convoy, desc)       // 1 = fastest

Windowed Temporal Functions

Operate on a sliding time window of historical samples. Takes 2 arguments: (field, window_seconds). Requires FieldHistoryStore to be active (automatic when computed fields reference these functions).

FunctionDescription
AVG_WINDOW(field, secs)Mean over time window
MIN_WINDOW(field, secs)Minimum over window
MAX_WINDOW(field, secs)Maximum over window
SUM_WINDOW(field, secs)Sum over window
STDDEV_WINDOW(field, secs)Sample standard deviation
RATE(field, secs)Rate of change: (latest − oldest) / dt
SLOPE(field, secs)Linear regression slope over window

Field History

The FieldHistoryStore maintains a ring buffer of timestamped samples per (entity, field) pair. Configuration:

  • Max samples: 2,048 per buffer (oldest evicted on overflow)
  • Max age: Automatically set to 1.2x the largest window referenced by any expression
  • Push rate: One sample per simulation tick per tracked field

Evaluation Context

Each computed field is evaluated per entity per tick. The evaluator receives the current entity's snapshot, all snapshots (for group aggs), group membership maps, and the field history store. Results are injected back into the snapshot before rendering and table display.

Questions?

Reach out for help with integration, deployment, or custom domain codecs.