use of jmri.jmrit.operations.rollingstock.engines.Consist in project JMRI by JMRI.
the class TrainBuilderTest method testAutoEnginesGrade.
public void testAutoEnginesGrade() {
// This test uses the maximum length of a train in route
Setup.setMaxTrainLength(1000);
Setup.setMaxNumberEngines(6);
Train train = tmanager.newTrain("TestAutoEnginesGrade");
train.setNumberEngines(Train.AUTO);
Route route = rmanager.newRoute("AutoEngineTest");
train.setRoute(route);
Location A = lmanager.newLocation("A");
Location B = lmanager.newLocation("B");
Location C = lmanager.newLocation("C");
Track At = A.addTrack("track", Track.SPUR);
Track Bt = B.addTrack("track", Track.SPUR);
Track Ct = C.addTrack("track", Track.SPUR);
At.setLength(300);
Bt.setLength(300);
Ct.setLength(300);
RouteLocation rA = route.addLocation(A);
RouteLocation rB = route.addLocation(B);
RouteLocation rC = route.addLocation(C);
rA.setMaxCarMoves(12);
rB.setMaxCarMoves(12);
rC.setMaxCarMoves(12);
// 2.5% grade!
rB.setGrade(2.5);
Engine e1 = emanager.newEngine("E", "1");
e1.setModel("GP40");
Engine e2 = emanager.newEngine("E", "2");
e2.setModel("GP40");
Engine e3 = emanager.newEngine("E", "3");
e3.setModel("GP40");
Engine e4 = emanager.newEngine("E", "4");
e4.setModel("GP40");
e1.setLocation(A, At);
e2.setLocation(A, At);
e3.setLocation(A, At);
e4.setLocation(A, At);
Consist c = emanager.newConsist("c");
e1.setConsist(c);
e2.setConsist(c);
// train should require four engines
train.reset();
new TrainBuilder().build(train);
Assert.assertFalse("Train should not build, needs four engines, only two", train.isBuilt());
e3.setConsist(c);
train.reset();
new TrainBuilder().build(train);
Assert.assertFalse("Train should not build, needs four engines, only three", train.isBuilt());
e4.setConsist(c);
train.reset();
new TrainBuilder().build(train);
Assert.assertTrue("Train should build, four engines available", train.isBuilt());
}
use of jmri.jmrit.operations.rollingstock.engines.Consist in project JMRI by JMRI.
the class TrainTest method testAutoEnginesTwoEngines.
public void testAutoEnginesTwoEngines() {
TrainManager tmanager = TrainManager.instance();
RouteManager rmanager = RouteManager.instance();
LocationManager lmanager = LocationManager.instance();
EngineManager emanager = EngineManager.instance();
// This test uses the maximum length of a train in route
Setup.setMaxTrainLength(1000);
Train train = tmanager.newTrain("AutoEngineTest");
train.setNumberEngines(Train.AUTO);
Route route = rmanager.newRoute("AutoEngineTest");
train.setRoute(route);
Location A = lmanager.newLocation("A");
Location B = lmanager.newLocation("B");
Location C = lmanager.newLocation("C");
Track At = A.addTrack("track", Track.SPUR);
Track Bt = B.addTrack("track", Track.SPUR);
Track Ct = C.addTrack("track", Track.SPUR);
At.setLength(300);
Bt.setLength(300);
Ct.setLength(300);
RouteLocation rA = route.addLocation(A);
RouteLocation rB = route.addLocation(B);
RouteLocation rC = route.addLocation(C);
rA.setMaxCarMoves(5);
rB.setMaxCarMoves(5);
rC.setMaxCarMoves(5);
Engine e1 = emanager.newEngine("E", "1");
e1.setModel("GP40");
Engine e2 = emanager.newEngine("E", "2");
e2.setModel("GP40");
Engine e3 = emanager.newEngine("E", "3");
e3.setModel("GP40");
Engine e4 = emanager.newEngine("E", "4");
e4.setModel("GP40");
e1.setLocation(A, At);
e2.setLocation(A, At);
e3.setLocation(A, At);
e4.setLocation(A, At);
// change requirements
rA.setMaxCarMoves(12);
rB.setMaxCarMoves(12);
rC.setMaxCarMoves(12);
train.build();
Assert.assertFalse("Train should not build, only single engines", train.isBuilt());
Consist c = emanager.newConsist("c");
e1.setConsist(c);
e2.setConsist(c);
// train should require two engines
train.build();
Assert.assertTrue("Train should build", train.isBuilt());
Assert.assertEquals("e1 should be assigned to train", train, e1.getTrain());
Assert.assertEquals("e2 should be assigned to train", train, e2.getTrain());
}
use of jmri.jmrit.operations.rollingstock.engines.Consist in project JMRI by JMRI.
the class TrainBuilderTest method testAggressiveBuildOption.
public void testAggressiveBuildOption() {
Setup.setBuildAggressive(true);
Setup.setStagingTrackImmediatelyAvail(false);
EngineTypes et = EngineTypes.instance();
// register the car and engine types used
ct.addName("Boxcar");
ct.addName("Caboose");
ct.addName("Flat");
et.addName("Diesel");
// create 2 consists and a single engine for testing
Consist con1 = emanager.newConsist("C1");
Engine e1 = emanager.newEngine("UP", "1");
e1.setModel("GP30");
e1.setOwner("AT");
e1.setBuilt("1957");
e1.setConsist(con1);
e1.setMoves(5);
Engine e2 = emanager.newEngine("SP", "2");
e2.setModel("GP30");
e2.setOwner("AT");
e2.setBuilt("1957");
e2.setConsist(con1);
e2.setMoves(5);
// one engine
Engine e3 = emanager.newEngine("SP", "3");
e3.setModel("GP40");
e3.setOwner("DAB");
e3.setBuilt("1957");
Consist con2 = emanager.newConsist("C2");
Engine e4 = emanager.newEngine("UP", "10");
e4.setModel("GP40");
e4.setOwner("DAB");
e4.setBuilt("1944");
e4.setConsist(con2);
e4.setMoves(20);
Engine e5 = emanager.newEngine("SP", "20");
e5.setModel("GP40");
e5.setOwner("DAB");
e5.setBuilt("1944");
e5.setConsist(con2);
e5.setMoves(20);
// 3 engine consist
Consist con3 = emanager.newConsist("C3");
Engine e6 = emanager.newEngine("UP", "100");
e6.setModel("GP40");
e6.setOwner("DAB");
e6.setBuilt("1944");
e6.setConsist(con3);
e6.setMoves(2);
Engine e7 = emanager.newEngine("SP", "200");
e7.setModel("GP40");
e7.setOwner("DAB");
e7.setBuilt("1944");
e7.setConsist(con3);
e7.setMoves(2);
Engine e8 = emanager.newEngine("SP", "300");
e8.setModel("GP40");
e8.setOwner("DAB");
e8.setBuilt("1944");
e8.setConsist(con3);
e8.setMoves(2);
// Set up cars
Car c1 = cmanager.newCar("PU", "13");
c1.setTypeName("Caboose");
c1.setLength("32");
c1.setMoves(10);
c1.setOwner("AT");
c1.setBuilt("1943");
c1.setCaboose(true);
Car c2 = cmanager.newCar("SP", "23");
c2.setTypeName("Boxcar");
c2.setLength("30");
c2.setMoves(5);
c2.setOwner("DAB");
c2.setBuilt("1957");
Car c3 = cmanager.newCar("UP", "33");
c3.setTypeName("Boxcar");
c3.setLength("33");
c3.setMoves(0);
c3.setOwner("DAB");
c3.setBuilt("1944");
Car c4 = cmanager.newCar("UP", "43");
c4.setTypeName("Boxcar");
c4.setLength("40");
c4.setMoves(16);
c4.setOwner("DAB");
c4.setBuilt("1958");
Car c5 = cmanager.newCar("SP", "53");
c5.setTypeName("Boxcar");
c5.setLength("40");
c5.setMoves(8);
c5.setOwner("DAB");
c5.setBuilt("1958");
Car c6 = cmanager.newCar("NH", "63");
c6.setTypeName("Boxcar");
c6.setLength("40");
c6.setMoves(2);
c6.setOwner("DAB");
c6.setBuilt("1958");
Car c7 = cmanager.newCar("UP", "73");
c7.setTypeName("Flat");
c7.setLength("40");
c7.setMoves(5);
c7.setOwner("DAB");
c7.setBuilt("1958");
Car c8 = cmanager.newCar("SP", "83");
c8.setTypeName("Boxcar");
c8.setLength("40");
c8.setMoves(4);
c8.setOwner("DAB");
c8.setBuilt("1958");
Car c9 = cmanager.newCar("NH", "93");
c9.setTypeName("Boxcar");
c9.setLength("40");
c9.setMoves(3);
c9.setOwner("DAB");
c9.setBuilt("1944");
Car c10 = cmanager.newCar("NH", "103");
c10.setTypeName("Boxcar");
c10.setLength("40");
c10.setMoves(10);
c10.setOwner("DAB");
c10.setBuilt("1958");
Car c11 = cmanager.newCar("SP", "113");
c11.setTypeName("Boxcar");
c11.setLength("40");
c11.setMoves(3);
c11.setOwner("DAB");
c11.setBuilt("1958");
// Create 5 locations
Location loc1 = lmanager.newLocation("New Harvard");
Track loc1trk1 = loc1.addTrack("Harvard Yard 1", Track.YARD);
loc1trk1.setLength(1000);
Track loc1trk2 = loc1.addTrack("Harvard Yard 2", Track.YARD);
loc1trk2.setLength(1000);
Location loc2 = lmanager.newLocation("New Arlington");
Track loc2trk1 = loc2.addTrack("Arlington Siding", Track.SPUR);
loc2trk1.setLength(50);
Location loc3 = lmanager.newLocation("New Boston");
Track loc3trk1 = loc3.addTrack("Boston Yard 1", Track.YARD);
loc3trk1.setLength(50);
Track loc3trk2 = loc3.addTrack("Boston Yard 2", Track.YARD);
loc3trk2.setLength(50);
Location loc4 = lmanager.newLocation("New Chelmsford");
Track loc4trk1 = loc4.addTrack("Chelmsford Yard 1", Track.YARD);
loc4trk1.setLength(50);
Track loc4trk2 = loc4.addTrack("Chelmsford Yard 2", Track.YARD);
loc4trk2.setLength(50);
Location loc5 = lmanager.newLocation("New Westford");
Track loc5trk1 = loc5.addTrack("Westford Yard 1", Track.YARD);
loc5trk1.setLength(1000);
Track loc5trk2 = loc5.addTrack("Westford Yard 2", Track.YARD);
loc5trk2.setLength(1000);
// Create route with 5 location
Route rte1 = rmanager.newRoute("Route 3 Westford");
rte1.addLocation(loc1);
rte1.addLocation(loc2);
rte1.addLocation(loc3);
rte1.addLocation(loc4);
rte1.addLocation(loc5);
// Create train
Train train1 = tmanager.newTrain("TestAggressiveBuildOption");
train1.setRoute(rte1);
// Place cars
Assert.assertEquals("Place c1", Track.OKAY, c1.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place c2", Track.OKAY, c2.setLocation(loc1, loc1trk2));
Assert.assertEquals("Place c3", Track.OKAY, c3.setLocation(loc2, loc2trk1));
Assert.assertEquals("Place c4", Track.OKAY, c4.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place c5", Track.OKAY, c5.setLocation(loc1, loc1trk2));
Assert.assertEquals("Place c6", Track.OKAY, c6.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place c7", Track.OKAY, c7.setLocation(loc3, loc3trk1));
Assert.assertEquals("Place c8", Track.OKAY, c8.setLocation(loc3, loc3trk2));
Assert.assertEquals("Place c9", Track.OKAY, c9.setLocation(loc4, loc4trk1));
Assert.assertEquals("Place c10", Track.OKAY, c10.setLocation(loc4, loc4trk2));
Assert.assertEquals("Place c11", Track.OKAY, c11.setLocation(loc1, loc1trk1));
// Place engines
Assert.assertEquals("Place e1", Track.OKAY, e1.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place e2", Track.OKAY, e2.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place e3", Track.OKAY, e3.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place e4", Track.OKAY, e4.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place e5", Track.OKAY, e5.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place e6", Track.OKAY, e6.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place e7", Track.OKAY, e7.setLocation(loc1, loc1trk1));
Assert.assertEquals("Place e8", Track.OKAY, e8.setLocation(loc1, loc1trk1));
train1.setRequirements(Train.CABOOSE);
train1.setNumberEngines("3");
train1.setOwnerOption(Train.ALL_OWNERS);
train1.reset();
new TrainBuilder().build(train1);
Assert.assertEquals("Train 1 After Build 1", true, train1.isBuilt());
// check destinations
Assert.assertEquals("c1 destination 1", "Westford Yard 2", c1.getDestinationTrackName());
Assert.assertEquals("c2 destination 1", "Westford Yard 1", c2.getDestinationTrackName());
Assert.assertEquals("c3 destination 1", "Westford Yard 2", c3.getDestinationTrackName());
Assert.assertEquals("c4 destination 1", "Boston Yard 1", c4.getDestinationTrackName());
Assert.assertEquals("c5 destination 1", "Arlington Siding", c5.getDestinationTrackName());
Assert.assertEquals("c6 destination 1", "Westford Yard 2", c6.getDestinationTrackName());
Assert.assertEquals("c7 destination 1", "Westford Yard 2", c7.getDestinationTrackName());
Assert.assertEquals("c8 destination 1", "Westford Yard 1", c8.getDestinationTrackName());
Assert.assertEquals("c9 destination 1", "", c9.getDestinationTrackName());
Assert.assertEquals("c10 destination 1", "", c10.getDestinationTrackName());
Assert.assertEquals("c11 destination 1", "Westford Yard 2", c11.getDestinationTrackName());
Assert.assertEquals("e1 destination 1", "", e1.getDestinationTrackName());
Assert.assertEquals("e2 destination 1", "", e2.getDestinationTrackName());
Assert.assertEquals("e3 destination 1", "", e3.getDestinationTrackName());
Assert.assertEquals("e4 destination 1", "", e4.getDestinationTrackName());
Assert.assertEquals("e5 destination 1", "", e5.getDestinationTrackName());
Assert.assertEquals("e6 destination 1", "Westford Yard 1", e6.getDestinationTrackName());
Assert.assertEquals("e7 destination 1", "Westford Yard 1", e7.getDestinationTrackName());
Assert.assertEquals("e8 destination 1", "Westford Yard 1", e8.getDestinationTrackName());
// test departing from staging in aggressive mode
Assert.assertTrue(train1.reset());
loc1trk1.setTrackType(Track.STAGING);
loc1trk2.setTrackType(Track.STAGING);
loc1.setLocationOps(Location.STAGING);
train1.reset();
new TrainBuilder().build(train1);
Assert.assertFalse("Train 1 After Build from staging, eight loco on departure track", train1.isBuilt());
// move locos to other departure track
Assert.assertEquals("Place e1", Track.OKAY, e1.setLocation(loc1, loc1trk2));
Assert.assertEquals("Place e2", Track.OKAY, e2.setLocation(loc1, loc1trk2));
Assert.assertEquals("Place e3", Track.OKAY, e3.setLocation(loc1, loc1trk2));
Assert.assertEquals("Place e4", Track.OKAY, e4.setLocation(loc1, loc1trk2));
Assert.assertEquals("Place e5", Track.OKAY, e5.setLocation(loc1, loc1trk2));
train1.reset();
new TrainBuilder().build(train1);
Assert.assertTrue("Train 1 After Build from staging, three loco on departure track", train1.isBuilt());
// check destinations
Assert.assertEquals("c1 destination 2", "Westford Yard 2", c1.getDestinationTrackName());
Assert.assertEquals("c2 destination 2", "", c2.getDestinationTrackName());
Assert.assertEquals("c3 destination 2", "Westford Yard 2", c3.getDestinationTrackName());
Assert.assertEquals("c4 destination 2", "Boston Yard 2", c4.getDestinationTrackName());
Assert.assertEquals("c5 destination 2", "", c5.getDestinationTrackName());
Assert.assertEquals("c6 destination 2", "Arlington Siding", c6.getDestinationTrackName());
Assert.assertEquals("c7 destination 2", "Westford Yard 1", c7.getDestinationTrackName());
Assert.assertEquals("c8 destination 2", "Westford Yard 2", c8.getDestinationTrackName());
Assert.assertEquals("c9 destination 2", "Westford Yard 2", c9.getDestinationTrackName());
Assert.assertEquals("c10 destination 2", "Westford Yard 1", c10.getDestinationTrackName());
Assert.assertEquals("c11 destination 2", "Chelmsford Yard 1", c11.getDestinationTrackName());
Assert.assertEquals("e1 destination 2", "", e1.getDestinationTrackName());
Assert.assertEquals("e2 destination 2", "", e2.getDestinationTrackName());
Assert.assertEquals("e3 destination 2", "", e3.getDestinationTrackName());
Assert.assertEquals("e4 destination 2", "", e4.getDestinationTrackName());
Assert.assertEquals("e5 destination 2", "", e5.getDestinationTrackName());
Assert.assertEquals("e6 destination 2", "Westford Yard 1", e6.getDestinationTrackName());
Assert.assertEquals("e7 destination 2", "Westford Yard 1", e7.getDestinationTrackName());
Assert.assertEquals("e8 destination 2", "Westford Yard 1", e8.getDestinationTrackName());
// test train move to a specific location
Assert.assertFalse("Old Harvard is not part of this trains route", train1.move("Old Harvard"));
Assert.assertFalse("Train departs New Harvard already there", train1.move("New Harvard"));
Assert.assertTrue("Next location in train's route is New Arlington", train1.move("New Arlington"));
Assert.assertFalse("Train is at New Arlington", train1.move("New Arlington"));
// next location is New Boston, skip it and go directly to New Chelmsford
Assert.assertTrue("New Chelmsford is in train's route", train1.move("New Chelmsford"));
Assert.assertTrue("Next location in train's route is New Westford", train1.move("New Westford"));
Assert.assertFalse("Train is at New Westford last location in train's route", train1.move("New Westford"));
// terminate train
train1.move();
// now try with a train returning to staging, test alternate track feature
// Create train
Train train2 = tmanager.newTrain("Westford to Harvard Aggressive");
Route rte2 = rmanager.copyRoute(rte1, "Route 4 Harvard", true);
train2.setRoute(rte2);
train2.setRequirements(Train.CABOOSE);
train2.setNumberEngines("3");
// add 2 yard tracks to siding at Arlington
Track loc2trk2 = loc2.addTrack("Arlington Yard 1", Track.YARD);
// only enough room for one car
loc2trk2.setLength(50);
Track loc2trk3 = loc2.addTrack("Arlington Alternate Track", Track.SPUR);
// only enough room for two cars
loc2trk3.setLength(100);
// set the alternate for Arlington siding
loc2trk1.setAlternateTrack(loc2trk3);
// send cars to Arlington siding
c3.setFinalDestination(loc2);
c3.setFinalDestinationTrack(loc2trk1);
c8.setFinalDestination(loc2);
c8.setFinalDestinationTrack(loc2trk1);
c9.setFinalDestination(loc2);
c9.setFinalDestinationTrack(loc2trk1);
c11.setFinalDestination(loc2);
c11.setFinalDestinationTrack(loc2trk1);
train2.reset();
new TrainBuilder().build(train2);
Assert.assertTrue("Train 2 returns to staging", train2.isBuilt());
// check destinations
Assert.assertEquals("c1 destination 3", "Harvard Yard 1", c1.getDestinationTrackName());
Assert.assertEquals("c2 destination 3", "", c2.getDestinationTrackName());
Assert.assertEquals("c3 destination 3", "Arlington Alternate Track", c3.getDestinationTrackName());
Assert.assertEquals("c4 destination 3", "Harvard Yard 1", c4.getDestinationTrackName());
Assert.assertEquals("c5 destination 3", "", c5.getDestinationTrackName());
Assert.assertEquals("c6 destination 3", "Harvard Yard 1", c6.getDestinationTrackName());
Assert.assertEquals("c7 destination 3", "Chelmsford Yard 2", c7.getDestinationTrackName());
Assert.assertEquals("c8 destination 3", "Arlington Yard 1", c8.getDestinationTrackName());
Assert.assertEquals("c9 destination 3", "Arlington Alternate Track", c9.getDestinationTrackName());
Assert.assertEquals("c10 destination 3", "Boston Yard 1", c10.getDestinationTrackName());
Assert.assertEquals("c11 destination 3", "Arlington Siding", c11.getDestinationTrackName());
Assert.assertEquals("e1 destination 3", "", e1.getDestinationTrackName());
Assert.assertEquals("e2 destination 3", "", e2.getDestinationTrackName());
Assert.assertEquals("e3 destination 3", "", e3.getDestinationTrackName());
Assert.assertEquals("e4 destination 3", "", e4.getDestinationTrackName());
Assert.assertEquals("e5 destination 3", "", e5.getDestinationTrackName());
Assert.assertEquals("e6 destination 3", "Harvard Yard 1", e6.getDestinationTrackName());
Assert.assertEquals("e7 destination 3", "Harvard Yard 1", e7.getDestinationTrackName());
Assert.assertEquals("e8 destination 3", "Harvard Yard 1", e8.getDestinationTrackName());
// check that cars on alternate track are sent to Arlington Siding
Assert.assertEquals("next dest Arlingtion", loc2, c3.getFinalDestination());
Assert.assertEquals("next dest track Arlingtion Siding", loc2trk1, c3.getFinalDestinationTrack());
Assert.assertEquals("next dest Arlingtion", loc2, c8.getFinalDestination());
Assert.assertEquals("next dest track Arlingtion Siding", loc2trk1, c8.getFinalDestinationTrack());
Assert.assertEquals("next dest Arlingtion", loc2, c9.getFinalDestination());
Assert.assertEquals("next dest track Arlingtion Siding", loc2trk1, c9.getFinalDestinationTrack());
Assert.assertEquals("next dest null", null, c11.getFinalDestination());
Assert.assertEquals("next dest track null", null, c11.getFinalDestinationTrack());
// test train move to a an exact location
Assert.assertFalse("Old Harvard is not part of this trains route", train2.moveToNextLocation("Old Harvard"));
Assert.assertFalse("New Harvard is the last location in this trains route", train2.moveToNextLocation("New Harvard"));
Assert.assertFalse("New Boston is the 3rd to last location in this trains route", train2.moveToNextLocation("New Boston"));
Assert.assertFalse("New Westford is the current location in this trains route", train2.moveToNextLocation("New Westford"));
Assert.assertFalse("New Arlington is the 2nd to last location in this trains route", train2.moveToNextLocation("New Arlington"));
Assert.assertTrue("New Chelmsford is the next location in this trains route", train2.moveToNextLocation("New Chelmsford"));
Assert.assertTrue("New Boston is the next location in this trains route", train2.moveToNextLocation("New Boston"));
Assert.assertTrue("New Arlington is the next location in this trains route", train2.moveToNextLocation("New Arlington"));
Assert.assertTrue("New Harvard is the next location in this trains route", train2.moveToNextLocation("New Harvard"));
Assert.assertFalse("Train is at New Harvard", train2.moveToNextLocation("New Harvard"));
// terminate train
train2.move();
// now test train returning to staging
rte1.addLocation(loc1);
train1.reset();
new TrainBuilder().build(train1);
// should fail, can't return to staging track
Assert.assertEquals("Train 1 departing and returning to staging", false, train1.isBuilt());
// change mode
Setup.setStagingTrackImmediatelyAvail(true);
train1.reset();
new TrainBuilder().build(train1);
Assert.assertEquals("Train 1 departing and returning to staging", true, train1.isBuilt());
train1.terminate();
// check car locations
Assert.assertEquals("c1 location", "Harvard Yard 1", c1.getTrackName());
Assert.assertEquals("c2 location", "Harvard Yard 2", c2.getTrackName());
Assert.assertEquals("c3 location", "Arlington Alternate Track", c3.getTrackName());
Assert.assertEquals("c4 location", "Boston Yard 2", c4.getTrackName());
Assert.assertEquals("c5 location", "Harvard Yard 2", c5.getTrackName());
Assert.assertEquals("c6 location", "Westford Yard 1", c6.getTrackName());
Assert.assertEquals("c7 location", "Harvard Yard 1", c7.getTrackName());
Assert.assertEquals("c8 location", "Arlington Siding", c8.getTrackName());
Assert.assertEquals("c9 location", "Arlington Alternate Track", c9.getTrackName());
Assert.assertEquals("c10 location", "Chelmsford Yard 1", c10.getTrackName());
Assert.assertEquals("c11 location", "Westford Yard 2", c11.getTrackName());
Assert.assertEquals("e1 location", "Harvard Yard 2", e1.getTrackName());
Assert.assertEquals("e2 location", "Harvard Yard 2", e2.getTrackName());
Assert.assertEquals("e3 location", "Harvard Yard 2", e3.getTrackName());
Assert.assertEquals("e4 location", "Harvard Yard 2", e4.getTrackName());
Assert.assertEquals("e5 location", "Harvard Yard 2", e5.getTrackName());
Assert.assertEquals("e6 location", "Harvard Yard 1", e6.getTrackName());
Assert.assertEquals("e7 location", "Harvard Yard 1", e7.getTrackName());
Assert.assertEquals("e8 location", "Harvard Yard 1", e8.getTrackName());
}
use of jmri.jmrit.operations.rollingstock.engines.Consist in project JMRI by JMRI.
the class JUnitOperationsUtil method initOperationsData.
/**
* Populate the Operations Managers with a common set of data for tests.
*/
public static void initOperationsData() {
TrainManager tmanager = TrainManager.instance();
RouteManager rmanager = RouteManager.instance();
LocationManager lmanager = LocationManager.instance();
EngineManager emanager = EngineManager.instance();
CarManager cmanager = CarManager.instance();
CarTypes ct = CarTypes.instance();
EngineTypes et = EngineTypes.instance();
// register the car and engine types used
ct.addName("Boxcar");
ct.addName("Caboose");
ct.addName("Flat");
et.addName("Diesel");
// Set up four engines in two consists
Consist con1 = emanager.newConsist("C16");
Consist con2 = emanager.newConsist("C14");
Engine e1 = new Engine("PC", "5016");
e1.setModel("GP40");
e1.setConsist(con1);
e1.setMoves(123);
e1.setOwner("AT");
e1.setBuilt("1990");
emanager.register(e1);
Engine e2 = new Engine("PC", "5019");
e2.setModel("GP40");
e2.setConsist(con1);
e2.setMoves(321);
e2.setOwner("AT");
e2.setBuilt("1990");
emanager.register(e2);
Engine e3 = new Engine("PC", "5524");
e3.setModel("SD45");
e3.setConsist(con2);
e3.setOwner("DAB");
e3.setBuilt("1980");
emanager.register(e3);
Engine e4 = new Engine("PC", "5559");
e4.setModel("SD45");
e4.setConsist(con2);
e4.setOwner("DAB");
e4.setBuilt("1980");
emanager.register(e4);
// Set up two cabooses and six box cars
Car c1 = new Car("CP", "C10099");
c1.setTypeName("Caboose");
c1.setLength("32");
c1.setMoves(23);
c1.setOwner("AT");
c1.setBuilt("1980");
c1.setCaboose(true);
cmanager.register(c1);
Car c2 = new Car("CP", "C20099");
c2.setTypeName("Caboose");
c2.setLength("32");
c2.setMoves(54);
c2.setOwner("DAB");
c2.setBuilt("1984");
c2.setCaboose(true);
cmanager.register(c2);
Car c3 = new Car("CP", "X10001");
c3.setTypeName("Boxcar");
c3.setLength("40");
c3.setOwner("DAB");
c3.setBuilt("1984");
cmanager.register(c3);
Car c4 = new Car("CP", "X10002");
c4.setTypeName("Boxcar");
c4.setLength("40");
c4.setOwner("AT");
c4.setBuilt("1-84");
c4.setMoves(4444);
cmanager.register(c4);
Car c5 = new Car("CP", "X20001");
c5.setTypeName("Boxcar");
c5.setLength("40");
c5.setOwner("DAB");
c5.setBuilt("1980");
cmanager.register(c5);
Car c6 = new Car("CP", "X20002");
c6.setTypeName("Boxcar");
c6.setLength("40");
c6.setOwner("DAB");
c6.setBuilt("1978");
cmanager.register(c6);
Car c7 = new Car("CP", "777");
c7.setTypeName("Flat");
c7.setLength("50");
c7.setOwner("AT");
c7.setBuilt("1990");
c7.setMoves(6);
cmanager.register(c7);
Car c8 = new Car("CP", "888");
c8.setTypeName("Boxcar");
c8.setLength("60");
c8.setOwner("DAB");
c8.setBuilt("1985");
cmanager.register(c8);
Car c9 = new Car("CP", "99");
c9.setTypeName("Flat");
c9.setLength("90");
c9.setOwner("AT");
c9.setBuilt("6-80");
cmanager.register(c9);
// Set up a route of 3 locations: North End Staging (2 tracks),
// North Industries (1 track), and South End Staging (2 tracks).
Location l1 = new Location("1", "North End");
l1.setLocationOps(Location.STAGING);
l1.setTrainDirections(DIRECTION_ALL);
l1.setSwitchListEnabled(true);
lmanager.register(l1);
Track l1s1 = new Track("1s1", "North End 1", Track.STAGING, l1);
l1s1.setLength(300);
l1s1.setTrainDirections(DIRECTION_ALL);
l1s1.setRoadOption(Track.ALL_ROADS);
l1s1.setDropOption(Track.ANY);
l1s1.setPickupOption(Track.ANY);
Track l1s2 = new Track("1s2", "North End 2", Track.STAGING, l1);
l1s2.setLength(400);
l1s2.setTrainDirections(DIRECTION_ALL);
l1s2.setRoadOption(Track.ALL_ROADS);
l1s2.setDropOption(Track.ANY);
l1s2.setPickupOption(Track.ANY);
l1.addTrack("North End 1", Track.STAGING);
l1.addTrack("North End 2", Track.STAGING);
l1.register(l1s1);
l1.register(l1s2);
Location l2 = new Location("2", "North Industries");
l2.setLocationOps(Location.NORMAL);
l2.setTrainDirections(DIRECTION_ALL);
l2.setSwitchListEnabled(true);
lmanager.register(l2);
Track l2s1 = new Track("2s1", "NI Yard", Track.YARD, l2);
l2s1.setLength(432);
l2s1.setTrainDirections(DIRECTION_ALL);
l2.register(l2s1);
Location l3 = new Location("3", "South End");
l3.setLocationOps(Location.STAGING);
l3.setTrainDirections(DIRECTION_ALL);
l3.setSwitchListEnabled(true);
lmanager.register(l3);
Track l3s1 = new Track("3s1", "South End 1", Track.STAGING, l3);
l3s1.setLength(300);
l3s1.setTrainDirections(DIRECTION_ALL);
l3s1.setRoadOption(Track.ALL_ROADS);
l3s1.setDropOption(Track.ANY);
l3s1.setPickupOption(Track.ANY);
Track l3s2 = new Track("3s2", "South End 2", Track.STAGING, l3);
l3s2.setLength(401);
l3s2.setTrainDirections(DIRECTION_ALL);
l3s2.setRoadOption(Track.ALL_ROADS);
l3s2.setDropOption(Track.ANY);
l3s2.setPickupOption(Track.ANY);
l3.addTrack("South End 1", Track.STAGING);
l3.addTrack("South End 2", Track.STAGING);
l3.register(l3s1);
l3.register(l3s2);
// Place 4 Boxcars on Staging tracks
c3.setLocation(l1, l1s1);
c4.setLocation(l1, l1s1);
c5.setLocation(l1, l1s2);
c6.setLocation(l1, l1s2);
// Place 2 Boxcars and Flat in yard
c7.setLocation(l2, l2s1);
c8.setLocation(l2, l2s1);
c9.setLocation(l2, l2s1);
// Place Cabooses on Staging tracks
c1.setLocation(l1, l1s1);
// Define the route.
Route route1 = new Route("1", "Southbound Main Route");
RouteLocation rl1 = new RouteLocation("1r1", l1);
rl1.setSequenceId(1);
rl1.setTrainDirection(RouteLocation.SOUTH);
rl1.setMaxCarMoves(5);
rl1.setMaxTrainLength(1000);
// set the train icon coordinates
rl1.setTrainIconX(25);
rl1.setTrainIconY(25);
RouteLocation rl2 = new RouteLocation("1r2", l2);
rl2.setSequenceId(2);
rl2.setTrainDirection(RouteLocation.SOUTH);
// test for only 1 pickup and 1 drop
rl2.setMaxCarMoves(2);
rl2.setMaxTrainLength(1000);
// set the train icon coordinates
rl2.setTrainIconX(75);
rl2.setTrainIconY(25);
RouteLocation rl3 = new RouteLocation("1r3", l3);
rl3.setSequenceId(3);
rl3.setTrainDirection(RouteLocation.SOUTH);
rl3.setMaxCarMoves(5);
rl3.setMaxTrainLength(1000);
// set the train icon coordinates
rl3.setTrainIconX(125);
rl3.setTrainIconY(25);
route1.register(rl1);
route1.register(rl2);
route1.register(rl3);
rmanager.register(route1);
// Finally ready to define the trains.
Train train1 = new Train("1", "STF");
train1.setRequirements(Train.CABOOSE);
train1.setCabooseRoad("CP");
train1.deleteTypeName("Flat");
train1.setRoadOption(Train.ALL_ROADS);
train1.setRoute(route1);
train1.setDepartureTime("6", "5");
tmanager.register(train1);
Train train2 = new Train("2", "SFF");
// there are boxcars waiting in staging so build should fail
train2.deleteTypeName("Boxcar");
train2.deleteTypeName("Flat");
train2.setRoute(route1);
train2.setDepartureTime("22", "45");
tmanager.register(train2);
}
Aggregations