Class SimSystem
java.lang.Object
simEngine.SimSystem
This is the system class which manages the simulation. All
the members of this class are static, so there is no need to
create an instance of this class.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Aborts the simulation!voidAdds a new entity to the simulation.doubleclock()Get the current simulation time.doublegetClock()A different name forSimSystem.clock().final SimEntitygetEntity(int id) Finds an entity by its id number.Finds an entity by its name.Returns the number format used for generating times in trace linesintGets the current number of entities in the simulationvoidInitializes the system, this function works as a constructor, and should be called at the start of any simulation program.voidrunStart()Starts the simulation running, by calling the start() method of each entity.voidrunStop()Stops the simulation, by calling the poison() method of each SimEntity.booleanrunTick()Runs one tick of the simulation: the system looks for events in the future queue.voidsetNetSystem(NetSystem netSystem)
-
Field Details
-
SIM_ANY
A standard predicate that matches any event. -
SIM_NONE
A standard predicate that does not match any events.
-
-
Constructor Details
-
SimSystem
public SimSystem()
-
-
Method Details
-
initialize
public void initialize()Initializes the system, this function works as a constructor, and should be called at the start of any simulation program. It comes in several flavours depending on what context the simulation is running.<P> This is the simplest, and should be used for standalone simulations It sets up trace output to a file in the current directory called `tracefile' -
getNumberFormat
Returns the number format used for generating times in trace lines -
clock
public double clock()Get the current simulation time.- Returns:
- The simulation time
-
getClock
public double getClock()A different name forSimSystem.clock().- Returns:
- The current simulation time
-
getNumEntities
public int getNumEntities()Gets the current number of entities in the simulation- Returns:
- A count of entities
-
getEntity
Finds an entity by its id number.- Parameters:
id- The entity's unique id number- Returns:
- A reference to the entity, or null if it could not be found
-
getEntity
-
add
Adds a new entity to the simulation. This is now done automatically in the SimEntity constructor, so there is no need to call this explicitly.- Parameters:
e- A reference to the new entity
-
runStart
public void runStart()Starts the simulation running, by calling the start() method of each entity. Of course this should be called after all the entities have been setup and added, and their ports linked. -
runTick
Runs one tick of the simulation: the system looks for events in the future queue.- Returns:
falseif there are no more future events to be processed- Throws:
NetException- if the operation cannot be completed
-
runStop
public void runStop()Stops the simulation, by calling the poison() method of each SimEntity. -
abort
public void abort()Aborts the simulation! -
setNetSystem
-