Search in sources :

Example 61 with Location

use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.

the class EngineAttributeEditFrameTest method loadEngines.

private void loadEngines() {
    // add Owner1 and Owner2
    CarOwners co = CarOwners.instance();
    co.addName("Owner1");
    co.addName("Owner2");
    // add road names
    CarRoads cr = CarRoads.instance();
    cr.addName("NH");
    cr.addName("UP");
    cr.addName("AA");
    cr.addName("SP");
    // add locations
    LocationManager lManager = LocationManager.instance();
    Location westford = lManager.newLocation("Westford");
    Track westfordYard = westford.addTrack("Yard", Track.YARD);
    westfordYard.setLength(300);
    Track westfordSiding = westford.addTrack("Siding", Track.SPUR);
    westfordSiding.setLength(300);
    Track westfordAble = westford.addTrack("Able", Track.SPUR);
    westfordAble.setLength(300);
    Location boxford = lManager.newLocation("Boxford");
    Track boxfordYard = boxford.addTrack("Yard", Track.YARD);
    boxfordYard.setLength(300);
    Track boxfordJacobson = boxford.addTrack("Jacobson", Track.SPUR);
    boxfordJacobson.setLength(300);
    Track boxfordHood = boxford.addTrack("Hood", Track.SPUR);
    boxfordHood.setLength(300);
    EngineManager eManager = EngineManager.instance();
    // add 5 Engines to table
    Engine e1 = eManager.newEngine("NH", "1");
    e1.setModel("RS1");
    e1.setBuilt("2009");
    e1.setMoves(55);
    e1.setOwner("Owner2");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 3");
    e1.setRfid("RFID 3");
    e1.setWeightTons("Tons of Weight");
    e1.setComment("Test Engine NH 1 Comment");
    Assert.assertEquals("e1 location", Track.OKAY, e1.setLocation(westford, westfordYard));
    Assert.assertEquals("e1 destination", Track.OKAY, e1.setDestination(boxford, boxfordJacobson));
    Engine e2 = eManager.newEngine("UP", "2");
    e2.setModel("FT");
    e2.setBuilt("2004");
    e2.setMoves(50);
    e2.setOwner("AT");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 2");
    e2.setRfid("RFID 2");
    Engine e3 = eManager.newEngine("AA", "3");
    e3.setModel("SW8");
    e3.setBuilt("2006");
    e3.setMoves(40);
    e3.setOwner("AB");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 5");
    e3.setRfid("RFID 5");
    Assert.assertEquals("e3 location", Track.OKAY, e3.setLocation(boxford, boxfordHood));
    Assert.assertEquals("e3 destination", Track.OKAY, e3.setDestination(boxford, boxfordYard));
    Engine e4 = eManager.newEngine("SP", "2");
    e4.setModel("GP35");
    e4.setBuilt("1990");
    e4.setMoves(30);
    e4.setOwner("AAA");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 4");
    e4.setRfid("RFID 4");
    Assert.assertEquals("e4 location", Track.OKAY, e4.setLocation(westford, westfordSiding));
    Assert.assertEquals("e4 destination", Track.OKAY, e4.setDestination(boxford, boxfordHood));
    Engine e5 = eManager.newEngine("NH", "5");
    e5.setModel("SW1200");
    e5.setBuilt("1956");
    e5.setMoves(25);
    e5.setOwner("DAB");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 1");
    e5.setRfid("RFID 1");
    Assert.assertEquals("e5 location", Track.OKAY, e5.setLocation(westford, westfordAble));
    Assert.assertEquals("e5 destination", Track.OKAY, e5.setDestination(westford, westfordAble));
}
Also used : LocationManager(jmri.jmrit.operations.locations.LocationManager) CarOwners(jmri.jmrit.operations.rollingstock.cars.CarOwners) CarRoads(jmri.jmrit.operations.rollingstock.cars.CarRoads) Track(jmri.jmrit.operations.locations.Track) Location(jmri.jmrit.operations.locations.Location)

Example 62 with Location

use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.

the class EngineEditFrameTest method loadEngines.

private void loadEngines() {
    // add Owner1 and Owner2
    CarOwners co = CarOwners.instance();
    co.addName("Owner1");
    co.addName("Owner2");
    // add road names
    CarRoads cr = CarRoads.instance();
    cr.addName("NH");
    cr.addName("UP");
    cr.addName("AA");
    cr.addName("SP");
    // add locations
    LocationManager lManager = LocationManager.instance();
    Location westford = lManager.newLocation("Westford");
    Track westfordYard = westford.addTrack("Yard", Track.YARD);
    westfordYard.setLength(300);
    Track westfordSiding = westford.addTrack("Siding", Track.SPUR);
    westfordSiding.setLength(300);
    Track westfordAble = westford.addTrack("Able", Track.SPUR);
    westfordAble.setLength(300);
    Location boxford = lManager.newLocation("Boxford");
    Track boxfordYard = boxford.addTrack("Yard", Track.YARD);
    boxfordYard.setLength(300);
    Track boxfordJacobson = boxford.addTrack("Jacobson", Track.SPUR);
    boxfordJacobson.setLength(300);
    Track boxfordHood = boxford.addTrack("Hood", Track.SPUR);
    boxfordHood.setLength(300);
    EngineManager eManager = EngineManager.instance();
    // add 5 Engines to table
    Engine e1 = eManager.newEngine("NH", "1");
    e1.setModel("RS1");
    e1.setBuilt("2009");
    e1.setMoves(55);
    e1.setOwner("Owner2");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 3");
    e1.setRfid("RFID 3");
    e1.setWeightTons("Tons of Weight");
    e1.setComment("Test Engine NH 1 Comment");
    Assert.assertEquals("e1 location", Track.OKAY, e1.setLocation(westford, westfordYard));
    Assert.assertEquals("e1 destination", Track.OKAY, e1.setDestination(boxford, boxfordJacobson));
    Engine e2 = eManager.newEngine("UP", "2");
    e2.setModel("FT");
    e2.setBuilt("2004");
    e2.setMoves(50);
    e2.setOwner("AT");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 2");
    e2.setRfid("RFID 2");
    Engine e3 = eManager.newEngine("AA", "3");
    e3.setModel("SW8");
    e3.setBuilt("2006");
    e3.setMoves(40);
    e3.setOwner("AB");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 5");
    e3.setRfid("RFID 5");
    Assert.assertEquals("e3 location", Track.OKAY, e3.setLocation(boxford, boxfordHood));
    Assert.assertEquals("e3 destination", Track.OKAY, e3.setDestination(boxford, boxfordYard));
    Engine e4 = eManager.newEngine("SP", "2");
    e4.setModel("GP35");
    e4.setBuilt("1990");
    e4.setMoves(30);
    e4.setOwner("AAA");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 4");
    e4.setRfid("RFID 4");
    Assert.assertEquals("e4 location", Track.OKAY, e4.setLocation(westford, westfordSiding));
    Assert.assertEquals("e4 destination", Track.OKAY, e4.setDestination(boxford, boxfordHood));
    Engine e5 = eManager.newEngine("NH", "5");
    e5.setModel("SW1200");
    e5.setBuilt("1956");
    e5.setMoves(25);
    e5.setOwner("DAB");
    jmri.InstanceManager.getDefault(jmri.IdTagManager.class).provideIdTag("RFID 1");
    e5.setRfid("RFID 1");
    Assert.assertEquals("e5 location", Track.OKAY, e5.setLocation(westford, westfordAble));
    Assert.assertEquals("e5 destination", Track.OKAY, e5.setDestination(westford, westfordAble));
}
Also used : LocationManager(jmri.jmrit.operations.locations.LocationManager) CarOwners(jmri.jmrit.operations.rollingstock.cars.CarOwners) CarRoads(jmri.jmrit.operations.rollingstock.cars.CarRoads) Track(jmri.jmrit.operations.locations.Track) Location(jmri.jmrit.operations.locations.Location)

Example 63 with Location

use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.

the class OperationsRoutesTest method testRouteLocationManagement.

// test route location management
public void testRouteLocationManagement() {
    Route r1 = new Route("TESTROUTEID", "TESTROUTENAME");
    Assert.assertEquals("Route Id", "TESTROUTEID", r1.getId());
    Assert.assertEquals("Route Name", "TESTROUTENAME", r1.getName());
    RouteLocation rladd;
    Location l1 = new Location("TESTLOCATIONID1", "TESTLOCATIONNAME1");
    rladd = r1.addLocation(l1);
    Location l2 = new Location("TESTLOCATIONID2", "TESTLOCATIONNAME2");
    rladd = r1.addLocation(l2);
    Location l3 = new Location("TESTLOCATIONID3", "TESTLOCATIONNAME3");
    rladd = r1.addLocation(l3);
    Assert.assertNotNull("exists", rladd);
    RouteLocation rl1test;
    rl1test = r1.getLastLocationByName("TESTLOCATIONNAME1");
    Assert.assertEquals("Add Location 1", "TESTLOCATIONNAME1", rl1test.getName());
    rl1test = r1.getLastLocationByName("TESTLOCATIONNAME2");
    Assert.assertEquals("Add Location 2", "TESTLOCATIONNAME2", rl1test.getName());
    rl1test = r1.getLastLocationByName("TESTLOCATIONNAME3");
    Assert.assertEquals("Add Location 3", "TESTLOCATIONNAME3", rl1test.getName());
    // Check that locations are in the expected order
    List<RouteLocation> list = r1.getLocationsBySequenceList();
    for (int i = 0; i < list.size(); i++) {
        rl1test = list.get(i);
        if (i == 0) {
            Assert.assertEquals("List Location 1 before", "TESTLOCATIONNAME1", rl1test.getName());
            Assert.assertEquals("List Location 1 sequence id", 1, rl1test.getSequenceId());
        }
        if (i == 1) {
            Assert.assertEquals("List Location 2 before", "TESTLOCATIONNAME2", rl1test.getName());
            Assert.assertEquals("List Location 2 sequence id", 2, rl1test.getSequenceId());
        }
        if (i == 2) {
            Assert.assertEquals("List Location 3 before", "TESTLOCATIONNAME3", rl1test.getName());
            Assert.assertEquals("List Location 3 sequence id", 3, rl1test.getSequenceId());
        }
    }
    // Add a fourth location but put it in the second spot and check that locations are in the expected order
    Location l4 = new Location("TESTLOCATIONID4", "TESTLOCATIONNAME4");
    rladd = r1.addLocation(l4, 2);
    rl1test = r1.getLastLocationByName("TESTLOCATIONNAME4");
    Assert.assertEquals("Add Location 4", "TESTLOCATIONNAME4", rl1test.getName());
    list = r1.getLocationsBySequenceList();
    for (int i = 0; i < list.size(); i++) {
        rl1test = list.get(i);
        if (i == 0) {
            Assert.assertEquals("List Location 1 after", "TESTLOCATIONNAME1", rl1test.getName());
            Assert.assertEquals("List Location 1 sequence id", 1, rl1test.getSequenceId());
        }
        if (i == 1) {
            Assert.assertEquals("List Location 2 after", "TESTLOCATIONNAME4", rl1test.getName());
            Assert.assertEquals("List Location 2 sequence id", 2, rl1test.getSequenceId());
        }
        if (i == 2) {
            Assert.assertEquals("List Location 3 after", "TESTLOCATIONNAME2", rl1test.getName());
            Assert.assertEquals("List Location 3 sequence id", 3, rl1test.getSequenceId());
        }
        if (i == 3) {
            Assert.assertEquals("List Location 4 after", "TESTLOCATIONNAME3", rl1test.getName());
            Assert.assertEquals("List Location 4 sequence id", 4, rl1test.getSequenceId());
        }
    }
    // Move up the third location and check that locations are in the expected order
    rl1test = r1.getLastLocationByName("TESTLOCATIONNAME3");
    r1.moveLocationUp(rl1test);
    list = r1.getLocationsBySequenceList();
    for (int i = 0; i < list.size(); i++) {
        rl1test = list.get(i);
        if (i == 0) {
            Assert.assertEquals("List Location 1 after move up", "TESTLOCATIONNAME1", rl1test.getName());
            Assert.assertEquals("List Location 1 sequence id", 1, rl1test.getSequenceId());
        }
        if (i == 1) {
            Assert.assertEquals("List Location 2 after move up", "TESTLOCATIONNAME4", rl1test.getName());
            Assert.assertEquals("List Location 2 sequence id", 2, rl1test.getSequenceId());
        }
        if (i == 2) {
            Assert.assertEquals("List Location 3 after move up", "TESTLOCATIONNAME3", rl1test.getName());
            Assert.assertEquals("List Location 3 sequence id", 3, rl1test.getSequenceId());
        }
        if (i == 3) {
            Assert.assertEquals("List Location 4 after move up", "TESTLOCATIONNAME2", rl1test.getName());
            Assert.assertEquals("List Location 4 sequence id", 4, rl1test.getSequenceId());
        }
    }
    // Move down the first location down 2 and check that locations are in the expected order
    rl1test = r1.getLastLocationByName("TESTLOCATIONNAME1");
    r1.moveLocationDown(rl1test);
    r1.moveLocationDown(rl1test);
    list = r1.getLocationsBySequenceList();
    for (int i = 0; i < list.size(); i++) {
        rl1test = list.get(i);
        if (i == 0) {
            Assert.assertEquals("List Location 1 after move up", "TESTLOCATIONNAME4", rl1test.getName());
            Assert.assertEquals("List Location 1 sequence id", 1, rl1test.getSequenceId());
        }
        if (i == 1) {
            Assert.assertEquals("List Location 2 after move up", "TESTLOCATIONNAME3", rl1test.getName());
            Assert.assertEquals("List Location 2 sequence id", 2, rl1test.getSequenceId());
        }
        if (i == 2) {
            Assert.assertEquals("List Location 3 after move up", "TESTLOCATIONNAME1", rl1test.getName());
            Assert.assertEquals("List Location 3 sequence id", 3, rl1test.getSequenceId());
        }
        if (i == 3) {
            Assert.assertEquals("List Location 4 after move up", "TESTLOCATIONNAME2", rl1test.getName());
            Assert.assertEquals("List Location 4 sequence id", 4, rl1test.getSequenceId());
        }
    }
    // Delete the third location and check that locations are in the expected order
    rl1test = r1.getLastLocationByName("TESTLOCATIONNAME3");
    r1.deleteLocation(rl1test);
    list = r1.getLocationsBySequenceList();
    for (int i = 0; i < list.size(); i++) {
        rl1test = list.get(i);
        if (i == 0) {
            Assert.assertEquals("List Location 1 after move up", "TESTLOCATIONNAME4", rl1test.getName());
            Assert.assertEquals("List Location 1 sequence id", 1, rl1test.getSequenceId());
        }
        if (i == 1) {
            Assert.assertEquals("List Location 2 after move up", "TESTLOCATIONNAME1", rl1test.getName());
            Assert.assertEquals("List Location 2 sequence id", 2, rl1test.getSequenceId());
        }
        if (i == 2) {
            Assert.assertEquals("List Location 3 after move up", "TESTLOCATIONNAME2", rl1test.getName());
            Assert.assertEquals("List Location 3 sequence id", 3, rl1test.getSequenceId());
        }
    }
}
Also used : Location(jmri.jmrit.operations.locations.Location)

Example 64 with Location

use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.

the class OperationsRoutesTest method testRouteLocationConstants.

// test public RouteLocation constants
public void testRouteLocationConstants() {
    Route r1 = new Route("TESTROUTEID", "TESTROUTENAME");
    Location l1 = new Location("TESTLOCATIONID1", "TESTLOCATIONNAME1");
    RouteLocation rl1 = new RouteLocation("TESTROUTELOCATIONID", l1);
    Assert.assertNotNull("exists", rl1);
    Assert.assertEquals("Route Id", "TESTROUTEID", r1.getId());
    Assert.assertEquals("Route Name", "TESTROUTENAME", r1.getName());
    Assert.assertEquals("RouteLocation Constant EAST", 1, RouteLocation.EAST);
    Assert.assertEquals("RouteLocation Constant WEST", 2, RouteLocation.WEST);
    Assert.assertEquals("RouteLocation Constant NORTH", 4, RouteLocation.NORTH);
    Assert.assertEquals("RouteLocation Constant SOUTH", 8, RouteLocation.SOUTH);
    Assert.assertEquals("RouteLocation Constant EAST_DIR", "East", RouteLocation.EAST_DIR);
    Assert.assertEquals("RouteLocation Constant WEST_DIR", "West", RouteLocation.WEST_DIR);
    Assert.assertEquals("RouteLocation Constant NORTH_DIR", "North", RouteLocation.NORTH_DIR);
    Assert.assertEquals("RouteLocation Constant SOUTH_DIR", "South", RouteLocation.SOUTH_DIR);
    Assert.assertEquals("RouteLocation Constant DROP_CHANGED_PROPERTY", "dropChange", RouteLocation.DROP_CHANGED_PROPERTY);
    Assert.assertEquals("RouteLocation Constant PICKUP_CHANGED_PROPERTY", "pickupChange", RouteLocation.PICKUP_CHANGED_PROPERTY);
    Assert.assertEquals("RouteLocation Constant MAXMOVES_CHANGED_PROPERTY", "maxMovesChange", RouteLocation.MAX_MOVES_CHANGED_PROPERTY);
    Assert.assertEquals("RouteLocation Constant DISPOSE", "routeLocationDispose", RouteLocation.DISPOSE);
}
Also used : Location(jmri.jmrit.operations.locations.Location)

Example 65 with Location

use of jmri.jmrit.operations.locations.Location in project JMRI by JMRI.

the class OperationsRoutesTest method testRouteStatus.

// test route status
public void testRouteStatus() {
    RouteManager rm = RouteManager.instance();
    Route r = rm.newRoute("TestRouteStatus");
    // note that the status strings are defined in JmritOperationsRoutesBundle.properties
    Assert.assertEquals("Route status error", "Error", r.getStatus());
    // now add a location to the route
    Location l = LocationManager.instance().newLocation("TestRouteStatusLoc");
    r.addLocation(l);
    // note that the status strings are defined in JmritOperationsRoutesBundle.properties
    Assert.assertEquals("Route status ophan", "Orphan", r.getStatus());
    // now connect route to a train
    Train t = TrainManager.instance().newTrain("TestRouteStatusTrain");
    t.setRoute(r);
    // note that the status strings are defined in JmritOperationsRoutesBundle.properties
    Assert.assertEquals("Route status okay", "OK", r.getStatus());
}
Also used : Train(jmri.jmrit.operations.trains.Train) Location(jmri.jmrit.operations.locations.Location)

Aggregations

Location (jmri.jmrit.operations.locations.Location)186 Track (jmri.jmrit.operations.locations.Track)108 RouteLocation (jmri.jmrit.operations.routes.RouteLocation)82 Route (jmri.jmrit.operations.routes.Route)51 LocationManager (jmri.jmrit.operations.locations.LocationManager)43 Car (jmri.jmrit.operations.rollingstock.cars.Car)41 Engine (jmri.jmrit.operations.rollingstock.engines.Engine)29 RouteManager (jmri.jmrit.operations.routes.RouteManager)21 CarManager (jmri.jmrit.operations.rollingstock.cars.CarManager)20 Consist (jmri.jmrit.operations.rollingstock.engines.Consist)19 Test (org.junit.Test)18 JCheckBox (javax.swing.JCheckBox)13 EngineManager (jmri.jmrit.operations.rollingstock.engines.EngineManager)13 Train (jmri.jmrit.operations.trains.Train)13 CarTypes (jmri.jmrit.operations.rollingstock.cars.CarTypes)12 Schedule (jmri.jmrit.operations.locations.schedules.Schedule)11 EngineTypes (jmri.jmrit.operations.rollingstock.engines.EngineTypes)10 File (java.io.File)9 ScheduleItem (jmri.jmrit.operations.locations.schedules.ScheduleItem)9 TrainManager (jmri.jmrit.operations.trains.TrainManager)8