public final class TSimInterface
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
static int |
SWITCH_LEFT |
|
static int |
SWITCH_RIGHT |
Modifier and Type | Method | Description |
---|---|---|
static TSimInterface |
getInstance() |
Returns the single instance (singleton pattern).
|
SensorEvent |
getSensor(int trainId) |
Blocks the calling thread until the specified train passes a sensor.
|
static void |
init(java.io.InputStream in,
java.io.OutputStream out) |
|
void |
setDebug(boolean debug) |
Turns on and off printing of debug info
|
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.
|
public static final int SWITCH_LEFT
public static final int SWITCH_RIGHT
public static void init(java.io.InputStream in, java.io.OutputStream out)
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