Search in sources :

Example 1 with Train

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;
}
Also used : Train(jmri.jmrit.operations.trains.Train)

Example 2 with Train

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;
}
Also used : Train(jmri.jmrit.operations.trains.Train)

Example 3 with Train

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;
}
Also used : Train(jmri.jmrit.operations.trains.Train)

Example 4 with Train

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;
}
Also used : Train(jmri.jmrit.operations.trains.Train)

Example 5 with Train

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;
}
Also used : Train(jmri.jmrit.operations.trains.Train)

Aggregations

Train (jmri.jmrit.operations.trains.Train)90 RouteLocation (jmri.jmrit.operations.routes.RouteLocation)21 Route (jmri.jmrit.operations.routes.Route)20 Track (jmri.jmrit.operations.locations.Track)14 Location (jmri.jmrit.operations.locations.Location)13 Car (jmri.jmrit.operations.rollingstock.cars.Car)12 TrainManager (jmri.jmrit.operations.trains.TrainManager)11 LocationManager (jmri.jmrit.operations.locations.LocationManager)8 CarManager (jmri.jmrit.operations.rollingstock.cars.CarManager)8 IOException (java.io.IOException)5 JLabel (javax.swing.JLabel)5 RollingStock (jmri.jmrit.operations.rollingstock.RollingStock)5 Schedule (jmri.jmrit.operations.locations.schedules.Schedule)4 ScheduleItem (jmri.jmrit.operations.locations.schedules.ScheduleItem)4 ScheduleManager (jmri.jmrit.operations.locations.schedules.ScheduleManager)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 JCheckBox (javax.swing.JCheckBox)3 JPanel (javax.swing.JPanel)3 CarTypes (jmri.jmrit.operations.rollingstock.cars.CarTypes)3