Skip to main content
Version: Next

ts_shape.events.production.multi_process_traceability

Multi-process traceability across parallel and sequential stations.

Handles real production topologies where:

  • Each station / process segment has its own ID UUID (carrying the current order / serial number).
  • Multiple handover signals exist between station pairs (fires when an item transfers).
  • Stations can run in parallel (e.g., two welding cells feeding one painting station).

Example topology::

Welding Cell 1 ─┐
├─► Painting ─► Assembly ─► Test
Welding Cell 2 ─┘

Each cell has its own id_uuid that carries the serial number currently being processed. Handover signals between cells confirm the transfer.

Classes
NameDescription
MultiProcessTraceabilityEventsTrace items across a multi-station topology with parallel paths.

MultiProcessTraceabilityEvents​

classsource
MultiProcessTraceabilityEvents(
dataframe: pd.DataFrame,
processes: list[dict[str, str]],
*,
handovers: list[dict[str, Any]] | None = None,
event_uuid: str = "prod:multi_process_trace",
value_column_id: str = "value_string",
value_column_handover: str = "value_integer",
time_column: str = "systime",
exclude: Exclude = None
) -> None

Bases: Base

Trace items across a multi-station topology with parallel paths.

Example usage::

trace = MultiProcessTraceabilityEvents(
df,
processes=[
{"id_uuid": "serial_weld1", "station": "Welding Cell 1"},
{"id_uuid": "serial_weld2", "station": "Welding Cell 2"},
{"id_uuid": "serial_paint", "station": "Painting"},
{"id_uuid": "serial_assy", "station": "Assembly"},
],
handovers=[
{"uuid": "ho_w1_paint", "from_station": "Welding Cell 1", "to_station": "Painting"},
{"uuid": "ho_w2_paint", "from_station": "Welding Cell 2", "to_station": "Painting"},
{"uuid": "ho_paint_assy", "from_station": "Painting", "to_station": "Assembly"},
],
)

timeline = trace.build_timeline()
lead = trace.lead_time()
parallel = trace.parallel_activity()
handover_log = trace.handover_log()
paths = trace.routing_paths()
station_stats = trace.station_statistics()
Functions
NameDescription
build_timelineBuild a full timeline of every item at every station.
lead_timeCompute end-to-end lead time per item across all processes.
parallel_activityFind items that were processed at multiple stations simultaneously.
handover_logExtract handover events and correlate with item IDs.
station_statisticsCompute dwell-time statistics per station across all items.
routing_pathsAnalyze routing path frequencies across all items.
to_intervalsThe timeline as an object interval table (one row per visit).
Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame with timeseries data.required
processeslist[dict[str, str]]List of process definitions, each a dict with: - id_uuid: UUID of the signal carrying item IDs at this station. - station: Human-readable station name.required
handoverslist[dict[str, Any]] | NoneOptional list of handover signal definitions, each a dict: - uuid: UUID of the handover signal. - from_station: Station name the item leaves. - to_station: Station name the item arrives at. - from_id_uuid (optional): the id_uuid of the cell (or a list of cells) of from_station the item leaves, for a station name shared by parallel cells. Without it the item is the latest reading of any cell of from_station. A rising edge of the handover signal to a value > 0 (or True) is a transfer event; a missing reading holds the previous value.None
event_uuidstrUUID to tag derived events with.'prod:multi_process_trace'
value_column_idstrColumn holding item ID strings in process signals.'value_string'
value_column_handoverstrColumn holding handover trigger values.'value_integer'
time_columnstrName of timestamp column.'systime'
excludeExcludeReadings of the process ID signals that are not item IDs, read like :attr:ts_shape.eventlog.ObjectSpec.exclude: "misreads" (:func:ts_shape.utils.id_codes.is_misread: NOREAD, #N/A, 0, 65535, blanks, ...), a collection of values, or a callable returning a boolean mask over a signal's readings in time order. Between two readings of the same item an excluded reading is a gap (the item is held across it); anywhere else it is an empty reading. None (default) keeps every reading; "misreads" is planned to become the default in the next major release.None

build_timeline​

methodsource
build_timeline(
*,
infer_dwell_from_next: bool = False,
interval_end: IntervalEnd = "last_sample"
) -> pd.DataFrame

Build a full timeline of every item at every station.

Handles parallel stations: the same item may appear at overlapping time intervals at different stations (concurrent processing), or different items at parallel cells of the same station type.

On one cell's ID signal a visit ends where the reading changes (an empty or missing reading is no item) or, for the same item, at a time gap longer than 3x the signal's median sample interval (a rework loop back to the station).

Parameters
NameTypeDescriptionDefault
infer_dwell_from_nextboolWhen False (default), an interval's end is the last sample of the item at that station, so a station that logs the item once on arrival reports a dwell of 0. When True, each sequential (non-parallel) visit's end is set to the item's next station arrival, giving the honest arrival-here → arrival-at-next-station dwell. Parallel / overlapping visits keep their own span, since a "next arrival" is not meaningful while the item is at two stations at once.False
interval_endIntervalEndWhere a visit ends on its process signal. "last_sample" (default): at the item's last sample there. "next_change": at the signal's next segment (the next item or an empty / missing reading), so the item is held until it changes, like :func:ts_shape.eventlog.object_intervals; a signal's last visit is held until the last timestamp of the process signals. A visit followed by the same item after a time gap keeps its last sample (the gap is a leave). is_parallel and infer_dwell_from_next use these ends.'last_sample'
Returns
TypeDescription
DataFrameDataFrame with columns:
DataFrame- item_id: Order / serial number.
DataFrame- station: Human-readable station name.
DataFrame- id_uuid: Source UUID for this station's ID signal.
DataFrame- start: Interval start.
DataFrame- end: Interval end.
DataFrame- duration_seconds: Time at this station.
DataFrame- sample_count: Number of data points.
DataFrame- step_sequence: Visit order per item (1-based, by start time).
DataFrame- is_parallel: True if this interval overlaps with another station for the same item.
DataFrame- uuid: Event UUID.
DataFrame- source_uuid: The cell's ID signal (same as id_uuid).

lead_time​

methodsource
lead_time() -> pd.DataFrame

Compute end-to-end lead time per item across all processes.

Returns
TypeDescription
DataFrameDataFrame with columns:
DataFrame- item_id
DataFrame- first_station: First station visited.
DataFrame- last_station: Last station visited.
DataFrame- first_seen: Earliest timestamp.
DataFrame- last_seen: Latest timestamp (the latest visit end, also when visits overlap).
DataFrame- lead_time_seconds: Total elapsed time.
DataFrame- stations_visited: Number of distinct stations.
DataFrame- station_path: Ordered station names (" -> ").
DataFrame- has_parallel: Whether item had parallel processing.
DataFrame- uuid: Event UUID.
DataFrame- start: Same as first_seen.
DataFrame- end: Same as last_seen.
DataFrame- duration_seconds: Same as lead_time_seconds (float seconds).
DataFrame- source_uuid: Comma-joined cell ID signals (id_uuid) in visit order (each listed once).

parallel_activity​

methodsource
parallel_activity() -> pd.DataFrame

Find items that were processed at multiple stations simultaneously.

Returns
TypeDescription
DataFrameDataFrame with columns:
DataFrame- item_id
DataFrame- station_a: First overlapping station.
DataFrame- station_b: Second overlapping station.
DataFrame- overlap_start: Start of overlap period.
DataFrame- overlap_end: End of overlap period.
DataFrame- overlap_seconds: Duration of overlap.
DataFrame- uuid: Event UUID.
DataFrame- start: Same as overlap_start.
DataFrame- end: Same as overlap_end.
DataFrame- duration_seconds: Same as overlap_seconds (float seconds).
DataFrame- source_uuid: The ID signals of the two visits (id_uuid of station_a, then of station_b), comma-joined, each once.

handover_log​

methodsource
handover_log() -> pd.DataFrame

Extract handover events and correlate with item IDs.

For each handover signal, detects trigger points (a rising edge to a value > 0 or True; a missing reading holds the previous value) and resolves which item was being transferred from the from-station's ID signal: its last reading before the trigger, so an ID written at the trigger instant (the next item arriving) is not the transferred item. A trigger whose reading before it is empty is skipped. Rows without a timestamp are left out.

A handover with from_id_uuid reads only those cells of from_station. Without it, a from_station shared by several cells (processes entries with the same station) takes the latest reading of any of its cells, and a :class:~ts_shape.errors.DataQualityWarning names the station. A from_station that is not in processes gives no rows, with a DataQualityWarning naming it (once per call).

Returns
TypeDescription
DataFrameDataFrame with columns:
DataFrame- timestamp: When the handover fired.
DataFrame- item_id: Item being transferred (from from_station's ID signal).
DataFrame- from_station: Source station.
DataFrame- to_station: Destination station.
DataFrame- handover_uuid: UUID of the handover signal.
DataFrame- handover_value: Raw value of the handover signal.
DataFrame- uuid: Event UUID.
DataFrame- systime: Same as timestamp.
DataFrame- source_uuid: The handover signal (same as handover_uuid).

station_statistics​

methodsource
station_statistics(
*,
infer_dwell_from_next: bool = False,
interval_end: IntervalEnd = "last_sample"
) -> pd.DataFrame

Compute dwell-time statistics per station across all items.

Distinguishes parallel cells of the same station type.

Parameters
NameTypeDescriptionDefault
infer_dwell_from_nextboolForwarded to :meth:build_timeline; pass True when stations log an item once on arrival so dwell is measured to the item's next station arrival instead of collapsing to zero.False
interval_endIntervalEndForwarded to :meth:build_timeline.'last_sample'
Returns
TypeDescription
DataFrameDataFrame with columns:
DataFrame- station: Station name.
DataFrame- id_uuid: Specific cell UUID (for parallel cells).
DataFrame- item_count: Distinct items processed.
DataFrame- min_dwell_seconds
DataFrame- avg_dwell_seconds
DataFrame- max_dwell_seconds
DataFrame- total_dwell_seconds

routing_paths​

methodsource
routing_paths() -> pd.DataFrame

Analyze routing path frequencies across all items.

Returns
TypeDescription
DataFrameDataFrame with columns:
DataFrame- station_path: Ordered station names (" -> ").
DataFrame- item_count: Items that followed this path.
DataFrame- avg_lead_time_seconds
DataFrame- min_lead_time_seconds
DataFrame- max_lead_time_seconds
DataFrame- has_parallel_steps: Whether path includes parallel processing.

to_intervals​

methodsource
to_intervals(
*, object_type: str = "serial", interval_end: IntervalEnd = "last_sample"
) -> pd.DataFrame

The timeline as an object interval table (one row per visit).

The result has the columns of :func:ts_shape.eventlog.object_intervals plus station, so it feeds :func:~ts_shape.eventlog.presence_events, :func:~ts_shape.eventlog.object_kpis, :func:~ts_shape.eventlog.wip_over_time, :func:~ts_shape.eventlog.attach_counts, :func:~ts_shape.eventlog.relate and :func:~ts_shape.eventlog.link_events_to_objects directly. Parallel visits stay separate rows (object_kpis counts both in the dwell).

Parameters
NameTypeDescriptionDefault
object_typestrObject type of the items ("serial", "work_order", "batch", ...).'serial'
interval_endIntervalEndForwarded to :meth:build_timeline.'last_sample'
Returns
TypeDescription
DataFrameDataFrame with columns:
DataFrame- oid: The item ID (text).
DataFrame- type: object_type.
DataFrame- start / end: The visit, in UTC (naive input is read as UTC).
DataFrame- duration_seconds
DataFrame- uuid: The cell's ID signal (id_uuid).
DataFrame- source_uuid: The cell's ID signal (id_uuid).
DataFrame- station: The station name (parallel cells share it); the analysis functions use it as the station (to :func:~ts_shape.eventlog.relate it is an object attribute, recorded at each visit).
DataFrameOrdered by item, then start. No visit gives an empty frame with
DataFramethese columns.