Class Router

  • All Implemented Interfaces:
    InstanceManagerAutoDefault

    public class Router
    extends TrainCommon
    implements InstanceManagerAutoDefault
    Router for car movement. This code attempts to find a way (a route) to move a car to its final destination through the use of two or more trains. First the code tries to move car using a single train. If that fails, attempts are made using two trains via a classification/interchange (C/I) tracks, then yard tracks if enabled. Next attempts are made using three or more trains using any combination of C/I and yard tracks. If that fails and routing via staging is enabled, the code tries two trains using staging tracks, then multiple trains using a combination of C/I, yards, and staging tracks. Currently the router is limited to seven trains.
    • Constructor Detail

    • Method Detail

      • getStatus

        public java.lang.String getStatus()
        Returns the status of the router when using the setDestination() for a car.
        Returns:
        Track.OKAY, STATUS_NOT_THIS_TRAIN, STATUS_NOT_ABLE, STATUS_ROUTER_DISABLED, or the destination track status is there's an issue.
      • isCarRouteable

        public boolean isCarRouteable​(Car car,
                                      Train train,
                                      Track track,
                                      java.io.PrintWriter buildReport)
        Determines if car can be routed to the destination track
        Parameters:
        car - the car being tested
        train - the first train servicing the car, can be null
        track - the destination track, can not be null
        buildReport - the report, can be null
        Returns:
        true if the car can be routed to the track
      • setDestination

        public boolean setDestination​(Car car,
                                      Train train,
                                      java.io.PrintWriter buildReport)
        Attempts to set the car's destination if a final destination exists. Only sets the car's destination if the train is part of the car's route.
        Parameters:
        car - the car to route
        train - the first train to carry this car, can be null
        buildReport - PrintWriter for build report, and can be null
        Returns:
        true if car can be routed.