|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTSim.TSimInterface
public 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
Switch state: switch points to the left. |
static int |
SWITCH_RIGHT
Switch state: switch points to the right. |
Method Summary | |
---|---|
Semaphore |
getSemaphore(int s)
Create a semaphore with specified starting value. |
SensorEvent |
getSensor()
Wait until the train passes a sensor. |
void |
loadUnload()
Load and unload as necessary at station. |
void |
run()
|
void |
setSpeed(int speed)
Set train target speed to the given value. |
void |
setSwitch(int xPos,
int yPos,
int switchPos)
Set the position 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 void run()
run
in interface java.lang.Runnable
public void setSpeed(int speed) throws CommandException
speed
- the new speed of the train.
CommandException
- if the train has encountered a fatal errorpublic void loadUnload() throws CommandException
CommandException
- if the train has encountered a fatal errorpublic void setSwitch(int xPos, int yPos, int switchPos) throws CommandException
xPos
- the x coordinate of the switch.yPos
- the y coordinate of the switch.switchPos
- the new position 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() throws CommandException
CommandException
- if the train has encountered a fatal error.public Semaphore getSemaphore(int s)
s
- Initial value to give semaphore (if not already created).
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |