Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
Menge::SimSystem Class Reference

Templated class for performing simulation. More...

#include <SimSystem.h>

Inheritance diagram for Menge::SimSystem:
Menge::SceneGraph::System

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).
 

Detailed Description

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.

Constructor & Destructor Documentation

Menge::SimSystem::SimSystem ( bool  visualize)

Constructor.

Parameters
visualizeTrue 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.

Parameters
visualizeTrue if the SimSystem will be connected to a visualizer (such as a Vis::GLViewer).
durationThe maximum duration (in simulation time) the system will run.

Member Function Documentation

void Menge::SimSystem::addAgentsToScene ( SceneGraph::GLScene scene)
virtual

Add visual representations of the simulation agents to the GLScene.

Parameters
sceneThe scene which receives nodes for drawing agents.
void Menge::SimSystem::addObstacleToScene ( SceneGraph::GLScene scene)

Add visual representations of the simulation obstcles to the GLScene.

Parameters
sceneThe scene which receives nodes for drawing obstacles.
size_t Menge::SimSystem::getAgentCount ( ) const

Reports the number of agents.

Returns
The number of VisAgents updated by the system.
VisAgent** Menge::SimSystem::getVisAgents ( )
inline

Returns a pointer to the visualization agents.

Returns
Returns the pointer to the pointers.
bool Menge::SimSystem::isFinished ( ) const

Reports if the SimSystem is finished updating.

Returns
True if the system will no longer update. False if still willing to evalute.
void Menge::SimSystem::populateScene ( SceneGraph::GLScene scene)

Add visual representations of obstacles and agents to the GLScene.

Parameters
sceneThe scene which receives nodes for drawing agents.
void Menge::SimSystem::setMaxDuration ( float  duration)
inline

Sets the maximum length allowed for the simulation to run.

Parameters
durationThe 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.

Parameters
simA pointer to the simulator.
fsmA pointer to the behavior finite state machine.
Exceptions
SimSystemFatalExceptionIf 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.

Parameters
simA pointer to the simulator.
fsmA pointer to the behavior finite state machine.
outFileNameThe name of the scb file to write.
scbVersionThe version of scb file to write.
Exceptions
SimSystemFatalExceptionIf there is an error in assigning the simulator, or in initializing the output file.
void Menge::SimSystem::updateAgentPosition ( int  agtCount)
virtual

Update the position of the visual agents from the simulation data.

Parameters
agtCountThe number of agents in the system.
bool Menge::SimSystem::updateScene ( float  time)
virtual

Update the simulation (and possibly visual elements) to the given global time.

Parameters
timeThe global time of the system.
Returns
True if the system has changed such that it requires a redraw.

Implements Menge::SceneGraph::System.


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