use of jmri.jmrit.operations.trains.TrainManager in project JMRI by JMRI.
the class OperationsTrainsGuiTest method testTrainModifyFrame.
@Test
public void testTrainModifyFrame() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
// confirm that train default accepts Boxcars
TrainManager tmanager = TrainManager.instance();
Train t = tmanager.newTrain("Test Train Name 2");
Assert.assertTrue("accepts Boxcar 1", t.acceptsTypeName("Boxcar"));
TrainsByCarTypeFrame f = new TrainsByCarTypeFrame();
f.initComponents("Boxcar");
// remove Boxcar from trains
enterClickAndLeave(f.clearButton);
enterClickAndLeave(f.saveButton);
Assert.assertFalse("accepts Boxcar 2", t.acceptsTypeName("Boxcar"));
// now add Boxcar to trains
enterClickAndLeave(f.setButton);
enterClickAndLeave(f.saveButton);
Assert.assertTrue("accepts Boxcar 3", t.acceptsTypeName("Boxcar"));
f.dispose();
}
use of jmri.jmrit.operations.trains.TrainManager in project JMRI by JMRI.
the class OperationsTrainsGuiTest method testTrainByCarTypeFrame.
@Test
public void testTrainByCarTypeFrame() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
TrainManager tmanager = TrainManager.instance();
Train train = tmanager.getTrainByName("Test Train Name");
TrainByCarTypeFrame f = new TrainByCarTypeFrame();
f.initComponents(train);
Assert.assertNotNull("frame exists", f);
f.dispose();
}
use of jmri.jmrit.operations.trains.TrainManager in project JMRI by JMRI.
the class OperationsTrainsGuiTest method loadTrains.
private void loadTrains() {
// Add some cars for the various tests in this suite
CarManager cm = CarManager.instance();
// add caboose to the roster
Car c = cm.newCar("NH", "687");
c.setCaboose(true);
c = cm.newCar("CP", "435");
c.setCaboose(true);
// load engines
EngineManager emanager = EngineManager.instance();
Engine e1 = emanager.newEngine("E", "1");
e1.setModel("GP40");
Engine e2 = emanager.newEngine("E", "2");
e2.setModel("GP40");
Engine e3 = emanager.newEngine("UP", "3");
e3.setModel("GP40");
Engine e4 = emanager.newEngine("UP", "4");
e4.setModel("FT");
TrainManager tmanager = TrainManager.instance();
// turn off build fail messages
tmanager.setBuildMessagesEnabled(true);
// turn off print preview
tmanager.setPrintPreviewEnabled(false);
// load 5 trains
for (int i = 0; i < 5; i++) {
tmanager.newTrain("Test_Train " + i);
}
// load 6 locations
for (int i = 0; i < 6; i++) {
LocationManager.instance().newLocation("Test_Location " + i);
}
// load 5 routes
RouteManager.instance().newRoute("Test Route A");
RouteManager.instance().newRoute("Test Route B");
RouteManager.instance().newRoute("Test Route C");
RouteManager.instance().newRoute("Test Route D");
RouteManager.instance().newRoute("Test Route E");
}
use of jmri.jmrit.operations.trains.TrainManager 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