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]);
}
}
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());
}
}
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());
}
}
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());
}
}
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;
}
Aggregations