jmri.jmrit.dispatcher
Class DispatcherFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by jmri.util.JmriJFrame
                          extended by jmri.jmrit.dispatcher.DispatcherFrame
All Implemented Interfaces:
ComponentListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, ModifiedFlag

public class DispatcherFrame
extends JmriJFrame

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: public methods may be addressed externally via jmri.jmrit.dispatcher.DispatcherFrame.instance(). ...

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.

Author:
Dave Duchamp Copyright (C) 2008-2011
See Also:
Serialized Form

Nested Class Summary
 class DispatcherFrame.ActiveTrainsTableModel
          Table model for Active Trains Table in Dispatcher window
 class DispatcherFrame.AllocatedSectionTableModel
          Table model for Allocated Section Table
 class DispatcherFrame.AllocationRequestTableModel
          Table model for Allocation Request Table in Dispatcher window
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JmriJFrame dispatcherFrame
           
 
Fields inherited from class jmri.util.JmriJFrame
reuseFrameSavedPosition, reuseFrameSavedSized
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
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
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 void allocateNewActiveTrain(ActiveTrain at)
           
 AllocatedSection allocateSection(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.
 ActiveTrain createActiveTrain(String transitID, String trainID, int tSource, String startBlockName, int startBlockSectionSequenceNumber, String endBlockName, int endBlockSectionSequenceNumber, boolean autoRun, String dccAddress, int priority, boolean resetWhenDone, boolean reverseAtEnd, boolean showErrorMessages, JmriJFrame frame)
          Creates a new ActiveTrain, and registers it with Dispatcher Required input entries: transitID - system or user name of a Transit in the Transit Table trainID - any text that identifies the train tSource - either ROSTER, OPERATIONS, or USER (see ActiveTrain.java) startBlockName - system or user name of Block where train currently resides startBlockSectionSequenceNumber - 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).
protected  AllocationRequest findAllocationRequestInQueue(Section s, int seq, int dir, ActiveTrain at)
           
protected  ArrayList<ActiveTrain> getActiveTrainsList()
           
protected  ArrayList<AllocatedSection> getAllocatedSectionsList()
           
protected  boolean getAutoAllocate()
           
protected  AutoTrainsFrame getAutoTrainsFrame()
           
protected  boolean getAutoTurnouts()
           
protected  boolean getExtraColorForAllocated()
           
protected  boolean getHasOccupancyDetection()
           
protected  LayoutEditor getLayoutEditor()
           
protected  boolean getNameInAllocatedBlock()
           
protected  int getScale()
           
 String getSectionName(Section sec)
           
protected  boolean getShortActiveTrainNames()
           
protected  boolean getShortNameInBlock()
           
protected  boolean getTrainsFromRoster()
           
protected  boolean getTrainsFromTrains()
           
protected  boolean getTrainsFromUser()
           
protected  boolean getUseConnectivity()
           
protected  boolean getUseScaleMeters()
           
static DispatcherFrame instance()
           
protected  boolean isFastClockTimeGE(int hr, int min)
          This method tests time assuming both times are on the same day (ignoring midnight) It also sets nowMinutes and nowHours to the latest fast clock values
protected  void newFastClockMinute()
          Handle activity that is triggered by the fast clock
protected  void newTrainDone(ActiveTrain at)
           
 void releaseAllocatedSection(AllocatedSection as, boolean terminatingTrain)
          Releases an allocated Section, and removes it from the Dispatcher Input consists of the AllocatedSection object (returned by "allocateSection") and whether this release is from a Terminate Train.
protected  boolean requestAllocation(ActiveTrain activeTrain, Section section, int direction, int seqNumber, boolean showErrorMessages, JmriJFrame frame)
          Creates an Allocation Request, and registers it with Dispatcher Required input entries: activeTrain - ActiveTrain requesting the allocation section - Section to be allocated direction - direction of travel in the allocated Section seqNumber - sequence number of the Section in the Transit of the ActiveTrain.
 void sectionOccupancyChanged()
          Updates display when occupancy of an allocated section changes Also drives auto release if it is selected
protected  void setAutoAllocate(boolean set)
           
protected  void setAutoTurnouts(boolean set)
           
protected  void setExtraColorForAllocated(boolean set)
           
protected  void setHasOccupancyDetection(boolean set)
           
protected  void setLayoutEditor(LayoutEditor editor)
           
protected  void setNameInAllocatedBlock(boolean set)
           
protected  void setScale(int sc)
           
protected  void setShortActiveTrainNames(boolean set)
           
protected  void setShortNameInBlock(boolean set)
           
protected  void setTrainsFromRoster(boolean set)
           
protected  void setTrainsFromTrains(boolean set)
           
protected  void setTrainsFromUser(boolean set)
           
protected  void setUseConnectivity(boolean set)
           
protected  void setUseScaleMeters(boolean set)
           
 void terminateActiveTrain(ActiveTrain at)
          Terminates an Active Train and removes it from the Dispatcher The ActiveTrain object should not be used again after this method is called
 
Methods inherited from class jmri.util.JmriJFrame
addHelpMenu, addNotify, componentHidden, componentMoved, componentResized, componentShown, dispose, generateWindowRef, getFrame, getFrameList, getMaximumSize, getModifiedFlag, getPreferredSize, getSavePosition, getSaveSize, getWindowFrameRef, handleModified, initComponents, markWindowModified, pack, setModifiedFlag, setSavePosition, setSaveSize, setShutDownTask, storeValues, 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
getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, transferFocusBackward, 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, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, isOpaque, 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, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

dispatcherFrame

protected JmriJFrame dispatcherFrame
Method Detail

getSectionName

public String getSectionName(Section sec)

createActiveTrain

public ActiveTrain createActiveTrain(String transitID,
                                     String trainID,
                                     int tSource,
                                     String startBlockName,
                                     int startBlockSectionSequenceNumber,
                                     String endBlockName,
                                     int endBlockSectionSequenceNumber,
                                     boolean autoRun,
                                     String dccAddress,
                                     int priority,
                                     boolean resetWhenDone,
                                     boolean reverseAtEnd,
                                     boolean showErrorMessages,
                                     JmriJFrame frame)
Creates a new ActiveTrain, and registers it with Dispatcher

Required input entries: transitID - system or user name of a Transit in the Transit Table trainID - any text that identifies the train tSource - either ROSTER, OPERATIONS, or USER (see ActiveTrain.java) startBlockName - system or user name of Block where train currently resides startBlockSectionSequenceNumber - 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 transit endBlockSectionSequenceNumber - 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 otherwise priority - any integer, higher number is higher priority. Used to arbitrate allocation request conflicts resetWhenDone - 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. 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 window

Returns an ActiveTrain object if successful, returns "null" otherwise


allocateNewActiveTrain

public void allocateNewActiveTrain(ActiveTrain at)

terminateActiveTrain

public void terminateActiveTrain(ActiveTrain at)
Terminates an Active Train and removes it from the Dispatcher The ActiveTrain object should not be used again after this method is called


requestAllocation

protected boolean requestAllocation(ActiveTrain activeTrain,
                                    Section section,
                                    int direction,
                                    int seqNumber,
                                    boolean showErrorMessages,
                                    JmriJFrame frame)
Creates an Allocation Request, and registers it with Dispatcher

Required input entries: activeTrain - ActiveTrain requesting the allocation section - Section to be allocated direction - direction of travel in the allocated Section seqNumber - 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 window


findAllocationRequestInQueue

protected AllocationRequest findAllocationRequestInQueue(Section s,
                                                         int seq,
                                                         int dir,
                                                         ActiveTrain at)

allocateSection

public AllocatedSection allocateSection(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. The user may choose to specify the next Section by entering "ns". If this method is to determine the next Section, or if the next section is the last section, null should be entered for ns. Null should also be entered for ns if allocating an Extra Section that is not the Next Section.


releaseAllocatedSection

public void releaseAllocatedSection(AllocatedSection as,
                                    boolean terminatingTrain)
Releases an allocated Section, and removes it from the Dispatcher Input consists of the AllocatedSection object (returned by "allocateSection") and whether this release is from a Terminate Train.


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

protected boolean isFastClockTimeGE(int hr,
                                    int min)
This method tests time assuming both times are on the same day (ignoring midnight) It also sets nowMinutes and nowHours to the latest fast clock values


getLayoutEditor

protected LayoutEditor getLayoutEditor()

setLayoutEditor

protected void setLayoutEditor(LayoutEditor editor)

getUseConnectivity

protected boolean getUseConnectivity()

setUseConnectivity

protected void setUseConnectivity(boolean set)

getTrainsFromRoster

protected boolean getTrainsFromRoster()

setTrainsFromRoster

protected void setTrainsFromRoster(boolean set)

getTrainsFromTrains

protected boolean getTrainsFromTrains()

setTrainsFromTrains

protected void setTrainsFromTrains(boolean set)

getTrainsFromUser

protected boolean getTrainsFromUser()

setTrainsFromUser

protected void setTrainsFromUser(boolean set)

getAutoAllocate

protected boolean getAutoAllocate()

setAutoAllocate

protected void setAutoAllocate(boolean set)

getAutoTurnouts

protected boolean getAutoTurnouts()

setAutoTurnouts

protected void setAutoTurnouts(boolean set)

getHasOccupancyDetection

protected boolean getHasOccupancyDetection()

setHasOccupancyDetection

protected void setHasOccupancyDetection(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)

getExtraColorForAllocated

protected boolean getExtraColorForAllocated()

setExtraColorForAllocated

protected void setExtraColorForAllocated(boolean set)

getNameInAllocatedBlock

protected boolean getNameInAllocatedBlock()

setNameInAllocatedBlock

protected void setNameInAllocatedBlock(boolean set)

getScale

protected int getScale()

setScale

protected void setScale(int sc)

getActiveTrainsList

protected ArrayList<ActiveTrain> getActiveTrainsList()

getAllocatedSectionsList

protected ArrayList<AllocatedSection> getAllocatedSectionsList()

newTrainDone

protected void newTrainDone(ActiveTrain at)

getAutoTrainsFrame

protected AutoTrainsFrame getAutoTrainsFrame()

instance

public static DispatcherFrame instance()


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads