public class SimEvent extends java.lang.Object implements java.lang.Comparable<SimEvent>
Modifier and Type | Field and Description |
---|---|
private double |
creationTime
The simulation time at which this event was created.
|
static double |
DEFAULT_PRIORITY |
protected java.lang.Integer |
eventHash
A hash value that depends on the owner, event name, and parameters.
|
private java.lang.String |
eventName
The name of the event associated with this SimEvent.
|
private java.lang.String |
fullMethodName
The methodName plus the signature.
|
private int |
id
A unique identifier for this SimEntity.
|
private java.lang.String |
methodName
The name of the method that will be called when this event is processed.
|
private static java.util.concurrent.atomic.AtomicInteger |
NEXT_ID |
private java.lang.Object[] |
parameters
Holds the parameters to be passed to the event method when called.
|
protected Priority |
priority
The event priority is used to determine which event is processed first if
the scheduled times are the same.
|
private double |
scheduledTime
The simulation time at which this event is scheduled to occur.
|
private int |
serial
A unique identifier for this SimEntity - the # of times an event of this
name has occurred.
|
private java.lang.Class<?>[] |
signature
Caches the signature of the event method.
|
private SimEventScheduler |
source
The SimEntity that will process this SimEvent.
|
private SimEventState |
waitState
The current state of this event.
|
Constructor and Description |
---|
SimEvent(SimEventScheduler source,
java.lang.String name,
double delay) |
SimEvent(SimEventScheduler source,
java.lang.String name,
java.lang.Object[] params,
double delay) |
SimEvent(SimEventScheduler source,
java.lang.String name,
java.lang.Object[] params,
double delay,
Priority priority)
Construct a new SimEvent.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
adjustEventName(java.lang.String name)
Converts an event name to the correct method name.
|
static int |
calculateEventHash(SimEventScheduler source,
java.lang.String eventName,
java.lang.Object[] params)
Returns a hash based on owner, event name, and the parameters.
|
int |
compareTo(SimEvent other)
Compares this SimEvent to another SimEvent.
|
java.lang.String |
countString() |
boolean |
eventEquals(java.lang.Object obj)
Determine if this SimEvent refers to the same event as the given Object.
|
double |
getCreationTime() |
int |
getEventHash() |
java.lang.String |
getEventName()
The event name is the method name with or without the "do"
|
double |
getEventPriority()
The event priority is used to determine which event is processed first if
the scheduled times are the same.
|
java.lang.String |
getFullMethodName() |
int |
getID() |
java.lang.String |
getMethodName()
It must start with "do"
|
java.lang.String |
getName()
The event name is the method name with or without the "do"
|
Priority |
getOwnerPriority() |
java.lang.Object[] |
getParameters() |
java.lang.String |
getParametersAsString() |
Priority |
getPriority() |
double |
getScheduledTime() |
int |
getSerial() |
java.lang.Class<?>[] |
getSignature()
The signature for the method associated with this event.
|
java.lang.String |
getSignatureAsString() |
SimEventScheduler |
getSource()
The SimEventScheduler that will process this SimEvent.
|
SimEventState |
getWaitState()
An event is either WAITING or INTERRUPTED.
|
private java.lang.String |
getWaitStateStr()
If the state is WAITING, returns an empty String, otherwise returns the
name of the waitState.
|
void |
interrupt()
Interrupts (cancels) this event.
|
boolean |
interruptParametersMatch(java.lang.Object[] params)
Determines if the given array of parameters match the parameters for this
event.
|
boolean |
isPending()
Returns true if this event is pending and has not been interrupted.
|
java.lang.String |
paramString() |
protected void |
setScheduledTime(double delay)
The simulation time at which this event is scheduled to occur is the
current simTime + delay.
|
void |
setSerial(int serial) |
void |
setWaitState(SimEventState state) |
java.lang.String |
toString()
Returns the scheduled time, the event name and parameters, and the
waitState of this SimEvent.
|
public static final double DEFAULT_PRIORITY
private static final java.util.concurrent.atomic.AtomicInteger NEXT_ID
private SimEventScheduler source
private java.lang.Class<?>[] signature
private java.lang.Object[] parameters
protected Priority priority
private SimEventState waitState
SimEventState
private double scheduledTime
private double creationTime
private java.lang.String eventName
private java.lang.String methodName
private java.lang.String fullMethodName
private int serial
private int id
protected java.lang.Integer eventHash
public SimEvent(SimEventScheduler source, java.lang.String name, java.lang.Object[] params, double delay, Priority priority)
source
- SimEntity that scheduled this eventname
- Name of scheduled eventparams
- given parametersdelay
- given delaypriority
- give Prioritypublic SimEvent(SimEventScheduler source, java.lang.String name, double delay)
public SimEvent(SimEventScheduler source, java.lang.String name, java.lang.Object[] params, double delay)
public void setWaitState(SimEventState state)
protected void setScheduledTime(double delay)
delay
- Amount of delaypublic void setSerial(int serial)
serial
- Given serial number for this SimEventpublic SimEventScheduler getSource()
public double getScheduledTime()
public double getCreationTime()
public double getEventPriority()
public SimEventState getWaitState()
SimEventState
public java.lang.String getEventName()
public java.lang.String getName()
public java.lang.String getMethodName()
public java.lang.String getFullMethodName()
public Priority getOwnerPriority()
public int getSerial()
public int getID()
public java.lang.Class<?>[] getSignature()
public java.lang.Object[] getParameters()
public java.lang.String getParametersAsString()
public void interrupt()
public java.lang.String paramString()
public java.lang.String countString()
paramString()
public java.lang.String toString()
toString
in class java.lang.Object
private java.lang.String getWaitStateStr()
public boolean eventEquals(java.lang.Object obj)
obj
- Given Objectpublic boolean interruptParametersMatch(java.lang.Object[] params)
params
- given array of parameterspublic boolean isPending()
public static java.lang.String adjustEventName(java.lang.String name)
name
- Given event namepublic java.lang.String getSignatureAsString()
public int getEventHash()
public static int calculateEventHash(SimEventScheduler source, java.lang.String eventName, java.lang.Object[] params)
source
- Given sourceeventName
- Given event nameparams
- Given parameterspublic Priority getPriority()
public int compareTo(SimEvent other)
compareTo
in interface java.lang.Comparable<SimEvent>
other
- other SimEvent