Files

3.7 KiB
Raw Permalink Blame History

Shift running-speed KPI

average_line_speed_m_min is the arithmetic mean of active, finite production-speed samples in [start, end). Each active sample has equal weight. The calculation does not interpolate or weight speed by elapsed time.

Activity gates

The speed block has exactly one activity method:

  • Simple numeric: production_gate_m_min selects speed samples strictly above the threshold. B1, E1 and K7 retain this behavior.
  • Boolean: running_signal_ref and optional running_when (default true) select samples whose status is exactly that Boolean. K5 uses running_when: false because its status signal is true when stopped.
  • Numeric dwell: numeric_dwell_gate has signal_ref, finite threshold, comparison (below or above), and positive integer minimum_duration_seconds. Gitter 1–4 use below and 150 seconds. Their production-speed signal holds its last value while stopped, and their PLC Boolean status did not reliably indicate downtime. The numeric gate follows the configured ENLYZE threshold and minimum duration concept.

For below, only a gate value strictly less than the threshold satisfies the condition. An equal value ends a below-threshold run. Rows are ordered by their UTC timestamps; a condition reading remains the observed state until the next reading. A continuous below-threshold run qualifies when the elapsed time from its first below-threshold timestamp to the first non-below reading is at least the minimum duration. If it qualifies, all speed samples in that run are inactive, including those before the minimum duration elapsed. A short run bracketed by non-below readings stays active. The same rules apply to above. The interval ending at the non-satisfying reading excludes that reading.

The service requests speed and the gate signal together from /v2/timeseries. For a dwell gate it extends the read window by one minimum duration on each side; only production-speed samples in the original report window enter the KPI. This lets a qualifying run crossing a report boundary be classified when the source provides enough surrounding readings. An unclosed short run, or a short run without a preceding non-satisfying reading, has unknown duration and is excluded conservatively. An invalid or non-finite gate reading breaks continuity and its speed row is excluded. A missing required gate column fails the read. No absent rows are synthesized; the result depends on the timestamps returned by ENLYZE, which deserves validation against live boundary cases.

Invalid speed values (including Boolean, null, non-numeric, NaN, and infinity) are excluded in every mode. Invalid timestamps are also excluded. In Boolean mode, missing or non-Boolean status is excluded. sample_count is the sum of active and inactive valid speed samples; excluded samples increment invalid_sample_count. If no active samples remain, average, minimum and maximum are None.

Machine UUIDs and gate settings live in config/shift-report-machines.yaml. The loader validates the gate fields and rejects overlapping Boolean and dwell gates. ShiftSpeedService.summarize() composes the gateway read with the pure aggregate_shift_speed() calculation. The calculation accepts ShiftSpeedSample(timestamp, value, running, gate_value) records. Structural timeseries and pagination errors fail the read instead of returning a partial KPI.

Supplied legacy reference

For 2026-10-07 06:00–14:00 Europe/Berlin:

Machine Samples Active samples Active average (m/min)
B1 2880 1603 2.3139663284001912
E1 2880 2782 7.933009468249328
K7 2880 2667 10.078945039942955

These are supplied validation values, not a new live read.