All Packages Class Hierarchy This Package Previous Next Index
Class eduni.simjava.Sim_entity
java.lang.Object
|
+----java.lang.Thread
|
+----eduni.simjava.Sim_entity
- public class Sim_entity
- extends Thread
This class represents entities, or processes, running in the system.
To create a new type of entity, it should be extended and
a definition for the body() method given. The body()
method is called by the Sim_system and defines the behaviour of
the entity during the simulation.
The methods with names starting with the prefix sim_ are
runtime methods, and should only be called from within the entity's
body() method.
- See Also:
- Sim_system
-
Sim_entity(String)
- The standard constructor.
-
Sim_entity(String, String, int, int)
- The constructor for use with the eduni.simanim animation package.
-
add_param(Anim_param)
- Add a parameter to this entity.
-
add_port(Sim_port)
- Add a port to this entity.
-
body()
- The method which defines the behavior of the entity.
-
get_id()
- Get the unique id number assigned to this entity
-
get_name()
- Get the name of this entity
-
get_port(Sim_event)
- Search through this entity's ports, for the one which sent this event.
-
get_port(String)
- Search through this entity's ports, for one called name.
-
run()
- Internal method - don't overide
-
send_on(Sim_event, Sim_port)
- Send on an event to an other entity, through a port.
-
set_invisible(boolean)
- Make entity icon invisible
-
sim_cancel(Sim_predicate, Sim_event)
- Cancel the first event waiting for this entity on the future
queue, matched by the predicate p.
-
sim_current()
- Get the id of the currently running entity
-
sim_get_next(Sim_event)
- Get the first event from the deferred queue waiting on the entity,
or, if there are none, wait for an event to arrive.
-
sim_get_next(Sim_predicate, Sim_event)
- Get the first event matching a predicate from the deferred queue,
or, if none match, wait for a matching event to arrive.
-
sim_hold(double)
- Causes the entity to hold for delay units of simulation time.
-
sim_putback(Sim_event)
- Put an event back on the defered queue.
-
sim_schedule(int, double, int)
- Send an event to another entity, by id number and with no data.
-
sim_schedule(int, double, int, Object)
- Send an event to another entity, by id number with data.
-
sim_schedule(Sim_port, double, int)
- Send an event to another entity, by a port reference with no data.
-
sim_schedule(Sim_port, double, int, Object)
- Send an event to another entity, by a port reference with data.
-
sim_schedule(String, double, int)
- Send an event to another entity, by a port name with no data.
-
sim_schedule(String, double, int, Object)
- Send an event to another entity, by a port name with data.
-
sim_select(Sim_predicate, Sim_event)
- Extract the first event waiting for this entity on the deferred
queue, matched by the predicate p.
-
sim_trace(int, String)
- Write a trace message.
-
sim_wait(Sim_event)
- Hold until the entity recieves an event.
-
sim_wait_for(Sim_predicate, Sim_event)
- Repeatedly sim_wait() until the entity receives an event
matched by a predicate, all other received events
are discarded.
-
sim_waiting()
- Count how many events are waiting of this entity on the deferred queue
-
sim_waiting(Sim_predicate)
- Count how many events matching a predicate are waiting
for this entity on the deferred queue.
Sim_entity
public Sim_entity(String name)
- The standard constructor.
- Parameters:
- name - The name to be associated with this entity
- Returns:
- A new instance of the class Sim_entity
Sim_entity
public Sim_entity(String name,
String image_name,
int x,
int y)
- The constructor for use with the eduni.simanim animation package.
- Parameters:
- name - The name to be associated with this entity
- image_name - The name of the gif image file for this entity's
icon, (without the .gif extension).
- x - The X co-ordinate at which the entity should be drawn
- y - The Y co-ordinate at which the entity should be drawn
set_invisible
public void set_invisible(boolean b)
- Make entity icon invisible
get_name
public String get_name()
- Get the name of this entity
- Returns:
- The entity's name
get_id
public int get_id()
- Get the unique id number assigned to this entity
- Returns:
- The id number
get_port
public Sim_port get_port(Sim_event ev)
- Search through this entity's ports, for the one which sent this event.
- Parameters:
- ev - The event
- Returns:
- A reference to the port which sent the event, or null if
it could not be found
get_port
public Sim_port get_port(String name)
- Search through this entity's ports, for one called name.
- Parameters:
- name - The name of the port to search for
- Returns:
- A reference to the port, or null if it could not be found
add_port
public void add_port(Sim_port port)
- Add a port to this entity.
- Parameters:
- port - A reference to the port to add
add_param
public void add_param(Anim_param param)
- Add a parameter to this entity.
Used with the eduni.simanim package for animation.
- Parameters:
- param - A reference to the parameter to add
body
public void body()
- The method which defines the behavior of the entity. This method
should be overidden in subclasses of Sim_entity.
sim_hold
public void sim_hold(double delay)
- Causes the entity to hold for delay units of simulation time.
- Parameters:
- delay - The amount of time to hold
sim_trace
public void sim_trace(int level,
String msg)
- Write a trace message.
- Parameters:
- level - The level at which the trace should be printed, used
with Sim_system.set_trc_level() to control
what traces are printed
- msg - The message to be printed
sim_schedule
public void sim_schedule(int dest,
double delay,
int tag,
Object data)
- Send an event to another entity, by id number with data.
- Parameters:
- dest - The unique id number of the destination entity
- delay - How long from the current simulation time the event
should be sent
- tag - An user-defined number representing the type of event.
- data - A reference to data to be sent with the event.
sim_schedule
public void sim_schedule(int dest,
double delay,
int tag)
- Send an event to another entity, by id number and with no data.
- Parameters:
- dest - The unique id number of the destination entity
- delay - How long from the current simulation time the event
should be sent
- tag - An user-defined number representing the type of event.
sim_schedule
public void sim_schedule(Sim_port dest,
double delay,
int tag,
Object data)
- Send an event to another entity, by a port reference with data.
- Parameters:
- dest - A reference to the port to send the event out of
- delay - How long from the current simulation time the event
should be sent
- tag - An user-defined number representing the type of event.
- data - A reference to data to be sent with the event.
sim_schedule
public void sim_schedule(Sim_port dest,
double delay,
int tag)
- Send an event to another entity, by a port reference with no data.
- Parameters:
- dest - A reference to the port to send the event out of
- delay - How long from the current simulation time the event
should be sent
- tag - An user-defined number representing the type of event.
sim_schedule
public void sim_schedule(String dest,
double delay,
int tag,
Object data)
- Send an event to another entity, by a port name with data.
- Parameters:
- dest - The name of the port to send the event out of
- delay - How long from the current simulation time the event
should be sent
- tag - An user-defined number representing the type of event.
- data - A reference to data to be sent with the event.
sim_schedule
public void sim_schedule(String dest,
double delay,
int tag)
- Send an event to another entity, by a port name with no data.
- Parameters:
- dest - The name of the port to send the event out of
- delay - How long from the current simulation time the event
should be sent
- tag - An user-defined number representing the type of event.
sim_wait
public void sim_wait(Sim_event ev)
- Hold until the entity recieves an event.
- Parameters:
- ev - The event recieved is copied into ev if
it points to an blank event, or discarded if ev is
null
sim_waiting
public int sim_waiting(Sim_predicate p)
- Count how many events matching a predicate are waiting
for this entity on the deferred queue.
- Parameters:
- p - The event selection predicate
- Returns:
- The count of matching events
sim_waiting
public int sim_waiting()
- Count how many events are waiting of this entity on the deferred queue
- Returns:
- The count of events
sim_select
public void sim_select(Sim_predicate p,
Sim_event ev)
- Extract the first event waiting for this entity on the deferred
queue, matched by the predicate p.
- Parameters:
- p - An event selection predicate
- ev - The event matched is copied into ev if
it points to a blank event, or discarded if ev is
null
sim_cancel
public int sim_cancel(Sim_predicate p,
Sim_event ev)
- Cancel the first event waiting for this entity on the future
queue, matched by the predicate p. Returns the
number of events cancelled (0 or 1).
- Parameters:
- p - An event selection predicate
- ev - The event matched is copied into ev if
it points to a blank event, or discarded if ev is
null
sim_wait_for
public void sim_wait_for(Sim_predicate p,
Sim_event ev)
- Repeatedly sim_wait() until the entity receives an event
matched by a predicate, all other received events
are discarded.
- Parameters:
- p - The event selection predicate
- ev - The event matched is copied into ev if
it points to a blank event, or discarded if ev is
null
sim_putback
public void sim_putback(Sim_event ev)
- Put an event back on the defered queue.
- Parameters:
- ev - The event to reinsert
sim_get_next
public void sim_get_next(Sim_predicate p,
Sim_event ev)
- Get the first event matching a predicate from the deferred queue,
or, if none match, wait for a matching event to arrive.
- Parameters:
- p - The predicate to match
- ev - The event matched is copied into ev if
it points to a blank event, or discarded if ev is
null
sim_get_next
public void sim_get_next(Sim_event ev)
- Get the first event from the deferred queue waiting on the entity,
or, if there are none, wait for an event to arrive.
- Parameters:
- ev - The event matched is copied into ev if
it points to a blank event, or discarded if ev is
null
sim_current
public int sim_current()
- Get the id of the currently running entity
- Returns:
- A unique entity id number
send_on
public void send_on(Sim_event ev,
Sim_port p)
- Send on an event to an other entity, through a port.
- Parameters:
- ev - A reference to the event to send
- p - A reference to the port through which to send
run
public final void run()
- Internal method - don't overide
- Overrides:
- run in class Thread
All Packages Class Hierarchy This Package Previous Next Index