VANET Simulator
 All Classes Functions Variables
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
vanetsim.simulation.SimulationMaster Class Reference
Inheritance diagram for vanetsim.simulation.SimulationMaster:

Public Member Functions

 SimulationMaster ()
 
synchronized void startThread ()
 
synchronized void stopThread ()
 
void jumpToTime (int time)
 
void setTargetStepTime (int time)
 
void doOneStep ()
 
WorkerThread[] createWorkers (int timePerStep, int threads)
 
void run ()
 
boolean isSimulationRunning ()
 
boolean isGuiEnabled ()
 
void setGuiEnabled (boolean guiEnabled)
 

Static Public Member Functions

static void writeAnyTextToFile (String anyText, String fileName, boolean append)
 
static boolean isLogPerformance_ ()
 
static long getStartTime ()
 
static void setStartTime (long theStartTime)
 

Static Public Attributes

static final int TIME_PER_STEP = 40
 

Detailed Description

This thread delegates the simulation processing to subthreads and then calls a repaint on the drawing area.

Constructor & Destructor Documentation

vanetsim.simulation.SimulationMaster.SimulationMaster ( )
inline

Instantiates a new simulation master.

Member Function Documentation

WorkerThread [] vanetsim.simulation.SimulationMaster.createWorkers ( int  timePerStep,
int  threads 
)
inline

Function to set up the worker threads with their corresponding regions. Each thread gets an equal amount of regions (some might get one more because of rounding). The amount of items in a region is not used as a method to improve equality between threads as this value might change over time (moving vehicles!). This function expects to get 2x the amount of CPU cores as threads so that the negative effects of an unequal allocation (some threads finishing faster as others => unused cpu power) are reduced.

Parameters
timePerStepthe time per step in milliseconds
threadsthe amount of threads that shall be created
Returns
the worker thread array
void vanetsim.simulation.SimulationMaster.doOneStep ( )
inline

Proceed one single step forward.

boolean vanetsim.simulation.SimulationMaster.isSimulationRunning ( )
inline

Returns if a simulation is currently running or not.

Returns
true if a simulation is running, else false
void vanetsim.simulation.SimulationMaster.jumpToTime ( int  time)
inline

Allows to jump to a specific time. While this mode is active, no display and statistics update is done.

Parameters
timethe target time in milliseconds
void vanetsim.simulation.SimulationMaster.run ( )
inline

The main method for the simulation master initializes the worker threads, manages them and initiates the render process and statistics updates.

void vanetsim.simulation.SimulationMaster.setTargetStepTime ( int  time)
inline

Sets the target step time. Decrease to get a faster simulation, increase to get a slower.

Parameters
time
synchronized void vanetsim.simulation.SimulationMaster.startThread ( )
inline

Method to let this thread start delegating work to subthreads. Work in the main function is resumed, the subthreads (workers) will wake up again and the Renderer is notified to get active again.

synchronized void vanetsim.simulation.SimulationMaster.stopThread ( )
inline

Method to let this thread stop delegating work to subthreads. Work in the main function is suspended, the subthreads (workers) will go to sleep and the Renderer is notified to get inactive.

static void vanetsim.simulation.SimulationMaster.writeAnyTextToFile ( String  anyText,
String  fileName,
boolean  append 
)
inlinestatic

Writes any data to file

Member Data Documentation

final int vanetsim.simulation.SimulationMaster.TIME_PER_STEP = 40
static

How much time passes in one step (in milliseconds). 40ms results in a smooth animation with 25fps.


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