mokomoking2501/MoonECAT/runtime does not have a README file

    EoeEndpoint

    pub(open) trait EoeEndpoint {
    fn read_frame(Self) -> Bytes?
    fn write_frame(Self, Bytes) -> Bool
    fn is_up(Self) -> Bool
    }

    Trait for bidirectional Ethernet frame exchange at the host boundary.

    Implementors:
    • QueueEndpoint: in-process async queue (default, no OS dependency)
    • Future: TapEndpoint (Linux TAP/TUN via C FFI)
    • Future: WintunEndpoint (Windows Wintun via C FFI)

    RunProgressSink

    pub(open) trait RunProgressSink {
    fn emit(Self, RunProgress) -> Unit
    }

    RunProgressSink receives structured run-loop progress events.

    ConfigurationComparisonReport

    pub(all) struct ConfigurationComparisonReport {
    expected_source : ConfigurationSource
    actual_source : ConfigurationSource
    total_expected : Int
    total_found : Int
    differences : Array[ConfigurationDifference]
    all_ok : Bool
    } derive(Eq,
    Debug
    )

    ConfigurationDifference

    pub(all) enum ConfigurationDifference {
    Missing(position~ : Int)
    OptionalMissing(position~ : Int, group_id~ : UInt?)
    Extra(position~ : Int)
    StationAddressMismatch(position~ : Int, expected~ : UInt?, actual~ : UInt?)
    AliasAddressMismatch(position~ : Int, expected~ : UInt?, actual~ : UInt?)
    IdentityMismatch(position~ : Int, expected~ :
    SlaveIdentity
    ?, actual~ :
    SlaveIdentity
    ?)
    IdentificationMismatch(position~ : Int, expected~ : UInt?, actual~ : UInt?)
    ProcessDataSummaryMismatch(position~ : Int, expected~ : ConfigurationProcessDataSummary, actual~ : ConfigurationProcessDataSummary)
    } derive(Eq,
    Debug
    )

    ConfigurationMailboxProtocols

    pub(all) struct ConfigurationMailboxProtocols {
    aoe : Bool
    coe : Bool
    eoe : Bool
    foe : Bool
    soe : Bool
    voe : Bool
    } derive(Eq,
    Debug
    )

    ConfigurationModel

    pub(all) struct ConfigurationModel {
    source : ConfigurationSource
    total_slaves : Int
    slaves : Array[ConfigurationSlave]
    } derive(Eq,
    Debug
    )

    ConfigurationProcessDataSummary

    pub(all) struct ConfigurationProcessDataSummary {
    sync_manager_count : Int
    fmmu_count : Int
    rx_pdo_count : Int
    tx_pdo_count : Int
    mailbox_protocols : ConfigurationMailboxProtocols?
    dc_op_mode_count : Int
    dc_assign_activate_count : Int
    } derive(Eq,
    Debug
    )

    ConfigurationSlave

    pub(all) struct ConfigurationSlave {
    position : Int
    configured_address : UInt?
    alias_address : UInt?
    identity :
    SlaveIdentity
    ?
    identification : UInt?
    process_data_summary : ConfigurationProcessDataSummary?
    presence :
    SlavePresence

    } derive(Eq,
    Debug
    )

    ConfigurationSource

    pub(all) enum ConfigurationSource {
    OnlineScan
    OfflineConfig
    EniImport
    } derive(Eq,
    Debug
    )

    ConfigurationSurfaceSummary

    pub(all) struct ConfigurationSurfaceSummary {
    slave_count : Int
    station_addresses : Array[UInt]
    expected_source : ConfigurationSource?
    actual_source : ConfigurationSource?
    validation_grade : ValidateGrade?
    difference_count : Int
    } derive(Eq,
    Debug
    )

    DiagnosisSession

    pub(all) struct DiagnosisSession {
    original_state :
    EsmState

    observed_state :
    EsmState
    ?
    observed_error_flag : Bool?
    observed_status_code : UInt?
    mailbox_config :
    MailboxConfig

    }

    DiagnosisSession captures the state needed around a diagnosis run.

    DiagnosticCategory

    pub(all) enum DiagnosticCategory {
    AlStatus
    ErrorRegister
    DiagnosisHistory
    Topology
    Identity
    Configuration
    RuntimeMetrics
    StateTransition
    MonitorVerdict
    } derive(Eq,
    Debug
    )

    DiagnosticIssue

    pub(all) struct DiagnosticIssue {
    source : DiagnosticSourceLayer
    category : DiagnosticCategory
    level : DiagnosticLevel
    detail : String
    } derive(Eq,
    Debug
    )

    DiagnosticLevel

    pub(all) enum DiagnosticLevel {
    Block
    Degrade
    Info
    } derive(Eq,
    Debug
    )

    DiagnosticSourceLayer

    pub(all) enum DiagnosticSourceLayer {
    Registers
    Mailbox
    Topology
    Configuration
    RuntimeTelemetry
    StateTransition
    Monitor
    } derive(Eq,
    Debug
    )

    DiagnosticSurface

    pub(all) struct DiagnosticSurface {
    station_address : UInt?
    state_summary : StateSurfaceSummary
    configuration_summary : ConfigurationSurfaceSummary?
    error_register : Byte?
    diagnosis_counter : UInt?
    runtime_metrics : RuntimeMetricsSummary?
    issues : Array[DiagnosticIssue]
    overall_level : DiagnosticLevel
    monitor_verdicts : Array[MonitorResult]?
    overall_verdict : Verdict?
    topology_fingerprint : TopologyFingerprint?
    } derive(Eq,
    Debug
    )

    EoeEndpointFrame

    pub(all) struct EoeEndpointFrame {
    station : UInt
    data : Bytes
    } derive(Eq,
    Debug
    )

    A frame in the endpoint queue, tagged with the destination/source station.

    EoeReassemblyBuffer

    type EoeReassemblyBuffer derive(
    Debug
    )

    Reassembly buffer for one in-progress EoE frame from a single slave.

    EoeReceivedFrame

    pub(all) struct EoeReceivedFrame {
    station : UInt
    data : Bytes
    } derive(Eq,
    Debug
    )

    Received EoE frame delivered to the host.

    EoeRelay

    pub(all) struct EoeRelay {
    stats : EoeRelayStats
    active : Bool
    } derive(
    Debug
    )

    EoE Embedded Relay engine.

    Processes frames synchronously during the PDO cycle:
    1. Collects all reassembled RX frames from EoeSwitch
    2. Invokes rx_handler for each (application processes inline)
    3. Invokes tx_provider to get frames to send (application provides inline)
    4. Sends collected TX frames via EoeSwitch

    The handler/provider are plain functions, not trait objects, keeping the relay free of dynamic dispatch overhead on embedded targets.

    EoeRelay::format_text

    fn EoeRelay::format_text(self : EoeRelay) -> String

    Format relay status as human-readable text.

    EoeRelay::new

    fn EoeRelay::new() -> EoeRelay

    EoeRelay::relay_cycle

    fn[N :
    Nic
    ] EoeRelay::relay_cycle(self : EoeRelay, sw : EoeSwitch, nic : N, timeout :
    Duration
    , rx_handler : (EoeRelayFrame) -> Bool, tx_provider : () -> EoeRelayFrame?) -> (Int, Int)

    Execute one relay cycle synchronously.

    rx_handler: Called for each reassembled Ethernet frame received from an EoE slave. Returns true if the frame was accepted, false to drop.

    tx_provider: Called repeatedly to collect frames to send. Returns None when no more frames are available this cycle.

    Returns (rx_count, tx_count) processed this cycle.

    EoeRelay::set_active

    fn EoeRelay::set_active(self : EoeRelay, active : Bool) -> Unit

    Activate or deactivate the relay.

    EoeRelay::to_json

    fn EoeRelay::to_json(self : EoeRelay) -> Json

    Get full relay status as JSON.

    EoeRelayDirection

    pub(all) enum EoeRelayDirection {
    HostToSlave
    SlaveToHost
    } derive(Eq,
    Debug
    )

    Direction of an EoE relay frame.

    EoeRelayFrame

    pub(all) struct EoeRelayFrame {
    direction : EoeRelayDirection
    station : UInt
    data : Bytes
    } derive(Eq,
    Debug
    )

    Metadata for a relayed EoE frame.

    EoeRelayStats

    pub(all) struct EoeRelayStats {
    tx_relayed : Int64
    rx_relayed : Int64
    dropped : Int64
    } derive(Eq,
    Debug
    )

    Statistics for the embedded relay.

    EoeRelayStats::new

    EoeRelayStats::to_json

    fn EoeRelayStats::to_json(self : EoeRelayStats) -> Json

    Get relay statistics as JSON.

    EoeStationContext

    pub(all) struct EoeStationContext {
    station : UInt
    mb_config :
    MailboxConfig

    reassembly : Array[EoeReassemblyBuffer?]
    tx_frame_number : UInt
    mb_counter : Byte
    } derive(
    Debug
    )

    Per-station EoE context: tracks reassembly state and send counter.

    EoeSwitch

    pub(all) struct EoeSwitch {
    stations : Array[EoeStationContext]
    rx_queue : Array[EoeReceivedFrame]
    tx_fragments : Int64
    rx_fragments : Int64
    rx_frames_complete : Int64
    rx_errors : Int64
    } derive(
    Debug
    )

    EoE Virtual Switch state.

    EoeSwitch::add_station

    fn EoeSwitch::add_station(self : EoeSwitch, station : UInt, mb_config :
    MailboxConfig
    ) -> Unit

    Register an EoE-capable station.

    EoeSwitch::drain_rx

    fn EoeSwitch::drain_rx(self : EoeSwitch) -> Array[EoeReceivedFrame]

    Drain all completed frames from the receive queue.

    EoeSwitch::format_text

    fn EoeSwitch::format_text(self : EoeSwitch) -> String

    Format EoE switch status as human-readable text.

    EoeSwitch::get_ip

    Send a Get IP parameters request to an EoE station.

    EoeSwitch::new

    fn EoeSwitch::new() -> EoeSwitch

    EoeSwitch::poll

    Poll all registered EoE stations for incoming mailbox data. Returns the number of complete Ethernet frames reassembled this cycle.

    EoeSwitch::process_received

    fn EoeSwitch::process_received(self : EoeSwitch, station : UInt, frame : Bytes) -> Bool

    Process a received raw mailbox frame as an EoE response. If a complete Ethernet frame is reassembled, it is placed in the rx_queue. Returns true if a complete frame was produced.

    EoeSwitch::send_frame

    fn[N :
    Nic
    ] EoeSwitch::send_frame(self : EoeSwitch, nic : N, station : UInt, eth_frame : Bytes, timeout :
    Duration
    ) -> Int raise
    EcError

    Fragment and send an Ethernet frame to a specific EoE station. Returns the number of fragments sent.

    EoeSwitch::set_ip

    Send a Set IP parameters request to an EoE station.

    EoeSwitch::to_json

    fn EoeSwitch::to_json(self : EoeSwitch) -> Json

    Get EoE switch telemetry as JSON.

    EsiJsonDcMode

    pub(all) struct EsiJsonDcMode {
    name : String
    description : String
    assign_activate : UInt
    cycle_time_sync0 : UInt
    sync0_factor : Int
    sync1_factor : Int
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonDevice

    pub(all) struct EsiJsonDevice {
    vendor_id : UInt
    product_code : UInt
    revision : UInt
    serial : UInt
    physics : String
    device_name : String
    type_name : String
    profile_no : UInt?
    slot_index_increment : UInt
    slot_pdo_increment : UInt
    mailbox : EsiJsonMailbox
    fmmu : Array[String]
    sync_managers : Array[EsiJsonSmEntry]
    dc_modes : Array[EsiJsonDcMode]
    eeprom_byte_size : UInt
    config_data : Bytes
    bootstrap : Bytes
    default_modules : Array[EsiJsonSelectedModule]
    init_commands : Array[EsiJsonInitCommand]
    rx_pdos : Array[EsiJsonPdo]
    tx_pdos : Array[EsiJsonPdo]
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonDocument

    pub(all) struct EsiJsonDocument {
    devices : Array[EsiJsonDevice]
    modules : Array[EsiJsonModule]
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonInitCommand

    pub(all) struct EsiJsonInitCommand {
    transition : String
    index : UInt
    subindex : Byte
    data : Bytes
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonMailbox

    pub(all) struct EsiJsonMailbox {
    data_link_layer : Bool
    aoe : Bool
    coe_present : Bool
    coe_sdo_info : Bool
    coe_pdo_assign : Bool
    coe_pdo_config : Bool
    coe_complete_access : Bool
    eoe : Bool
    foe : Bool
    soe : Bool
    voe : Bool
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonModule

    pub(all) struct EsiJsonModule {
    module_ident : UInt
    module_name : String
    rx_pdos : Array[EsiJsonPdo]
    tx_pdos : Array[EsiJsonPdo]
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonPdo

    pub(all) struct EsiJsonPdo {
    direction : String
    base_index : UInt
    depend_on_slot_pdo : Bool
    sync_manager : Byte
    name : String
    entries : Array[EsiJsonPdoEntry]
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonPdoEntry

    pub(all) struct EsiJsonPdoEntry {
    base_index : UInt
    depend_on_slot_index : Bool
    subindex : Byte
    bit_length : Byte
    name : String
    data_type_name : String
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonSelectedModule

    pub(all) struct EsiJsonSelectedModule {
    module_ident : UInt
    slot_index : Int
    } derive(Eq, ToJson,
    Debug
    )

    EsiJsonSmEntry

    pub(all) struct EsiJsonSmEntry {
    physical_start : UInt
    length : UInt
    control : Byte
    status : Byte
    enable : Bool
    sm_type : String
    } derive(Eq, ToJson,
    Debug
    )

    MailboxSession

    MailboxSession captures generic mailbox preparation state for one slave.

    MasterIdentity

    pub(all) struct MasterIdentity {
    vendor_id : UInt
    product_code : UInt
    revision : UInt
    serial : UInt
    } derive(Eq,
    Debug
    )

    Identity used when building the master's own 0x1018.

    MasterObjectDictionary

    pub(all) struct MasterObjectDictionary {
    entries : Array[MasterOdEntry]
    } derive(Eq,
    Debug
    )

    The master object dictionary: a flat list of entries.

    MasterObjectDictionary::entries_at

    fn MasterObjectDictionary::entries_at(self : MasterObjectDictionary, index : UInt) -> Array[MasterOdEntry]

    Get all entries for a given index.

    MasterObjectDictionary::format_text

    fn MasterObjectDictionary::format_text(self : MasterObjectDictionary) -> String

    Format the full OD as a human-readable text table.

    MasterObjectDictionary::indices

    List all unique indices in the dictionary.

    MasterObjectDictionary::lookup

    fn MasterObjectDictionary::lookup(self : MasterObjectDictionary, index : UInt, subindex : Byte) -> MasterOdEntry?

    Lookup a single entry by index and subindex.

    MasterObjectDictionary::to_json

    Serialize the full OD to JSON.

    MasterOdAccess

    pub(all) enum MasterOdAccess {
    ReadOnly
    ReadWrite
    } derive(Eq,
    Debug
    )

    Access mode for an OD entry.

    MasterOdDataType

    pub(all) enum MasterOdDataType {
    Unsigned8
    Unsigned16
    Unsigned32
    Integer32
    VisibleString
    OctetString
    } derive(Eq,
    Debug
    )

    Standard data types for OD entries (CiA-301 subset).

    MasterOdEntry

    pub(all) struct MasterOdEntry {
    index : UInt
    subindex : Byte
    name : String
    data_type : MasterOdDataType
    access : MasterOdAccess
    value : MasterOdValue
    } derive(Eq,
    Debug
    )

    One entry in the master object dictionary.

    MasterOdValue

    pub(all) enum MasterOdValue {
    U8(Byte)
    U16(UInt)
    U32(UInt)
    I32(Int)
    Str(String)
    Raw(Bytes)
    } derive(Eq,
    Debug
    )

    Value stored (or computed) for an OD entry.

    MasterOdValue::format

    fn MasterOdValue::format(self : MasterOdValue) -> String

    Format an OD value as a human-readable string.

    MonitorFn

    pub(all) struct MonitorFn {
    run : (Runtime) -> MonitorResult
    }

    MonitorFn — the function signature for a runtime monitor. Each monitor takes a Runtime snapshot and returns a MonitorResult.

    MonitorRegistry

    pub(all) struct MonitorRegistry {
    monitors : Array[(String, MonitorFn)]
    }

    MonitorRegistry manages a composable set of monitors. Both built-in and user-defined monitors are registered uniformly.

    MonitorRegistry::len

    fn MonitorRegistry::len(self : MonitorRegistry) -> Int

    Count of registered monitors.

    MonitorRegistry::new

    MonitorRegistry::register

    fn MonitorRegistry::register(self : MonitorRegistry, name : String, f : MonitorFn) -> Unit

    Register a named monitor function.

    MonitorRegistry::run

    Run all registered monitors and return results with aggregate worst verdict.

    MonitorRegistry::unregister

    fn MonitorRegistry::unregister(self : MonitorRegistry, name : String) -> Unit

    Remove a monitor by name (for overriding defaults).

    MonitorRegistry::with_defaults

    fn MonitorRegistry::with_defaults() -> MonitorRegistry

    Create a registry pre-loaded with all built-in monitors.

    MonitorResult

    pub(all) struct MonitorResult {
    name : String
    verdict : Verdict
    } derive(Eq,
    Debug
    )

    MonitorResult binds a named monitor to its verdict.

    NullRunProgressSink

    pub struct NullRunProgressSink {
    _unused : Unit
    }

    Default no-op sink for library callers that do not need progress events.

    NullRunProgressSink::new

    ObservedSlaveAddress

    pub(all) struct ObservedSlaveAddress {
    position : UInt
    current_station_address : UInt
    } derive(Eq,
    Debug
    )

    OperationalStartupStep

    type OperationalStartupStep derive(Eq,
    Debug
    )

    QueueEndpoint

    pub(all) struct QueueEndpoint {
    tx_pending : Array[EoeEndpointFrame]
    rx_pending : Array[EoeEndpointFrame]
    max_depth : Int
    up : Bool
    } derive(
    Debug
    )

    Queue-based EoE endpoint for in-process async bridging.

    The host application pushes frames into tx_pending (host→slave direction) and reads frames from rx_pending (slave→host direction). The bridge cycle transfers frames between these queues and the EoeSwitch.

    This endpoint requires no OS network stack — suitable for user-space applications, unit tests, and embedded systems with application-level networking.

    QueueEndpoint::consume_rx

    fn QueueEndpoint::consume_rx(self : QueueEndpoint) -> EoeEndpointFrame?

    Consume the next received frame from the slave→host queue. Returns None if no frames are available.

    QueueEndpoint::is_up

    fn QueueEndpoint::is_up(self : QueueEndpoint) -> Bool

    QueueEndpoint::new

    fn QueueEndpoint::new(max_depth? : Int) -> QueueEndpoint

    QueueEndpoint::read_frame

    fn QueueEndpoint::read_frame(self : QueueEndpoint) -> Bytes?

    EoeEndpoint implementation for QueueEndpoint.

    QueueEndpoint::rx_depth

    fn QueueEndpoint::rx_depth(self : QueueEndpoint) -> Int

    Number of frames received from slaves, waiting for host consumption.

    QueueEndpoint::set_up

    fn QueueEndpoint::set_up(self : QueueEndpoint, up : Bool) -> Unit

    Set endpoint up/down state.

    QueueEndpoint::submit_tx

    fn QueueEndpoint::submit_tx(self : QueueEndpoint, station : UInt, data : Bytes) -> Bool

    Submit a frame for sending to an EoE slave (host→slave direction). Returns false if the queue is full or endpoint is down.

    QueueEndpoint::to_json

    fn QueueEndpoint::to_json(self : QueueEndpoint) -> Json

    Get endpoint status as JSON.

    QueueEndpoint::tx_depth

    fn QueueEndpoint::tx_depth(self : QueueEndpoint) -> Int

    Number of frames waiting to be sent to slaves.

    QueueEndpoint::write_frame

    fn QueueEndpoint::write_frame(self : QueueEndpoint, data : Bytes) -> Bool

    ReportEntry

    pub(all) struct ReportEntry {
    cycle : Int64
    timestamp_ns : Int64
    event_type : String
    detail : String
    verdict : Verdict
    } derive(
    Debug
    )

    ReportEntry records a single event on the verdict timeline.

    RunFault

    pub(all) enum RunFault {
    StartupTransitionFailed(station~ : UInt, target~ :
    EsmState
    , current~ :
    EsmState
    ?, error_indication~ : Bool?, status_code~ : UInt?, raw_status_code~ : UInt?, control_wkc~ : UInt?)
    TimeoutRecoveryRequired(observed_timeouts~ : Int64, consecutive_timeouts~ : Int)
    RuntimeRecoveryRequired(expected_wkc~ : UInt, observed_wkc_errors~ : Int64)
    DcDrift(delta_ns~ : Int64)
    } derive(Eq,
    Debug
    )

    RunLoopSettings

    pub(all) struct RunLoopSettings {
    cycles : Int
    until_fault : Bool
    cycle_period_ns : Int64?
    output_period_ns : Int64?
    max_consecutive_timeouts : Int
    } derive(Eq,
    Debug
    )

    RunLoopSettings controls runtime loop behavior beyond startup/shutdown state sequencing.

    RunLoopSettings::fixed_cycles

    fn RunLoopSettings::fixed_cycles(cycles : Int) -> RunLoopSettings

    RunLoopSettings::until_fault

    fn RunLoopSettings::until_fault() -> RunLoopSettings

    RunMode

    pub(all) enum RunMode {
    FreeRun
    DcSync
    } derive(Eq,
    Debug
    )

    RunMode controls how the cyclic loop synchronizes.

    RunPhase

    pub(all) enum RunPhase {
    Scanning
    Validating
    Configuring
    Operational
    Stopping
    Done
    } derive(Eq,
    Debug
    )

    RunPhase describes which phase the run command is in.

    RunProgress

    pub(all) struct RunProgress {
    cycles_completed : Int64
    cycles_ok : Int
    cycles_requested : Int?
    until_fault : Bool
    cycle_period_ns : Int64
    output_period_ns : Int
    telemetry : Telemetry
    consecutive_timeouts : Int
    } derive(
    Debug
    )

    Structured run-loop progress snapshot emitted during long-running execution.

    RunReport

    pub(all) struct RunReport {
    scan : ScanReport
    validation : ValidateReport
    cycles_requested : Int
    cycles_ok : Int
    until_fault : Bool
    cycle_period_ns : Int64
    output_period_ns : Int64?
    telemetry : Telemetry
    final_phase : RunPhase
    fault : RunFault?
    } derive(
    Debug
    )

    RunReport summarizes the outcome of a full run cycle.

    RunReport::format

    fn RunReport::format(self : RunReport) -> String

    Format a RunReport as a human-readable summary.

    RunStartupPreparation

    pub(all) struct RunStartupPreparation {
    pdo_ctx :
    PdoContext

    expected_wkc : UInt
    dc_cycle_period_ns : Int64?
    startup_mailbox_plans : Array[StationStartupMailboxPlan]
    esm_timeout_policies : Array[(UInt,
    EsmTimeoutPolicy
    )]
    slave_preparations : Array[(UInt, SlaveStartupPreparation)]?
    }

    Runtime

    pub(all) struct Runtime {
    state : RuntimeState
    telemetry : Telemetry
    config :
    MasterConfig

    pdo_ctx :
    PdoContext
    ?
    expected_wkc : UInt
    max_wkc_errors : Int
    consecutive_wkc_errors : Int
    max_consecutive_timeouts : Int
    consecutive_timeouts : Int
    dc_state :
    DcState

    dc_reference_station : UInt?
    dc_stations : Array[UInt]
    dc_cycle_counter : Int
    emergency_stations : Array[(UInt,
    MailboxConfig
    )]
    eoe_switch : EoeSwitch
    } derive(
    Debug
    )

    Runtime orchestrator: manages the full lifecycle from scan to cyclic PDO.

    Runtime::configure_emergency_stations

    fn Runtime::configure_emergency_stations(self : Runtime, stations : Array[(UInt,
    MailboxConfig
    )]) -> Unit

    Configure stations eligible for Emergency mailbox polling during PDO cycles.

    Runtime::configure_pdo

    fn Runtime::configure_pdo(self : Runtime, ctx :
    PdoContext
    , expected_wkc : UInt) -> Unit

    Set the PDO context and expected WKC for cyclic operation.

    Runtime::get_telemetry

    fn Runtime::get_telemetry(self : Runtime) -> Telemetry

    Get a snapshot of the current telemetry.

    Runtime::init_dc

    Initialize distributed clocks for the configured station list. Returns true when DC was initialized and locked.

    Runtime::needs_recovery

    fn Runtime::needs_recovery(self : Runtime) -> Bool

    Check if the runtime needs recovery due to excessive WKC errors.

    Runtime::record_retry

    fn Runtime::record_retry(self : Runtime) -> Unit

    Record a retry event in telemetry.

    Runtime::record_timeout

    fn Runtime::record_timeout(self : Runtime) -> Unit

    Record a timeout event in telemetry.

    Runtime::reset_error_counter

    fn Runtime::reset_error_counter(self : Runtime) -> Unit

    Reset the WKC error counter after recovery.

    Runtime::run_cycle

    Execute one PDO cycle in the runtime loop. Updates telemetry and tracks consecutive errors.

    Runtime::run_cycles

    Run N PDO cycles. Returns the number of successful cycles.

    Runtime::run_cycles_with_reporting

    fn[N :
    Nic
    ] Runtime::run_cycles_with_reporting(self : Runtime, nic : N, count : Int, timeout :
    Duration
    , progress_every_cycles : Int?) -> Int raise
    EcError

    Run N PDO cycles and optionally emit progress snapshots.

    Runtime::run_cycles_with_reporting_to

    fn[N :
    Nic
    , S : RunProgressSink] Runtime::run_cycles_with_reporting_to(self : Runtime, nic : N, count : Int, timeout :
    Duration
    , progress_every_cycles : Int?, output_period_ns : Int?, sink : S) -> Int raise
    EcError

    Run N PDO cycles and emit structured progress snapshots to the provided sink.

    Runtime::run_until_fault

    Run PDO cycles until a runtime recovery condition occurs.

    Runtime::run_until_fault_with_reporting

    fn[N :
    Nic
    ] Runtime::run_until_fault_with_reporting(self : Runtime, nic : N, timeout :
    Duration
    , progress_every_cycles : Int?) -> Int raise
    EcError

    Run PDO cycles until a runtime recovery condition occurs and optionally emit progress snapshots.

    Runtime::run_until_fault_with_reporting_to

    fn[N :
    Nic
    , S : RunProgressSink] Runtime::run_until_fault_with_reporting_to(self : Runtime, nic : N, timeout :
    Duration
    , progress_every_cycles : Int?, output_period_ns : Int?, sink : S) -> Int raise
    EcError

    Run PDO cycles until a runtime recovery condition occurs and emit structured progress snapshots to the provided sink.

    Runtime::set_state

    fn Runtime::set_state(self : Runtime, new_state : RuntimeState) -> Unit

    Transition the runtime state machine.

    Runtime::set_timeout_threshold

    fn Runtime::set_timeout_threshold(self : Runtime, threshold : Int) -> Unit

    Configure the threshold for consecutive receive timeouts.

    RuntimeMetricsSummary

    pub(all) struct RuntimeMetricsSummary {
    cycles : Int64
    tx_frames : Int64
    rx_frames : Int64
    timeouts : Int64
    retries : Int64
    wkc_errors : Int64
    irq_events : Int64
    dc_delay_updates : Int64
    emergency_events : Int64
    } derive(Eq,
    Debug
    )

    RuntimeState

    pub(all) enum RuntimeState {
    Idle
    Scanning
    Configuring
    Running(RunMode)
    Stopping
    Error(
    EcError
    )
    } derive(
    Debug
    )

    RuntimeState tracks the overall master state.

    ScanReport

    pub(all) struct ScanReport {
    slave_count : Int
    slaves : Array[SlaveReport]
    } derive(Eq,
    Debug
    )

    ScanReport holds the results of a bus scan.

    ScanReport::format

    fn ScanReport::format(self : ScanReport) -> String

    Format a ScanReport as a human-readable string.

    ScanStationAddressStrategy

    pub(all) enum ScanStationAddressStrategy {
    PreserveExistingUniqueNonZero
    TwinCATCompatible
    } derive(Eq,
    Debug
    )

    SlaveDiagnosis

    pub(all) struct SlaveDiagnosis {
    station_address : UInt
    al_state :
    EsmState
    ?
    al_error_flag : Bool?
    al_status_code : UInt?
    error_register : Byte
    diagnosis_counter : UInt?
    dl_error_counters :
    DlErrorCounters
    ?
    } derive(Eq,
    Debug
    )

    SlaveDiagnosis aggregates a minimal diagnosis snapshot for one slave.

    SlaveReport

    pub(all) struct SlaveReport {
    position : Int
    station_address : UInt
    alias_address : UInt?
    vendor_id : UInt
    product_code : UInt
    revision : UInt
    serial : UInt
    identification : UInt
    } derive(Eq,
    Debug
    )

    SlaveReport holds info for one discovered slave.

    SlaveStartupPreparation

    pub(all) struct SlaveStartupPreparation {
    mapping :
    SlaveMapping

    dc_cycle_period_ns : Int64?
    startup_outputs : Bytes?
    startup_mailbox_commands : Array[StartupMailboxCommand]
    mailbox_config :
    MailboxConfig

    sii :
    SiiFullInfo

    sii_categories : Array[
    SiiCategoryEntry
    ]
    prefer_live_pdo_state : Bool
    }

    SmWatchdogValidation

    pub(all) struct SmWatchdogValidation {
    station : UInt
    config :
    SmWatchdogConfig

    watchdog_active : Bool
    } derive(Eq,
    Debug
    )

    SM Watchdog validation result for a single station.

    StartupCommandTransition

    pub(all) enum StartupCommandTransition {
    InitToPreOp
    InitToBoot
    PreOpToInit
    PreOpToSafeOp
    SafeOpToInit
    SafeOpToPreOp
    SafeOpToOp
    OpToInit
    OpToPreOp
    OpToSafeOp
    BootToInit
    } derive(Eq,
    Debug
    )

    StartupMailboxCommand

    pub(all) struct StartupMailboxCommand {
    transition : StartupCommandTransition
    index : UInt
    subindex : Byte
    data : Bytes
    } derive(Eq,
    Debug
    )

    StartupRecoveryStrategy

    type StartupRecoveryStrategy derive(Eq,
    Debug
    )

    StateSurfaceSummary

    pub(all) struct StateSurfaceSummary {
    target_state :
    EsmState
    ?
    current_state :
    EsmState
    ?
    final_state :
    EsmState
    ?
    al_state :
    EsmState
    ?
    al_error_flag : Bool?
    al_status_code : UInt?
    wkc : UInt?
    } derive(Eq,
    Debug
    )

    StationStartupMailboxPlan

    pub(all) struct StationStartupMailboxPlan {
    station : UInt
    mailbox_config :
    MailboxConfig

    commands : Array[StartupMailboxCommand]
    } derive(Eq,
    Debug
    )

    Telemetry

    pub(all) struct Telemetry {
    cycles : Int64
    tx_frames : Int64
    rx_frames : Int64
    timeouts : Int64
    retries : Int64
    wkc_errors : Int64
    irq_events : Int64
    dc_delay_updates : Int64
    emergency_events : Int64
    } derive(Eq,
    Debug
    )

    Telemetry holds runtime diagnostic counters.

    Telemetry::new

    fn Telemetry::new() -> Telemetry

    Telemetry::reset

    fn Telemetry::reset(self : Telemetry) -> Unit

    TopologyFingerprint

    pub(all) struct TopologyFingerprint {
    slave_count : Int
    identity_hash : Int64
    } derive(Eq,
    Debug
    )

    TopologyFingerprint captures the essential topology identity as a compact, comparable value. Two fingerprints are equal iff the slave count and ordered identity sequence match exactly.

    TopologyFingerprintMatch

    pub(all) enum TopologyFingerprintMatch {
    Identical
    SlaveCountChanged(expected~ : Int, actual~ : Int)
    IdentityChanged
    } derive(Eq,
    Debug
    )

    TopologyFingerprintMatch describes how two fingerprints differ.

    ValidateDifferenceCategory

    pub(all) enum ValidateDifferenceCategory {
    Topology
    Identity
    Configuration
    Informational
    } derive(Eq,
    Debug
    )

    ValidateGrade

    pub(all) enum ValidateGrade {
    Pass
    Warn
    Block
    } derive(Eq,
    Debug
    )

    ValidateReport

    pub(all) struct ValidateReport {
    expected_source : ConfigurationSource
    actual_source : ConfigurationSource
    total_expected : Int
    total_found : Int
    results : Array[ValidationResult]
    differences : Array[ConfigurationDifference]
    all_ok : Bool
    grade : ValidateGrade
    } derive(
    Debug
    )

    ValidateReport holds the full validation result.

    ValidateReport::format

    fn ValidateReport::format(self : ValidateReport) -> String

    Format a ValidateReport as a human-readable string.

    ValidationResult

    pub(all) enum ValidationResult {
    Ok
    StationAddressMismatch(position~ : Int, expected~ : UInt, actual~ : UInt)
    AliasAddressMismatch(position~ : Int, expected~ : UInt, actual~ : UInt)
    IdentityMismatch(expected~ :
    SlaveIdentity
    , actual~ :
    SlaveIdentity
    )
    IdentificationMismatch(position~ : Int, expected~ : UInt, actual~ : UInt)
    ProcessDataMismatch(position~ : Int)
    Missing(position~ : Int)
    OptionalMissing(position~ : Int, group_id~ : UInt?)
    Extra(position~ : Int)
    } derive(
    Debug
    )

    ValidationResult describes the outcome of one slave check.

    Verdict

    pub(all) enum Verdict {
    Pass
    Warn(String)
    Fail(String)
    Block(String)
    } derive(Eq,
    Debug
    )

    Verdict represents the outcome severity of a runtime monitor check. Mirrors ETG diagnostic severity model.

    Verdict::is_passing

    fn Verdict::is_passing(self : Verdict) -> Bool

    Verdict::severity

    fn Verdict::severity(self : Verdict) -> Int

    VerificationReport

    pub(all) struct VerificationReport {
    title : String
    summary_verdict : Verdict
    total_cycles : Int64
    duration_ns : Int64
    monitor_results : Array[MonitorResult]
    timeline : Array[ReportEntry]
    fault_injections : Array[String]
    metadata : Array[(String, String)]
    } derive(
    Debug
    )

    VerificationReport collects all data needed to render a final report.

    VerificationReport::add_event

    fn VerificationReport::add_event(self : VerificationReport, cycle : Int64, event_type : String, detail : String, verdict : Verdict) -> Unit

    Add a timeline entry.

    VerificationReport::add_fault

    fn VerificationReport::add_fault(self : VerificationReport, description : String) -> Unit

    Add a fault injection annotation.

    VerificationReport::add_meta

    fn VerificationReport::add_meta(self : VerificationReport, key : String, value : String) -> Unit

    Add metadata key-value pair.

    VerificationReport::new

    fn VerificationReport::new(title : String) -> VerificationReport

    VerificationReport::to_json

    fn VerificationReport::to_json(self : VerificationReport) -> String

    Render the report as JSON text.

    VerificationReport::to_markdown

    fn VerificationReport::to_markdown(self : VerificationReport) -> String

    Render the report as Markdown text.

    apply_presafeop_startup_mailbox_commands

    apply_safeop_startup_mailbox_commands

    apply_startup_mailbox_commands

    bridge_eoe_cycle

    fn[N :
    Nic
    ] bridge_eoe_cycle(sw : EoeSwitch, ep : QueueEndpoint, nic : N, timeout :
    Duration
    ) -> (Int, Int)

    Bridge one cycle between EoeSwitch and QueueEndpoint.

    TX direction (host→slave): Drains tx_pending, fragments and sends each frame to its target EoE station via the switch.

    RX direction (slave→host): Drains the switch rx_queue and pushes reassembled frames into rx_pending for host consumption.

    Returns (tx_sent, rx_delivered) counts.

    build_master_od

    fn build_master_od(identity : MasterIdentity, scan : ScanReport?, telemetry : Telemetry?, surface : DiagnosticSurface?) -> MasterObjectDictionary

    Build the full master OD from current runtime state.

    build_run_startup_preparation

    fn[N :
    Nic
    ] build_run_startup_preparation(nic : N, scan_report : ScanReport, logical_base : UInt, eeprom_word_count : Int, timeout :
    Duration
    ) -> RunStartupPreparation raise
    EcError

    compare_configurations

    fn compare_configurations(expected : ConfigurationModel, actual : ConfigurationModel) -> ConfigurationComparisonReport

    configuration_from_eni_json

    fn configuration_from_eni_json(json_content : String) -> ConfigurationModel raise
    EcError

    Parse ENI JSON interchange and project slave info into the unified configuration model.

    configuration_from_expected

    configuration_from_scan

    fn configuration_from_scan(scan_report : ScanReport) -> ConfigurationModel

    configuration_to_eni_json

    fn configuration_to_eni_json(model : ConfigurationModel) -> Json

    configuration_to_eni_json_string

    fn configuration_to_eni_json_string(model : ConfigurationModel, indent? : Int) -> String

    dc_cycle_period_ns

    fn dc_cycle_period_ns(clock :
    SiiDcClock
    ) -> Int64?

    default_master_identity

    fn default_master_identity() -> MasterIdentity

    diagnosis_restore_path

    Build the diagnosis-specific restore path from PreOp back to the target state.

    diagnostic_surface_from_run

    fn diagnostic_surface_from_run(report : RunReport) -> DiagnosticSurface

    diagnostic_surface_from_slave_diagnosis

    fn diagnostic_surface_from_slave_diagnosis(scan : ScanReport, report : SlaveDiagnosis) -> DiagnosticSurface

    diagnostic_surface_from_state_transition

    fn diagnostic_surface_from_state_transition(station : UInt?, target :
    EsmState
    , current :
    EsmState
    ?, final_state :
    EsmState
    ?, al_error_flag : Bool?, status_code : UInt?, wkc : UInt?) -> DiagnosticSurface

    diagnostic_surface_from_validate

    fn diagnostic_surface_from_validate(scan : ScanReport, report : ValidateReport) -> DiagnosticSurface

    enrich_surface_with_fingerprint

    fn enrich_surface_with_fingerprint(surface : DiagnosticSurface, fingerprint : TopologyFingerprint) -> DiagnosticSurface

    Enrich an existing DiagnosticSurface with a topology fingerprint.

    enrich_surface_with_monitors

    fn enrich_surface_with_monitors(surface : DiagnosticSurface, results : Array[MonitorResult], verdict : Verdict) -> DiagnosticSurface

    Enrich an existing DiagnosticSurface with monitor verdicts. Monitor-originated issues are appended to the issue list and the overall level is recomputed.

    eoe_max_fragment_size

    fn eoe_max_fragment_size(mb_config :
    MailboxConfig
    ) -> Int

    Calculate the maximum fragment data size for a given mailbox config. Follows SOEM convention: (mailbox_out_size - overhead) rounded down to 32-byte boundary.

    esi_json_to_string

    fn esi_json_to_string(document : EsiJsonDocument, indent? : Int) -> String

    fingerprint_match

    fn fingerprint_match(expected : TopologyFingerprint, actual : TopologyFingerprint) -> TopologyFingerprintMatch

    Compare two topology fingerprints.

    master_config_with_optional_dc

    fn master_config_with_optional_dc(dc_cycle_period_ns : Int64?) ->
    MasterConfig

    monitor_consecutive_timeouts

    fn monitor_consecutive_timeouts(rt : Runtime) -> MonitorResult

    Monitor: consecutive timeout threshold. Emits Fail when consecutive_timeouts >= max, Warn when > 0.

    monitor_cycle_success_rate

    fn monitor_cycle_success_rate(rt : Runtime, min_success_ratio_pct : Int) -> MonitorResult

    Monitor: cycle success rate. Emits Fail when wkc_errors / cycles exceeds threshold.

    monitor_dc_drift

    fn monitor_dc_drift(rt : Runtime) -> MonitorResult

    Monitor: DC drift detection. Emits Fail when dc_state is Drifting.

    monitor_pdo_configured

    fn monitor_pdo_configured(rt : Runtime) -> MonitorResult

    Monitor: PDO configuration readiness. Emits Block when PDO context is not configured, Warn when expected_wkc is zero.

    monitor_result_to_issue

    fn monitor_result_to_issue(r : MonitorResult) -> DiagnosticIssue?

    Convert a non-Pass MonitorResult into a DiagnosticIssue. Returns None for Pass verdicts.

    monitor_startup_state

    fn monitor_startup_state(rt : Runtime) -> MonitorResult

    Monitor: startup state verification. Emits Block when runtime is in Error state, Warn when not Running.

    monitor_wkc_errors

    fn monitor_wkc_errors(rt : Runtime) -> MonitorResult

    Monitor: WKC error threshold. Emits Fail when consecutive_wkc_errors >= max, Warn when > 0.

    offline_sii_report_from_esi_document

    fn offline_sii_report_from_esi_document(document : EsiJsonDocument, device_index : Int) -> EsiOfflineSiiReport raise
    EcError

    offline_sii_report_from_esi_json

    fn offline_sii_report_from_esi_json(json_content : String, device_index : Int) -> EsiOfflineSiiReport raise
    EcError

    parse_error_register_payload

    fn parse_error_register_payload(payload : Bytes) -> Byte raise
    EcError

    Parse a one-byte error register payload.

    parse_esi_json_document

    fn parse_esi_json_document(json_content : String) -> EsiJsonDocument raise
    EcError

    parse_u32_payload

    fn parse_u32_payload(payload : Bytes) -> UInt raise
    EcError

    Parse a little-endian UInt32 payload.

    plan_scan_station_addresses_with_strategy

    fn plan_scan_station_addresses_with_strategy(observed : Array[ObservedSlaveAddress], strategy : ScanStationAddressStrategy) -> Array[UInt] raise
    EcError

    prepare_slave_diagnosis_ap

    fn[N :
    Nic
    ] prepare_slave_diagnosis_ap(nic : N, position : UInt, station : UInt, timeout :
    Duration
    ) -> DiagnosisSession raise
    EcError

    Prepare one slave for mailbox-based diagnosis via AP discovery and FP state control.

    This flow is intentionally diagnosis-specific: it normalizes the slave back to Init before entering PreOp so mailbox SM programming happens from a known base state.

    prepare_slave_mailbox_ap

    fn[N :
    Nic
    ] prepare_slave_mailbox_ap(nic : N, position : UInt, station : UInt, timeout :
    Duration
    ) -> MailboxSession raise
    EcError

    Prepare one slave for generic mailbox-based access via AP discovery and FP state control. Unlike diagnosis-specific helpers, this only returns the mailbox configuration and original state needed for restoring the slave after read-only mailbox operations.

    prepare_slave_startup

    fn[N :
    Nic
    ] prepare_slave_startup(nic : N, station : UInt, logical_base : UInt, eeprom_word_count : Int, timeout :
    Duration
    ) -> SlaveStartupPreparation raise
    EcError

    read_diagnosis_counter

    Read diagnosis object counter (0x10F3:0) from one slave. Some slaves may not implement this object; callers can handle errors.

    read_diagnosis_counter_ap

    Read diagnosis object counter (0x10F3:0) via AP mailbox transport.

    read_error_register

    Read Error Register (0x1001:0) from one slave.

    read_error_register_ap

    Read Error Register (0x1001:0) from one slave via AP mailbox transport.

    read_sii_with_metadata_ap

    fn[N :
    Nic
    ] read_sii_with_metadata_ap(nic : N, position : UInt, initial_word_count : Int, timeout :
    Duration
    ) -> Bytes raise
    EcError

    read_sii_with_metadata_fp

    fn[N :
    Nic
    ] read_sii_with_metadata_fp(nic : N, station : UInt, initial_word_count : Int, timeout :
    Duration
    ) -> Bytes raise
    EcError

    read_slave_diagnosis

    Read a diagnosis snapshot for one slave. If 0x10F3 is unavailable, the counter is returned as None.

    read_slave_diagnosis_ap

    Read a diagnosis snapshot for one slave via AP mailbox transport.

    refine_startup_preparation_in_preop

    fn[N :
    Nic
    ] refine_startup_preparation_in_preop(nic : N, station : UInt, logical_base : UInt, preparation : SlaveStartupPreparation, timeout :
    Duration
    ) -> SlaveStartupPreparation

    required_sii_read_word_count

    fn required_sii_read_word_count(initial_eeprom : Bytes, initial_word_count : Int) -> Int

    restore_slave_diagnosis_state

    Restore a slave after diagnosis using a legal path from PreOp back to the original state.

    restore_slave_mailbox_state

    Restore a slave after generic mailbox-based access using the legal path from PreOp back to the original state.

    run

    Execute a full EtherCAT run workflow:
    1. Scan the bus to discover slaves.
    2. Validate discovered slaves against expected configuration.
    3. Transition all slaves to Operational.
    4. Run PDO cycles.
    5. Transition slaves back to Init.
    6. Return a summary report.

    run_monitors

    fn run_monitors(rt : Runtime) -> (Array[MonitorResult], Verdict)

    Run all built-in monitors against the current runtime state. Returns individual results plus the aggregate worst verdict.

    run_startup_preparation_from_slave_preparations

    fn run_startup_preparation_from_slave_preparations(slave_preparations : Array[(UInt, SlaveStartupPreparation)], logical_base : UInt) -> RunStartupPreparation raise
    EcError

    run_with_scan_and_states_and_settings_prepared_reporting_to

    run_with_states_and_settings_prepared_reporting_to

    scan

    Run the scan procedure: count slaves, assign addresses, read identity from SII EEPROM registers. Returns a ScanReport summarizing what was found.

    scan_with_identification_ado

    fn[N :
    Nic
    ] scan_with_identification_ado(nic : N, timeout :
    Duration
    , identification_ado : UInt) -> ScanReport raise
    EcError

    Run the scan procedure with a configurable IdentificationAdo register.

    scan_with_identification_ado_and_station_address_strategy

    fn[N :
    Nic
    ] scan_with_identification_ado_and_station_address_strategy(nic : N, timeout :
    Duration
    , identification_ado : UInt, strategy : ScanStationAddressStrategy) -> ScanReport raise
    EcError

    startup_preparation_from_esi_json

    fn startup_preparation_from_esi_json(json_content : String, device_index : Int, logical_base : UInt) -> SlaveStartupPreparation raise
    EcError

    startup_preparation_from_esi_offline_report

    fn startup_preparation_from_esi_offline_report(report : EsiOfflineSiiReport, logical_base : UInt) -> SlaveStartupPreparation

    topology_fingerprint

    fn topology_fingerprint(scan : ScanReport) -> TopologyFingerprint

    Compute a topology fingerprint from a ScanReport.

    topology_fingerprint_from_config

    fn topology_fingerprint_from_config(config : ConfigurationModel) -> TopologyFingerprint

    Compute a topology fingerprint from a ConfigurationModel.

    validate

    Validate that scan results match expected slaves by position.

    validate_configuration

    fn validate_configuration(actual : ConfigurationModel, expected : ConfigurationModel) -> ValidateReport

    validation_difference_category

    fn validation_difference_category(difference : ConfigurationDifference) -> ValidateDifferenceCategory

    validation_difference_grade

    fn validation_difference_grade(difference : ConfigurationDifference) -> ValidateGrade

    verdict_to_diagnostic_level

    fn verdict_to_diagnostic_level(v : Verdict) -> DiagnosticLevel

    Convert a Verdict severity to a DiagnosticLevel.

    worst_verdict

    fn worst_verdict(results : Array[MonitorResult]) -> Verdict

    Compute the worst verdict from a set of monitor results.

    write_mailbox_mapping

    Write only mailbox SyncManager configuration derived from SII.

    write_process_data_mapping

    Write process-data SyncManager and FMMU configuration derived from SII. Call this only after mailbox configuration is accepted and the station is already in PreOp.