|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTSim.TSimInterface
public final class TSimInterface
The TSimInterface is the intended interface between TSim and the laboration. It handles the extraction of information from TSim and provides methods for manipulating trains, sensors and switches.
Field Summary | |
---|---|
static int |
SWITCH_LEFT
|
static int |
SWITCH_RIGHT
|
Method Summary | |
---|---|
static TSimInterface |
getInstance()
Returns the single instance (singleton pattern). |
SensorEvent |
getSensor(int trainId)
Blocks the calling thread until the specified train passes a sensor. |
void |
setDebug(boolean debug)
Turns on and off printing of debug info to System.err. |
void |
setSpeed(int trainId,
int speed)
Sets the speed of a train. |
void |
setSwitch(int xPos,
int yPos,
int switchDir)
Sets the direction of the specified switch. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SWITCH_LEFT
public static final int SWITCH_RIGHT
Method Detail |
---|
public static TSimInterface getInstance()
public void setDebug(boolean debug)
public void setSpeed(int trainId, int speed) throws CommandException
trainId
- the id of the train to be affected by the command.speed
- the new speed of the train.
CommandException
- if the supplied id was false (NO_SUCH_TRAIN),
if the speed was illegal (ILLEGAL_SPEED)
or if the train had crashed.public void setSwitch(int xPos, int yPos, int switchDir) throws CommandException
xPos
- the x coordinate of the switch.yPos
- the y coordinate of the switch.switchDir
- the new direction of the switch.
CommandException
- if the coordinates of the switch were invalid
(NO_SUCH_SWITCH) or if there was a train on
the switch (TRAIN_ON_SWITCH)public SensorEvent getSensor(int trainId) throws CommandException, java.lang.InterruptedException
trainId
- the id of the train to wait for.
CommandException
- if the train has crashed.
java.lang.InterruptedException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |