|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcz.zcu.fav.kiv.cs.CSProcess
One of the most importatnt classes for the user, he should extend this class, if he wants to describe a process of the distributed simulation.
| Nested Class Summary | |
private class |
CSProcess.Shadow
This nested class extends JSimProcess and represents this CSProcess in the J-Sim. |
| Field Summary | |
private int |
autoID
This ID becomes CSProcess from CSSimulation at the time of birth. |
private int |
fromWho
It says, who has planned the current part of life of this process. |
private int |
ID
This ID gives the user to that CSProcess. |
private java.lang.String |
message
Carries the actual message from neigbour for the current part of life of this process. |
private java.io.PrintWriter |
out
Output channel of parent submodel. |
protected CSSimulation |
parent
The simulation submodel that this process is a part of. |
private CSProcess.Shadow |
shadow
This JSimProcess represents the CSProcess in the J-Sim. |
private java.util.HashMap |
timesToNeighbours
This map remembers neigbours (Integer) and distances to them (Double) of this process. |
| Constructor Summary | |
CSProcess(java.lang.String name,
CSSimulation parent,
int ID,
int[] neighbours,
double[] timeToNeighbour)
Creates the CSProcess and sends his description to the server. |
|
| Method Summary | |
protected void |
activate(double when,
int who)
Schedules the specified neighbour for the specified time with null message. |
protected void |
activate(double when,
int who,
java.lang.String message)
Schedules the specified neighbour for the specified time with the specified message. |
(package private) void |
activateShadow(double when,
java.lang.String message,
int fromWho)
Schedules event for shadow JSimProcess representing this CSProces in J-Sim. |
protected void |
cancel(int who,
java.lang.String message)
Cancel events of the specified process with the specified message. |
protected void |
cancelAll(int who)
Cancel all events of the specified process. |
protected void |
csLife()
The programmer should overwrite this method. |
private java.lang.String |
encode(java.lang.String message)
Avoids transfer of null or "" messages. |
protected void |
error(java.lang.String line)
Prints out a text error message, either to the error output or to the simulation window. |
protected int |
getAutoID()
Returns the local ID assigned by the submodel. |
private double |
getCorrectTime(int who)
Returns the minimum time to the neighbour. |
protected int |
getFromWho()
Returns an ID of a neighbour, who has me scheduled for now. |
protected int |
getID()
Returns an ID specified by user. |
protected java.lang.String |
getMessage()
Returns the actual message for this process in the current part of his life. |
java.lang.String |
getName()
Returns the local ID assigned by the submodel. |
protected CSCalendarEvent |
getNextCE()
Returns the event of my next execution in this step of the distributed simulation. |
protected int |
getNextFromWho()
Returns the neighbour who has scheduled my next execution in this step of the distributed simulation. |
protected java.lang.String |
getNextMessage()
Returns the message for my next execution in this step of the distributed simulation. |
protected double |
getNextTime()
Returns the time of my next execution in this step of the distributed simulation. |
protected long |
getNumber()
Returns the ID assigned by J-Sim. |
protected void |
hold(double howLong)
Holds this process for the specified time with the null message. |
protected void |
hold(double howLong,
java.lang.String message)
Holds this process for the specified time with the specified message. |
protected void |
life()
It's here only to tell the user, that this method is not used in CSProcess. |
protected void |
message(java.lang.String line)
Prints out a text message, either to the standard output or to the simulation window. |
(package private) void |
setFromWho(int fromWho)
Sets the ID of a neighbour, who has scheduled my next execution. |
(package private) void |
setMessage(java.lang.String message)
Sets the actual message for this process for the next part of his life. |
protected boolean |
somethingNext()
Returns True, if there is a message for me in this step of the distributed simulation. |
void |
startAt(double when,
java.lang.String message)
Schedules the first execution of this process. |
protected void |
waitForNextMessage()
Passivates the current process, he will be woken up with a new message for him. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected CSSimulation parent
private final int ID
private final int autoID
private final CSProcess.Shadow shadow
private final java.io.PrintWriter out
private final java.util.HashMap timesToNeighbours
private java.lang.String message
private int fromWho
| Constructor Detail |
public CSProcess(java.lang.String name,
CSSimulation parent,
int ID,
int[] neighbours,
double[] timeToNeighbour)
throws cz.zcu.fav.kiv.jsim.JSimSimulationAlreadyTerminatedException,
cz.zcu.fav.kiv.jsim.JSimInvalidParametersException,
cz.zcu.fav.kiv.jsim.JSimTooManyProcessesException
name - String Name of this process.parent - CSSimulation Parent submodel.ID - int ID of this process from the user.neighbours - int[] Array of neigbours.timeToNeighbour - double[] Distances to these neighbours.| Method Detail |
protected void csLife()
protected final void life()
protected final void waitForNextMessage()
throws cz.zcu.fav.kiv.jsim.JSimSecurityException
cz.zcu.fav.kiv.jsim.JSimSecurityException
protected final void hold(double howLong)
throws cz.zcu.fav.kiv.jsim.JSimSecurityException
howLong - double The time how long should I sleep.
cz.zcu.fav.kiv.jsim.JSimSecurityException
protected final void hold(double howLong,
java.lang.String message)
throws cz.zcu.fav.kiv.jsim.JSimSecurityException
howLong - double The time how long should I sleep.message - String The message I will have after sleep.
cz.zcu.fav.kiv.jsim.JSimSecurityException
public final void startAt(double when,
java.lang.String message)
throws cz.zcu.fav.kiv.jsim.JSimSecurityException,
cz.zcu.fav.kiv.jsim.JSimInvalidParametersException,
CSSecurityException
when - double Whenmessage - String With what message.
CSSecurityException - This process has already started.
cz.zcu.fav.kiv.jsim.JSimSecurityException
cz.zcu.fav.kiv.jsim.JSimInvalidParametersException
protected final void activate(double when,
int who)
throws CSSecurityException
CSSecurityException - Attempt to activate wrong neighbour and/or at wrong time.
protected final void activate(double when,
int who,
java.lang.String message)
throws CSSecurityException
when - double When should he be woken up.who - int Who is this message for.message - String What message will he have in scheduling part of life.
CSSecurityException - Attempt to activate a wrong neighbour and/or at a wrong time.protected final void cancelAll(int who)
who - int ID of requested process
protected final void cancel(int who,
java.lang.String message)
who - int ID of requested processmessage - String Requested messagesprotected void message(java.lang.String line)
protected void error(java.lang.String line)
private final java.lang.String encode(java.lang.String message)
message - String
protected final java.lang.String getMessage()
final void setMessage(java.lang.String message)
protected final int getFromWho()
final void setFromWho(int fromWho)
protected final int getID()
protected final int getAutoID()
protected final long getNumber()
public final java.lang.String getName()
protected final boolean somethingNext()
protected final double getNextTime()
protected final java.lang.String getNextMessage()
protected final int getNextFromWho()
protected final CSCalendarEvent getNextCE()
private final double getCorrectTime(int who)
who - int To what neigbour.
final void activateShadow(double when,
java.lang.String message,
int fromWho)
when - double For what time.message - String With what message.fromWho - int Who has scheduled this event.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||