Class Track

    • Constructor Detail

      • Track

        public Track​(java.lang.String id,
                     java.lang.String name,
                     java.lang.String type,
                     Location location)
      • Track

        public Track​(org.jdom2.Element e,
                     Location location)
        Construct this Entry from XML. This member has to remain synchronized with the detailed DTD in operations-location.dtd.
        Parameters:
        e - Consist XML element
        location - The Location loading this track.
    • Method Detail

      • copyTrack

        public Track copyTrack​(java.lang.String newName,
                               Location newLocation)
        Creates a copy of this track.
        Parameters:
        newName - The name of the new track.
        newLocation - The location of the new track.
        Returns:
        Track
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getId

        public java.lang.String getId()
      • setName

        public void setName​(java.lang.String name)
      • getName

        public java.lang.String getName()
      • isSpur

        public boolean isSpur()
      • isYard

        public boolean isYard()
      • getTrackType

        public java.lang.String getTrackType()
        Gets the track type
        Returns:
        Track.SPUR Track.YARD Track.INTERCHANGE or Track.STAGING
      • setTrackType

        public void setTrackType​(java.lang.String type)
        Sets the track type, spur, interchange, yard, staging
        Parameters:
        type - Track.SPUR Track.YARD Track.INTERCHANGE Track.STAGING
      • getTrackTypeName

        public static java.lang.String getTrackTypeName​(java.lang.String trackType)
      • setLength

        public void setLength​(int length)
      • setMinimumLength

        public void setMinimumLength​(int length)
        Sets the minimum length of this track when the track is in a pool.
        Parameters:
        length - minimum
      • setReserved

        public void setReserved​(int reserved)
      • getReservedInRoute

        public int getReservedInRoute()
        Used to determine how much track space is going to be consumed by cars in route to this track. See isSpaceAvailable().
        Returns:
        The length of all cars en route to this track including couplers.
      • setReservationFactor

        public void setReservationFactor​(int factor)
        Set the reservation factor. Default 100 (100%). Used by the program when generating car loads from staging. A factor of 100% allows the program to fill a track with car loads. Numbers over 100% can overload a track.
        Parameters:
        factor - A number from 0 to 10000.
      • setScheduleMode

        public void setScheduleMode​(int mode)
        Sets the mode of operation for the schedule assigned to this track.
        Parameters:
        mode - Track.SEQUENTIAL or Track.MATCH
      • getScheduleMode

        public int getScheduleMode()
        Gets the mode of operation for the schedule assigned to this track.
        Returns:
        Mode of operation: Track.SEQUENTIAL or Track.MATCH
      • getAlternateTrack

        public Track getAlternateTrack()
        Returns the alternate track for a spur
        Returns:
        alternate track
      • isHoldCarsWithCustomLoadsEnabled

        public boolean isHoldCarsWithCustomLoadsEnabled()
        If enabled (true), hold cars with custom loads rather than allowing them to go to staging if the spur and the alternate track were full. If disabled, cars with custom loads can be forwarded to staging when this spur and all others with this option are also false.
        Returns:
        True if enabled
      • isSpaceAvailable

        public boolean isSpaceAvailable​(Car car)
        Used to determine if there's space available at this track for the car. Considers cars en-route to this track. Used to prevent overloading the track.
        Parameters:
        car - The car to be set out.
        Returns:
        true if space available.
      • setIgnoreUsedLengthPercentage

        public void setIgnoreUsedLengthPercentage​(int percentage)
        The amount of consumed track space to be ignored when sending new rolling stock to the track. See Planned Pickups in help.
        Parameters:
        percentage - a number between 0 and 100
      • getNumberRS

        public int getNumberRS()
        Returns:
        The number of rolling stock (cars and engines) on this track
      • getNumberCars

        public int getNumberCars()
        Returns:
        The number of cars on this track
      • getNumberEngines

        public int getNumberEngines()
        Returns:
        The number of engines on this track
      • addRS

        public void addRS​(RollingStock rs)
        Adds rolling stock to a specific track.
        Parameters:
        rs - The rolling stock to place on the track.
      • addPickupRS

        public void addPickupRS​(RollingStock rs)
        Increments the number of cars and or engines that will be picked up by a train from this track.
        Parameters:
        rs - The rolling stock.
      • getPickupRS

        public int getPickupRS()
        Returns:
        the number of rolling stock (cars and or locos) that are scheduled for pick up from this track.
      • setComment

        public void setComment​(java.lang.String comment)
      • getComment

        public java.lang.String getComment()
      • setCommentBoth

        public void setCommentBoth​(java.lang.String comment)
      • getTypeNames

        public java.lang.String[] getTypeNames()
        Returns all of the rolling stock type names serviced by this track.
        Returns:
        rolling stock type names
      • addTypeName

        public void addTypeName​(java.lang.String type)
      • deleteTypeName

        public void deleteTypeName​(java.lang.String type)
      • setTrainDirections

        public void setTrainDirections​(int direction)
        Sets the train directions that can service this track
        Parameters:
        direction - EAST, WEST, NORTH, SOUTH
      • setRoadOption

        public void setRoadOption​(java.lang.String option)
        Set the road option for this track.
        Parameters:
        option - ALLROADS, INCLUDEROADS, or EXCLUDEROADS
      • addRoadName

        public void addRoadName​(java.lang.String road)
      • deleteRoadName

        public void deleteRoadName​(java.lang.String road)
      • getLoadOption

        public java.lang.String getLoadOption()
        Gets the car receive load option for this track.
        Returns:
        ALL_LOADS INCLUDE_LOADS EXCLUDE_LOADS
      • setLoadOption

        public void setLoadOption​(java.lang.String option)
        Set how this track deals with receiving car loads
        Parameters:
        option - ALL_LOADS INCLUDE_LOADS EXCLUDE_LOADS
      • getLoadNames

        public java.lang.String[] getLoadNames()
        Provides a list of receive loads that the track will either service or exclude. See setLoadOption
        Returns:
        Array of load names as Strings
      • addLoadName

        public void addLoadName​(java.lang.String load)
        Add a receive load that the track will either service or exclude. See setLoadOption
        Parameters:
        load - The string load name.
      • deleteLoadName

        public void deleteLoadName​(java.lang.String load)
        Delete a receive load name that the track will either service or exclude. See setLoadOption
        Parameters:
        load - The string load name.
      • isLoadNameAccepted

        public boolean isLoadNameAccepted​(java.lang.String load)
        Determine if track will service a specific receive load name.
        Parameters:
        load - the load name to check.
        Returns:
        true if track will service this load.
      • isLoadNameAndCarTypeAccepted

        public boolean isLoadNameAndCarTypeAccepted​(java.lang.String load,
                                                    java.lang.String type)
        Determine if track will service a specific receive load and car type.
        Parameters:
        load - the load name to check.
        type - the type of car used to carry the load.
        Returns:
        true if track will service this load.
      • getShipLoadOption

        public java.lang.String getShipLoadOption()
        Gets the car ship load option for this track.
        Returns:
        ALL_LOADS INCLUDE_LOADS EXCLUDE_LOADS
      • setShipLoadOption

        public void setShipLoadOption​(java.lang.String option)
        Set how this track deals with shipping car loads
        Parameters:
        option - ALL_LOADS INCLUDE_LOADS EXCLUDE_LOADS
      • getShipLoadNames

        public java.lang.String[] getShipLoadNames()
        Provides a list of ship loads that the track will either service or exclude. See setShipLoadOption
        Returns:
        Array of load names as Strings
      • addShipLoadName

        public void addShipLoadName​(java.lang.String load)
        Add a ship load that the track will either service or exclude. See setShipLoadOption
        Parameters:
        load - The string load name.
      • deleteShipLoadName

        public void deleteShipLoadName​(java.lang.String load)
        Delete a ship load name that the track will either service or exclude. See setLoadOption
        Parameters:
        load - The string load name.
      • isLoadNameShipped

        public boolean isLoadNameShipped​(java.lang.String load)
        Determine if track will service a specific ship load name.
        Parameters:
        load - the load name to check.
        Returns:
        true if track will service this load.
      • isLoadNameAndCarTypeShipped

        public boolean isLoadNameAndCarTypeShipped​(java.lang.String load,
                                                   java.lang.String type)
        Determine if track will service a specific ship load and car type.
        Parameters:
        load - the load name to check.
        type - the type of car used to carry the load.
        Returns:
        true if track will service this load.
      • getDropOption

        public java.lang.String getDropOption()
        Gets the drop option for this track. ANY means that all trains and routes can drop cars to this track. The other four options are used to restrict the track to certain trains or routes.
        Returns:
        ANY, TRAINS, ROUTES, EXCLUDE_TRAINS, or EXCLUDE_ROUTES
      • setDropOption

        public void setDropOption​(java.lang.String option)
        Set the car drop option for this track.
        Parameters:
        option - ANY, TRAINS, ROUTES, EXCLUDE_TRAINS, or EXCLUDE_ROUTES
      • getPickupOption

        public java.lang.String getPickupOption()
        Gets the pickup option for this track. ANY means that all trains and routes can pull cars from this track. The other four options are used to restrict the track to certain trains or routes.
        Returns:
        ANY, TRAINS, ROUTES, EXCLUDE_TRAINS, or EXCLUDE_ROUTES
      • setPickupOption

        public void setPickupOption​(java.lang.String option)
        Set the car pick up option for this track.
        Parameters:
        option - ANY, TRAINS, ROUTES, EXCLUDE_TRAINS, or EXCLUDE_ROUTES
      • getDropIds

        public java.lang.String[] getDropIds()
      • addDropId

        public void addDropId​(java.lang.String id)
      • deleteDropId

        public void deleteDropId​(java.lang.String id)
      • isDropTrainAccepted

        public boolean isDropTrainAccepted​(Train train)
        Determine if train can set out cars to this track. Based on the train's id or train's route id. See setDropOption(option).
        Parameters:
        train - The Train to test.
        Returns:
        true if the train can set out cars to this track.
      • containsDropId

        public boolean containsDropId​(java.lang.String id)
      • addPickupId

        public void addPickupId​(java.lang.String id)
        Add train or route id to this track.
        Parameters:
        id - The string id for the train or route.
      • deletePickupId

        public void deletePickupId​(java.lang.String id)
      • isPickupTrainAccepted

        public boolean isPickupTrainAccepted​(Train train)
        Determine if train can pick up cars from this track. Based on the train's id or train's route id. See setPickupOption(option).
        Parameters:
        train - The Train to test.
        Returns:
        true if the train can pick up cars from this track.
      • checkPickups

        public java.lang.String checkPickups()
        Checks to see if all car types can be pulled from this track
        Returns:
        PICKUP_OKAY if any train can pull all car types from this track
      • isRollingStockAccepted

        public java.lang.String isRollingStockAccepted​(RollingStock rs)
        Used to determine if track can service the rolling stock.
        Parameters:
        rs - the car or loco to be tested
        Returns:
        Error string starting with TYPE, ROAD, CAPACITY, LENGTH, DESTINATION or LOAD if there's an issue. OKAY if track can service Rolling Stock.
      • getAvailableTrackSpace

        public int getAvailableTrackSpace()
        Available track space. Adjusted when a track is using the planned pickups feature
        Returns:
        available track space
      • setMoves

        public void setMoves​(int moves)
      • getBlockingOrder

        public int getBlockingOrder()
        Gets the blocking order for this track. Default is zero, in that case, tracks are sorted by name.
        Returns:
        the blocking order
      • getServiceOrder

        public java.lang.String getServiceOrder()
        Get the service order for this track. Yards and interchange have this feature for cars. Staging has this feature for trains.
        Returns:
        Service order: Track.NORMAL, Track.FIFO, Track.LIFO
      • setServiceOrder

        public void setServiceOrder​(java.lang.String order)
        Set the service order for this track. Only yards and interchange have this feature.
        Parameters:
        order - Track.NORMAL, Track.FIFO, Track.LIFO
      • getScheduleName

        public java.lang.String getScheduleName()
        Returns the name of the schedule. Note that this returns the schedule name based on the schedule's id. A schedule's name can be modified by the user.
        Returns:
        Schedule name
      • setScheduleId

        public void setScheduleId​(java.lang.String id)
      • getScheduleItemId

        public java.lang.String getScheduleItemId()
        Recommend getCurrentScheduleItem() to get the current schedule item for this track. Protects against user deleting a schedule item from the schedule.
        Returns:
        schedule item id
      • getCurrentScheduleItem

        public ScheduleItem getCurrentScheduleItem()
        Get's the current schedule item for this track Protects against user deleting an item in a shared schedule. Recommend using this versus getScheduleItemId() as the id can be obsolete.
        Returns:
        The current ScheduleItem.
      • bumpSchedule

        public void bumpSchedule()
        Increments the schedule count if there's a schedule and the schedule is running in sequential mode. Resets the schedule count if the maximum is reached and then goes to the next item in the schedule's list.
      • getScheduleCount

        public int getScheduleCount()
        Returns how many times the current schedule item has been accessed.
        Returns:
        count
      • checkScheduleValid

        public java.lang.String checkScheduleValid()
        Check to see if schedule is valid for the track at this location.
        Returns:
        SCHEDULE_OKAY if schedule okay, otherwise an error message.
      • checkSchedule

        public java.lang.String checkSchedule​(Car car)
        Checks to see if car can be placed on this spur using this schedule. Returns OKAY if the schedule can service the car.
        Parameters:
        car - The Car to be tested.
        Returns:
        Track.OKAY track.CUSTOM track.SCHEDULE
      • scheduleNext

        public java.lang.String scheduleNext​(Car car)
        Check to see if track has schedule and if it does will schedule the next item in the list. Load the car with the next schedule load if one exists, and set the car's final destination if there's one in the schedule.
        Parameters:
        car - The Car to be modified.
        Returns:
        Track.OKAY or Track.SCHEDULE
      • checkScheduleAttribute

        public boolean checkScheduleAttribute​(java.lang.String attribute,
                                              java.lang.String carType,
                                              Car car)
      • setLoadSwapEnabled

        public void setLoadSwapEnabled​(boolean enable)
        Enable changing the car generic load state when car arrives at this track.
        Parameters:
        enable - when true, swap generic car load state
      • setLoadEmptyEnabled

        public void setLoadEmptyEnabled​(boolean enable)
        Enable setting the car generic load state to empty when car arrives at this track.
        Parameters:
        enable - when true, set generic car load to empty
      • setRemoveCustomLoadsEnabled

        public void setRemoveCustomLoadsEnabled​(boolean enable)
        When enabled, remove Scheduled car loads.
        Parameters:
        enable - when true, remove Scheduled loads from cars
      • setAddCustomLoadsEnabled

        public void setAddCustomLoadsEnabled​(boolean enable)
        When enabled, add custom car loads if there's a demand.
        Parameters:
        enable - when true, add custom loads to cars
      • setAddCustomLoadsAnySpurEnabled

        public void setAddCustomLoadsAnySpurEnabled​(boolean enable)
        When enabled, add custom car loads if there's a demand by any spur/industry.
        Parameters:
        enable - when true, add custom loads to cars
      • setAddCustomLoadsAnyStagingTrackEnabled

        public void setAddCustomLoadsAnyStagingTrackEnabled​(boolean enable)
        When enabled, add custom car loads to cars in staging for new destinations that are staging.
        Parameters:
        enable - when true, add custom load to car
      • isBlockCarsEnabled

        public boolean isBlockCarsEnabled()
        When enabled block cars from staging.
        Returns:
        true if blocking is enabled.
      • addDestination

        public void addDestination​(Location destination)
        adds a location to the list of acceptable destinations for this track.
        Parameters:
        destination - location that is acceptable
      • isDestinationAccepted

        public boolean isDestinationAccepted​(Location destination)
        Returns true if destination is valid from this track.
        Parameters:
        destination - The Location to be checked.
        Returns:
        true if track services the destination
      • setDestinationOption

        public void setDestinationOption​(java.lang.String option)
        Sets the destination option for this track. The three options are:

        ALL_DESTINATIONS which means this track services all destinations, the default.

        INCLUDE_DESTINATIONS which means this track services only certain destinations.

        EXCLUDE_DESTINATIONS which means this track does not service certain destinations.

        Parameters:
        option - Track.ALL_DESTINATIONS, Track.INCLUDE_DESTINATIONS, or Track.EXCLUDE_DESTINATIONS
      • getDestinationOption

        public java.lang.String getDestinationOption()
        Get destination option for interchange or staging track
        Returns:
        option
      • isOnlyCarsWithFinalDestinationEnabled

        public boolean isOnlyCarsWithFinalDestinationEnabled()
        When true the track will only accept cars that have a final destination that can be serviced by the track. See acceptsDestination(Location).
        Returns:
        false if any car spotted, true if only cars with a FD.
      • isAlternate

        public boolean isAlternate()
        Used to determine if track has been assigned as an alternate
        Returns:
        true if track is an alternate
      • store

        public org.jdom2.Element store()
        Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-location.dtd.
        Returns:
        Contents in a JDOM Element
      • setDirtyAndFirePropertyChange

        protected void setDirtyAndFirePropertyChange​(java.lang.String p,
                                                     java.lang.Object old,
                                                     java.lang.Object n)