nl.tudelft.simulation.dsol.formalisms.devs
Class AbstractSimEvent

java.lang.Object
  extended by nl.tudelft.simulation.dsol.formalisms.devs.AbstractSimEvent
All Implemented Interfaces:
Serializable, Comparable, SimEventInterface
Direct Known Subclasses:
SimEvent

public abstract class AbstractSimEvent
extends Object
implements SimEventInterface, Comparable, Serializable

The AbstractSimEvent forms the basement for SimEvents and defines a compare method by which eventLists can compare priority of the event.

(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Since:
1.0
Version:
$Revision: 1.1 $ $Date: 2007/01/06 13:21:28 $
Author:
Peter Jacobs
See Also:
Serialized Form

Field Summary
protected  double absoluteExecutionTime
          absoluteExecutionTime reflects the time at which the event is scheduled
protected  long id
          the id used in compare statements
protected  short priority
          priority reflects the priority of the event
 
Fields inherited from interface nl.tudelft.simulation.dsol.formalisms.devs.SimEventInterface
MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
 
Constructor Summary
AbstractSimEvent(double executionTime)
          The constuctor of the event stores the time the event must be executed and the object and method to invoke
AbstractSimEvent(double executionTime, short priority)
          The constuctor of the event stores the time the event must be executed and the object and method to invoke
 
Method Summary
 int compareTo(Object object)
           
abstract  void execute()
          executes the simEvent
 double getAbsoluteExecutionTime()
           
 long getID()
          sets the id of an event.
 short getPriority()
           
 void setID(long id)
          sets the id of an event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

absoluteExecutionTime

protected double absoluteExecutionTime
absoluteExecutionTime reflects the time at which the event is scheduled


priority

protected short priority
priority reflects the priority of the event


id

protected long id
the id used in compare statements

Constructor Detail

AbstractSimEvent

public AbstractSimEvent(double executionTime)
The constuctor of the event stores the time the event must be executed and the object and method to invoke

Parameters:
executionTime - reflects the time the event has to be executed.

AbstractSimEvent

public AbstractSimEvent(double executionTime,
                        short priority)
The constuctor of the event stores the time the event must be executed and the object and method to invoke

Parameters:
executionTime - reflects the time the event has to be executed.
priority - reflects the priority of the event
Method Detail

compareTo

public int compareTo(Object object)
Specified by:
compareTo in interface Comparable
See Also:
Comparable.compareTo(java.lang.Object)

execute

public abstract void execute()
                      throws SimRuntimeException
executes the simEvent

Specified by:
execute in interface SimEventInterface
Throws:
SimRuntimeException - on execution failure

getAbsoluteExecutionTime

public double getAbsoluteExecutionTime()
Specified by:
getAbsoluteExecutionTime in interface SimEventInterface
Returns:
The execution time of a simulation event

getPriority

public short getPriority()
Specified by:
getPriority in interface SimEventInterface
Returns:
The priority of a simulation event. The priorities are programmed according to the Java thread priority. Use 10 (MAX_PRIORITY), -9, .. , 5 (NORMAL_PRIORITY), 1(MIN_PRIORITY)

getID

public long getID()
Description copied from interface: SimEventInterface
sets the id of an event. Whenever a simulation event is added or removed from an eventlist, the list might want to set an ID for comparison. This is the only way to ensure a comparison on equal priority and execution time.

Specified by:
getID in interface SimEventInterface
Returns:
Returns the id.

setID

public void setID(long id)
Description copied from interface: SimEventInterface
sets the id of an event. Whenever a simulation event is added or removed from an eventlist, the list might want to set an ID for comparison. This is the only way to ensure a comparison on equal priority and execution time.

Specified by:
setID in interface SimEventInterface
Parameters:
id - The id to set.


Copyright © 2002-2010 Delft University of Technology, the Netherlands. All Rights Reserved.