Search in sources :

Example 1 with Track

use of trackmodel.model.Track in project on-track by michaelplazek.

the class TrackControllerInitializer method parseTrack.

/**
 * Searches the Track Model instances and populates TrackControllerLineManagers
 * and TrackControllers.
 */
public static void parseTrack() {
    HashMap<String, Track> track = Track.getListOfTracks();
    TrackControllerLineManager[] lms = new TrackControllerLineManager[2];
    // TrackControllerLineManager[] lms = new TrackControllerLineManager[track.size()];
    // Create TrackControllerLineManagers
    // int i = 0;
    // for (Map.Entry<String, Track> entry : track.entrySet()) {
    // i++;
    // lms[i] = new TrackControllerLineManager(entry.getKey());
    // for (String block : entry.getValue().getBlockList()) {
    // //add each block to a track controller
    // 
    // 
    // }
    // }
    lms[0] = new TrackControllerLineManager("Green");
    lms[1] = new TrackControllerLineManager("Red");
    // DUMMY DATA
    TrackController[] gtc = new TrackController[10];
    TrackController[] rtc = new TrackController[10];
    for (int i = 0; i < 10; i++) {
        gtc[i] = new TrackController(i + 1, 0);
        lms[0].addController(gtc[i]);
        rtc[i] = new TrackController(i + 1, 0);
        lms[1].addController(rtc[i]);
    }
}
Also used : TrackController(trackctrl.model.TrackController) TrackControllerLineManager(trackctrl.model.TrackControllerLineManager) Track(trackmodel.model.Track)

Example 2 with Track

use of trackmodel.model.Track in project on-track by michaelplazek.

the class CentralTrafficControl method makeBlockList.

/**
 * Create the list of strings for the block dropdown.
 */
public void makeBlockList() {
    Track track = Track.getListOfTracks().get(line);
    // clear the list before refreshing
    blockList.clear();
    if (track != null) {
        blockList.addAll(track.getBlockList());
    }
}
Also used : Track(trackmodel.model.Track)

Example 3 with Track

use of trackmodel.model.Track in project on-track by michaelplazek.

the class CentralTrafficControl method makeStationList.

/**
 * Update the list of stations held by the CTC.
 */
public void makeStationList() {
    Track track = Track.getListOfTracks().get(line);
    // clear the list before refreshing
    stationList.clear();
    if (track != null) {
        stationList.addAll(track.getStationList());
    }
}
Also used : Track(trackmodel.model.Track)

Example 4 with Track

use of trackmodel.model.Track in project on-track by michaelplazek.

the class TrackMaintenance method makeBlockList.

/**
 * Create the list of strings for the block dropdown.
 */
public void makeBlockList() {
    Track track = Track.getListOfTracks().get(line);
    // clear the list before refreshing
    blockList.clear();
    if (track != null) {
        blockList.addAll(track.getBlockList());
    }
}
Also used : Track(trackmodel.model.Track)

Example 5 with Track

use of trackmodel.model.Track in project on-track by michaelplazek.

the class PowerCalculator method recursiveSpeedLimit.

private static double recursiveSpeedLimit(Block currentBlock, Block lastBlock, double remainingDistance) {
    if (currentBlock == null) {
        return 0;
    }
    double max;
    Track track = Track.getTrack(currentBlock.getLine());
    remainingDistance -= currentBlock.getSize();
    if (remainingDistance <= 0) {
        max = currentBlock.getSpeedLimit();
    } else {
        max = Math.max(currentBlock.getSpeedLimit(), recursiveSpeedLimit(track.getNextBlock(lastBlock.getNumber(), currentBlock.getNumber()), currentBlock, remainingDistance));
        if (currentBlock.isSwitch()) {
            max = Math.max(max, recursiveSpeedLimit(track.getNextBlock2(currentBlock.getNumber()), currentBlock, remainingDistance));
        }
    }
    return max;
}
Also used : Track(trackmodel.model.Track)

Aggregations

Track (trackmodel.model.Track)7 Block (trackmodel.model.Block)2 Switch (trackmodel.model.Switch)2 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 TrackController (trackctrl.model.TrackController)1 TrackControllerLineManager (trackctrl.model.TrackControllerLineManager)1