Package jmri.jmrit.logix
Class SCWarrant
java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.jmrit.logix.Warrant
jmri.jmrit.logix.SCWarrant
- All Implemented Interfaces:
PropertyChangeListener,Comparable<NamedBean>,EventListener,PropertyChangeProvider,NamedBean,ThrottleListener
An SCWarrant is a warrant that is controlled by the signals on a layout.
It will not run unless you have your layout fully covered with sensors and
signals.
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrit.logix.Warrant
Warrant.SpeedStateNested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameExceptionNested classes/interfaces inherited from interface jmri.ThrottleListener
ThrottleListener.DecisionType -
Field Summary
FieldsModifier and TypeFieldDescription(package private) float(package private) SignalSpeedMapMove the train if _nextSignal permits.static final floatstatic final floatstatic final float(package private) static LinkedBlockingQueue<SCWarrant>The waiting for event must happen in a separate thread.Fields inherited from class jmri.jmrit.logix.Warrant
_message, _runMode, _stoppingBlock, _trace, _trainName, ABORT, AT_SPEED, BUFFER_DISTANCE, CNTRL_CMDS, DEBUG, EStop, ESTOP, HALT, LEARNING, MODE_ABORT, MODE_LEARN, MODE_MANUAL, MODE_NONE, MODE_RUN, MODES, Normal, PROPERTY_ABORT_LEARN, PROPERTY_BLOCK_CHANGE, PROPERTY_CANNOT_RUN, PROPERTY_CONTROL_CHANGE, PROPERTY_CONTROL_FAILED, PROPERTY_OCCUPY_OVERRUN, PROPERTY_READY_TO_RUN, PROPERTY_SIGNAL_OVERRUN, PROPERTY_STOP_WARRANT, PROPERTY_THROTTLE_FAIL, PROPERTY_WARRANT_OVERRUN, PROPERTY_WARRANT_START, RAMP_DOWN, RAMP_HALT, RAMP_UP, RESUME, RETRY_BKWD, RETRY_FWD, RUN_STATE, RUNNING, SPEED_RESTRICTED, SPEED_UP, Stop, STOP, STOP_PENDING, WAIT_FOR_CLEAR, WAIT_FOR_DELAYED_START, WAIT_FOR_SENSOR, WAIT_FOR_TRAINFields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidallocateBlocksAndSetTurnouts(int startIndex) Do what the title says.(package private) boolean(package private) booleanAre we close to the destination block?protected voiddeallocateUpToBlock(int idx) Deallocate all blocks up to and including idx, but only on these conditions in order to ensure that only a consecutive list of blocks are allocated at any time: 1.booleanvoidFind the next signal along our route and setup subscription for status changes on that signal.boolean(package private) floatprotected StringGenerate status message to show in warrant table.floatlongprotected voidgoingActive(OBlock block) Block in the route going active.protected voidgoingInactive(OBlock block) Block in the route is going Inactive.inthashCode()(package private) booleanAre we still in the start block?booleanIs the next block free or occupied, i.e do we risk to crash into an other train, if we proceed?(package private) booleanbooleanprotected booleanWait until there is a train in the start block.voidnotifyThrottleFound(DccThrottle throttle) Callback from acquireThrottle() when the throttle has become available.syncvoidSomething has fired a property change event.protected voidUse _throttle to control the train.voidsetForward(boolean set) (package private) voidsetRoute(boolean delay, List<BlockOrder> orders) This method has been overridden in order to avoid allocation of occupied blocks.setRunMode(int mode, DccLocoAddress address, LearnThrottleFrame student, List<ThrottleSetting> commands, boolean runBlind) Sets up recording and playing back throttle commands - also cleans up afterwards.voidsetSpeedFactor(float factor) voidvoidsetTimeToPlatform(long TTP) voidSet this train to run backwards or forwards as specified in the command list.voidstopWarrant(boolean abort, boolean turnOffFunctions) Make sure to free up additional resources for a running SCWarrant.protected voidMethods inherited from class jmri.jmrit.logix.Warrant
abortWarrant, acquireThrottle, addBlockOrder, addThrottleCommand, allocateRoute, checkforTrackers, checkRoute, checkStartBlock, controlRunTrain, deAllocate, debugInfo, dispose, downRampBegun, downRampDone, fireRunStatus, getAddTracker, getAvoidOrder, getBeanType, getBlockAt, getBlockingWarrant, getBlockOrderAt, getBlockOrders, getCurrentBlockName, getCurrentBlockOrder, getCurrentOrderIndex, getfirstOrder, getHaltStart, getIndexOfBlockAfter, getIndexOfBlockBefore, getLastOrder, getMessage, getNoRamp, getNumOrders, getRunBlind, getRunMode, getRunModeMessage, getShareRoute, getSpeedUtil, getState, getThrottleCommands, getTrainName, getUsageReport, getViaOrder, getWarrantSpeedMessage, hasRouteSet, incrementCurrentOrderIndex, isAllocated, isNXWarrant, isTotalAllocated, isWaitingForBlock, isWaitingForSignal, isWaitingForWarrant, notifyDecisionRequired, notifyFailedThrottleRequest, releaseThrottle, routeIsFree, routeIsOccupied, runWarrant, setAddTracker, setAvoidOrder, setBlockOrders, setHaltStart, setNoRamp, setNXWarrant, setRunBlind, setShareRoute, setSpeedUtil, setState, setThrottleCommands, setTrackSpeeds, setTrainName, setViaOrder, startupWarrantMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef, vetoableChangeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
compareTo, getRecommendedToolTip
-
Field Details
-
SPEED_STOP
- See Also:
-
SPEED_TO_PLATFORM
- See Also:
-
SPEED_UNSIGNALLED
- See Also:
-
_maxBlockLength
float _maxBlockLength -
_speedMap
Move the train if _nextSignal permits. If there is no next signal, we will move forward with half speed. -
waitToRunQ
The waiting for event must happen in a separate thread. Therefore the main code of runSignalControlledTrain is put in this class.
-
-
Constructor Details
-
SCWarrant
Create an object with no route defined.The list of BlockOrders is the route from an Origin to a Destination.
- Parameters:
sName- system name.uName- username.TTP- time to platform.
-
-
Method Details
-
getTimeToPlatform
-
setTimeToPlatform
-
setForward
-
getForward
-
setSpeedFactor
-
getSpeedFactor
-
getMaxBlockLength
float getMaxBlockLength() -
setMaxBlockLength
void setMaxBlockLength() -
setRoute
This method has been overridden in order to avoid allocation of occupied blocks. -
allTurnoutsSet
boolean allTurnoutsSet() -
isRouteFree
-
isRouteAllocated
boolean isRouteAllocated() -
notifyThrottleFound
Callback from acquireThrottle() when the throttle has become available.sync- Specified by:
notifyThrottleFoundin interfaceThrottleListener- Overrides:
notifyThrottleFoundin classWarrant- Parameters:
throttle- the throttle with the requested address
-
getRunningMessage
Generate status message to show in warrant table.- Overrides:
getRunningMessagein classWarrant
-
runSignalControlledTrain
Use _throttle to control the train. Get notified of signals, block occupancy and take care of block allocation status to determine speed. We have three speeds: Stop == SPEED_STOP Normal == SPEED_NORMAL Anything else == SPEED_MID (Limited, Medium, Slow, Restricted) If you have blocks large enough to ramp speed nicely up and down and to have further control of speed settings: Use a normal warrant and not a signal controlled one. This is "the main loop" for running a Signal Controlled Warrant -
isStartBlockOccupied
Wait until there is a train in the start block.- Returns:
- true if block not UNOCCUPIED
-
waitForStartblockToGetOccupied
-
setTrainDirection
Set this train to run backwards or forwards as specified in the command list. -
isNextBlockFreeAndAllocated
Is the next block free or occupied, i.e do we risk to crash into an other train, if we proceed? And is it allocated to us?- Returns:
- true if allocated to us and unoccupied, else false.
-
getAndGetNotifiedFromNextSignal
Find the next signal along our route and setup subscription for status changes on that signal. -
inStartBlock
boolean inStartBlock()Are we still in the start block?- Returns:
- true if still in start block
-
approchingDestination
boolean approchingDestination()Are we close to the destination block?- Returns:
- true if close
-
setSpeedFromNextSignal
-
allocateBlocksAndSetTurnouts
Do what the title says. But make sure not to set the turnouts if already done, since that would just cause all signals to go to Stop aspects and thus cause a jerky train movement.- Parameters:
startIndex- Allocate starting with this index
-
setRunMode
public String setRunMode(int mode, DccLocoAddress address, LearnThrottleFrame student, List<ThrottleSetting> commands, boolean runBlind) Description copied from class:WarrantSets up recording and playing back throttle commands - also cleans up afterwards. MODE_LEARN and MODE_RUN sessions must end by calling again with MODE_NONE. It is important that the route be deAllocated (remove listeners).Rule for (auto) MODE_RUN: 1. At least the Origin block must be owned (allocated) by this warrant. (block._warrant == this) and path set for Run Mode Rule for (auto) LEARN_RUN: 2. Entire Route must be allocated and Route Set for Learn Mode. i.e. this warrant has listeners on all block sensors in the route. Rule for MODE_MANUAL The Origin block must be allocated to this warrant and path set for the route
- Overrides:
setRunModein classWarrant- Parameters:
mode- run modeaddress- DCC loco addressstudent- throttle frame for learn mode parameterscommands- list of throttle commandsrunBlind- true if occupancy should be ignored- Returns:
- error message, if any
-
goingActive
Block in the route going active. Make sure to allocate the rest of the route, update our present location and then tell the main loop to find a new throttle setting.- Overrides:
goingActivein classWarrant- Parameters:
block- Block in the route is going active.
-
goingInactive
Block in the route is going Inactive. Release the blocks that we have left. Check if current block has been left (i.e. we have left our route) and stop the train in that case.- Overrides:
goingInactivein classWarrant- Parameters:
block- Block in the route is going Inactive
-
deallocateUpToBlock
Deallocate all blocks up to and including idx, but only on these conditions in order to ensure that only a consecutive list of blocks are allocated at any time: 1. Only if our train has left not only this block, but also all previous blocks. 2. Only if the block shall not be re-used ahead and all block up until the block are allocated.- Parameters:
idx- Index of final block
-
propertyChange
Something has fired a property change event. React if: - it is a warrant that we need to synchronize with. And then again: Why? - it is _nextSignal Do not worry about sensors and blocks. They are handled by goingActive and goingInactive.- Specified by:
propertyChangein interfacePropertyChangeListener- Overrides:
propertyChangein classWarrant
-
stopWarrant
Make sure to free up additional resources for a running SCWarrant.- Overrides:
stopWarrantin classWarrant
-
equals
Description copied from class:WarrantThis implementation tests that
NamedBean.getSystemName()is equal for this and obj.This implementation tests that
NamedBean.getSystemName()is equal for this and obj. To allow a warrant to run with sections, DccLocoAddress is included to test equality -
hashCode
Description copied from class:Warrant
-