public class TrainController extends java.lang.Object implements TrainControllerInterface
Modifier and Type | Field and Description |
---|---|
protected static TrainController[] |
allTrainControllers |
protected boolean |
applyBrakes |
protected boolean |
applyEBrakes |
protected boolean |
coast |
protected double |
distanceTraveled |
protected boolean |
estop |
protected int |
ID |
protected boolean |
leftShouldBeOpen |
protected boolean |
lightsShouldBeOn |
protected static int |
numTrains |
protected boolean |
onSwitch |
protected double |
Pcmd |
protected boolean |
rightShouldBeOpen |
protected java.lang.String |
station |
protected boolean |
stop |
protected double |
t |
protected MapTracker |
theMap |
protected Train |
theTrain |
Constructor and Description |
---|
TrainController() |
TrainController(boolean showUI,
Train newTrain,
int trainID) |
TrainController(int trainID) |
TrainController(Train newTrain,
int trackID) |
TrainController(Train newTrain,
int trainID,
StaticTrack track,
StaticBlock startBlock) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addTrain(Train newTrain,
int trainID) |
protected void |
addTrainController(TrainController newTrainController) |
protected boolean |
checkBeacon() |
protected boolean |
checkForTrain() |
protected double |
computeSafeBrake()
Computes the minimum safe braking distance for a train, given its
Speed.
|
protected double |
computeSafeSpeed()
Computes the maximum safe speed for a train, given an authority.
|
protected void |
displayStation(java.lang.String name)
Displays Station and the distance to that station.
|
protected void |
doAllUpdates() |
protected boolean |
emergencyStop()
Bring the train to a complete stop regardless of circumstances using the ebrake.
|
protected int |
getID() |
protected int |
getNumTrains() |
double |
getPower()
Computes the necessary power at which to set a train, given an authority.
|
double |
getPower2() |
protected TrainController |
getTrainControllerByID(int traincontrollerID) |
static void |
initUI() |
protected boolean |
justStop()
Bring the train to a complete stop regardless of circumstances as quickly
as safely possible.
|
static void |
main(java.lang.String[] args)
Main does nothing.
|
protected boolean |
sendForService()
Does the necessary work to send a train in for maintenance.
|
protected byte |
setDoors(boolean leftOpen,
boolean rightOpen)
Commands the Train in question to open their right or left doors.
|
protected byte |
setDoors(int status) |
protected void |
setKiKp(double newKi,
double newKp) |
protected void |
setKu(double newVal) |
protected boolean |
setLights(boolean on)
Commands the Train in question to turn their lights on or off.
|
protected void |
setT(double newT) |
protected double |
setTemp(double temperature) |
protected void |
setTrack(StaticTrack newTrack) |
static void |
show() |
void |
signalFailure(boolean isFailed) |
java.lang.String |
toString() |
protected void |
updateDistTraveled() |
protected void |
updateStation() |
protected void |
updateTime() |
protected boolean |
youCanGoNow()
Allow train to start up again.
|
protected static int numTrains
protected static TrainController[] allTrainControllers
protected MapTracker theMap
protected Train theTrain
protected boolean onSwitch
protected double t
protected double Pcmd
protected double distanceTraveled
protected boolean leftShouldBeOpen
protected boolean rightShouldBeOpen
protected boolean lightsShouldBeOn
protected boolean applyBrakes
protected boolean applyEBrakes
protected boolean stop
protected boolean estop
protected boolean coast
protected java.lang.String station
protected int ID
public TrainController()
public TrainController(int trainID)
public TrainController(Train newTrain, int trackID)
public TrainController(boolean showUI, Train newTrain, int trainID)
public TrainController(Train newTrain, int trainID, StaticTrack track, StaticBlock startBlock)
public static void initUI()
public static void main(java.lang.String[] args)
args
- the command line argumentspublic static void show()
protected void setTrack(StaticTrack newTrack)
protected void doAllUpdates()
protected void updateDistTraveled()
protected void updateTime()
protected boolean checkBeacon()
protected void updateStation()
protected double computeSafeBrake()
protected double computeSafeSpeed()
public double getPower()
getPower
in interface TrainControllerInterface
public double getPower2()
protected void setKu(double newVal)
protected void setKiKp(double newKi, double newKp)
protected boolean setLights(boolean on)
on
- is true if the lights should be on, and false if the lights
should be off.protected byte setDoors(boolean leftOpen, boolean rightOpen)
leftOpen
- is true if the left doors should be opened (or remain
open); false if the doors should be closed (or remain closed).rightOpen
- is true if the right doors should be opened (or remain
open); false if the doors should be closed (or remain closed).protected byte setDoors(int status)
protected boolean justStop()
protected boolean emergencyStop()
protected boolean youCanGoNow()
protected boolean sendForService()
public void signalFailure(boolean isFailed)
protected void displayStation(java.lang.String name)
name
- is the name of the stationprotected void addTrainController(TrainController newTrainController)
protected int getNumTrains()
protected TrainController getTrainControllerByID(int traincontrollerID)
protected int getID()
protected double setTemp(double temperature)
protected boolean addTrain(Train newTrain, int trainID)
protected boolean checkForTrain()
protected void setT(double newT)
public java.lang.String toString()
toString
in class java.lang.Object