|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.cau.cs.kieler.sj.EmbeddedSJProgram<StateLabel>
StateLabel
- This parameter is used to tell the program all labels existing in the concrete SJ
program. By using this parameter we are able to make sure that every label we working
with is existing in the enumeration of labels in the sub class.public abstract class EmbeddedSJProgram<StateLabel extends Enum<?>>
Basic class for synchronous programming in java. Use this class via extends
to write
a synchronous java program. This class contains the methods to control the program.
EmbeddedABRO
Field Summary | |
---|---|
static int |
INITIAL_TICK
Value of the tickNr if the program is in the initial tick. |
Constructor Summary | |
---|---|
EmbeddedSJProgram(StateLabel startLabel,
int prio)
The constructor to start a new SJ-program. |
|
EmbeddedSJProgram(StateLabel startLabel,
int prio,
SJLogger myLogger)
The constructor to start a new SJ-program. |
Method Summary | |
---|---|
void |
abort()
Does a abort to all descendant created by the thread currently running. |
void |
activateCausalityCheck()
Activates the causality check for all signals of the program. |
void |
addSignals(Signal... declaredSignals)
Method to declare signal used by SJ. |
boolean |
awaitDoneCB(Signal signal)
Waits for a signal after a initial pause. |
Signal[] |
doTick(Signal... inputs)
Do a tick in the SJ program. |
void |
fork(StateLabel label,
int prio)
Part of a Process to execute 2 Program parts in a simulated parallel way. |
void |
forkEB(StateLabel label)
Ends a number of forks and says there this thread should continue after the forks. |
SJLogger |
getLogger()
Returns the logger used by this program. |
String |
getName()
Returns the name of the program. |
Signal[] |
getSignals()
Returns all signals known by the program. |
int |
getTickNr()
Returns the Number of the current tick. |
void |
gotoB(StateLabel label)
Goes to a label and continue with the code at this label. |
void |
haltCB()
Halts at the current position. |
boolean |
isCausalityCheckActive()
Tells if the causality check is active. |
boolean |
isInInitialTick()
Gives you a information if the program is in the initial tick and not has been started. |
boolean |
isTerminated()
Tells us if a SJ program is terminated. |
boolean |
isThreadRunning()
Tells us if at the moment a thread is running. |
boolean |
isTickDone()
Return true if the current tick is Done. |
boolean |
joinDoneCB()
Joins threads by checking if all created descendants of the current thread are executed successful. |
void |
pauseB(StateLabel resumeLabel)
Stops the execution of the state in which it is used for the current tick. |
void |
prioB(StateLabel label,
int prio)
Changes the priority of a thread and cause a new schedule. |
void |
removeSignals(Signal... declaredSignals)
Removes signals and so undeclare them. |
void |
setLogger(SJLogger myLogger)
Set the logger to log the JSON informations about the program. |
StateLabel |
state()
Returns the next state (also called thread) to execute of a program. |
void |
suspend()
Suspends all descendants threads of the current thread. |
void |
termB()
Terminates the current Thread. |
abstract void |
tick()
Function that should be implemented with a SJ-Program. |
String |
toString()
|
void |
transB(StateLabel label)
Aborts all descendants and their descendants of the executing thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INITIAL_TICK
Constructor Detail |
---|
public EmbeddedSJProgram(StateLabel startLabel, int prio)
startLabel
- The label at which the program should start.prio
- The priority the program should start with.public EmbeddedSJProgram(StateLabel startLabel, int prio, SJLogger myLogger)
startLabel
- The label at which the program should start.prio
- The priority the program should start with.myLogger
- The logger to process the logging informations. If you set this to
null
there will be no logging.Method Detail |
---|
public int getTickNr()
doTick(Signal...)
public boolean isInInitialTick()
true
if the program is in an initial tick else
false
.public boolean isTerminated()
true
if the program is terminated else false
.public boolean isTickDone()
doTick(Signal...)
.
true
if the current tick is done. Otherwise the
boolean is false
.doTick(Signal...)
,
tick()
public boolean isThreadRunning()
true
if a thread is running.public abstract void tick()
doTick(Signal...)
doTick(Signal...)
public StateLabel state()
public void addSignals(Signal... declaredSignals)
declaredSignals
- The signal you want to declare.public void removeSignals(Signal... declaredSignals)
declaredSignals
- The signals to removepublic Signal[] doTick(Signal... inputs)
tick()
and does all the management like
incrementing the tick number and logging.
inputs
- The input signals.
public Signal[] getSignals()
public String getName()
public void setLogger(SJLogger myLogger)
null
there will be no logging.
myLogger
- The new logger.getLogger()
public SJLogger getLogger()
null
no logger
is used.
public void activateCausalityCheck()
public boolean isCausalityCheckActive()
true
if the check is active else false.public String toString()
toString
in class Object
public void abort()
fork(Enum, int)
and forkEB(Enum)
.
suspend()
public boolean awaitDoneCB(Signal signal)
true
. Otherwise it will do a pause checked
in the next tick again and return false. For the check of awaitDone in the next tick
awaitDone has to be the first statement after a case so that we can return exactly to this
statement in the next tick.
signal
- the signal to check
true
if signal present and an initial pause done otherwise
false
public void fork(StateLabel label, int prio)
label
- The label for the new thread created with fork.prio
- The priority for the new thread created with fork.public void forkEB(StateLabel label)
label
- The label to continue after the forks.fork(Enum, int)
public void gotoB(StateLabel label)
break;
in your program.
label
- The label to continue at.public void haltCB()
public boolean joinDoneCB()
public void pauseB(StateLabel resumeLabel)
break;
in your program.
Child threads are not destroyed by pause.
resumeLabel
- - the label this thread will resume at in the next tick.public void prioB(StateLabel label, int prio)
label
- the label to continue at the next time executing this threadprio
- the new priority of this threadpublic void suspend()
abort()
public void termB()
break;
in your program.
public void transB(StateLabel label)
state()
is used.
This method is a shorthand for abort()
+ gotoB(Enum)
.
label
- the label to go toabort()
,
gotoB(Enum)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |