Class DispatcherFrame
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Frame
-
- javax.swing.JFrame
-
- jmri.util.JmriJFrame
-
- jmri.jmrit.dispatcher.DispatcherFrame
-
- All Implemented Interfaces:
java.awt.event.ComponentListener,java.awt.event.WindowListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,javax.swing.RootPaneContainer,javax.swing.WindowConstants,BeanInterface,InstanceManagerAutoDefault,ModifiedFlag,WindowInterface
public class DispatcherFrame extends JmriJFrame implements InstanceManagerAutoDefault
Dispatcher functionality, working with Sections, Transits and ActiveTrain.Dispatcher serves as the manager for ActiveTrains. All allocation of Sections to ActiveTrains is performed here.
Programming Note: Use the managed instance returned by
InstanceManager.getDefault(java.lang.Class)to access the running Dispatcher.Dispatcher listens to fast clock minutes to handle all ActiveTrain items tied to fast clock time.
Delayed start of manual and automatic trains is enforced by not allocating Sections for trains until the fast clock reaches the departure time.
This file is part of JMRI.
JMRI is open source software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDispatcherFrame.ActiveTrainsTableModelTable model for Active Trains Table in Dispatcher windowclassDispatcherFrame.AllocatedSectionTableModelTable model for Allocated Section TableclassDispatcherFrame.AllocationRequestTableModelTable model for Allocation Request Table in Dispatcher windowprotected static classDispatcherFrame.HeaderActionListener(package private) static classDispatcherFrame.HeldMastDetails(package private) classDispatcherFrame.TableHeaderListenerClass to support Columnheader popup menu on XTableColum model.protected static classDispatcherFrame.TrainsFrom-
Nested classes/interfaces inherited from class jmri.util.JmriJFrame
JmriJFrame.ScreenDimensions
-
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
-
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from interface jmri.util.swing.WindowInterface
WindowInterface.Hint
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<AllocatedSection>allocatedSectionsprotected JmriJFramedispatcherFramestatic booleandispatcherSystemSchedulingInOperation(package private) java.util.List<DispatcherFrame.HeldMastDetails>heldMastsstatic java.lang.StringOVERRIDETYPE_DCCADDRESSstatic java.lang.StringOVERRIDETYPE_NONEConstants for the override typestatic java.lang.StringOVERRIDETYPE_OPERATIONSstatic java.lang.StringOVERRIDETYPE_ROSTERstatic java.lang.StringOVERRIDETYPE_USERstatic intSECTIONSALLOCATEDstatic intSIGNALHEADstatic intSIGNALMAST-
Fields inherited from class jmri.util.JmriJFrame
allowInFrameServlet, properties, reuseFrameSavedPosition, reuseFrameSavedSized, windowInterface
-
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
Constructor Summary
Constructors Constructor Description DispatcherFrame()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddDelayedTrain(ActiveTrain at, int restartType, Sensor delaySensor, boolean resetSensor)protected voidaddMouseListenerToHeader(javax.swing.JTable table)Adds the column header pop listener to a JTable using XTableColumnModelvoidallocateExtraSection(java.awt.event.ActionEvent e, ActiveTrain at)voidallocateNewActiveTrain(ActiveTrain at)(package private) voidallocateNextRequested(int index)protected voidallocateNextRequestedForTrain(ActiveTrain at)AllocatedSectionallocateSection(AllocationRequest ar, Section ns)Allocates a Section to an Active Train according to the information in an AllocationRequest.(package private) voidcancelRestart(java.awt.event.ActionEvent e)protected voidcheckAutoRelease()Check if any allocation requests need to be allocated, or if any allocated sections need to be releasedprotected SectioncheckBlocksNotInAllocatedSection(Section s, AllocationRequest ar)protected booleancheckForBlockInAllocatedSection(Block b, Section ignoreSection)Checks for a block in allocated section, except one(package private) java.util.List<LayoutTrackExpectedState<LayoutTurnout>>checkTurnoutStates(Section s, int sSeqNum, Section nextSection, ActiveTrain at, Section prevSection)ActiveTraincreateActiveTrain(java.lang.String transitID, java.lang.String trainID, int tSource, java.lang.String startBlockName, int startBlockSectionSequenceNumber, java.lang.String endBlockName, int endBlockSectionSequenceNumber, boolean autoRun, java.lang.String dccAddress, int priority, boolean resetWhenDone, boolean reverseAtEnd, boolean showErrorMessages, JmriJFrame frame, int allocateMethod)Creates a new ActiveTrain, and registers it with Dispatcher.protected TransitcreateTemporaryTransit(Block start, Block dest, Block via)Converts a list ofLayoutBlockthat represent a route to a transit.voiddispose()When window is finally destroyed, remove it from the list of windows.protected voiddoReleaseAllocatedSection(AllocatedSection as, boolean terminatingTrain)booleanextendActiveTrainsPath(Section s, ActiveTrain at, JmriJFrame jFrame)Extend the allocation of a section to a active train.protected AllocationRequestfindAllocationRequestInQueue(Section s, int seq, int dir, ActiveTrain at)ActiveTraingetActiveTrainForRoster(RosterEntry re)ActivateTrainFramegetActiveTrainFrame()java.util.List<ActiveTrain>getActiveTrainsList()protected java.util.List<LayoutBlock>getAdHocRoute(Block start, Block dest, Block via)Get a list ofLayoutBlockthat represent a routeprotected java.util.List<AllocatedSection>getAllocatedSectionsList()protected booleangetAutoAllocate()protected booleangetAutoRelease()AutoTrainsFramegetAutoTrainsFrame()protected booleangetAutoTurnouts()protected AutoTurnoutsgetAutoTurnoutsHelper()protected booleangetExtraColorForAllocated()protected intgetFullRampTime()protected booleangetHasOccupancyDetection()protected LayoutEditorgetLayoutEditor()protected floatgetMaximumLineSpeed()protected intgetMinThrottleInterval()protected booleangetNameInAllocatedBlock()booleangetNewTrainActive()protected booleangetRosterEntryInBlock()ScalegetScale()java.lang.StringgetSectionName(Section sec)protected booleangetSetSSLDirectionalSensors()protected booleangetShortActiveTrainNames()protected booleangetShortNameInBlock()protected intgetSignalType()protected java.lang.StringgetSignalTypeString()protected java.lang.StringgetStoppingSpeedName()protected booleangetSupportVSDecoder()protected DispatcherFrame.TrainsFromgetTrainsFrom()protected booleangetTrustKnownTurnouts()protected booleangetUseConnectivity()protected booleangetUseScaleMeters()protected booleangetUseTurnoutConnectionDelay()protected booleanhasTrainAnOccupiedSection(ActiveTrain at)Check an active train has an occupied section(package private) voidinitializeOptions()booleanisAddressFree(int addr)Check DCC not already in usebooleanisFastClockTimeGE(int hr, int min)This method tests timebooleanisMastHeldByDispatcher(SignalMast sm, ActiveTrain at)protected booleanisTrainFree(java.lang.String rName)voidloadAtStartup()reads thru all the traininfo files found in the dispatcher directory and loads the ones flagged as "loadAtStartup"intloadTrainFromTrainInfo(java.lang.String traininfoFileName)Loads a train into the Dispatcher from a traininfo fileintloadTrainFromTrainInfo(java.lang.String traininfoFileName, java.lang.String overRideType, java.lang.String overRideValue)Loads a train into the Dispatcher from a traininfo file, overriding dccaddressintloadTrainFromTrainInfo(TrainInfo info)Loads a train into the DispatcherintloadTrainFromTrainInfo(TrainInfo info, java.lang.String overRideType, java.lang.String overRideValue)Loads a train into the Dispatcher returns an integer.voidloadTrainFromTrainInfoThrowsException(TrainInfo info, java.lang.String overRideType, java.lang.String overRideValue)Loads a train into the Dispatcher throws IllegalArgumentException on errorsprotected voidnewFastClockMinute()Handle activity that is triggered by the fast clockvoidnewTrainDone(ActiveTrain at)(package private) voidopenDispatcherWindow()protected voidqueueAllocate(AllocationRequest aRequest)protected voidqueueReleaseOfCompletedAllocations()protected voidqueueReleaseOfReservedSections(java.lang.String trainName)protected voidqueueScanOfAllocationRequests()protected voidqueueWaitForEmpty()voidreleaseAllocatedSection(AllocatedSection as, boolean terminatingTrain)Releases an allocated Section, and removes it from the Dispatcher Input.(package private) voidreleaseAllocatedSectionFromTable(int index)protected voidremoveDelayedTrain(ActiveTrain at)booleanremoveFromActiveTrainPath(Section s, ActiveTrain at, JmriJFrame jFrame)protected booleanrequestAllocation(ActiveTrain activeTrain, Section section, int direction, int seqNumber, boolean showErrorMessages, JmriJFrame frame)protected booleanrequestAllocation(ActiveTrain activeTrain, Section section, int direction, int seqNumber, boolean showErrorMessages, JmriJFrame frame, boolean firstAllocation)Creates an Allocation Request, and registers it with DispatchervoidsectionOccupancyChanged()Updates display when occupancy of an allocated section changes Also drives auto release if it is selectedprotected voidsetAutoAllocate(boolean set)protected voidsetAutoRelease(boolean set)protected voidsetAutoTurnouts(boolean set)protected voidsetExtraColorForAllocated(boolean set)protected voidsetFullRampTime(int set)protected voidsetHasOccupancyDetection(boolean set)protected voidsetLayoutEditor(LayoutEditor editor)protected voidsetMinThrottleInterval(int set)protected voidsetNameInAllocatedBlock(boolean set)voidsetNewTrainActive(boolean boo)protected voidsetRosterEntryInBlock(boolean set)protected voidsetScale(Scale sc)protected voidsetSetSSLDirectionalSensors(boolean set)protected voidsetShortActiveTrainNames(boolean set)protected voidsetShortNameInBlock(boolean set)protected voidsetSignalType(int type)protected voidsetStoppingSpeedName(java.lang.String speedName)protected voidsetSupportVSDecoder(boolean set)protected voidsetTrainsFrom(DispatcherFrame.TrainsFrom value)protected voidsetTrustKnownTurnouts(boolean set)protected voidsetUseConnectivity(boolean set)protected voidsetUseScaleMeters(boolean set)protected voidsetUseTurnoutConnectionDelay(boolean set)protected voidshowTableHeaderPopup(JmriMouseEvent e, javax.swing.JTable table)Process the column header clickprotected voidstopStartAutoAllocateRelease()voidterminateActiveTrain(ActiveTrain at, boolean terminateNow, boolean runNextTrain)Terminate an Active Train and remove it from the Dispatcher.(package private) voidterminateTrain(java.awt.event.ActionEvent e)-
Methods inherited from class jmri.util.JmriJFrame
addHelpMenu, componentHidden, componentMoved, componentResized, componentShown, generateWindowRef, getAllowInFrameServlet, getEscapeKeyAction, getEscapeKeyClosesWindow, getFrame, getFrame, getFrameList, getFrameList, getIndexedProperty, getMaximumSize, getModifiedFlag, getPreferredSize, getProperty, getPropertyNames, getSavePosition, getSaveSize, getScreenDimensions, getWindowFrameRef, getWindowInterface, handleModified, hasIndexedProperty, hasProperty, initComponents, makePrivateWindow, makePublicWindow, markWindowModified, multipleInstances, pack, setAllowInFrameServlet, setEscapeKeyAction, setEscapeKeyClosesWindow, setFrameLocation, setIndexedProperty, setModifiedFlag, setProperty, setSavePosition, setSaveSize, setShutDownTask, setWindowInterface, show, show, storeValues, undecorate, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
-
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
-
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
dispatcherSystemSchedulingInOperation
public static boolean dispatcherSystemSchedulingInOperation
-
OVERRIDETYPE_NONE
public static final java.lang.String OVERRIDETYPE_NONE
Constants for the override type- See Also:
- Constant Field Values
-
OVERRIDETYPE_USER
public static final java.lang.String OVERRIDETYPE_USER
- See Also:
- Constant Field Values
-
OVERRIDETYPE_DCCADDRESS
public static final java.lang.String OVERRIDETYPE_DCCADDRESS
- See Also:
- Constant Field Values
-
OVERRIDETYPE_OPERATIONS
public static final java.lang.String OVERRIDETYPE_OPERATIONS
- See Also:
- Constant Field Values
-
OVERRIDETYPE_ROSTER
public static final java.lang.String OVERRIDETYPE_ROSTER
- See Also:
- Constant Field Values
-
SIGNALHEAD
public static final int SIGNALHEAD
- See Also:
- Constant Field Values
-
SIGNALMAST
public static final int SIGNALMAST
- See Also:
- Constant Field Values
-
SECTIONSALLOCATED
public static final int SECTIONSALLOCATED
- See Also:
- Constant Field Values
-
allocatedSections
protected final java.util.List<AllocatedSection> allocatedSections
-
dispatcherFrame
protected JmriJFrame dispatcherFrame
-
heldMasts
java.util.List<DispatcherFrame.HeldMastDetails> heldMasts
-
-
Constructor Detail
-
DispatcherFrame
public DispatcherFrame()
-
-
Method Detail
-
loadAtStartup
public void loadAtStartup()
reads thru all the traininfo files found in the dispatcher directory and loads the ones flagged as "loadAtStartup"
-
dispose
public void dispose()
Description copied from class:JmriJFrameWhen window is finally destroyed, remove it from the list of windows.Subclasses that over-ride this method must invoke this implementation with super.dispose() right before returning.
- Specified by:
disposein interfaceWindowInterface- Overrides:
disposein classJmriJFrame
-
loadTrainFromTrainInfo
public int loadTrainFromTrainInfo(java.lang.String traininfoFileName)
Loads a train into the Dispatcher from a traininfo file- Parameters:
traininfoFileName- the file name of a traininfo file.- Returns:
- 0 good, -1 create failure, -2 -3 file errors, -9 bother.
-
loadTrainFromTrainInfo
public int loadTrainFromTrainInfo(java.lang.String traininfoFileName, java.lang.String overRideType, java.lang.String overRideValue)
Loads a train into the Dispatcher from a traininfo file, overriding dccaddress- Parameters:
traininfoFileName- the file name of a traininfo file.overRideType- "NONE", "USER", "ROSTER" or "OPERATIONS"overRideValue- "" , dccAddress, RosterEntryName or Operations trainname.- Returns:
- 0 good, -1 create failure, -2 -3 file errors, -9 bother.
-
loadTrainFromTrainInfo
public int loadTrainFromTrainInfo(TrainInfo info)
Loads a train into the Dispatcher- Parameters:
info- a completed TrainInfo class.- Returns:
- 0 good, -1 failure
-
loadTrainFromTrainInfo
public int loadTrainFromTrainInfo(TrainInfo info, java.lang.String overRideType, java.lang.String overRideValue)
Loads a train into the Dispatcher returns an integer. Messages written to log.- Parameters:
info- a completed TrainInfo class.overRideType- "NONE", "USER", "ROSTER" or "OPERATIONS"overRideValue- "" , dccAddress, RosterEntryName or Operations trainName.- Returns:
- 0 good, -1 failure
-
loadTrainFromTrainInfoThrowsException
public void loadTrainFromTrainInfoThrowsException(TrainInfo info, java.lang.String overRideType, java.lang.String overRideValue) throws java.lang.IllegalArgumentException
Loads a train into the Dispatcher throws IllegalArgumentException on errors- Parameters:
info- a completed TrainInfo class.overRideType- "NONE", "USER", "ROSTER" or "OPERATIONS"overRideValue- "" , dccAddress, RosterEntryName or Operations trainName.- Throws:
java.lang.IllegalArgumentException- validation errors.
-
getAdHocRoute
protected java.util.List<LayoutBlock> getAdHocRoute(Block start, Block dest, Block via)
Get a list ofLayoutBlockthat represent a route- Parameters:
start- First Blockdest- Last Blockvia- Next Block- Returns:
- null if a route cannot be found, else the list.
-
createTemporaryTransit
protected Transit createTemporaryTransit(Block start, Block dest, Block via)
Converts a list ofLayoutBlockthat represent a route to a transit.- Parameters:
start- First Blockdest- Last Blockvia- Next Block- Returns:
- null if the transit is valid. Else an AdHoc transit
-
getActiveTrainFrame
public ActivateTrainFrame getActiveTrainFrame()
-
getNewTrainActive
public boolean getNewTrainActive()
-
setNewTrainActive
public void setNewTrainActive(boolean boo)
-
initializeOptions
void initializeOptions()
-
openDispatcherWindow
void openDispatcherWindow()
-
releaseAllocatedSectionFromTable
void releaseAllocatedSectionFromTable(int index)
-
allocateExtraSection
public void allocateExtraSection(java.awt.event.ActionEvent e, ActiveTrain at)
-
queueScanOfAllocationRequests
protected void queueScanOfAllocationRequests()
-
queueReleaseOfReservedSections
protected void queueReleaseOfReservedSections(java.lang.String trainName)
-
queueAllocate
protected void queueAllocate(AllocationRequest aRequest)
-
queueWaitForEmpty
protected void queueWaitForEmpty()
-
queueReleaseOfCompletedAllocations
protected void queueReleaseOfCompletedAllocations()
-
isTrainFree
protected boolean isTrainFree(java.lang.String rName)
-
isAddressFree
public boolean isAddressFree(int addr)
Check DCC not already in use- Parameters:
addr- DCC address.- Returns:
- true / false
-
getSectionName
public java.lang.String getSectionName(Section sec)
-
extendActiveTrainsPath
public boolean extendActiveTrainsPath(Section s, ActiveTrain at, JmriJFrame jFrame)
Extend the allocation of a section to a active train. Allows a dispatcher to manually route a train to its final destination.- Parameters:
s- the section to allocateat- the associated trainjFrame- the window to update- Returns:
- true if section was allocated; false otherwise
-
removeFromActiveTrainPath
public boolean removeFromActiveTrainPath(Section s, ActiveTrain at, JmriJFrame jFrame)
-
cancelRestart
void cancelRestart(java.awt.event.ActionEvent e)
-
terminateTrain
void terminateTrain(java.awt.event.ActionEvent e)
-
allocateNextRequested
void allocateNextRequested(int index)
-
allocateNextRequestedForTrain
protected void allocateNextRequestedForTrain(ActiveTrain at)
-
createActiveTrain
public ActiveTrain createActiveTrain(java.lang.String transitID, java.lang.String trainID, int tSource, java.lang.String startBlockName, int startBlockSectionSequenceNumber, java.lang.String endBlockName, int endBlockSectionSequenceNumber, boolean autoRun, java.lang.String dccAddress, int priority, boolean resetWhenDone, boolean reverseAtEnd, boolean showErrorMessages, JmriJFrame frame, int allocateMethod)
Creates a new ActiveTrain, and registers it with Dispatcher.- Parameters:
transitID- system or user name of a Transit in the Transit TabletrainID- any text that identifies the traintSource- either ROSTER, OPERATIONS, or USER (see ActiveTrain.java)startBlockName- system or user name of Block where train currently residesstartBlockSectionSequenceNumber- sequence number in the Transit of the Section containing the startBlock (if the startBlock is within the Transit), or of the Section the train will enter from the startBlock (if the startBlock is outside the Transit)endBlockName- system or user name of Block where train will end up after its transitendBlockSectionSequenceNumber- sequence number in the Transit of the Section containing the endBlock.autoRun- set to "true" if computer is to run the train automatically, otherwise "false"dccAddress- required if "autoRun" is "true", set to null otherwisepriority- any integer, higher number is higher priority. Used to arbitrate allocation request conflictsresetWhenDone- set to "true" if the Active Train is capable of continuous running and the user has requested that it be automatically reset for another run thru its Transit each time it completes running through its Transit.reverseAtEnd- true if train should automatically reverse at end of transit; false otherwiseshowErrorMessages- "true" if error message dialogs are to be displayed for detected errors Set to "false" to suppress error message dialogs from this method.frame- window request is from, or "null" if not from a windowallocateMethod- How allocations will be performed. 999 - Allocate as many section from start to finish as it can 0 - Allocate to the next "Safe" section. If it cannot allocate all the way to the next "safe" section it does not allocate any sections. It will not allocate beyond the next safe section until it arrives there. This is useful for bidirectional single track running. Any other positive number (in reality thats 1-150 as the create transit allows a max of 150 sections) allocate the specified number of sections a head.- Returns:
- a new ActiveTrain or null on failure
-
allocateNewActiveTrain
public void allocateNewActiveTrain(ActiveTrain at)
-
terminateActiveTrain
public void terminateActiveTrain(ActiveTrain at, boolean terminateNow, boolean runNextTrain)
Terminate an Active Train and remove it from the Dispatcher. The ActiveTrain object should not be used again after this method is called.- Parameters:
at- the train to terminateterminateNow- TRue if doing a full terminate, not just an end of transit.runNextTrain- if false the next traininfo is not run.
-
requestAllocation
protected boolean requestAllocation(ActiveTrain activeTrain, Section section, int direction, int seqNumber, boolean showErrorMessages, JmriJFrame frame, boolean firstAllocation)
Creates an Allocation Request, and registers it with DispatcherRequired input entries:
- Parameters:
activeTrain- ActiveTrain requesting the allocationsection- Section to be allocateddirection- direction of travel in the allocated SectionseqNumber- sequence number of the Section in the Transit of the ActiveTrain. If the requested Section is not in the Transit, a sequence number of -99 should be entered.showErrorMessages- "true" if error message dialogs are to be displayed for detected errors Set to "false" to suppress error message dialogs from this method.frame- window request is from, or "null" if not from a windowfirstAllocation- True if first allocation- Returns:
- true if successful; false otherwise
-
requestAllocation
protected boolean requestAllocation(ActiveTrain activeTrain, Section section, int direction, int seqNumber, boolean showErrorMessages, JmriJFrame frame)
-
findAllocationRequestInQueue
protected AllocationRequest findAllocationRequestInQueue(Section s, int seq, int dir, ActiveTrain at)
-
addDelayedTrain
protected void addDelayedTrain(ActiveTrain at, int restartType, Sensor delaySensor, boolean resetSensor)
-
allocateSection
public AllocatedSection allocateSection(@Nonnull AllocationRequest ar, Section ns)
Allocates a Section to an Active Train according to the information in an AllocationRequest.If successful, returns an AllocatedSection and removes the AllocationRequest from the queue. If not successful, returns null and leaves the AllocationRequest in the queue.
To be allocatable, a Section must be FREE and UNOCCUPIED. If a Section is OCCUPIED, the allocation is rejected unless the dispatcher chooses to override this restriction. To be allocatable, the Active Train must not be waiting for its start time. If the start time has not been reached, the allocation is rejected, unless the dispatcher chooses to override the start time.
- Parameters:
ar- the request containing the section to allocatens- the next section; use null to allow the next section to be automatically determined, if the next section is the last section, of if an extra section is being allocated- Returns:
- the allocated section or null if not successful
-
hasTrainAnOccupiedSection
protected boolean hasTrainAnOccupiedSection(ActiveTrain at)
Check an active train has an occupied section- Parameters:
at- ActiveTRain object- Returns:
- true / false
-
checkTurnoutStates
java.util.List<LayoutTrackExpectedState<LayoutTurnout>> checkTurnoutStates(Section s, int sSeqNum, Section nextSection, ActiveTrain at, Section prevSection)
- Parameters:
s- Section to checksSeqNum- Sequence number of sectionnextSection- section afterat- the active trainprevSection- the section before- Returns:
- null if error else a list of the turnouts and their expected states.
-
isMastHeldByDispatcher
public boolean isMastHeldByDispatcher(SignalMast sm, ActiveTrain at)
-
checkForBlockInAllocatedSection
protected boolean checkForBlockInAllocatedSection(Block b, Section ignoreSection)
Checks for a block in allocated section, except one- Parameters:
b- - The BlockignoreSection- - ignore this section, can be null- Returns:
- true is The Block is being used in a section.
-
checkBlocksNotInAllocatedSection
protected Section checkBlocksNotInAllocatedSection(Section s, AllocationRequest ar)
-
checkAutoRelease
protected void checkAutoRelease()
Check if any allocation requests need to be allocated, or if any allocated sections need to be released
-
releaseAllocatedSection
public void releaseAllocatedSection(AllocatedSection as, boolean terminatingTrain)
Releases an allocated Section, and removes it from the Dispatcher Input.- Parameters:
as- the section to releaseterminatingTrain- true if the associated train is being terminated; false otherwise
-
doReleaseAllocatedSection
protected void doReleaseAllocatedSection(AllocatedSection as, boolean terminatingTrain)
-
sectionOccupancyChanged
public void sectionOccupancyChanged()
Updates display when occupancy of an allocated section changes Also drives auto release if it is selected
-
newFastClockMinute
protected void newFastClockMinute()
Handle activity that is triggered by the fast clock
-
isFastClockTimeGE
public boolean isFastClockTimeGE(int hr, int min)
This method tests time- Parameters:
hr- the hour to test against (0-23)min- the minute to test against (0-59)- Returns:
- true if fast clock time and tested time are the same
-
getLayoutEditor
protected LayoutEditor getLayoutEditor()
-
setLayoutEditor
protected void setLayoutEditor(LayoutEditor editor)
-
getUseConnectivity
protected boolean getUseConnectivity()
-
setUseConnectivity
protected void setUseConnectivity(boolean set)
-
setSignalType
protected void setSignalType(int type)
-
getSignalType
protected int getSignalType()
-
getSignalTypeString
protected java.lang.String getSignalTypeString()
-
setStoppingSpeedName
protected void setStoppingSpeedName(java.lang.String speedName)
-
getStoppingSpeedName
protected java.lang.String getStoppingSpeedName()
-
getMaximumLineSpeed
protected float getMaximumLineSpeed()
-
setTrainsFrom
protected void setTrainsFrom(DispatcherFrame.TrainsFrom value)
-
getTrainsFrom
protected DispatcherFrame.TrainsFrom getTrainsFrom()
-
getAutoAllocate
protected boolean getAutoAllocate()
-
getAutoRelease
protected boolean getAutoRelease()
-
stopStartAutoAllocateRelease
protected void stopStartAutoAllocateRelease()
-
setAutoAllocate
protected void setAutoAllocate(boolean set)
-
setAutoRelease
protected void setAutoRelease(boolean set)
-
getAutoTurnoutsHelper
protected AutoTurnouts getAutoTurnoutsHelper()
-
getAutoTurnouts
protected boolean getAutoTurnouts()
-
setAutoTurnouts
protected void setAutoTurnouts(boolean set)
-
getTrustKnownTurnouts
protected boolean getTrustKnownTurnouts()
-
setTrustKnownTurnouts
protected void setTrustKnownTurnouts(boolean set)
-
getUseTurnoutConnectionDelay
protected boolean getUseTurnoutConnectionDelay()
-
setUseTurnoutConnectionDelay
protected void setUseTurnoutConnectionDelay(boolean set)
-
getMinThrottleInterval
protected int getMinThrottleInterval()
-
setMinThrottleInterval
protected void setMinThrottleInterval(int set)
-
getFullRampTime
protected int getFullRampTime()
-
setFullRampTime
protected void setFullRampTime(int set)
-
getHasOccupancyDetection
protected boolean getHasOccupancyDetection()
-
setHasOccupancyDetection
protected void setHasOccupancyDetection(boolean set)
-
getSetSSLDirectionalSensors
protected boolean getSetSSLDirectionalSensors()
-
setSetSSLDirectionalSensors
protected void setSetSSLDirectionalSensors(boolean set)
-
getUseScaleMeters
protected boolean getUseScaleMeters()
-
setUseScaleMeters
protected void setUseScaleMeters(boolean set)
-
getShortActiveTrainNames
protected boolean getShortActiveTrainNames()
-
setShortActiveTrainNames
protected void setShortActiveTrainNames(boolean set)
-
getShortNameInBlock
protected boolean getShortNameInBlock()
-
setShortNameInBlock
protected void setShortNameInBlock(boolean set)
-
getRosterEntryInBlock
protected boolean getRosterEntryInBlock()
-
setRosterEntryInBlock
protected void setRosterEntryInBlock(boolean set)
-
getExtraColorForAllocated
protected boolean getExtraColorForAllocated()
-
setExtraColorForAllocated
protected void setExtraColorForAllocated(boolean set)
-
getNameInAllocatedBlock
protected boolean getNameInAllocatedBlock()
-
setNameInAllocatedBlock
protected void setNameInAllocatedBlock(boolean set)
-
getActiveTrainsList
public java.util.List<ActiveTrain> getActiveTrainsList()
-
getAllocatedSectionsList
protected java.util.List<AllocatedSection> getAllocatedSectionsList()
-
getActiveTrainForRoster
public ActiveTrain getActiveTrainForRoster(RosterEntry re)
-
getSupportVSDecoder
protected boolean getSupportVSDecoder()
-
setSupportVSDecoder
protected void setSupportVSDecoder(boolean set)
-
newTrainDone
public void newTrainDone(ActiveTrain at)
-
removeDelayedTrain
protected void removeDelayedTrain(ActiveTrain at)
-
getAutoTrainsFrame
public AutoTrainsFrame getAutoTrainsFrame()
-
showTableHeaderPopup
protected void showTableHeaderPopup(JmriMouseEvent e, javax.swing.JTable table)
Process the column header click- Parameters:
e- the evnt datatable- the JTable
-
addMouseListenerToHeader
protected void addMouseListenerToHeader(javax.swing.JTable table)
Adds the column header pop listener to a JTable using XTableColumnModel- Parameters:
table- The JTable effected.
-
-