use of jmri.jmrit.operations.locations.schedules.ScheduleManager in project JMRI by JMRI.
the class OperationsCarRouterTest method testRoutingWithSchedulesMatchMode.
/*
* Using the setup from the previous tests, use trains and schedules to move
* cars. This test creates 1 schedule in match mode with multiple items.
* Test uses car loads to activate schedule.
*/
public void testRoutingWithSchedulesMatchMode() {
TrainManager tmanager = TrainManager.instance();
CarManager cmanager = CarManager.instance();
LocationManager lmanager = LocationManager.instance();
loadLocationsTrainsAndCars();
List<Train> trains = tmanager.getTrainsByNameList();
Assert.assertEquals("confirm number of trains", 7, trains.size());
Car c3 = cmanager.getByRoadAndNumber("BA", "3");
Car c4 = cmanager.getByRoadAndNumber("BB", "4");
Car c5 = cmanager.getByRoadAndNumber("BC", "5");
Car c6 = cmanager.getByRoadAndNumber("BD", "6");
Car c7 = cmanager.getByRoadAndNumber("BA", "7");
Car c8 = cmanager.getByRoadAndNumber("BB", "8");
Car c9 = cmanager.getByRoadAndNumber("BC", "9");
Location Acton = lmanager.getLocationByName("Acton MA");
Location Clinton = lmanager.getLocationByName("Clinton MA");
Location Danbury = lmanager.getLocationByName("Danbury MA");
Location Essex = lmanager.getLocationByName("Essex MA");
Track AS1 = Acton.getTrackByName("Acton Siding 1", Track.SPUR);
Track CS1 = Clinton.getTrackByName("Clinton Siding 1", Track.SPUR);
Track DS1 = Danbury.getTrackByName("Danbury Siding 1", Track.SPUR);
Track DS2 = Danbury.getTrackByName("Danbury Siding 2", Track.SPUR);
Track ES1 = Essex.getTrackByName("Essex Siding 1", Track.SPUR);
Track ES2 = Essex.getTrackByName("Essex Siding 2", Track.SPUR);
// set the depart track Acton to service by local train only
AS1.setTrainDirections(0);
// create schedules
ScheduleManager scheduleManager = ScheduleManager.instance();
Schedule schA = scheduleManager.newSchedule("Schedule AAA");
ScheduleItem schAItem1 = schA.addItem("Boxcar");
schAItem1.setReceiveLoadName("Empty");
schAItem1.setShipLoadName("Metal");
schAItem1.setDestination(Acton);
schAItem1.setDestinationTrack(AS1);
ScheduleItem schAItem2 = schA.addItem("Flat");
schAItem2.setReceiveLoadName("Junk");
schAItem2.setShipLoadName("Metal");
schAItem2.setDestination(Danbury);
schAItem2.setDestinationTrack(DS2);
ScheduleItem schAItem3 = schA.addItem("Boxcar");
schAItem3.setReceiveLoadName("Boxes");
schAItem3.setShipLoadName("Screws");
schAItem3.setDestination(Essex);
schAItem3.setDestinationTrack(ES1);
ScheduleItem schAItem4 = schA.addItem("Boxcar");
schAItem4.setReceiveLoadName("Boxes");
schAItem4.setShipLoadName("Bolts");
schAItem4.setDestination(Danbury);
schAItem4.setDestinationTrack(DS1);
ScheduleItem schAItem5 = schA.addItem("Boxcar");
schAItem5.setReceiveLoadName("");
schAItem5.setShipLoadName("Nuts");
schAItem5.setDestination(Essex);
schAItem5.setDestinationTrack(ES2);
// Add schedule to tracks
CS1.setScheduleId("");
ES1.setScheduleId(schA.getId());
// set schedule into match mode
ES1.setScheduleMode(Track.MATCH);
// c3 (BA 3) is a Boxcar
c3.setLoadName("Boxes");
// c4 (BB 4) is a Flat
c4.setLoadName("Junk");
// c5 (BC 5) is a Boxcar
c5.setLoadName("Boxes");
// c6 (BD 6) is a Boxcar
c6.setLoadName("Boxes");
// place cars
Assert.assertEquals("Place car", Track.OKAY, c3.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c4.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c5.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c6.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c7.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c8.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c9.setLocation(Acton, AS1));
// build train
Train ActonTrain = tmanager.getTrainByName("Acton Local");
ActonTrain.build();
Assert.assertTrue("Acton train built", ActonTrain.isBuilt());
// check car destinations
Assert.assertEquals("Car BA 3 destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "Acton Interchange", c3.getDestinationTrackName());
Assert.assertEquals("Car BA 3 final destination", "Essex MA", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "Essex Siding 1", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 4 destination", "Acton MA", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "Acton Interchange", c4.getDestinationTrackName());
Assert.assertEquals("Car BB 4 final destination", "Essex MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "Essex Siding 1", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 destination", "Acton MA", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "Acton Interchange", c5.getDestinationTrackName());
Assert.assertEquals("Car BC 5 final destination", "Essex MA", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "Essex Siding 1", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 6 destination", "Acton MA", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "Acton Interchange", c6.getDestinationTrackName());
Assert.assertEquals("Car BD 6 final destination", "Essex MA", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "Essex Siding 1", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 7 destination", "Acton MA", c7.getDestinationName());
Assert.assertEquals("Car BD 7 destination track", "Acton Interchange", c7.getDestinationTrackName());
Assert.assertEquals("Car BD 7 final destination", "Essex MA", c7.getFinalDestinationName());
Assert.assertEquals("Car BD 7 final destination track", "Essex Siding 1", c7.getFinalDestinationTrackName());
// check car schedule ids
Assert.assertEquals("Car BA 3 schedule id", schAItem3.getId(), c3.getScheduleItemId());
Assert.assertEquals("Car BB 4 schedule id", schAItem2.getId(), c4.getScheduleItemId());
Assert.assertEquals("Car BC 5 schedule id", schAItem3.getId(), c5.getScheduleItemId());
Assert.assertEquals("Car BD 6 schedule id", schAItem4.getId(), c6.getScheduleItemId());
Assert.assertEquals("Car BA 7 schedule id", schAItem5.getId(), c7.getScheduleItemId());
Assert.assertEquals("Car BB 8 schedule id", schAItem1.getId(), c8.getScheduleItemId());
Assert.assertEquals("Car BC 9 schedule id", schAItem5.getId(), c9.getScheduleItemId());
ActonTrain.reset();
}
use of jmri.jmrit.operations.locations.schedules.ScheduleManager in project JMRI by JMRI.
the class ScheduleManagerTest method testScheduleManager.
public void testScheduleManager() {
LocationManager lm = LocationManager.instance();
Location l = lm.newLocation("new test location");
Track t = l.addTrack("track 1", Track.SPUR);
ScheduleManager sm = ScheduleManager.instance();
// clear out any previous schedules
sm.dispose();
sm = ScheduleManager.instance();
Schedule s1 = sm.newSchedule("new schedule");
Schedule s2 = sm.newSchedule("newer schedule");
ScheduleItem i1 = s1.addItem("BoxCar");
i1.setRoadName("new road");
i1.setReceiveLoadName("new load");
i1.setShipLoadName("new ship load");
ScheduleItem i2 = s1.addItem("Caboose");
i2.setRoadName("road");
i2.setReceiveLoadName("load");
i2.setShipLoadName("ship load");
Assert.assertEquals("1 First schedule name", "new schedule", s1.getName());
Assert.assertEquals("1 First schedule name", "newer schedule", s2.getName());
List<Schedule> names = sm.getSchedulesByNameList();
Assert.assertEquals("There should be 2 schedules", 2, names.size());
Schedule sch1 = names.get(0);
Schedule sch2 = names.get(1);
Assert.assertEquals("2 First schedule name", "new schedule", sch1.getName());
Assert.assertEquals("2 First schedule name", "newer schedule", sch2.getName());
Assert.assertEquals("Schedule 1", sch1, sm.getScheduleByName("new schedule"));
Assert.assertEquals("Schedule 2", sch2, sm.getScheduleByName("newer schedule"));
// Remove references to swing
// JComboBox box = sm.getComboBox();
// Assert.assertEquals("3 First schedule name", "", box.getItemAt(0));
// Assert.assertEquals("3 First schedule name", sch1, box.getItemAt(1));
// Assert.assertEquals("3 First schedule name", sch2, box.getItemAt(2));
//
// JComboBox box2 = sm.getSidingsByScheduleComboBox(s1);
// Assert.assertEquals("First siding name", null, box2.getItemAt(0));
// now add a schedule to siding
t.setScheduleId(sch1.getId());
// JComboBox box3 = sm.getSidingsByScheduleComboBox(s1);
// LocationTrackPair ltp = (LocationTrackPair)box3.getItemAt(0);
// Assert.assertEquals("Location track pair location", l, ltp.getLocation());
// Assert.assertEquals("Location track pair track", t, ltp.getTrack());
Assert.assertEquals("1 Schedule Item 1 type", "BoxCar", i1.getTypeName());
Assert.assertEquals("1 Schedule Item 1 road", "new road", i1.getRoadName());
Assert.assertEquals("1 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
Assert.assertEquals("1 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
Assert.assertEquals("1 Schedule Item 2 type", "Caboose", i2.getTypeName());
Assert.assertEquals("1 Schedule Item 2 road", "road", i2.getRoadName());
Assert.assertEquals("1 Schedule Item 2 load", "load", i2.getReceiveLoadName());
Assert.assertEquals("1 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
sm.replaceRoad("new road", "replaced road");
Assert.assertEquals("2 Schedule Item 1 type", "BoxCar", i1.getTypeName());
Assert.assertEquals("2 Schedule Item 1 road", "replaced road", i1.getRoadName());
Assert.assertEquals("2 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
Assert.assertEquals("2 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
Assert.assertEquals("2 Schedule Item 2 type", "Caboose", i2.getTypeName());
Assert.assertEquals("2 Schedule Item 2 road", "road", i2.getRoadName());
Assert.assertEquals("2 Schedule Item 2 load", "load", i2.getReceiveLoadName());
Assert.assertEquals("2 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
sm.replaceType("BoxCar", "replaced car type");
Assert.assertEquals("3 Schedule Item 1 type", "replaced car type", i1.getTypeName());
Assert.assertEquals("3 Schedule Item 1 road", "replaced road", i1.getRoadName());
Assert.assertEquals("3 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
Assert.assertEquals("3 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
Assert.assertEquals("3 Schedule Item 2 type", "Caboose", i2.getTypeName());
Assert.assertEquals("3 Schedule Item 2 road", "road", i2.getRoadName());
Assert.assertEquals("3 Schedule Item 2 load", "load", i2.getReceiveLoadName());
Assert.assertEquals("3 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
sm.replaceType("Caboose", "BoxCar");
Assert.assertEquals("4 Schedule Item 1 type", "replaced car type", i1.getTypeName());
Assert.assertEquals("4 Schedule Item 1 road", "replaced road", i1.getRoadName());
Assert.assertEquals("4 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
Assert.assertEquals("4 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
Assert.assertEquals("4 Schedule Item 2 type", "BoxCar", i2.getTypeName());
Assert.assertEquals("4 Schedule Item 2 road", "road", i2.getRoadName());
Assert.assertEquals("4 Schedule Item 2 load", "load", i2.getReceiveLoadName());
Assert.assertEquals("4 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
sm.replaceLoad("BoxCar", "load", "new load");
Assert.assertEquals("5 Schedule Item 1 type", "replaced car type", i1.getTypeName());
Assert.assertEquals("5 Schedule Item 1 road", "replaced road", i1.getRoadName());
Assert.assertEquals("5 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
Assert.assertEquals("5 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
Assert.assertEquals("5 Schedule Item 2 type", "BoxCar", i2.getTypeName());
Assert.assertEquals("5 Schedule Item 2 road", "road", i2.getRoadName());
Assert.assertEquals("5 Schedule Item 2 load", "new load", i2.getReceiveLoadName());
Assert.assertEquals("5 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
sm.replaceLoad("BoxCar", "new load", "next load");
Assert.assertEquals("6 Schedule Item 1 type", "replaced car type", i1.getTypeName());
Assert.assertEquals("6 Schedule Item 1 road", "replaced road", i1.getRoadName());
Assert.assertEquals("6 Schedule Item 1 load", "new load", i1.getReceiveLoadName());
Assert.assertEquals("6 Schedule Item 1 ship", "new ship load", i1.getShipLoadName());
Assert.assertEquals("6 Schedule Item 2 type", "BoxCar", i2.getTypeName());
Assert.assertEquals("6 Schedule Item 2 road", "road", i2.getRoadName());
Assert.assertEquals("6 Schedule Item 2 load", "next load", i2.getReceiveLoadName());
Assert.assertEquals("6 Schedule Item 2 ship", "ship load", i2.getShipLoadName());
// remove all schedules
sm.dispose();
names = sm.getSchedulesByNameList();
Assert.assertEquals("There should be no schedules", 0, names.size());
}
use of jmri.jmrit.operations.locations.schedules.ScheduleManager in project JMRI by JMRI.
the class LocationTest method testRoadNameSupport.
public void testRoadNameSupport() {
// use LocationManager to allow replace car road to work properly
Location l = LocationManager.instance().newLocation("Test Name 2");
Assert.assertEquals("Location Name", "Test Name 2", l.getName());
Track t = l.addTrack("new track", Track.SPUR);
Assert.assertEquals("Location", l, t.getLocation());
t.setRoadOption(Track.INCLUDE_ROADS);
t.addRoadName("Test Road Name");
t.addRoadName("Test Road Name 2");
ScheduleManager sm = ScheduleManager.instance();
Schedule s = sm.newSchedule("test schedule");
ScheduleItem i1 = s.addItem("BoxCar");
ScheduleItem i2 = s.addItem("BoxCar");
i1.setRoadName("Test Road Name");
i2.setRoadName("Test Road Name 2");
Assert.assertTrue("track should accept road Test Road Name", t.acceptsRoadName("Test Road Name"));
Assert.assertTrue("track should accept road Test Road Name 2", t.acceptsRoadName("Test Road Name 2"));
Assert.assertFalse("track should Not accept road New Test Road Name", t.acceptsRoadName("New Test Road Name"));
Assert.assertEquals("ScheudleItem i1 Road Test Road Name", "Test Road Name", i1.getRoadName());
Assert.assertEquals("ScheudleItem i2 Road Test Road Name", "Test Road Name 2", i2.getRoadName());
CarRoads cr = CarRoads.instance();
cr.replaceName("Test Road Name", "New Test Road Name");
Assert.assertFalse("track should Not accept road Test Road Name", t.acceptsRoadName("Test Road Name"));
Assert.assertTrue("track should accept road Test Road Name 2", t.acceptsRoadName("Test Road Name 2"));
Assert.assertTrue("track should accept road New Test Road Name", t.acceptsRoadName("New Test Road Name"));
Assert.assertEquals("ScheudleItem i1 Road Test Road Name", "New Test Road Name", i1.getRoadName());
Assert.assertEquals("Check ScheudleItem i2 Road Test Road Name", "Test Road Name 2", i2.getRoadName());
// remove all schedules
sm.dispose();
}
use of jmri.jmrit.operations.locations.schedules.ScheduleManager in project JMRI by JMRI.
the class OperationsCarRouterTest method testRoutingWithSchedulesMatchMode2.
/*
* Using the setup from the previous tests, use trains and schedules to move
* cars. This test creates 1 schedule in match mode with multiple items.
* Cars use final destination to activate schedule
*/
public void testRoutingWithSchedulesMatchMode2() {
TrainManager tmanager = TrainManager.instance();
CarManager cmanager = CarManager.instance();
LocationManager lmanager = LocationManager.instance();
loadLocationsTrainsAndCars();
List<Train> trains = tmanager.getTrainsByNameList();
Assert.assertEquals("confirm number of trains", 7, trains.size());
Car c3 = cmanager.getByRoadAndNumber("BA", "3");
Car c4 = cmanager.getByRoadAndNumber("BB", "4");
Car c5 = cmanager.getByRoadAndNumber("BC", "5");
Car c6 = cmanager.getByRoadAndNumber("BD", "6");
Car c7 = cmanager.getByRoadAndNumber("BA", "7");
Car c8 = cmanager.getByRoadAndNumber("BB", "8");
Car c9 = cmanager.getByRoadAndNumber("BC", "9");
Assert.assertNotNull("confirm car not null", c3);
Assert.assertNotNull("confirm car not null", c4);
Assert.assertNotNull("confirm car not null", c5);
Assert.assertNotNull("confirm car not null", c6);
Assert.assertNotNull("confirm car not null", c7);
Assert.assertNotNull("confirm car not null", c8);
Assert.assertNotNull("confirm car not null", c9);
Location Acton = lmanager.getLocationByName("Acton MA");
Location Bedford = lmanager.getLocationByName("Bedford MA");
Location Clinton = lmanager.getLocationByName("Clinton MA");
Location Danbury = lmanager.getLocationByName("Danbury MA");
Location Essex = lmanager.getLocationByName("Essex MA");
Location Foxboro = lmanager.getLocationByName("Foxboro MA");
Track AS1 = Acton.getTrackByName("Acton Siding 1", Track.SPUR);
Track BS1 = Bedford.getTrackByName("Bedford Siding 1", Track.SPUR);
Track CS1 = Clinton.getTrackByName("Clinton Siding 1", Track.SPUR);
Track DS1 = Danbury.getTrackByName("Danbury Siding 1", Track.SPUR);
Track DS2 = Danbury.getTrackByName("Danbury Siding 2", Track.SPUR);
Track ES1 = Essex.getTrackByName("Essex Siding 1", Track.SPUR);
//Track ES2 = Essex.getTrackByName("Essex Siding 2", Track.SIDING);
Track FS1 = Foxboro.getTrackByName("Foxboro Siding 1", Track.SPUR);
// set the depart track Acton to service by local train only
AS1.setTrainDirections(0);
// create schedules
ScheduleManager scheduleManager = ScheduleManager.instance();
Schedule schA = scheduleManager.newSchedule("Schedule ABC");
ScheduleItem schAItem1 = schA.addItem("Boxcar");
schAItem1.setReceiveLoadName("Cardboard");
schAItem1.setShipLoadName("Metal");
schAItem1.setDestination(Acton);
schAItem1.setDestinationTrack(AS1);
ScheduleItem schAItem2 = schA.addItem("Flat");
//schAItem2.setLoad("Junk");
schAItem2.setShipLoadName("Metal");
schAItem2.setDestination(Danbury);
schAItem2.setDestinationTrack(DS2);
ScheduleItem schAItem3 = schA.addItem("Boxcar");
schAItem3.setReceiveLoadName("Tools");
schAItem3.setShipLoadName("Screws");
schAItem3.setDestination(Bedford);
schAItem3.setDestinationTrack(BS1);
ScheduleItem schAItem4 = schA.addItem("Boxcar");
schAItem4.setReceiveLoadName(CarLoads.instance().getDefaultEmptyName());
schAItem4.setShipLoadName("Bolts");
schAItem4.setDestination(Danbury);
schAItem4.setDestinationTrack(DS1);
ScheduleItem schAItem5 = schA.addItem("Boxcar");
schAItem5.setReceiveLoadName(CarLoads.instance().getDefaultLoadName());
schAItem5.setShipLoadName("Nuts");
schAItem5.setDestination(Foxboro);
schAItem5.setDestinationTrack(FS1);
// Add schedule to tracks
CS1.setScheduleId("");
ES1.setScheduleId(schA.getId());
// set schedule into match mode
ES1.setScheduleMode(Track.MATCH);
// c3 (BA 3) is a Boxcar
c3.setLoadName("Tools");
c3.setFinalDestination(Essex);
// c4 (BB 4) is a Flat
c4.setLoadName(CarLoads.instance().getDefaultEmptyName());
c4.setFinalDestination(Essex);
c4.setFinalDestinationTrack(ES1);
// c5 (BC 5) is a Boxcar
c5.setLoadName("Tools");
c5.setFinalDestination(Essex);
// c6 (BD 6) is a Boxcar
c6.setLoadName(CarLoads.instance().getDefaultEmptyName());
c6.setFinalDestination(Essex);
// c7 (BA 7) is a Boxcar
c7.setLoadName("Cardboard");
c7.setFinalDestination(Essex);
c7.setFinalDestinationTrack(ES1);
// c8 (BB 8) is a Boxcar
c8.setLoadName("Tools");
// serve BB 8 and BC 9 after the other cars
c8.setMoves(20);
// c9 (BC 9) is a Boxcar
c9.setLoadName(CarLoads.instance().getDefaultEmptyName());
c9.setMoves(21);
// place cars
Assert.assertEquals("Place car", Track.OKAY, c3.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c4.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c5.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c6.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c7.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c8.setLocation(Danbury, DS1));
Assert.assertEquals("Place car", Track.OKAY, c9.setLocation(Danbury, DS1));
// build train
Train ActonTrain = tmanager.getTrainByName("Acton Local");
ActonTrain.build();
Assert.assertTrue("Acton train built", ActonTrain.isBuilt());
// check car destinations
Assert.assertEquals("Car BA 3 destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "Acton Interchange", c3.getDestinationTrackName());
Assert.assertEquals("Car BA 3 final destination", "Essex MA", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 4 destination", "Acton MA", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "Acton Interchange", c4.getDestinationTrackName());
Assert.assertEquals("Car BB 4 final destination", "Essex MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "Essex Siding 1", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 destination", "Acton MA", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "Acton Interchange", c5.getDestinationTrackName());
Assert.assertEquals("Car BC 5 final destination", "Essex MA", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 6 destination", "Acton MA", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "Acton Interchange", c6.getDestinationTrackName());
Assert.assertEquals("Car BD 6 final destination", "Essex MA", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 destination", "Acton MA", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "Acton Interchange", c7.getDestinationTrackName());
Assert.assertEquals("Car BA 7 final destination", "Essex MA", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "Essex Siding 1", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 destination", "", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "", c8.getDestinationTrackName());
Assert.assertEquals("Car BB 8 final destination", "", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 destination", "", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "", c9.getDestinationTrackName());
Assert.assertEquals("Car BC 9 final destination", "", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "", c9.getFinalDestinationTrackName());
// check car schedule ids
// no track assignment, schedule not tested
Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleItemId());
// has track assignment
Assert.assertEquals("Car BB 4 schedule id", schAItem2.getId(), c4.getScheduleItemId());
Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleItemId());
Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleItemId());
// has track assignment
Assert.assertEquals("Car BA 7 schedule id", schAItem1.getId(), c7.getScheduleItemId());
Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleItemId());
Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleItemId());
ActonTrain.terminate();
// move the cars to Bedford
Train ActonToBedfordTrain = tmanager.getTrainByName("Acton to Bedford");
ActonToBedfordTrain.build();
Assert.assertTrue("Acton train built", ActonToBedfordTrain.isBuilt());
ActonToBedfordTrain.terminate();
// move the cars to Clinton
Train BedfordToClintonTrain = tmanager.getTrainByName("Bedford to Clinton");
BedfordToClintonTrain.build();
Assert.assertTrue("Bedford train built", BedfordToClintonTrain.isBuilt());
BedfordToClintonTrain.terminate();
// move the cars to Danbury
Train ClintonToDanburyTrain = tmanager.getTrainByName("Clinton to Danbury");
ClintonToDanburyTrain.build();
Assert.assertTrue("Clinton train built", ClintonToDanburyTrain.isBuilt());
ClintonToDanburyTrain.terminate();
// move the cars to Essex (number of moves is 8)
Train DanburyToEssexTrain = tmanager.getTrainByName("Danbury to Essex");
DanburyToEssexTrain.build();
Assert.assertTrue("Danbury train built", DanburyToEssexTrain.isBuilt());
// check car destinations
// BA 3 (Boxcar)
Assert.assertEquals("Car BA 3 destination", "Essex MA", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "Essex Siding 1", c3.getDestinationTrackName());
// new final destination and load for car BA 3
Assert.assertEquals("Car BA 3 final destination", "Bedford MA", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "Bedford Siding 1", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 3 final load", "Screws", c3.getNextLoadName());
Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleItemId());
// BB 4 (Flat)
Assert.assertEquals("Car BB 4 destination", "Essex MA", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "Essex Siding 1", c4.getDestinationTrackName());
// new final destination and load for car BB 4
Assert.assertEquals("Car BB 4 final destination", "Danbury MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "Danbury Siding 2", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 4 final load", "Metal", c4.getNextLoadName());
Assert.assertEquals("Car BB 4 schedule id", "", c4.getScheduleItemId());
// BC 5 (Boxcar)
Assert.assertEquals("Car BC 5 destination", "Essex MA", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "Essex Siding 1", c5.getDestinationTrackName());
// new final destination and load for car BC 5, same as BA 3
Assert.assertEquals("Car BC 5 final destination", "Bedford MA", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "Bedford Siding 1", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 final load", "Screws", c5.getNextLoadName());
Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleItemId());
// BD 6 (Boxcar) note second Boxcar
Assert.assertEquals("Car BD 6 destination", "Essex MA", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "Essex Siding 1", c6.getDestinationTrackName());
// new final destination and load for car BD 6
Assert.assertEquals("Car BD 6 final destination", "Danbury MA", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "Danbury Siding 1", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 6 final load", "Bolts", c6.getNextLoadName());
Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleItemId());
// BA 7 (Boxcar) note 3rd Boxcar
Assert.assertEquals("Car BA 7 destination", "Essex MA", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "Essex Siding 1", c7.getDestinationTrackName());
// new final destination and load for car BA 7
Assert.assertEquals("Car BA 7 final destination", "Acton MA", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "Acton Siding 1", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 final load", "Metal", c7.getNextLoadName());
Assert.assertEquals("Car BA 7 schedule id", "", c7.getScheduleItemId());
// BB 8 (Boxcar) at Danbury to be added to train
Assert.assertEquals("Car BB 8 destination", "Essex MA", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "Essex Siding 1", c8.getDestinationTrackName());
// Should match schedule item 16c3
Assert.assertEquals("Car BB 8 final destination", "Bedford MA", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "Bedford Siding 1", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 final load", "Screws", c8.getNextLoadName());
Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleItemId());
// BB 9 (Boxcar) at Danbury to be added to train
Assert.assertEquals("Car BC 9 destination", "Essex MA", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "Essex Siding 1", c9.getDestinationTrackName());
// Should match schedule item 16c4
Assert.assertEquals("Car BC 9 final destination", "Danbury MA", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "Danbury Siding 1", c9.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 final load", "Bolts", c9.getNextLoadName());
Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleItemId());
// test reset, car final destinations should revert.
DanburyToEssexTrain.reset();
Assert.assertEquals("Car BA 3 destination", "", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "", c3.getDestinationTrackName());
Assert.assertEquals("Car BA 3 final destination", "Essex MA", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 3 next load", "", c3.getNextLoadName());
Assert.assertEquals("Car BB 4 destination", "", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "", c4.getDestinationTrackName());
Assert.assertEquals("Car BB 4 final destination", "Essex MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "Essex Siding 1", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 destination", "", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "", c5.getDestinationTrackName());
Assert.assertEquals("Car BC 5 final destination", "Essex MA", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 6 destination", "", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "", c6.getDestinationTrackName());
Assert.assertEquals("Car BD 6 final destination", "Essex MA", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 destination", "", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "", c7.getDestinationTrackName());
Assert.assertEquals("Car BA 7 final destination", "Essex MA", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "Essex Siding 1", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 destination", "", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "", c8.getDestinationTrackName());
Assert.assertEquals("Car BB 8 final destination", "", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 destination", "", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "", c9.getDestinationTrackName());
Assert.assertEquals("Car BC 9 final destination", "", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "", c9.getFinalDestinationTrackName());
// // try again
// DanburyToEssexTrain.build();
// Assert.assertTrue("Bedford train built", DanburyToEssexTrain.isBuilt());
//
// // check car destinations
// // BA 3 (Boxcar) this car's load and final destination is now different
// Assert.assertEquals("Car BA 3 destination","Essex MA", c3.getDestinationName());
// Assert.assertEquals("Car BA 3 destination track","Essex Siding 1", c3.getDestinationTrackName());
// // new final destination and load for car BA 3
// Assert.assertEquals("Car BA 3 final destination","Acton MA", c3.getFinalDestinationName());
// Assert.assertEquals("Car BA 3 final destination track","Acton Siding 1", c3.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 3 next load","Metal", c3.getNextLoadName());
// Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleId());
// // BB 4 (Flat) resets the match pointer so car BC 5 final destination and load is the same as last time
// Assert.assertEquals("Car BB 4 destination","Essex MA", c4.getDestinationName());
// Assert.assertEquals("Car BB 4 destination track","Essex Siding 1", c4.getDestinationTrackName());
// // new final destination and load for car BB 4
// Assert.assertEquals("Car BB 4 final destination","Danbury MA", c4.getFinalDestinationName());
// Assert.assertEquals("Car BB 4 final destination track","Danbury Siding 2", c4.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 4 next load","Metal", c4.getNextLoadName());
// Assert.assertEquals("Car BB 4 schedule id", "", c4.getScheduleId());
// // BC 5 (Boxcar)
// Assert.assertEquals("Car BC 5 destination","Essex MA", c5.getDestinationName());
// Assert.assertEquals("Car BC 5 destination track","Essex Siding 1", c5.getDestinationTrackName());
// // new final destination and load for car BC 5, same as BA 3
// Assert.assertEquals("Car BC 5 final destination","Bedford MA", c5.getFinalDestinationName());
// Assert.assertEquals("Car BC 5 final destination track","Bedford Siding 1", c5.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 5 next load","Screws", c5.getNextLoadName());
// Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleId());
// // BD 6 (Boxcar) note second Boxcar
// Assert.assertEquals("Car BD 6 destination","Essex MA", c6.getDestinationName());
// Assert.assertEquals("Car BD 6 destination track","Essex Siding 1", c6.getDestinationTrackName());
// // new final destination and load for car BD 6
// Assert.assertEquals("Car BD 6 final destination","Danbury MA", c6.getFinalDestinationName());
// Assert.assertEquals("Car BD 6 final destination track","Danbury Siding 1", c6.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 6 next load", "Bolts", c6.getNextLoadName());
// Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleId());
// // BA 7 (Boxcar) note 3rd Boxcar
// Assert.assertEquals("Car BA 7 destination","Essex MA", c7.getDestinationName());
// Assert.assertEquals("Car BA 7 destination track","Essex Siding 1", c7.getDestinationTrackName());
// // new final destination and load for car BA 7
// Assert.assertEquals("Car BA 7 final destination","Acton MA", c7.getFinalDestinationName());
// Assert.assertEquals("Car BA 7 final destination track","Acton Siding 1", c7.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 7 next load", "Metal", c7.getNextLoadName());
// Assert.assertEquals("Car BA 7 schedule id", "", c7.getScheduleId());
// // BB 8 (Boxcar) at Danbury to be added to train
// Assert.assertEquals("Car BB 8 destination","Essex MA", c8.getDestinationName());
// Assert.assertEquals("Car BB 8 destination track","Essex Siding 1", c8.getDestinationTrackName());
// // Should match schedule item 16c3
// Assert.assertEquals("Car BB 8 final destination","Bedford MA", c8.getFinalDestinationName());
// Assert.assertEquals("Car BB 8 final destination track","Bedford Siding 1", c8.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 8 next load", "Screws", c8.getNextLoadName());
// Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleId());
// // BB 9 (Boxcar) at Danbury to be added to train
// Assert.assertEquals("Car BC 9 destination","Essex MA", c9.getDestinationName());
// Assert.assertEquals("Car BC 9 destination track","Essex Siding 1", c9.getDestinationTrackName());
// // Should match schedule item 16c4
// Assert.assertEquals("Car BC 9 final destination","Danbury MA", c9.getFinalDestinationName());
// Assert.assertEquals("Car BC 9 final destination track","Danbury Siding 1", c9.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 9 next load", "Bolts", c9.getNextLoadName());
// Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleId());
//
// DanburyToEssexTrain.terminate();
//
// // check car destinations
// // BA 3 (Boxcar)
// Assert.assertEquals("Car BA 3 destination","", c3.getDestinationName());
// Assert.assertEquals("Car BA 3 destination track","", c3.getDestinationTrackName());
// // new final destination and load for car BA 3
// Assert.assertEquals("Car BA 3 final destination","Acton MA", c3.getFinalDestinationName());
// Assert.assertEquals("Car BA 3 final destination track","Acton Siding 1", c3.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 3 load","Metal", c3.getLoadName());
// Assert.assertEquals("Car BA 3 next load","", c3.getNextLoadName());
// Assert.assertEquals("Car BA 3 schedule id", "", c3.getScheduleId());
// // BB 4 (Flat)
// Assert.assertEquals("Car BB 4 destination","", c4.getDestinationName());
// Assert.assertEquals("Car BB 4 destination track","", c4.getDestinationTrackName());
// // new final destination and load for car BB 4
// Assert.assertEquals("Car BB 4 final destination","Danbury MA", c4.getFinalDestinationName());
// Assert.assertEquals("Car BB 4 final destination track","Danbury Siding 2", c4.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 4 load","Metal", c4.getLoadName());
// Assert.assertEquals("Car BB 4 next load","", c4.getNextLoadName());
// Assert.assertEquals("Car BB 4 schedule id", "", c4.getScheduleId());
// // BC 5 (Boxcar)
// Assert.assertEquals("Car BC 5 destination","", c5.getDestinationName());
// Assert.assertEquals("Car BC 5 destination track","", c5.getDestinationTrackName());
// // new final destination and load for car BC 5, same as BA 3
// Assert.assertEquals("Car BC 5 final destination","Bedford MA", c5.getFinalDestinationName());
// Assert.assertEquals("Car BC 5 final destination track","Bedford Siding 1", c5.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 5 load","Screws", c5.getLoadName());
// Assert.assertEquals("Car BC 5 next load","", c5.getNextLoadName());
// Assert.assertEquals("Car BC 5 schedule id", "", c5.getScheduleId());
// // BD 6 (Boxcar) note second Boxcar
// Assert.assertEquals("Car BD 6 destination","", c6.getDestinationName());
// Assert.assertEquals("Car BD 6 destination track","", c6.getDestinationTrackName());
// // new final destination and load for car BD 6
// Assert.assertEquals("Car BD 6 final destination","Danbury MA", c6.getFinalDestinationName());
// Assert.assertEquals("Car BD 6 final destination track","Danbury Siding 1", c6.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 6 load", "Bolts", c6.getLoadName());
// Assert.assertEquals("Car BC 6 next load", "", c6.getNextLoadName());
// Assert.assertEquals("Car BD 6 schedule id", "", c6.getScheduleId());
// // BA 7 (Boxcar) note 3rd Boxcar
// Assert.assertEquals("Car BA 7 destination","", c7.getDestinationName());
// Assert.assertEquals("Car BA 7 destination track","", c7.getDestinationTrackName());
// // new final destination and load for car BA 7
// Assert.assertEquals("Car BA 7 final destination","Acton MA", c7.getFinalDestinationName());
// Assert.assertEquals("Car BA 7 final destination track","Acton Siding 1", c7.getFinalDestinationTrackName());
// Assert.assertEquals("Car BA 7 load", "Metal", c7.getLoadName());
// Assert.assertEquals("Car BA 7 next load", "", c7.getNextLoadName());
// Assert.assertEquals("Car BA 7 schedule id", "", c7.getScheduleId());
// // BB 8 (Boxcar)
// Assert.assertEquals("Car BB 8 destination","", c8.getDestinationName());
// Assert.assertEquals("Car BB 8 destination track","", c8.getDestinationTrackName());
// // Should match schedule item 16c3
// Assert.assertEquals("Car BB 8 final destination","Bedford MA", c8.getFinalDestinationName());
// Assert.assertEquals("Car BB 8 final destination track","Bedford Siding 1", c8.getFinalDestinationTrackName());
// Assert.assertEquals("Car BB 8 load", "Screws", c8.getLoadName());
// Assert.assertEquals("Car BB 8 next load", "", c8.getNextLoadName());
// Assert.assertEquals("Car BB 8 schedule id", "", c8.getScheduleId());
// // BB 9 (Boxcar)
// Assert.assertEquals("Car BC 9 destination","", c9.getDestinationName());
// Assert.assertEquals("Car BC 9 destination track","", c9.getDestinationTrackName());
// // Should match schedule item 16c4
// Assert.assertEquals("Car BC 9 final destination","Danbury MA", c9.getFinalDestinationName());
// Assert.assertEquals("Car BC 9 final destination track","Danbury Siding 1", c9.getFinalDestinationTrackName());
// Assert.assertEquals("Car BC 9 load", "Bolts", c9.getLoadName());
// Assert.assertEquals("Car BC 9 next load", "", c9.getNextLoadName());
// Assert.assertEquals("Car BC 9 schedule id", "", c9.getScheduleId());
}
use of jmri.jmrit.operations.locations.schedules.ScheduleManager in project JMRI by JMRI.
the class OperationsCarRouterTest method testRoutingWithSchedulesLocal.
/* This test confirms that schedules can be linked together.
* Note that there are schedules at Essex that are still active
* but not reachable because the Clinton to Danbury train is
* removed as part of this test.
* has 5 tracks, 3 sidings, yard, and an interchange track.
*
*/
public void testRoutingWithSchedulesLocal() {
TrainManager tmanager = TrainManager.instance();
CarManager cmanager = CarManager.instance();
LocationManager lmanager = LocationManager.instance();
loadLocationsTrainsAndCars();
List<Train> trains = tmanager.getTrainsByNameList();
Assert.assertEquals("confirm number of trains", 7, trains.size());
Car c3 = cmanager.getByRoadAndNumber("BA", "3");
Car c4 = cmanager.getByRoadAndNumber("BB", "4");
Car c5 = cmanager.getByRoadAndNumber("BC", "5");
Car c6 = cmanager.getByRoadAndNumber("BD", "6");
Car c7 = cmanager.getByRoadAndNumber("BA", "7");
Car c8 = cmanager.getByRoadAndNumber("BB", "8");
Car c9 = cmanager.getByRoadAndNumber("BC", "9");
// c3 (BA 3) is a Boxcar
c3.setLoadName("Cardboard");
// c4 (BB 4) is a Flat
c4.setLoadName("Trucks");
// c5 (BC 5) is a Boxcar
c5.setLoadName(CarLoads.instance().getDefaultEmptyName());
// c6 (BD 6) is a Boxcar
c6.setLoadName(CarLoads.instance().getDefaultEmptyName());
// c7 (7) is a Boxcar
c7.setLoadName(CarLoads.instance().getDefaultEmptyName());
// c8 (8) is a Boxcar
c8.setLoadName("Trucks");
// c9 (9) is a Boxcar
c9.setLoadName(CarLoads.instance().getDefaultEmptyName());
Location Acton = lmanager.getLocationByName("Acton MA");
Location Bedford = lmanager.getLocationByName("Bedford MA");
Location Clinton = lmanager.getLocationByName("Clinton MA");
Track CS1 = Clinton.getTrackByName("Clinton Siding 1", Track.SPUR);
Track AS1 = Acton.getTrackByName("Acton Siding 1", Track.SPUR);
AS1.setTrainDirections(Track.NORTH + Track.SOUTH);
Track AS2 = Acton.getTrackByName("Acton Siding 2", Track.SPUR);
Track AS3 = Acton.addTrack("Acton Siding 3", Track.SPUR);
AS3.setLength(300);
Track AY = Acton.getTrackByName("Acton Yard", Track.YARD);
Track AI = Acton.getTrackByName("Acton Interchange", Track.INTERCHANGE);
// create schedules
ScheduleManager scheduleManager = ScheduleManager.instance();
Schedule schA = scheduleManager.newSchedule("Schedule Action");
ScheduleItem schAItem1 = schA.addItem("Boxcar");
schAItem1.setReceiveLoadName("Cardboard");
schAItem1.setShipLoadName("Scrap");
ScheduleItem schAItem2 = schA.addItem("Gon");
schAItem2.setReceiveLoadName("Trucks");
schAItem2.setShipLoadName("Tires");
schAItem2.setDestination(Bedford);
ScheduleItem schAItem3 = schA.addItem("Boxcar");
schAItem3.setReceiveLoadName("Trucks");
schAItem3.setShipLoadName("Wire");
schAItem3.setDestination(Clinton);
schAItem3.setDestinationTrack(CS1);
ScheduleItem schAItem4 = schA.addItem("Flat");
schAItem4.setReceiveLoadName("Trucks");
schAItem4.setShipLoadName("Coils");
schAItem4.setDestination(Bedford);
ScheduleItem schAItem5 = schA.addItem("Flat");
schAItem5.setReceiveLoadName("Coils");
schAItem5.setShipLoadName("Trucks");
schAItem5.setDestination(Bedford);
ScheduleItem schAItem6 = schA.addItem("Boxcar");
schAItem6.setReceiveLoadName("Scrap");
schAItem6.setShipLoadName("E");
ScheduleItem schAItem7 = schA.addItem("Boxcar");
schAItem7.setReceiveLoadName("Wire");
schAItem7.setShipLoadName("L");
// add schedules to tracks
AS1.setScheduleId(schA.getId());
AS1.setScheduleMode(Track.SEQUENTIAL);
AS2.setScheduleId(schA.getId());
AS2.setScheduleMode(Track.SEQUENTIAL);
AS3.setScheduleId(schA.getId());
// put Action Siding 3 into match mode
AS3.setScheduleMode(Track.MATCH);
// place cars
Assert.assertEquals("Place car", Track.OKAY, c3.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c4.setLocation(Acton, AS1));
Assert.assertEquals("Place car", Track.OKAY, c5.setLocation(Acton, AS2));
Assert.assertEquals("Place car", Track.OKAY, c6.setLocation(Acton, AS2));
Assert.assertEquals("Place car", Track.OKAY, c7.setLocation(Acton, AS3));
Assert.assertEquals("Place car", Track.OKAY, c8.setLocation(Acton, AY));
Assert.assertEquals("Place car", Track.OKAY, c9.setLocation(Acton, AI));
// Build train
Train ActonToBedfordTrain = tmanager.getTrainByName("Acton to Bedford");
Route ActonToBeford = ActonToBedfordTrain.getRoute();
RouteLocation rl = ActonToBeford.getDepartsRouteLocation();
RouteLocation rd = ActonToBeford.getLastLocationByName("Bedford MA");
// increase the number of moves so all cars are used
rl.setMaxCarMoves(10);
rd.setMaxCarMoves(10);
// kill the Clinton to Danbury train
Train ClintonToDanburyTrain = tmanager.getTrainByName("Clinton to Danbury");
tmanager.deregister(ClintonToDanburyTrain);
ActonToBedfordTrain.build();
Assert.assertTrue("Acton train built", ActonToBedfordTrain.isBuilt());
// check cars
Assert.assertEquals("Car BA 3 destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "Acton Siding 2", c3.getDestinationTrackName());
Assert.assertEquals("Car BA 3 final destination", "", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 3 load", "Cardboard", c3.getLoadName());
Assert.assertEquals("Car BA 3 next load", "Scrap", c3.getNextLoadName());
Assert.assertEquals("Car BB 4 destination", "Acton MA", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "Acton Siding 3", c4.getDestinationTrackName());
Assert.assertEquals("Car BB 4 final destination", "Bedford MA", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 4 load", "Trucks", c4.getLoadName());
Assert.assertEquals("Car BB 4 next load", "Coils", c4.getNextLoadName());
Assert.assertEquals("Car BC 5 destination", "Bedford MA", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "Bedford Siding 1", c5.getDestinationTrackName());
Assert.assertEquals("Car BC 5 final destination", "", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 load", "E", c5.getLoadName());
Assert.assertEquals("Car BC 5 next load", "", c5.getNextLoadName());
Assert.assertEquals("Car BD 6 destination", "Bedford MA", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "Bedford Siding 2", c6.getDestinationTrackName());
Assert.assertEquals("Car BD 6 final destination", "", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 6 load", "E", c6.getLoadName());
Assert.assertEquals("Car BD 6 next load", "", c6.getNextLoadName());
Assert.assertEquals("Car BA 7 destination", "Bedford MA", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "Bedford Yard", c7.getDestinationTrackName());
Assert.assertEquals("Car BA 7 final destination", "", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 load", "E", c7.getLoadName());
Assert.assertEquals("Car BA 7 next load", "", c7.getNextLoadName());
Assert.assertEquals("Car BB 8 destination", "Acton MA", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "Acton Siding 3", c8.getDestinationTrackName());
Assert.assertEquals("Car BB 8 final destination", "Clinton MA", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "Clinton Siding 1", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 load", "Trucks", c8.getLoadName());
Assert.assertEquals("Car BB 8 next load", "Wire", c8.getNextLoadName());
Assert.assertEquals("Car BC 9 destination", "Bedford MA", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "Bedford Interchange", c9.getDestinationTrackName());
Assert.assertEquals("Car BC 9 final destination", "", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "", c9.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 load", "E", c9.getLoadName());
Assert.assertEquals("Car BC 9 next load", "", c9.getNextLoadName());
ActonToBedfordTrain.terminate();
// Build train
Train BedfordToActonTrain = tmanager.newTrain("BedfordToActonToBedford");
Route BedfordToActon = RouteManager.instance().newRoute("BedfordToActonToBedford");
RouteLocation rlB2 = BedfordToActon.addLocation(Bedford);
RouteLocation rlA2 = BedfordToActon.addLocation(Acton);
RouteLocation rlB3 = BedfordToActon.addLocation(Bedford);
// increase the number of moves so all cars are used
rlB2.setMaxCarMoves(10);
rlA2.setMaxCarMoves(10);
rlB3.setMaxCarMoves(10);
BedfordToActonTrain.setRoute(BedfordToActon);
BedfordToActonTrain.build();
// check cars
Assert.assertEquals("Car BA 3 destination", "Acton MA", c3.getDestinationName());
Assert.assertEquals("Car BA 3 destination track", "Acton Siding 3", c3.getDestinationTrackName());
Assert.assertEquals("Car BA 3 final destination", "", c3.getFinalDestinationName());
Assert.assertEquals("Car BA 3 final destination track", "", c3.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 3 load", "Scrap", c3.getLoadName());
Assert.assertEquals("Car BA 3 next load", "E", c3.getNextLoadName());
Assert.assertEquals("Car BB 4 destination", "Bedford MA", c4.getDestinationName());
Assert.assertEquals("Car BB 4 destination track", "Bedford Yard", c4.getDestinationTrackName());
Assert.assertEquals("Car BB 4 final destination", "", c4.getFinalDestinationName());
Assert.assertEquals("Car BB 4 final destination track", "", c4.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 4 load", "Coils", c4.getLoadName());
Assert.assertEquals("Car BB 4 next load", "", c4.getNextLoadName());
Assert.assertEquals("Car BC 5 destination", "Acton MA", c5.getDestinationName());
Assert.assertEquals("Car BC 5 destination track", "Acton Yard", c5.getDestinationTrackName());
Assert.assertEquals("Car BC 5 final destination", "", c5.getFinalDestinationName());
Assert.assertEquals("Car BC 5 final destination track", "", c5.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 5 load", "L", c5.getLoadName());
Assert.assertEquals("Car BC 5 next load", "", c5.getNextLoadName());
Assert.assertEquals("Car BD 6 destination", "Acton MA", c6.getDestinationName());
Assert.assertEquals("Car BD 6 destination track", "Acton Interchange", c6.getDestinationTrackName());
Assert.assertEquals("Car BD 6 final destination", "", c6.getFinalDestinationName());
Assert.assertEquals("Car BD 6 final destination track", "", c6.getFinalDestinationTrackName());
Assert.assertEquals("Car BD 6 load", "L", c6.getLoadName());
Assert.assertEquals("Car BD 6 next load", "", c6.getNextLoadName());
Assert.assertEquals("Car BA 7 destination", "Acton MA", c7.getDestinationName());
Assert.assertEquals("Car BA 7 destination track", "Acton Yard", c7.getDestinationTrackName());
Assert.assertEquals("Car BA 7 final destination", "", c7.getFinalDestinationName());
Assert.assertEquals("Car BA 7 final destination track", "", c7.getFinalDestinationTrackName());
Assert.assertEquals("Car BA 7 load", "E", c7.getLoadName());
Assert.assertEquals("Car BA 7 next load", "", c7.getNextLoadName());
Assert.assertEquals("Car BB 8 destination", "Bedford MA", c8.getDestinationName());
Assert.assertEquals("Car BB 8 destination track", "Bedford Interchange", c8.getDestinationTrackName());
Assert.assertEquals("Car BB 8 final destination", "Clinton MA", c8.getFinalDestinationName());
Assert.assertEquals("Car BB 8 final destination track", "Clinton Siding 1", c8.getFinalDestinationTrackName());
Assert.assertEquals("Car BB 8 load", "Wire", c8.getLoadName());
Assert.assertEquals("Car BB 8 next load", "", c8.getNextLoadName());
Assert.assertEquals("Car BC 9 destination", "Acton MA", c9.getDestinationName());
Assert.assertEquals("Car BC 9 destination track", "Acton Interchange", c9.getDestinationTrackName());
Assert.assertEquals("Car BC 9 final destination", "", c9.getFinalDestinationName());
Assert.assertEquals("Car BC 9 final destination track", "", c9.getFinalDestinationTrackName());
Assert.assertEquals("Car BC 9 load", "E", c9.getLoadName());
Assert.assertEquals("Car BC 9 next load", "", c9.getNextLoadName());
BedfordToActonTrain.terminate();
}
Aggregations