diff --git a/sim/simulation.go b/sim/simulation.go index 5e1ac8b..27b9006 100644 --- a/sim/simulation.go +++ b/sim/simulation.go @@ -2,6 +2,7 @@ package sim // A Simulation provides the service requires to define a simulation. type Simulation struct { + engine Engine components []Component compNameIndex map[string]int ports []Port @@ -16,6 +17,16 @@ func NewSimulation() *Simulation { } } +// RegisterEngine registers the engine used in the simulation. +func (s *Simulation) RegisterEngine(e Engine) { + s.engine = e +} + +// GetEngine returns the engine used in the simulation. +func (s *Simulation) GetEngine() Engine { + return s.engine +} + // RegisterComponent registers a component with the simulation. func (s *Simulation) RegisterComponent(c Component) { compName := c.Name() diff --git a/sim/ticker.go b/sim/ticker.go index 3595472..b2e7334 100644 --- a/sim/ticker.go +++ b/sim/ticker.go @@ -47,6 +47,7 @@ func NewTickScheduler( ticker.handler = handler ticker.Engine = engine ticker.Freq = freq + ticker.nextTickTime = -1 // This will make sure the first tick is scheduled return ticker } @@ -64,6 +65,7 @@ func NewSecondaryTickScheduler( ticker.Engine = engine ticker.Freq = freq ticker.secondary = true + ticker.nextTickTime = -1 // This will make sure the first tick is scheduled return ticker }