Class SimSystem

java.lang.Object
simEngine.SimSystem

public class SimSystem extends Object
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
    Modifier and Type
    Field
    Description
    static final SimAnyP
    A standard predicate that matches any event.
    static final SimNoneP
    A standard predicate that does not match any events.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Aborts the simulation!
    void
    Adds a new entity to the simulation.
    double
    Get the current simulation time.
    double
    A different name for SimSystem.clock().
    final SimEntity
    getEntity(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 lines
    int
    Gets the current number of entities in the simulation
    void
    Initializes the system, this function works as a constructor, and should be called at the start of any simulation program.
    void
    Starts the simulation running, by calling the start() method of each entity.
    void
    Stops the simulation, by calling the poison() method of each SimEntity.
    boolean
    Runs one tick of the simulation: the system looks for events in the future queue.
    void
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SIM_ANY

      public static final SimAnyP SIM_ANY
      A standard predicate that matches any event.
    • SIM_NONE

      public static final SimNoneP 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

      public NumberFormat 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 for SimSystem.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

      public final SimEntity getEntity(int id)
      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

      public SimEntity getEntity(String name)
      Finds an entity by its name.
      Parameters:
      name - The entity's name
      Returns:
      A reference to the entity, or null if it could not be found
    • add

      public void add(SimEntity e)
      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

      public boolean runTick() throws NetException
      Runs one tick of the simulation: the system looks for events in the future queue.
      Returns:
      false if 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

      public void setNetSystem(NetSystem netSystem)