mokomoking2501/MoonECAT/runtime/hil does not have a README file

    CycleHook

    CycleHook — the runtime calls these methods at each cycle boundary.

    Trait methods use Self (not &Self) following MoonBit trait convention. The runtime passes CycleSnapshot by value (16-24 bytes, stack-allocated).

    CycleDirective

    pub(all) enum CycleDirective {
    Continue
    SkipCycle
    StopGraceful
    } derive(Eq,
    Debug
    )

    CycleDirective tells the runtime what action to take after a hook returns.

    CycleResult

    pub(all) struct CycleResult {
    wkc : UInt
    expected_wkc : UInt
    ok : Bool
    } derive(Eq,
    Debug
    )

    CycleSnapshot

    pub(all) struct CycleSnapshot {
    cycle : Int64
    result : CycleResult?
    dc_state : DcState
    recovery_pending : Bool
    } derive(
    Debug
    )

    CycleSnapshot captures the minimal state exposed to hooks at each cycle boundary.

    DcState

    pub(all) enum DcState {
    Disabled
    Measuring
    Locked
    Drifting(Int64)
    } derive(
    Debug
    )

    HilCycleHook

    pub(all) struct HilCycleHook[A] {
    adapter : A
    session : HilSession
    }

    HilCycleHook — CycleHook implementation that drives a CoSimAdapter.

    Generic over A : @simulation.CoSimAdapter so the plant model is monomorphized into the hook → zero dispatch overhead in the PDO hot path.

    HilCycleHook::new

    fn[A] HilCycleHook::new(adapter : A, session : HilSession) -> HilCycleHook[A]

    HilSession

    pub(all) struct HilSession {
    sim_time :
    SimTime

    cycle_period_ns : Int64
    schedule :
    TaskSchedule

    step_log : Array[
    SimStepResult
    ]
    terminated : Bool
    termination_reason : String
    }

    HilSession holds the state for one HIL closed-loop run.

    HilSession::get_sim_time

    Get the current simulation time from the HIL session.

    HilSession::get_termination_reason

    fn HilSession::get_termination_reason(self : HilSession) -> String

    Get the termination reason.

    HilSession::is_terminated

    fn HilSession::is_terminated(self : HilSession) -> Bool

    Check if the HIL session has been terminated.

    HilSession::new

    HilSession::step_count

    fn HilSession::step_count(self : HilSession) -> Int

    Get the number of simulation steps completed.

    HilSessionSummary

    pub(all) struct HilSessionSummary {
    total_steps : Int
    ok_steps : Int
    error_steps : Int
    terminated : Bool
    termination_reason : String
    final_sim_time_ns : Int64
    } derive(
    Debug
    )

    Summary statistics extracted from a HilSession step log.

    NullCycleHook

    pub struct NullCycleHook {
    _unused : Unit
    }

    NullCycleHook — default no-op hook. Compiles to nothing in monomorphized code.

    NullCycleHook::new

    hil_session_summary

    fn hil_session_summary(session : HilSession) -> HilSessionSummary

    hil_session_to_json

    fn hil_session_to_json(session : HilSession) -> String

    Export a HilSession to a JSON trace string.