Search in sources :

Example 41 with Route

use of jmri.jmrit.operations.routes.Route in project JMRI by JMRI.

the class Train method services.

public boolean services(PrintWriter buildReport, Car car) {
    boolean addToReport = Setup.getRouterBuildReportLevel().equals(SEVEN);
    setServiceStatus(NONE);
    // check to see if train can carry car
    if (!acceptsTypeName(car.getTypeName())) {
        if (addToReport) {
            TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotServiceCarType"), new Object[] { getName(), car.toString(), car.getTypeName() }));
        }
        return false;
    }
    if (!acceptsLoad(car.getLoadName(), car.getTypeName())) {
        if (addToReport) {
            TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotServiceCarLoad"), new Object[] { getName(), car.toString(), car.getTypeName(), car.getLoadName() }));
        }
        return false;
    }
    if (!acceptsBuiltDate(car.getBuilt()) || !acceptsOwnerName(car.getOwner()) || !acceptsRoadName(car.getRoadName())) {
        if (addToReport) {
            TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotServiceCar"), new Object[] { getName(), car.toString() }));
        }
        return false;
    }
    int length = car.getTotalLength();
    // car can be a kernel so get total length
    if (car.getKernel() != null) {
        length = car.getKernel().getTotalLength();
    }
    Route route = getRoute();
    if (route != null) {
        // determine if the car's location and destination is serviced by this train
        if (route.getLastLocationByName(car.getLocationName()) == null) {
            if (addToReport) {
                TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainNotThisLocation"), new Object[] { getName(), car.getLocationName() }));
            }
            return false;
        }
        if (car.getDestination() != null && route.getLastLocationByName(car.getDestinationName()) == null) {
            if (addToReport) {
                TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainNotThisLocation"), new Object[] { getName(), car.getDestinationName() }));
            }
            return false;
        }
        List<RouteLocation> rLocations = route.getLocationsBySequenceList();
        for (int j = 0; j < rLocations.size(); j++) {
            RouteLocation rLoc = rLocations.get(j);
            if (rLoc.getName().equals(car.getLocationName()) && rLoc.isPickUpAllowed() && rLoc.getMaxCarMoves() > 0 && !skipsLocation(rLoc.getId()) && ((car.getLocation().getTrainDirections() & rLoc.getTrainDirection()) != 0 || isLocalSwitcher())) {
                if (car.getTrack() != null) {
                    if (((car.getTrack().getTrainDirections() & rLoc.getTrainDirection()) == 0 && !isLocalSwitcher()) || !car.getTrack().acceptsPickupTrain(this)) {
                        if (addToReport) {
                            TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotServiceCarFrom"), new Object[] { getName(), car.toString(), car.getLocationName(), car.getTrackName(), rLoc.getId() }));
                        }
                        continue;
                    }
                }
                if (debugFlag) {
                    log.debug("Car ({}) can be picked up by train ({}) location ({}, {}) destination ({}, {})", car.toString(), getName(), car.getLocationName(), car.getTrackName(), car.getDestinationName(), car.getDestinationTrackName());
                }
                if (addToReport) {
                    TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanPickUpCar"), new Object[] { getName(), car.toString(), car.getLocationName(), car.getTrackName(), rLoc.getId() }));
                }
                if (car.getDestination() == null) {
                    if (debugFlag) {
                        log.debug("Car ({}) does not have a destination", car.toString());
                    }
                    return true;
                }
                // now check car's destination
                for (int k = j; k < rLocations.size(); k++) {
                    RouteLocation rldest = rLocations.get(k);
                    if (rldest.getName().equals(car.getDestinationName()) && rldest.isDropAllowed() && rldest.getMaxCarMoves() > 0 && !skipsLocation(rldest.getId()) && ((car.getDestination().getTrainDirections() & rldest.getTrainDirection()) != 0 || isLocalSwitcher()) && (!Setup.isCheckCarDestinationEnabled() || car.getTrack() == null || car.getTrack().acceptsDestination(car.getDestination()))) {
                        // found a destination, now check destination track
                        if (car.getDestinationTrack() != null) {
                            if ((car.getDestinationTrack().getTrainDirections() & rldest.getTrainDirection()) == 0 && !isLocalSwitcher()) {
                                if (addToReport) {
                                    TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("buildCanNotDropRsUsingTrain"), new Object[] { car.toString(), rldest.getTrainDirectionString() }));
                                    TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("buildCanNotDropRsUsingTrain2"), new Object[] { car.getDestinationTrackName() }));
                                }
                                continue;
                            }
                            if (!car.getDestinationTrack().acceptsDropTrain(this)) {
                                if (addToReport) {
                                    TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("buildCanNotDropCarTrain"), new Object[] { car.toString(), getName(), car.getDestinationTrack().getTrackTypeName(), car.getDestinationTrackName() }));
                                }
                                continue;
                            }
                        } else if (rldest.getLocation().isStaging() && getStatusCode() == CODE_BUILDING && getTerminationTrack() != null && getTerminationTrack().getLocation() == rldest.getLocation()) {
                            if (debugFlag) {
                                log.debug("Car ({}) destination is staging, check train ({}) termination track ({})", car.toString(), getName(), getTerminationTrack().getName());
                            }
                            String status = car.testDestination(getTerminationTrack().getLocation(), getTerminationTrack());
                            if (!status.equals(Track.OKAY)) {
                                if (addToReport) {
                                    TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotDeliverToStaging"), new Object[] { getName(), car.toString(), getTerminationTrack().getLocation().getName(), getTerminationTrack().getName(), status }));
                                }
                                continue;
                            }
                        } else {
                            if (debugFlag) {
                                log.debug("Find track for car ({}) at destination ({})", car.toString(), car.getDestinationName());
                            }
                            // determine if there's a track that is willing to accept this car
                            String status = "";
                            List<Track> tracks = rldest.getLocation().getTrackList();
                            for (Track track : tracks) {
                                if ((track.getTrainDirections() & rldest.getTrainDirection()) == 0 && !isLocalSwitcher()) {
                                    if (addToReport) {
                                        TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("buildCanNotDropRsUsingTrain"), new Object[] { car.toString(), rldest.getTrainDirectionString() }));
                                        TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("buildCanNotDropRsUsingTrain2"), new Object[] { track.getName() }));
                                    }
                                    continue;
                                }
                                if (!track.acceptsDropTrain(this)) {
                                    if (addToReport) {
                                        TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("buildCanNotDropCarTrain"), new Object[] { car.toString(), getName(), track.getTrackTypeName(), track.getName() }));
                                    }
                                    continue;
                                }
                                // will the track accept this car?
                                status = track.accepts(car);
                                if (status.equals(Track.OKAY) || status.startsWith(Track.LENGTH)) {
                                    if (debugFlag) {
                                        log.debug("Found track ({}) for car ({})", track.getName(), car.toString());
                                    }
                                    // yes, done
                                    break;
                                }
                            }
                            if (!status.equals(Track.OKAY) && !status.startsWith(Track.LENGTH)) {
                                if (debugFlag) {
                                    log.debug("Destination ({}) can not service car ({}) using train ({}) no track available", car.getDestinationName(), car.toString(), // NOI18N
                                    getName());
                                }
                                if (addToReport) {
                                    TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotDeliverNoTracks"), new Object[] { getName(), car.toString(), car.getDestinationName(), rldest.getId() }));
                                }
                                continue;
                            }
                        }
                        // carry cars only to terminal?
                        if (isSendCarsToTerminalEnabled() && !TrainCommon.splitString(car.getLocationName()).equals(TrainCommon.splitString(getTrainDepartsName())) && !TrainCommon.splitString(car.getDestinationName()).equals(TrainCommon.splitString(getTrainTerminatesName()))) {
                            if (debugFlag) {
                                log.debug("option send cars to terminal is enabled");
                            }
                            if (addToReport) {
                                TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotCarryCarOption"), new Object[] { getName(), car.toString(), car.getLocationName(), car.getTrackName(), car.getDestinationName(), car.getDestinationTrackName() }));
                            }
                            continue;
                        }
                        // allow car to return to staging?
                        if (isAllowReturnToStagingEnabled() && car.getTrack().getTrackType().equals(Track.STAGING) && rldest.getLocation() == car.getLocation()) {
                            if (addToReport) {
                                TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanReturnCarToStaging"), new Object[] { getName(), car.toString(), car.getDestinationName(), car.getDestinationTrackName() }));
                            }
                            return true;
                        }
                        // is this a local move?
                        if (!isAllowLocalMovesEnabled() && !car.isCaboose() && !car.hasFred() && !car.isPassenger() && TrainCommon.splitString(car.getLocationName()).equals(TrainCommon.splitString(car.getDestinationName()))) {
                            if (debugFlag) {
                                log.debug("Local moves is disabled");
                            }
                            if (addToReport) {
                                TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotPerformLocalMove"), new Object[] { getName(), car.toString(), car.getLocationName() }));
                            }
                            continue;
                        }
                        // Can cars travel from origin to terminal?
                        if (!isAllowThroughCarsEnabled() && TrainCommon.splitString(getTrainDepartsName()).equals(TrainCommon.splitString(rLoc.getName())) && TrainCommon.splitString(getTrainTerminatesName()).equals(TrainCommon.splitString(rldest.getName())) && !isLocalSwitcher() && !car.isCaboose() && !car.hasFred() && !car.isPassenger()) {
                            if (debugFlag) {
                                log.debug("Through car (" + car.toString() + ") not allowed");
                            }
                            if (addToReport) {
                                TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainDoesNotCarryOriginTerminal"), new Object[] { getName(), car.getLocationName(), car.getDestinationName() }));
                            }
                            continue;
                        }
                        // check to see if moves are available
                        if (getStatusCode() == CODE_BUILDING && rldest.getMaxCarMoves() - rldest.getCarMoves() <= 0) {
                            setServiceStatus(MessageFormat.format(Bundle.getMessage("trainNoMoves"), new Object[] { getName(), getRoute().getName(), rldest.getId(), rldest.getName() }));
                            if (debugFlag) {
                                log.debug("No available moves for destination " + rldest.getName());
                            }
                            if (addToReport) {
                                TrainCommon.addLine(buildReport, SEVEN, getServiceStatus());
                            }
                            continue;
                        }
                        if (debugFlag) {
                            log.debug("Car (" + car.toString() + ") can be dropped by train (" + getName() + ") to (" + car.getDestinationName() + // NOI18N
                            ", " + car.getDestinationTrackName() + ")");
                        }
                        return true;
                    }
                    // check to see if train length is okay
                    if (getStatusCode() == CODE_BUILDING && rLoc.getTrainLength() + length > rLoc.getMaxTrainLength()) {
                        setServiceStatus(MessageFormat.format(Bundle.getMessage("trainExceedsMaximumLength"), new Object[] { getName(), getRoute().getName(), rLoc.getId(), rLoc.getMaxTrainLength(), Setup.getLengthUnit().toLowerCase(), rLoc.getName(), car.toString() }));
                        if (debugFlag) {
                            log.debug("Car (" + car.toString() + ") exceeds maximum train length " + rldest.getMaxTrainLength() + // NOI18N
                            " when departing (" + rldest.getName() + ")");
                        }
                        if (addToReport) {
                            TrainCommon.addLine(buildReport, SEVEN, getServiceStatus());
                        }
                        return false;
                    }
                }
                if (addToReport) {
                    TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotDeliverToDestination"), new Object[] { getName(), car.toString(), car.getDestinationName(), car.getDestinationTrackName() }));
                }
            } else if (addToReport && rLoc.getName().equals(car.getLocationName())) {
                TrainCommon.addLine(buildReport, SEVEN, MessageFormat.format(Bundle.getMessage("trainCanNotServiceCarFrom"), new Object[] { getName(), car.toString(), car.getLocationName(), car.getTrackName(), rLoc.getId() }));
            }
        }
    }
    if (debugFlag) {
        log.debug("Train ({}) can't service car ({}) from ({}, {})", getName(), car.toString(), car.getLocationName(), car.getTrackName());
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) RouteLocation(jmri.jmrit.operations.routes.RouteLocation) Route(jmri.jmrit.operations.routes.Route) Track(jmri.jmrit.operations.locations.Track)

Example 42 with Route

use of jmri.jmrit.operations.routes.Route in project JMRI by JMRI.

the class Train method getNumberEmptyCarsInTrain.

/**
     * Gets the number of empty cars in the train when train departs the route
     * location.
     * @param routeLocation The RouteLocation.
     *
     * @return The number of empty cars in the train departing the route
     *         location.
     */
public int getNumberEmptyCarsInTrain(RouteLocation routeLocation) {
    int number = 0;
    Route route = getRoute();
    if (route != null) {
        for (RouteLocation rl : route.getLocationsBySequenceList()) {
            for (RollingStock rs : CarManager.instance().getList(this)) {
                Car car = (Car) rs;
                if (!car.getLoadType().equals(CarLoad.LOAD_TYPE_EMPTY)) {
                    continue;
                }
                if (car.getRouteLocation() == rl) {
                    number++;
                }
                if (car.getRouteDestination() == rl) {
                    number--;
                }
            }
            if (rl == routeLocation) {
                break;
            }
        }
    }
    return number;
}
Also used : Car(jmri.jmrit.operations.rollingstock.cars.Car) RouteLocation(jmri.jmrit.operations.routes.RouteLocation) Route(jmri.jmrit.operations.routes.Route) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock)

Example 43 with Route

use of jmri.jmrit.operations.routes.Route in project JMRI by JMRI.

the class Train method getTrainHorsePower.

/**
     * Gets the train's locomotive horsepower at the route location specified
     *
     * @param routeLocation The route location
     * @return The train's locomotive horsepower at the route location
     */
public int getTrainHorsePower(RouteLocation routeLocation) {
    int hp = 0;
    Route route = getRoute();
    if (route != null) {
        for (RouteLocation rl : route.getLocationsBySequenceList()) {
            for (RollingStock rs : EngineManager.instance().getList(this)) {
                Engine eng = (Engine) rs;
                if (eng.getRouteLocation() == rl) {
                    hp += eng.getHpInteger();
                }
                if (eng.getRouteDestination() == rl) {
                    hp += -eng.getHpInteger();
                }
            }
            if (rl == routeLocation) {
                break;
            }
        }
    }
    return hp;
}
Also used : RouteLocation(jmri.jmrit.operations.routes.RouteLocation) Route(jmri.jmrit.operations.routes.Route) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock) Engine(jmri.jmrit.operations.rollingstock.engines.Engine)

Example 44 with Route

use of jmri.jmrit.operations.routes.Route in project JMRI by JMRI.

the class TrainCsvSwitchLists method buildSwitchList.

/**
     * builds a csv file containing the switch list for a location
     * @param location The Location requesting a switch list.
     *
     * @return File
     */
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
public File buildSwitchList(Location location) {
    // create csv switch list file
    File file = TrainManagerXml.instance().createCsvSwitchListFile(location.getName());
    PrintWriter fileOut = null;
    try {
        fileOut = new // NOI18N
        PrintWriter(// NOI18N
        new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")), // NOI18N
        true);
    } catch (IOException e) {
        log.error("Can not open CSV switch list file: {}", file.getName());
        return null;
    }
    // build header
    addLine(fileOut, HEADER);
    // this is a switch list
    addLine(fileOut, SWL);
    addLine(fileOut, RN + ESC + Setup.getRailroadName() + ESC);
    addLine(fileOut, LN + ESC + splitString(location.getName()) + ESC);
    addLine(fileOut, PRNTR + ESC + location.getDefaultPrinterName() + ESC);
    addLine(fileOut, SWLC + ESC + location.getSwitchListComment() + ESC);
    // add location comment
    if (Setup.isPrintLocationCommentsEnabled() && !location.getComment().equals(Location.NONE)) {
        // location comment can have multiple lines
        // NOI18N
        String[] comments = location.getComment().split(NEW_LINE);
        for (String comment : comments) {
            addLine(fileOut, LC + ESC + comment + ESC);
        }
    }
    addLine(fileOut, VT + getDate(true));
    // get a list of trains sorted by arrival time
    List<Train> trains = TrainManager.instance().getTrainsArrivingThisLocationList(location);
    for (Train train : trains) {
        if (!train.isBuilt()) {
            // train wasn't built so skip
            continue;
        }
        if (!Setup.isSwitchListRealTime() && train.getSwitchListStatus().equals(Train.PRINTED)) {
            // already printed this train
            continue;
        }
        int pickupCars = 0;
        int dropCars = 0;
        int stops = 1;
        boolean trainDone = false;
        List<Car> carList = CarManager.instance().getByTrainDestinationList(train);
        List<Engine> enginesList = EngineManager.instance().getByTrainBlockingList(train);
        // does the train stop once or more at this location?
        Route route = train.getRoute();
        if (route == null) {
            // no route for this train
            continue;
        }
        List<RouteLocation> routeList = route.getLocationsBySequenceList();
        RouteLocation rlPrevious = null;
        // need to know where in the route we are for the various comments
        for (RouteLocation rl : routeList) {
            if (!splitString(rl.getName()).equals(splitString(location.getName()))) {
                rlPrevious = rl;
                continue;
            }
            String expectedArrivalTime = train.getExpectedArrivalTime(rl);
            if (expectedArrivalTime.equals(Train.ALREADY_SERVICED)) {
                trainDone = true;
            }
            // if it terminates at this location
            if (stops == 1) {
                // newLine(fileOut);
                addLine(fileOut, TN + train.getName());
                addLine(fileOut, TM + train.getDescription());
                if (train.isTrainEnRoute()) {
                    addLine(fileOut, TIR);
                    addLine(fileOut, ETE + expectedArrivalTime);
                } else {
                    addLine(fileOut, DL + splitString(splitString(train.getTrainDepartsName())));
                    addLine(fileOut, DT + train.getDepartureTime());
                    if (rl == train.getRoute().getDepartsRouteLocation() && routeList.size() > 1) {
                        addLine(fileOut, TD + splitString(rl.getName()) + DEL + rl.getTrainDirectionString());
                    }
                    if (rl != train.getRoute().getDepartsRouteLocation()) {
                        addLine(fileOut, ETA + expectedArrivalTime);
                        addLine(fileOut, TA + splitString(rl.getName()) + DEL + rl.getTrainDirectionString());
                    }
                }
                if (rl == train.getRoute().getTerminatesRouteLocation()) {
                    addLine(fileOut, TT + splitString(rl.getName()));
                }
            }
            if (stops > 1) {
                // Print visit number, etc. only if previous location wasn't the same
                if (rlPrevious == null || !splitString(rl.getName()).equals(splitString(rlPrevious.getName()))) {
                    // After the first time a train stops at a location provide:
                    // if the train has started its route
                    // the arrival time or relative time if the train has started its route
                    // the train's direction when it arrives
                    // if it terminate at this location
                    addLine(fileOut, VN + stops);
                    if (train.isTrainEnRoute()) {
                        addLine(fileOut, ETE + expectedArrivalTime);
                    } else {
                        addLine(fileOut, ETA + expectedArrivalTime);
                    }
                    addLine(fileOut, TA + splitString(rl.getName()) + DEL + rl.getTrainDirectionString());
                    if (rl == train.getRoute().getTerminatesRouteLocation()) {
                        addLine(fileOut, TT + splitString(rl.getName()));
                    }
                } else {
                    // don't bump stop count, same location
                    stops--;
                    // Does the train change direction?
                    if (rl.getTrainDirection() != rlPrevious.getTrainDirection()) {
                        addLine(fileOut, TDC + rl.getTrainDirectionString());
                    }
                }
            }
            rlPrevious = rl;
            // add route comment
            if (!rl.getComment().equals(RouteLocation.NONE)) {
                addLine(fileOut, RLC + ESC + rl.getComment() + ESC);
            }
            // engine change or helper service?
            checkForEngineOrCabooseChange(fileOut, train, rl);
            // go through the list of engines and determine if the engine departs here
            for (Engine engine : enginesList) {
                if (engine.getRouteLocation() == rl && engine.getTrack() != null) {
                    fileOutCsvEngine(fileOut, engine, PL);
                }
            }
            // block pick up cars by destination
            for (RouteLocation rld : routeList) {
                for (Car car : carList) {
                    if (car.getRouteLocation() == rl && car.getTrack() != null && car.getRouteDestination() == rld) {
                        pickupCars++;
                        int count = 0;
                        if (car.isUtility()) {
                            count = countPickupUtilityCars(carList, car, !IS_MANIFEST);
                            if (count == 0) {
                                // already done this set of utility cars
                                continue;
                            }
                        }
                        fileOutCsvCar(fileOut, car, PC, count);
                    }
                }
            }
            for (Engine engine : enginesList) {
                if (engine.getRouteDestination() == rl) {
                    fileOutCsvEngine(fileOut, engine, SL);
                }
            }
            // now do car set outs
            for (Car car : carList) {
                if (car.getRouteDestination() == rl) {
                    dropCars++;
                    int count = 0;
                    if (car.isUtility()) {
                        count = countSetoutUtilityCars(carList, car, !LOCAL, !IS_MANIFEST);
                        if (count == 0) {
                            // already done this set of utility cars
                            continue;
                        }
                    }
                    fileOutCsvCar(fileOut, car, SC, count);
                }
            }
            stops++;
            if (rl != train.getRoute().getTerminatesRouteLocation()) {
                addLine(fileOut, TL + train.getTrainLength(rl) + DEL + train.getNumberEmptyCarsInTrain(rl) + DEL + train.getNumberCarsInTrain(rl));
                addLine(fileOut, TW + train.getTrainWeight(rl));
            }
        }
        if (trainDone && pickupCars == 0 && dropCars == 0) {
            addLine(fileOut, TDONE);
        } else if (stops > 1) {
            if (pickupCars == 0) {
                addLine(fileOut, NCPU);
            }
            if (dropCars == 0) {
                addLine(fileOut, NCSO);
            }
            // done with this train
            addLine(fileOut, TEND + train.getName());
        }
    }
    // done with switch list
    addLine(fileOut, END);
    // now list hold cars
    List<RollingStock> rsByLocation = CarManager.instance().getByLocationList();
    List<Car> carList = new ArrayList<Car>();
    for (RollingStock rs : rsByLocation) {
        if (rs.getLocation() != null && splitString(rs.getLocation().getName()).equals(splitString(location.getName())) && rs.getRouteLocation() == null) {
            carList.add((Car) rs);
        }
    }
    // list utility cars by quantity
    clearUtilityCarTypes();
    for (Car car : carList) {
        int count = 0;
        if (car.isUtility()) {
            count = countPickupUtilityCars(carList, car, !IS_MANIFEST);
            if (count == 0) {
                // already done this set of utility cars
                continue;
            }
        }
        fileOutCsvCar(fileOut, car, HOLD, count);
    }
    // done with hold cars
    addLine(fileOut, END);
    // Are there any cars that need to be found?
    listCarsLocationUnknown(fileOut);
    fileOut.flush();
    fileOut.close();
    location.setStatus(Location.CSV_GENERATED);
    return file;
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) RouteLocation(jmri.jmrit.operations.routes.RouteLocation) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock) BufferedWriter(java.io.BufferedWriter) Car(jmri.jmrit.operations.rollingstock.cars.Car) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) Engine(jmri.jmrit.operations.rollingstock.engines.Engine) Route(jmri.jmrit.operations.routes.Route) PrintWriter(java.io.PrintWriter) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 45 with Route

use of jmri.jmrit.operations.routes.Route in project JMRI by JMRI.

the class TrainEditFrame method comboBoxActionPerformed.

@Override
public void comboBoxActionPerformed(java.awt.event.ActionEvent ae) {
    if (_train == null) {
        return;
    }
    if (ae.getSource() == numEnginesBox) {
        modelEngineBox.setEnabled(!numEnginesBox.getSelectedItem().equals("0"));
        roadEngineBox.setEnabled(!numEnginesBox.getSelectedItem().equals("0"));
    }
    if (ae.getSource() == modelEngineBox) {
        updateEngineRoadComboBox();
    }
    if (ae.getSource() == routeBox) {
        if (routeBox.isEnabled()) {
            Route route = _train.getRoute();
            if (route != null) {
                route.removePropertyChangeListener(this);
            }
            Object selected = routeBox.getSelectedItem();
            if (selected != null) {
                route = (Route) selected;
                _train.setRoute(route);
                route.addPropertyChangeListener(this);
            } else {
                _train.setRoute(null);
            }
            updateLocationCheckboxes();
            packFrame();
        }
    }
}
Also used : Route(jmri.jmrit.operations.routes.Route)

Aggregations

Route (jmri.jmrit.operations.routes.Route)87 RouteLocation (jmri.jmrit.operations.routes.RouteLocation)69 Location (jmri.jmrit.operations.locations.Location)51 Track (jmri.jmrit.operations.locations.Track)43 Car (jmri.jmrit.operations.rollingstock.cars.Car)32 Engine (jmri.jmrit.operations.rollingstock.engines.Engine)31 LocationManager (jmri.jmrit.operations.locations.LocationManager)23 RouteManager (jmri.jmrit.operations.routes.RouteManager)23 Train (jmri.jmrit.operations.trains.Train)20 Consist (jmri.jmrit.operations.rollingstock.engines.Consist)19 CarManager (jmri.jmrit.operations.rollingstock.cars.CarManager)14 CarTypes (jmri.jmrit.operations.rollingstock.cars.CarTypes)13 EngineManager (jmri.jmrit.operations.rollingstock.engines.EngineManager)13 RollingStock (jmri.jmrit.operations.rollingstock.RollingStock)11 EngineTypes (jmri.jmrit.operations.rollingstock.engines.EngineTypes)10 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)5 ArrayList (java.util.ArrayList)5 JLabel (javax.swing.JLabel)5 TrainManager (jmri.jmrit.operations.trains.TrainManager)5 Kernel (jmri.jmrit.operations.rollingstock.cars.Kernel)4