Skip to content

History

pyrung.core.history

Historical SystemState storage for PLCRunner debug APIs.

LabeledSnapshot dataclass

Label metadata attached to one retained scan snapshot.

History

Stores retained scan snapshots with optional oldest-first eviction.

oldest_scan_id property

oldest_scan_id: int

Oldest retained scan id.

newest_scan_id property

newest_scan_id: int

Newest retained scan id.

at

at(scan_id: int) -> SystemState

Return snapshot for a retained scan id.

range

range(
    start_scan_id: int, end_scan_id: int
) -> list[SystemState]

Return retained snapshots where start <= scan_id < end.

latest

latest(n: int) -> list[SystemState]

Return up to the latest n retained snapshots (oldest -> newest).

find

find(label: str) -> SystemState | None

Return the most recent retained snapshot labeled label.

find_all

find_all(label: str) -> list[SystemState]

Return all retained snapshots labeled label (oldest -> newest).

find_labeled

find_labeled(label: str) -> LabeledSnapshot | None

Return the most recent labeled snapshot with attached metadata.

find_all_labeled

find_all_labeled(label: str) -> list[LabeledSnapshot]

Return all labeled snapshots with metadata (oldest -> newest).

contains

contains(scan_id: int) -> bool

Return True if scan id is currently retained.

at_or_before_timestamp

at_or_before_timestamp(
    timestamp: float,
) -> SystemState | None

Return newest retained snapshot with state.timestamp <= timestamp.