Menge
Modular Pedestrian Simulation Framework for Research and Development
|
Templated class for performing simulation. More...
#include <SimSystem.h>
Public Member Functions | |
SimSystem (bool visualize) | |
Constructor. More... | |
SimSystem (bool visualize, float duration) | |
Constructor with duration limit. More... | |
~SimSystem () | |
Destructor. | |
void | setMaxDuration (float duration) |
Sets the maximum length allowed for the simulation to run. More... | |
virtual bool | updateScene (float time) |
Update the simulation (and possibly visual elements) to the given global time. More... | |
bool | isFinished () const |
Reports if the SimSystem is finished updating. More... | |
void | setSimulator (Agents::SimulatorInterface *sim, BFSM::FSM *fsm) |
Set the simulator and corresponding FSM for the simulator. More... | |
void | setSimulator (Agents::SimulatorInterface *sim, BFSM::FSM *fsm, const std::string &outFileName, const std::string &scbVersion) |
Set the simulator and corresponding FSM for the simulator. More... | |
void | addObstacleToScene (SceneGraph::GLScene *scene) |
Add visual representations of the simulation obstcles to the GLScene. More... | |
virtual void | addAgentsToScene (SceneGraph::GLScene *scene) |
Add visual representations of the simulation agents to the GLScene. More... | |
void | populateScene (SceneGraph::GLScene *scene) |
Add visual representations of obstacles and agents to the GLScene. More... | |
virtual void | updateAgentPosition (int agtCount) |
Update the position of the visual agents from the simulation data. More... | |
VisAgent ** | getVisAgents () |
Returns a pointer to the visualization agents. More... | |
size_t | getAgentCount () const |
Reports the number of agents. More... | |
Public Member Functions inherited from Menge::SceneGraph::System | |
System () | |
Default constructor. | |
virtual | ~System () |
Virtual destructor. | |
virtual void | finish () |
Finalizing function for the system. More... | |
Protected Attributes | |
bool | _forVis |
Determines if the system is actually for driving a visual scene. | |
Agents::SimulatorInterface * | _sim |
Simulator to run and (possibly) visualize. | |
VisAgent ** | _visAgents |
The visualization agents the system is responsible for updating. | |
BFSM::FSM * | _fsm |
The behavior finite state machine for the simulator. | |
Agents::SCBWriter * | _scbWriter |
The optional scb writer (if an output file has been successfully specified. | |
float | _lastUpdate |
The global time of last system update. | |
bool | _isRunning |
Indicates if the simulation is running. | |
float | _maxDuration |
Maximum length of simulation time to compute (in simulation time). | |
Templated class for performing simulation.
The SimSystem is the main mechanism which performs the simulation loop. It is responsible for updating the simulation step after step, with appropriate calls to the BFSM and the simulator.
Menge::SimSystem::SimSystem | ( | bool | visualize | ) |
Constructor.
visualize | True if the SimSystem will be connected to a visualizer (such as a Vis::GLViewer). |
Menge::SimSystem::SimSystem | ( | bool | visualize, |
float | duration | ||
) |
Constructor with duration limit.
visualize | True if the SimSystem will be connected to a visualizer (such as a Vis::GLViewer). |
duration | The maximum duration (in simulation time) the system will run. |
|
virtual |
Add visual representations of the simulation agents to the GLScene.
scene | The scene which receives nodes for drawing agents. |
void Menge::SimSystem::addObstacleToScene | ( | SceneGraph::GLScene * | scene | ) |
Add visual representations of the simulation obstcles to the GLScene.
scene | The scene which receives nodes for drawing obstacles. |
size_t Menge::SimSystem::getAgentCount | ( | ) | const |
Reports the number of agents.
|
inline |
Returns a pointer to the visualization agents.
bool Menge::SimSystem::isFinished | ( | ) | const |
Reports if the SimSystem is finished updating.
void Menge::SimSystem::populateScene | ( | SceneGraph::GLScene * | scene | ) |
Add visual representations of obstacles and agents to the GLScene.
scene | The scene which receives nodes for drawing agents. |
|
inline |
Sets the maximum length allowed for the simulation to run.
duration | The maximum duration of the simulation (in simulation time). After this time has elapsed, the system no longer updates. |
void Menge::SimSystem::setSimulator | ( | Agents::SimulatorInterface * | sim, |
BFSM::FSM * | fsm | ||
) |
Set the simulator and corresponding FSM for the simulator.
This assumes that no output file (scb file) will be written. Once the simulator and finite state machine have been given to the SimSystem, the SimSystem is repsonsible for managing the memory (i.e. freeing up the memory.)
Throws a SimSystemStateException if the simulator/fsm can't be set. It remains the responsibility of the caller to delete the sim and fsm in this case.
sim | A pointer to the simulator. |
fsm | A pointer to the behavior finite state machine. |
SimSystemFatalException | If there is an error in assigning the simulator. |
void Menge::SimSystem::setSimulator | ( | Agents::SimulatorInterface * | sim, |
BFSM::FSM * | fsm, | ||
const std::string & | outFileName, | ||
const std::string & | scbVersion | ||
) |
Set the simulator and corresponding FSM for the simulator.
This is used if an output file (scb file) is to be written. Once the simulator and finite state machine have been given to the SimSystem, the SimSystem is repsonsible for managing the memory (i.e. freeing up the memory.)
Throws a SimSystemStateException if the simulator/fsm can't be set. It remains the responsibility of the caller to delete the sim and fsm in this case.
sim | A pointer to the simulator. |
fsm | A pointer to the behavior finite state machine. |
outFileName | The name of the scb file to write. |
scbVersion | The version of scb file to write. |
SimSystemFatalException | If there is an error in assigning the simulator, or in initializing the output file. |
|
virtual |
Update the position of the visual agents from the simulation data.
agtCount | The number of agents in the system. |
|
virtual |
Update the simulation (and possibly visual elements) to the given global time.
time | The global time of the system. |
Implements Menge::SceneGraph::System.