All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class eduni.simjava.Sim_system

java.lang.Object
   |
   +----eduni.simjava.Sim_system

public class Sim_system
extends Object
This is the system class which manages the simulation. All of the members of this class are static, so there is no need to create an instance of this class.


Variable Index

 o SIM_ANY
A standard predicate that matches any event.
 o SIM_NONE
A standard predicate that does not match any events.

Constructor Index

 o Sim_system()

Method Index

 o add(Sim_entity)
Add a new entity to the simulation.
 o clock()
Get the current simulation time.
 o current_ent()
Find the currently running entity.
 o get_entity(int)
Find an entity by its id number.
 o get_entity(String)
Find an entity by its name.
 o get_entity_id(String)
Find out an entities unique id number from its name.
 o get_num_entities()
Get the current number of entities in the simulation
 o get_trc_level()
Get the current trace level (initially 0xff), which controls trace output.
 o get_trcout()
 o getNumberFormat()
Returns the number format used for generating times in trace lines
 o initialise()
Initialise the system, this function does the job of a constructor, and should be called at the start of any simulation program.
 o initialise(Sim_anim, Thread)
This version of initialise() is used by the standard animation package eduni.simanim
 o initialise(Sim_output, Thread)
This version of initialise() is for experienced users who want to use the trace output to draw a graph or an animation as part of the application.
 o link_ports(String, String, String, String)
Link the ports the ports on two entities, so that events secheduled from one port are sent to the other.
 o run()
Start the simulation running.
 o run_start()
Start the simulation running.
 o run_stop()
Stop the simulation
 o run_tick()
Run one tick of the simulation.
 o set_auto_trace(boolean)
Switch the auto trace messages on and off.
 o set_trc_level(int)
Set the trace level flags which control trace output.
 o sim_clock()
A different name for Sim_system.clock().

Variables

 o SIM_ANY
 public static Sim_any_p SIM_ANY
A standard predicate that matches any event.

 o SIM_NONE
 public static Sim_none_p SIM_NONE
A standard predicate that does not match any events.

Constructors

 o Sim_system
 public Sim_system()

Methods

 o initialise
 public static void initialise()
Initialise the system, this function does the job of 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.

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'

 o initialise
 public static void initialise(Sim_anim out,
                               Thread sim)
This version of initialise() is used by the standard animation package eduni.simanim

 o initialise
 public static void initialise(Sim_output out,
                               Thread sim)
This version of initialise() is for experienced users who want to use the trace output to draw a graph or an animation as part of the application.

Parameters:
out - The object to be used for trace output
sim - The thread the simulation is running under, (set to null if not applicable
 o getNumberFormat
 public static NumberFormat getNumberFormat()
Returns the number format used for generating times in trace lines

 o clock
 public static double clock()
Get the current simulation time.

Returns:
The simulation time
 o sim_clock
 public static double sim_clock()
A different name for Sim_system.clock().

Returns:
The current simulation time
 o get_num_entities
 public static int get_num_entities()
Get the current number of entities in the simulation

Returns:
A count of entities
 o get_trc_level
 public static int get_trc_level()
Get the current trace level (initially 0xff), which controls trace output.

Returns:
The trace level flags
 o get_entity
 public static Sim_entity get_entity(int id)
Find 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
 o get_entity
 public static Sim_entity get_entity(String name)
Find 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
 o get_entity_id
 public static int get_entity_id(String name)
Find out an entities unique id number from its name.

Parameters:
name - The entity's name
Returns:
The entity's unique id number, or -1 if it could not be found
 o current_ent
 public static Sim_entity current_ent()
Find the currently running entity.

Returns:
A reference to the entity, or null if none are running
 o set_trc_level
 public static void set_trc_level(int level)
Set the trace level flags which control trace output.

Parameters:
level - The new flags
 o set_auto_trace
 public static void set_auto_trace(boolean on)
Switch the auto trace messages on and off.

Parameters:
on - If true then the messages are switched on
 o add
 public static void add(Sim_entity e)
Add a new entity to the simulation. This is now done automatically in the Sim_entity constructor, so there is no need to call this explicitly.

Parameters:
e - A reference to the new entity
 o link_ports
 public static void link_ports(String ent1,
                               String port1,
                               String ent2,
                               String port2)
Link the ports the ports on two entities, so that events secheduled from one port are sent to the other.

Parameters:
ent1 - The name of the first entity
port1 - The name of the port on the first entity
ent2 - The name of the second entity
port2 - The name of the port on the second entity
 o run_start
 public static void run_start()
Start the simulation running. This should be called after all the entities have been setup and added, and their ports linked Phase 1.

 o run_tick
 public static boolean run_tick()
Run one tick of the simulation.

 o run_stop
 public static void run_stop()
Stop the simulation

 o run
 public static void run()
Start the simulation running. This should be called after all the entities have been setup and added, and their ports linked

 o get_trcout
 public static Sim_output get_trcout()

All Packages  Class Hierarchy  This Package  Previous  Next  Index