gps.event
Class SimEvent

java.lang.Object
  extended by gps.event.SimEvent
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
BTEvent

public class SimEvent
extends java.lang.Object
implements java.lang.Comparable

the base class of all events in simulator. events includes simulator internal events, protocol events, and user action events.

Version:
1.2, 6/20/2005
Author:
Weishuai Yang

Field Summary
static int SIM_AGENT_ACTIVE
          activate an agent
static int SIM_AGENT_DEACTIVE
          deactivate an agent
static int SIM_END
          end simulation event
static int SIM_NODE_ACTIVE
          activate a node
static int SIM_NODE_DEACTIVE
          deactivate a node
static int SIM_START
          start simulation event, don't have to be explicitely triggered
 
Constructor Summary
SimEvent()
          don't do anything, just for complete
SimEvent(double timeStamp, int type, java.util.ArrayList handlerList, java.lang.Object obj)
          constructs a new event with a list of handler
SimEvent(double timeStamp, int type, SimEventHandler handler, java.lang.Object obj)
          constructs a new event with one handler
 
Method Summary
 int compareTo(java.lang.Object event)
          compare the order of two events
 void dispatch()
          dispatchs the event to it's handler
 java.lang.String format(java.lang.String ss)
          generate a formated string with basic event information and additional information provided by parameter
 java.lang.Object getAddParam()
          gets the second param for the event
 long getEventID()
          gets the unique id for this event
 java.lang.Object getParam()
          gets first param for the event
 double getTimeStamp()
          gets the timestamp of the event
 int getType()
          gets event type
 void setAddParam(java.lang.Object obj)
          sets the second param for the event
 void setEventID()
          sets next available unique id for this event
 void setTimeStamp(double t)
          sets timestamp
 void setType(int type)
          sets event type
 java.lang.String toString()
          generates a string representation of the event
 java.lang.String typeString(int type)
          generates a String description of the type
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIM_START

public static final int SIM_START
start simulation event, don't have to be explicitely triggered

See Also:
Constant Field Values

SIM_END

public static final int SIM_END
end simulation event

See Also:
Constant Field Values

SIM_NODE_ACTIVE

public static final int SIM_NODE_ACTIVE
activate a node

See Also:
Constant Field Values

SIM_NODE_DEACTIVE

public static final int SIM_NODE_DEACTIVE
deactivate a node

See Also:
Constant Field Values

SIM_AGENT_ACTIVE

public static final int SIM_AGENT_ACTIVE
activate an agent

See Also:
Constant Field Values

SIM_AGENT_DEACTIVE

public static final int SIM_AGENT_DEACTIVE
deactivate an agent

See Also:
Constant Field Values
Constructor Detail

SimEvent

public SimEvent()
don't do anything, just for complete


SimEvent

public SimEvent(double timeStamp,
                int type,
                SimEventHandler handler,
                java.lang.Object obj)
constructs a new event with one handler

Parameters:
timeStamp - the time this event to be triggered
type - the event type
obj - the paramater for this event
handler - the handler for this event

SimEvent

public SimEvent(double timeStamp,
                int type,
                java.util.ArrayList handlerList,
                java.lang.Object obj)
constructs a new event with a list of handler

Parameters:
timeStamp - the time this event to be triggered
type - the event type
obj - the paramater for this event
handlerList - the handler for this event
Method Detail

getEventID

public long getEventID()
gets the unique id for this event

Returns:
id of the event

setEventID

public void setEventID()
sets next available unique id for this event


dispatch

public void dispatch()
dispatchs the event to it's handler


getTimeStamp

public double getTimeStamp()
gets the timestamp of the event

Returns:
timestamp

setTimeStamp

public void setTimeStamp(double t)
sets timestamp

Parameters:
t - new timestamp

getParam

public java.lang.Object getParam()
gets first param for the event

Returns:
the first param object of the event

setAddParam

public void setAddParam(java.lang.Object obj)
sets the second param for the event

Parameters:
obj - the object to be included int the event as the second parameter

getAddParam

public java.lang.Object getAddParam()
gets the second param for the event

Returns:
the second param object of the event

compareTo

public int compareTo(java.lang.Object event)
compare the order of two events

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
event - the events to be compared to

getType

public int getType()
gets event type

Returns:
event type

setType

public void setType(int type)
sets event type

Parameters:
type - the new event type

typeString

public java.lang.String typeString(int type)
generates a String description of the type

Returns:
event type in string format

toString

public java.lang.String toString()
generates a string representation of the event

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the event

format

public java.lang.String format(java.lang.String ss)
generate a formated string with basic event information and additional information provided by parameter

Parameters:
ss - the additional information to be included in the formated string
Returns:
formated String