Hermes
Simulation Orchestration Platform for Aerospace
Loading...
Searching...
No Matches
hermes.core.scheduler.Scheduler Class Reference
Collaboration diagram for hermes.core.scheduler.Scheduler:

Public Member Functions

None __init__ (self, ProcessManager process_mgr, ExecutionConfig config)
int frame (self)
float time (self)
int time_ns (self)
float dt (self)
int dt_ns (self)
bool running (self)
bool paused (self)
ExecutionMode mode (self)
None stage (self)
None step (self, int count=1)
None reset (self)
None run (self, Callable[[int, float], Awaitable[None]]|None callback=None)
None pause (self)
None resume (self)
None stop (self)

Public Attributes

 time

Static Public Attributes

int NANOSECONDS_PER_SECOND = 1_000_000_000

Protected Attributes

 _pm = process_mgr
 _config = config
int _frame = 0
int _time_ns = 0
int _dt_ns = config.get_dt_ns()
bool _running = False
bool _paused = False
bool _needs_wall_rebase = False
WireRouter|None _router = None
dict _module_substeps = {}

Detailed Description

Runtime simulation scheduler.

Controls simulation execution with support for realtime, AFAP,
and single-frame modes. Coordinates with ProcessManager for
module stepping and provides pause/resume/stop control.

Example:
    >>> scheduler = Scheduler(process_mgr, config.execution)
    >>> scheduler.stage()
    >>> await scheduler.run(callback=my_telemetry_fn)

Constructor & Destructor Documentation

◆ __init__()

None hermes.core.scheduler.Scheduler.__init__ ( self,
ProcessManager process_mgr,
ExecutionConfig config )
Initialize the scheduler.

Args:
    process_mgr: ProcessManager for controlling modules
    config: Execution configuration (mode, rate, end_time)

Member Function Documentation

◆ dt()

float hermes.core.scheduler.Scheduler.dt ( self)
Timestep in seconds.

Derived from `dt_ns` for API convenience.

◆ dt_ns()

int hermes.core.scheduler.Scheduler.dt_ns ( self)
Timestep in nanoseconds.

This is the authoritative timestep value for deterministic simulations.

◆ frame()

int hermes.core.scheduler.Scheduler.frame ( self)
Current simulation frame number.

◆ mode()

ExecutionMode hermes.core.scheduler.Scheduler.mode ( self)
Current execution mode.

◆ pause()

None hermes.core.scheduler.Scheduler.pause ( self)
Pause the run loop.

The simulation will stop advancing but remain in the run loop.
Use resume() to continue.

◆ paused()

bool hermes.core.scheduler.Scheduler.paused ( self)
Whether the simulation is paused.

◆ reset()

None hermes.core.scheduler.Scheduler.reset ( self)
Reset simulation to initial state.

Resets frame/time counters, flags wall_start for rebasing so
realtime pacing resumes correctly, and resets all modules to
their initial conditions (restoring signal values).

◆ resume()

None hermes.core.scheduler.Scheduler.resume ( self)
Resume the run loop after pause.

◆ run()

None hermes.core.scheduler.Scheduler.run ( self,
Callable[[int, float], Awaitable[None]] | None callback = None )
Run simulation loop until stopped or end_time reached.

In realtime mode, paces execution to wall-clock time.
In AFAP mode, runs as fast as possible.
In single_frame mode, waits for explicit step() calls.

Args:
    callback: Optional async callback invoked after each frame
             with (frame_number, simulation_time_seconds)

◆ running()

bool hermes.core.scheduler.Scheduler.running ( self)
Whether the simulation run loop is active.

◆ stage()

None hermes.core.scheduler.Scheduler.stage ( self)
Stage simulation for execution.

Calls stage() on all modules via ProcessManager, configures
wire routing, and resets frame/time counters to zero.

◆ step()

None hermes.core.scheduler.Scheduler.step ( self,
int count = 1 )
Execute N major frames.

Each major frame routes wires, then steps each module according to
its configured rate (faster modules sub-step multiple times).

Args:
    count: Number of major frames to execute (default: 1)

Raises:
    ValueError: If count is not positive

◆ stop()

None hermes.core.scheduler.Scheduler.stop ( self)
Stop the run loop.

The simulation will exit the run() method cleanly.

◆ time()

float hermes.core.scheduler.Scheduler.time ( self)
Current simulation time in seconds.

This is derived from `time_ns` for API convenience.
For deterministic comparisons, use `time_ns` instead.

◆ time_ns()

int hermes.core.scheduler.Scheduler.time_ns ( self)
Current simulation time in nanoseconds.

This is the authoritative time value for deterministic simulations.
Use this for exact comparisons and reproducibility.

Member Data Documentation

◆ _config

hermes.core.scheduler.Scheduler._config = config
protected

◆ _dt_ns

int hermes.core.scheduler.Scheduler._dt_ns = config.get_dt_ns()
protected

◆ _frame

hermes.core.scheduler.Scheduler._frame = 0
protected

◆ _module_substeps

dict hermes.core.scheduler.Scheduler._module_substeps = {}
protected

◆ _needs_wall_rebase

bool hermes.core.scheduler.Scheduler._needs_wall_rebase = False
protected

◆ _paused

bool hermes.core.scheduler.Scheduler._paused = False
protected

◆ _pm

hermes.core.scheduler.Scheduler._pm = process_mgr
protected

◆ _router

WireRouter | None hermes.core.scheduler.Scheduler._router = None
protected

◆ _running

bool hermes.core.scheduler.Scheduler._running = False
protected

◆ _time_ns

hermes.core.scheduler.Scheduler._time_ns = 0
protected

◆ NANOSECONDS_PER_SECOND

int hermes.core.scheduler.Scheduler.NANOSECONDS_PER_SECOND = 1_000_000_000
static

◆ time

hermes.core.scheduler.Scheduler.time

The documentation for this class was generated from the following file: