public abstract class SimEntity
extends java.lang.Object
implements java.lang.Cloneable
startEntity() is invoked by the Simulation class when the simulation is
started. This method should be responsible for starting the entity up.
processEvent(SimEvent) is invoked by the Simulation class whenever there is
an event in the deferred queue, which needs to be processed by the entity.
shutdownEntity() is invoked by the Simulation before the simulation
finishes. If you want to save data in log files this is the method in which the corresponding
code would be placed.
| Modifier and Type | Field and Description |
|---|---|
static int |
FINISHED
The Constant FINISHED.
|
static int |
HOLDING
The Constant HOLDING.
|
static int |
RUNNABLE
The Constant RUNNABLE.
|
static int |
WAITING
The Constant WAITING.
|
| Constructor and Description |
|---|
SimEntity(java.lang.String name)
Creates a new entity.
|
| Modifier and Type | Method and Description |
|---|---|
SimEvent |
cancelEvent(Predicate p)
Cancel the first event matching a predicate waiting in the entity's future queue.
|
protected java.lang.Object |
clone()
Get a clone of the entity.
|
protected SimEvent |
getEventBuffer()
Gets the event buffer.
|
int |
getId()
Get the unique id number assigned to this entity.
|
java.lang.String |
getName()
Get the name of this entity.
|
SimEvent |
getNextEvent()
Get the first event waiting in the entity's deferred queue, or if there are none, wait for an
event to arrive.
|
SimEvent |
getNextEvent(Predicate p)
Get the first event matching a predicate from the deferred queue, or if none match, wait for
a matching event to arrive.
|
protected int |
getState()
Gets the state.
|
int |
numEventsWaiting()
Count how many events are waiting in the entity's deferred queue.
|
int |
numEventsWaiting(Predicate p)
Count how many events matching a predicate are waiting in the entity's deferred queue.
|
void |
pause(double delay)
Set the entity to be inactive for a time period.
|
abstract void |
processEvent(SimEvent ev)
This method is invoked by the
Simulation class whenever there is an event in the
deferred queue, which needs to be processed by the entity. |
void |
run() |
void |
schedule(int dest,
double delay,
int tag)
Send an event to another entity by id number and with no data.
|
void |
schedule(int dest,
double delay,
int tag,
java.lang.Object data)
Send an event to another entity by id number, with data.
|
void |
schedule(java.lang.String dest,
double delay,
int tag)
Send an event to another entity through a port with a given name, with no data.
|
void |
schedule(java.lang.String dest,
double delay,
int tag,
java.lang.Object data)
Send an event to another entity through a port with a given name, with data.
|
void |
scheduleFirst(int dest,
double delay,
int tag)
Send a high priority event to another entity by id number and with no data.
|
void |
scheduleFirst(int dest,
double delay,
int tag,
java.lang.Object data)
Send a high priority event to another entity by id number, with data.
|
void |
scheduleFirst(java.lang.String dest,
double delay,
int tag)
Send a high priority event to another entity through a port with a given name, with no
data.
|
void |
scheduleFirst(java.lang.String dest,
double delay,
int tag,
java.lang.Object data)
Send a high priority event to another entity through a port with a given name, with data.
|
void |
scheduleFirstNow(int dest,
int tag)
Send a high priority event to another entity by id number and with no data.
|
void |
scheduleFirstNow(int dest,
int tag,
java.lang.Object data)
Send a high priority event to another entity by id number, with data.
|
void |
scheduleFirstNow(java.lang.String dest,
int tag)
Send a high priority event to another entity through a port with a given name, with no
data.
|
void |
scheduleFirstNow(java.lang.String dest,
int tag,
java.lang.Object data)
Send a high priority event to another entity through a port with a given name, with data.
|
void |
scheduleNow(int dest,
int tag)
Send an event to another entity by id number and with no data.
|
void |
scheduleNow(int dest,
int tag,
java.lang.Object data)
Send an event to another entity by id number, with data.
|
void |
scheduleNow(java.lang.String dest,
int tag)
Send an event to another entity through a port with a given name, with no data.
|
void |
scheduleNow(java.lang.String dest,
int tag,
java.lang.Object data)
Send an event to another entity through a port with a given name, with data.
|
SimEvent |
selectEvent(Predicate p)
Extract the first event matching a predicate waiting in the entity's deferred queue.
|
protected void |
send(int entityId,
double delay,
int cloudSimTag)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
send(int entityId,
double delay,
int cloudSimTag,
java.lang.Object data)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
send(java.lang.String entityName,
double delay,
int cloudSimTag)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
send(java.lang.String entityName,
double delay,
int cloudSimTag,
java.lang.Object data)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
sendNow(int entityId,
int cloudSimTag)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
sendNow(int entityId,
int cloudSimTag,
java.lang.Object data)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
sendNow(java.lang.String entityName,
int cloudSimTag)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
sendNow(java.lang.String entityName,
int cloudSimTag,
java.lang.Object data)
Sends an event/message to another entity by delaying the simulation time from the
current time, with a tag representing the event type.
|
protected void |
setEventBuffer(SimEvent e)
Sets the event buffer.
|
protected void |
setId(int id)
Sets the id.
|
protected void |
setState(int state)
Sets the state.
|
abstract void |
shutdownEntity()
This method is invoked by the
Simulation before the simulation finishes. |
abstract void |
startEntity()
This method is invoked by the
Simulation class when the simulation is started. |
void |
waitForEvent(Predicate p)
Wait for an event matching a specific predicate.
|
public static final int RUNNABLE
public static final int WAITING
public static final int HOLDING
public static final int FINISHED
public SimEntity(java.lang.String name)
name - the name to be associated with this entitypublic java.lang.String getName()
public int getId()
public void schedule(int dest,
double delay,
int tag,
java.lang.Object data)
9999
is reserved.dest - The unique id number of the destination entitydelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.data - The data to be sent with the event.public void schedule(int dest,
double delay,
int tag)
9999 is reserved.dest - The unique id number of the destination entitydelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.public void schedule(java.lang.String dest,
double delay,
int tag,
java.lang.Object data)
9999 is reserved.dest - The name of the port to send the event throughdelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.data - The data to be sent with the event.public void schedule(java.lang.String dest,
double delay,
int tag)
9999 is reserved.dest - The name of the port to send the event throughdelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.public void scheduleNow(int dest,
int tag,
java.lang.Object data)
9999
is reserved.dest - The unique id number of the destination entitytag - An user-defined number representing the type of event.data - The data to be sent with the event.public void scheduleNow(int dest,
int tag)
9999 is reserved.dest - The unique id number of the destination entitytag - An user-defined number representing the type of event.public void scheduleNow(java.lang.String dest,
int tag,
java.lang.Object data)
9999 is reserved.dest - The name of the port to send the event throughtag - An user-defined number representing the type of event.data - The data to be sent with the event.public void scheduleNow(java.lang.String dest,
int tag)
9999 is reserved.dest - The name of the port to send the event throughtag - An user-defined number representing the type of event.public void scheduleFirst(int dest,
double delay,
int tag,
java.lang.Object data)
9999 is reserved.dest - The unique id number of the destination entitydelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.data - The data to be sent with the event.public void scheduleFirst(int dest,
double delay,
int tag)
9999 is reserved.dest - The unique id number of the destination entitydelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.public void scheduleFirst(java.lang.String dest,
double delay,
int tag,
java.lang.Object data)
9999 is reserved.dest - The name of the port to send the event throughdelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.data - The data to be sent with the event.public void scheduleFirst(java.lang.String dest,
double delay,
int tag)
9999 is reserved.dest - The name of the port to send the event throughdelay - How long from the current simulation time the event should be senttag - An user-defined number representing the type of event.public void scheduleFirstNow(int dest,
int tag,
java.lang.Object data)
9999 is reserved.dest - The unique id number of the destination entitytag - An user-defined number representing the type of event.data - The data to be sent with the event.public void scheduleFirstNow(int dest,
int tag)
9999 is reserved.dest - The unique id number of the destination entitytag - An user-defined number representing the type of event.public void scheduleFirstNow(java.lang.String dest,
int tag,
java.lang.Object data)
9999 is reserved.dest - The name of the port to send the event throughtag - An user-defined number representing the type of event.data - The data to be sent with the event.public void scheduleFirstNow(java.lang.String dest,
int tag)
9999 is reserved.dest - The name of the port to send the event throughtag - An user-defined number representing the type of event.public void pause(double delay)
delay - the time period for which the entity will be inactivepublic int numEventsWaiting(Predicate p)
p - The event selection predicatepublic int numEventsWaiting()
public SimEvent selectEvent(Predicate p)
p - The event selection predicatepublic SimEvent cancelEvent(Predicate p)
p - The event selection predicatepublic SimEvent getNextEvent(Predicate p)
p - The predicate to matchpublic void waitForEvent(Predicate p)
p - The predicate to matchpublic SimEvent getNextEvent()
public abstract void startEntity()
Simulation class when the simulation is started. This
method should be responsible for starting the entity up.public abstract void processEvent(SimEvent ev)
Simulation class whenever there is an event in the
deferred queue, which needs to be processed by the entity.ev - the event to be processed by the entitypublic abstract void shutdownEntity()
Simulation before the simulation finishes. If you want
to save data in log files this is the method in which the corresponding code would be placed.public void run()
protected final java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - the clone not supported exceptionprotected int getState()
protected SimEvent getEventBuffer()
protected void setState(int state)
state - the new stateprotected void setId(int id)
id - the new idprotected void setEventBuffer(SimEvent e)
e - the new event bufferprotected void send(int entityId,
double delay,
int cloudSimTag,
java.lang.Object data)
entityId - the id number of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/messagedata - A reference to data to be sent with the eventprotected void send(int entityId,
double delay,
int cloudSimTag)
entityId - the id number of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/messageprotected void send(java.lang.String entityName,
double delay,
int cloudSimTag,
java.lang.Object data)
entityName - the name of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/messagedata - A reference to data to be sent with the eventprotected void send(java.lang.String entityName,
double delay,
int cloudSimTag)
entityName - the name of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/messageprotected void sendNow(int entityId,
int cloudSimTag,
java.lang.Object data)
entityId - the id number of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/messagedata - A reference to data to be sent with the eventprotected void sendNow(int entityId,
int cloudSimTag)
entityId - the id number of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/messageprotected void sendNow(java.lang.String entityName,
int cloudSimTag,
java.lang.Object data)
entityName - the name of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/messagedata - A reference to data to be sent with the eventprotected void sendNow(java.lang.String entityName,
int cloudSimTag)
entityName - the name of the destination entitydelay - how long from the current simulation time the event should be sent. If delay is
a negative number, then it will be changed to 0cloudSimTag - an user-defined number representing the type of an event/message