Skip to main content
Version: Next

ts_shape.events.production.runtime_accounting

Runtime / operating-hours accounting for equipment.

Computes operating-time metrics from a single boolean run signal:

  • total run time, idle time and utilization,
  • equipment start count and longest continuous run,
  • run time per calendar window,
  • a cumulative operating-hours meter (like a physical hour meter).

Per-sample duration is the gap to the next sample, summed over True samples -- the same approach as OEEEvents.availability. Per window, each sample's interval is split at the window boundaries, so a run that crosses midnight counts in both days (the ISO 22400-2 time model). This is distinct from DutyCycleEvents (duty percentage and cycle counts): here the focus is absolute run time and an hour-meter reading.

Classes
NameDescription
RuntimeAccountingEventsOperating-hours accounting from one boolean run signal.

RuntimeAccountingEvents​

classsource
RuntimeAccountingEvents(
dataframe: pd.DataFrame,
run_state_uuid: str,
*,
event_uuid: str = "prod:runtime",
value_column: str = "value_bool",
time_column: str = "systime",
run_states: Collection[Any] | None = None,
value_range: tuple[float | None, float | None] | None = None
) -> None

Bases: Base

Operating-hours accounting from one boolean run signal.

Example usage::

rt = RuntimeAccountingEvents(df, run_state_uuid="machine:running")
rt.runtime_summary()
rt.runtime_by_window(window="1D")
rt.operating_hours_meter(window="1h")
Functions
NameDescription
runtime_summaryOverall operating-time summary across the whole dataset.
runtime_by_windowRun time per calendar window.
operating_hours_meterCumulative operating-hours meter, sampled per window.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame with timeseries data.required
run_state_uuidstrUUID of the boolean run-state signal (True = running).required
event_uuidstrUUID to tag derived events with.'prod:runtime'
value_columnstrColumn holding the boolean run state.'value_bool'
time_columnstrName of the timestamp column.'systime'
run_statesCollection[Any] | NoneValues of the run signal that mean running (e.g. {2} for a mode signal where 2 is automatic, or {"RUN"}); every other known value is not running. None (default) uses value_range or reads the signal as a bool, with a DataQualityWarning when it is not one.None
value_rangetuple[float | None, float | None] | None(lower, upper) inclusive bounds; a value inside counts as running (either bound may be None). Used when run_states is None.None

run_uuid​

propertysource
run_uuid: str

Deprecated read-only alias of :attr:run_state_uuid.

runtime_summary​

methodsource
runtime_summary(*, max_gap: str | None = None) -> pd.DataFrame

Overall operating-time summary across the whole dataset.

Parameters
NameTypeDescriptionDefault
max_gapstr | NoneOptional cap (e.g. "15min"). A gap to the next sample longer than this is treated as a logging outage and excluded, so it does not inflate run/idle time or utilization. Without it, a gap while the last state was running is booked as run time. None (default) applies no cap: every interval between readings, however long, counts toward the preceding state.None
Returns
TypeDescription
DataFrameSummary-shape DataFrame (one row) with columns: start, end,
DataFrameduration_seconds, run_seconds, run_hours, idle_seconds,
DataFramestart_count, longest_run_seconds, mean_run_seconds,
DataFrameutilization_pct.

runtime_by_window​

methodsource
runtime_by_window(
window: str = "1D", *, max_gap: str | None = None
) -> pd.DataFrame

Run time per calendar window.

Each sample's state holds until the next sample; the interval is split at the window boundaries, so each window gets the run and idle time that fell inside it. A start counts in the window of the sample that begins the run. Windows holding a sample or any observed time are reported.

Parameters
NameTypeDescriptionDefault
windowstrResample window (e.g. "1D", "8h").'1D'
max_gapstr | NoneOptional cap (e.g. "15min") excluding a logging gap from run time and utilization (see :meth:runtime_summary). None (default) applies no cap.None
Returns
TypeDescription
DataFrameSummary-shape DataFrame with columns: start, end, duration_seconds,
DataFramerun_seconds, run_hours, start_count, utilization_pct.

operating_hours_meter​

methodsource
operating_hours_meter(
window: str = "1h", *, max_gap: str | None = None
) -> pd.DataFrame

Cumulative operating-hours meter, sampled per window.

Mirrors a physical equipment hour meter: a monotonically increasing total of run hours. Run time is split at the window boundaries (see :meth:runtime_by_window); every window holding a sample or any observed time is reported, so the meter has no holes.

Parameters
NameTypeDescriptionDefault
windowstrResample window for the meter readings.'1h'
max_gapstr | NoneOptional cap (e.g. "15min") excluding a logging gap from run time so the meter does not advance across an outage. None (default) applies no cap.None
Returns
TypeDescription
DataFrameSummary-shape DataFrame with columns: start, end, duration_seconds,
DataFramerun_seconds, cumulative_run_hours.