Skip to content

Commit

Permalink
Merge pull request #103 from sarchlab/engine_in_simulation
Browse files Browse the repository at this point in the history
Engine in simulation
  • Loading branch information
syifan committed May 23, 2024
2 parents 231c1ec + 8e3b648 commit 0fb6eec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sim/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions sim/ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 0fb6eec

Please sign in to comment.