ts_shape.events.production.setup_time_tracking
Setup/changeover time tracking for SMED analysis.
Track setup durations to support Single-Minute Exchange of Die improvement:
- Setup event durations
- Setup time by product transition
- Setup statistics
- Setup time trends
| Name | Description |
|---|---|
SetupTimeEvents | Track and analyze setup/changeover durations. |
SetupTimeEvents
SetupTimeEvents(
dataframe: pd.DataFrame,
*,
time_column: str = "systime",
shift_definitions: dict[str, tuple[str, str]] | None = None,
event_uuid: str = "prod:setup_time"
) -> None
Bases: Base
Track and analyze setup/changeover durations.
Each UUID represents one signal:
- run_state_uuid: machine state signal containing a setup indicator value
- part_id_uuid: part number / product type signal (optional)
Merge keys: [date, shift] for shift-level, [period] for trend data, [from_product, to_product] for product transition analysis.
Durations are reported in seconds (*_seconds); the *_minutes
columns are kept as a convenience.
Pipeline example::
setup = SetupTimeEvents(df)
durations = setup.setup_durations('machine_state', setup_value='Setup')
# → merge with ShiftReportEvents.shift_production() on [date, shift]
stats = setup.setup_statistics('machine_state')
# → standalone KPI reporting
Example usage
tracker = SetupTimeEvents(df)
List all setup events
events = tracker.setup_durations(run_state_uuid='machine_state')
Setup time by product transition
by_product = tracker.setup_by_product( run_state_uuid='machine_state', part_id_uuid='part_number', )
| Name | Description |
|---|---|
setup_durations | List every setup event with duration. |
setup_by_product | Setup time statistics by product transition (from → to). |
setup_statistics | Overall setup time statistics. |
setup_trend | Track setup time trend over time. |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Input DataFrame with timeseries data. | required |
time_column | str | Name of timestamp column (default: 'systime'). | 'systime' |
shift_definitions | dict[str, tuple[str, str]] | None | Mapping of shift name to (start, end) times. Default: 3-shift operation (06:00-14:00, 14:00-22:00, 22:00-06:00). | None |
event_uuid | str | UUID tagged on derived interval events (the uuid column of :meth:setup_durations; default: 'prod:setup_time'). | 'prod:setup_time' |
setup_durations
setup_durations(
run_state_uuid: str,
*,
setup_value: str = "Setup",
value_column: str = "value_string",
production_day: bool = True
) -> pd.DataFrame
List every setup event with duration.
| Name | Type | Description | Default |
|---|---|---|---|
run_state_uuid | str | UUID for machine state signal. | required |
setup_value | str | Value that indicates a setup state. | 'Setup' |
value_column | str | Column containing state values. | 'value_string' |
production_day | bool | Attribute an overnight shift's post-midnight setups to the shift's start date, so a night shift is one (date, shift) row (default). False groups by raw calendar date, which splits a night shift across two rows. | True |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: |
DataFrame | - start, end, duration_seconds (float seconds, end - start), uuid (event uuid), source_uuid (run_state_uuid), duration_minutes (convenience: duration_seconds / 60), date, shift |
setup_by_product
setup_by_product(
run_state_uuid: str,
part_id_uuid: str,
*,
setup_value: str = "Setup",
value_column_state: str = "value_string",
value_column_part: str = "value_string"
) -> pd.DataFrame
Setup time statistics by product transition (from → to).
| Name | Type | Description | Default |
|---|---|---|---|
run_state_uuid | str | UUID for machine state signal. | required |
part_id_uuid | str | UUID for part number / product type signal. | required |
setup_value | str | Value indicating setup state. | 'Setup' |
value_column_state | str | Column containing state values. | 'value_string' |
value_column_part | str | Column containing part number values. | 'value_string' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: |
DataFrame | - from_product, to_product, avg_minutes, avg_seconds, min_minutes, min_seconds, max_minutes, max_seconds, count, setup_count |
DataFrame | The *_minutes columns are a convenience (*_seconds / 60). |
DataFrame | Canonical twin columns: setup_count (after count); it holds the same |
DataFrame | values as the deprecated column right before it, which is removed |
DataFrame | in the next major release. |
setup_statistics
setup_statistics(
run_state_uuid: str,
*,
setup_value: str = "Setup",
value_column: str = "value_string"
) -> pd.DataFrame
Overall setup time statistics.
| Name | Type | Description | Default |
|---|---|---|---|
run_state_uuid | str | UUID for machine state signal. | required |
setup_value | str | Value indicating setup state. | 'Setup' |
value_column | str | Column containing state values. | 'value_string' |
| Type | Description |
|---|---|
DataFrame | DataFrame (single row) with columns: |
DataFrame | - total_setups, total_minutes, total_seconds, avg_minutes, avg_seconds, median_minutes, median_seconds, std_minutes, std_seconds, pct_of_available_time |
DataFrame | The *_minutes columns are a convenience (*_seconds / 60). |
DataFrame | Canonical twin columns: share_of_available_time_pct (after |
DataFrame | pct_of_available_time); each holds the same values as the deprecated |
DataFrame | column right before it, which is removed in the next major release. |
setup_trend
setup_trend(
run_state_uuid: str,
*,
setup_value: str = "Setup",
value_column: str = "value_string",
window: str = "1W"
) -> pd.DataFrame
Track setup time trend over time.
| Name | Type | Description | Default |
|---|---|---|---|
run_state_uuid | str | UUID for machine state signal. | required |
setup_value | str | Value indicating setup state. | 'Setup' |
value_column | str | Column containing state values. | 'value_string' |
window | str | Time window for aggregation (default '1W'). | '1W' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: |
DataFrame | - start, end, duration_seconds: the period's bin bounds (for the default '1W' the Monday-to-Monday week; period is the pandas bin label, i.e. the week's Sunday) |
DataFrame | - period, avg_setup_minutes, avg_setup_seconds, setup_count, total_setup_minutes, total_setup_seconds (the *_minutes columns are a convenience) |