use of jmri.jmrit.operations.trains.Train in project JMRI by JMRI.
the class AbstractOperationsServer method terminateTrain.
/**
* tells Operations that a train has terminated. If not found in Operations,
* an error message is sent to the client
*
* @param trainName is the name of the train
* @return the termination String
* @throws IOException on failure to send an error message to the client
*/
public String terminateTrain(String trainName) throws IOException {
Train train = tm.getTrainByName(trainName);
if (train != null) {
train.terminate();
return constructTrainStatus(trainName);
}
sendErrorStatus("ERROR train name doesn't exist " + trainName);
return null;
}
use of jmri.jmrit.operations.trains.Train in project JMRI by JMRI.
the class AbstractOperationsServer method constructTrainNumberOfCars.
/**
* constructs a String containing the number of cars in a train
*
* @param trainName is the name of the desired train. If not found in
* Operations, an error message is sent to the client
* @return the number of cars in a train, as known by Operations
* @throws IOException on failure to send an error message to the client
*/
public String constructTrainNumberOfCars(String trainName) throws IOException {
Train train = tm.getTrainByName(trainName);
if (train != null) {
return String.valueOf(train.getNumberCarsInTrain());
}
sendErrorStatus("ERROR train name doesn't exist " + trainName);
return null;
}
use of jmri.jmrit.operations.trains.Train in project JMRI by JMRI.
the class AbstractOperationsServer method constructTrainCaboose.
/**
* constructs a String containing the caboose on a train
*
* @param trainName is the name of the desired train. If not found in
* Operations, an error message is sent to the client
* @return the caboose on a train, as known by Operations
* @throws IOException on failure to send an error message to the client
*/
public String constructTrainCaboose(String trainName) throws IOException {
Train train = tm.getTrainByName(trainName);
if (train != null) {
return train.getCabooseRoadAndNumber();
}
sendErrorStatus("ERROR train name doesn't exist " + trainName);
return null;
}
use of jmri.jmrit.operations.trains.Train in project JMRI by JMRI.
the class AbstractOperationsServer method setTrainLocation.
/**
* constructs a String containing the location of a train
*
* @param trainName is the name of the desired train. If not found in
* Operations, an error message is sent to the client
* @param locationName is the name of the desired location.
* @return the train's location, as known by Operations
* @throws IOException on failure to send an error message to the client
*/
public String setTrainLocation(String trainName, String locationName) throws IOException {
log.debug("Set train " + trainName + " Location " + locationName);
Train train = tm.getTrainByName(trainName);
if (train != null) {
if (!exactLocationName && train.move(locationName) || exactLocationName && train.moveToNextLocation(locationName)) {
return constructTrainLocation(trainName);
} else {
sendErrorStatus("WARNING move of " + trainName + " to location " + locationName + " failed. Train's current location " + train.getCurrentLocationName() + " next location " + train.getNextLocationName());
}
} else {
sendErrorStatus("ERROR train name doesn't exist " + trainName);
}
return null;
}
use of jmri.jmrit.operations.trains.Train in project JMRI by JMRI.
the class AbstractOperationsServer method constructTrainLocation.
/**
* constructs a String containing the location of a train
*
* @param trainName is the name of the desired train. If not found in
* Operations, an error message is sent to the client
* @return the train's location, as known by Operations
* @throws IOException on failure to send an error message to the client
*/
public String constructTrainLocation(String trainName) throws IOException {
Train train = tm.getTrainByName(trainName);
if (train != null) {
return train.getCurrentLocationName();
}
sendErrorStatus("ERROR train name doesn't exist " + trainName);
return null;
}
Aggregations