runtime_accounting
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.
RuntimeAccountingEvents ¤
RuntimeAccountingEvents(
dataframe: DataFrame,
run_state_uuid: str,
*,
event_uuid: str = "prod:runtime",
value_column: str = "value_bool",
time_column: str = "systime"
)
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")
Initialize the runtime-accounting analyzer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame with timeseries data. |
required |
run_state_uuid
|
str
|
UUID of the boolean run-state signal (True = running). |
required |
event_uuid
|
str
|
UUID to tag derived events with. |
'prod:runtime'
|
value_column
|
str
|
Column holding the boolean run state. |
'value_bool'
|
time_column
|
str
|
Name of the timestamp column. |
'systime'
|
runtime_summary ¤
runtime_summary(
*, max_gap: str | None = None
) -> pd.DataFrame
Overall operating-time summary across the whole dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_gap
|
str | None
|
Optional 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 |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Summary-shape DataFrame (one row) with columns: start, end, |
DataFrame
|
duration_seconds, run_seconds, run_hours, idle_seconds, |
DataFrame
|
start_count, longest_run_seconds, mean_run_seconds, |
DataFrame
|
utilization_pct. |
runtime_by_window ¤
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:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Resample window (e.g. |
'1D'
|
max_gap
|
str | None
|
Optional cap (e.g. "15min") excluding a logging gap from
run time and utilization (see :meth: |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Summary-shape DataFrame with columns: start, end, duration_seconds, |
DataFrame
|
run_seconds, run_hours, start_count, utilization_pct. |
operating_hours_meter ¤
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:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Resample window for the meter readings. |
'1h'
|
max_gap
|
str | None
|
Optional cap (e.g. "15min") excluding a logging gap from
run time so the meter does not advance across an outage.
|
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Summary-shape DataFrame with columns: start, end, duration_seconds, |
DataFrame
|
run_seconds, cumulative_run_hours. |