Class AbstractBoardProgPanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,EventListener,Accessible,LocoNetListener,LnPanelInterface
- Direct Known Subclasses:
BDL16Panel,Ds64TabbedPanel,PM4Panel,SE8Panel
Supports boards which can be read and write using LocoNet opcode OPC_MULTI_SENSE, such as PM4x, DS64, SE8c, BDL16x.
The read and write require a sequence of operations, which we handle with a state variable.
Each read or write OpSw access requires a response from the addressed board. If a response is not received within a fixed time, then the process will repeat the read or write OpSw access up to MAX_OPSW_ACCESS_RETRIES additional times to try to get a response from the addressed board. If the board does not respond, the access sequence is aborted and a failure message is populated in the "status" variable.
Programming of the board is done via configuration messages, so the board should not be put into programming mode via the built-in pushbutton while this tool is in use.
Throughout, the terminology is "closed" == true, "thrown" == false. Variables are named for their closed state.
Some of the message formats used in this class are Copyright Digitrax, Inc. and used with permission as part of the JMRI project. That permission does not extend to uses in other software products. If you wish to use this code, algorithm or these message formats outside of JMRI, please contact Digitrax Inc for separate permission.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescription(package private) int(package private) boolean(package private) JPanelbooleanprotected boolean[]True is "closed", false is "thrown".boolean(package private) boolean(package private) intint(package private) JLabel(package private) intFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBoardProgPanel(boolean readOnInit, String boardTypeName) Constructor which accepts a boolean which specifies whether to automatically read the board, plus a string defining the "board type".protectedAbstractBoardProgPanel(int boardNum, boolean readOnInit, String boardTypeName) Constructor which accepts parameters for the initial board number, whether to automatically read the board, and a "board type" string.protectedAbstractBoardProgPanel(int boardNum, String boardTypeName) Constructor which allows the caller to pass in the board ID number and board type nameprotectedAbstractBoardProgPanel(String boardTypeName) Constructor which accepts a "board type" string. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHandle GUI layout details during construction.protected abstract voidCopy from the GUI to the opsw array.voiddispose()voidHelps continue sequences of OpSw accesses.void2nd stage of initialization, invoked after the constructor is complete.void2nd stage of initialization, invoked after the constructor is complete.voidProcesses incoming LocoNet message m for OpSw responses to read and write operation messages, and automatically advances to the next OpSw operation as directed bynextState(int).protected abstract intnextState(int state) Compute the next OpSw number to be accessed, based on the current OpSw number.protected voidIn order to get the scrollpanel on the screen it must be added at the end when all components and sub panels have been added to the one panel.protected JPanelCreates a JPanel to allow the user to specify a board address.protected JPanelprovideAddressing(String boardTypeName) Creates a JPanel to allow the user to specify a board address and to read and write the device.protected JComponentCreate the status line for the GUI.voidreadAll()Provides a mechanism to read several OpSw values in a sequence.(package private) voidsetAddress(int maxValid) Convert the GUI text field containing the address into a valid integer address, and handles user-input errors as needed.voidsetBoardIdValue(Integer boardId) Set the Board ID number (also known as board address number)protected voidUpdate the status line.protected voidsetTypeWord(int type) Configure the type word in the LocoNet messages.protected abstract voidUpdate the GUI based on the contents of opsw[].voidwriteAll()Provide a mechanism to write several OpSw values in a sequence.voidwriteOne(int opswIndex) writeOne() is intended to provide a mechanism to write a single OpSw value, rather than a sequence of OpSws as done by writeAll().Methods inherited from class jmri.jmrix.loconet.swing.LnPanel
getTitle, getTitleHelper, initContextMethods inherited from class jmri.util.swing.JmriPanel
getHelpTarget, getMenus, getMinimumDimension, getTitle, getWindowInterface, isMultipleInstances, setWindowInterfaceMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
contents
-
readAllButton
-
writeAllButton
-
addrField
-
status
-
read
-
state
-
awaitingReply
boolean awaitingReply -
replyTryCount
int replyTryCount -
responseTimer
-
pacingTimer
-
onlyOneOperation
-
address
int address -
typeWord
int typeWord -
readOnInit
boolean readOnInit -
opsw
True is "closed", false is "thrown". This matches how we do the check boxes also, where we use the terminology for the "closed" option. Note that opsw[0] is not a legal OpSwitch.
-
-
Constructor Details
-
AbstractBoardProgPanel
Constructor which accepts a "board type" string. The board number defaults to 1, and the board will not be automatically read.- Parameters:
boardTypeName- device type name, to be included in read and write GUI buttons
-
AbstractBoardProgPanel
Constructor which accepts a boolean which specifies whether to automatically read the board, plus a string defining the "board type". The board number defaults to 1.- Parameters:
readOnInit- true to read OpSw values of board 1 upon panel creationboardTypeName- device type name, to be included in read and write GUI buttons
-
AbstractBoardProgPanel
Constructor which accepts parameters for the initial board number, whether to automatically read the board, and a "board type" string.- Parameters:
boardNum- default board ID number upon panel creationreadOnInit- true to read OpSw values of board 1 upon panel creationboardTypeName- device type name, to be included in read and write GUI buttons
-
AbstractBoardProgPanel
Constructor which allows the caller to pass in the board ID number and board type name- Parameters:
boardNum- default board ID number upon panel creationboardTypeName- device type name, to be included in read and write GUI buttons
-
-
Method Details
-
panelToScroll
In order to get the scrollpanel on the screen it must be added at the end when all components and sub panels have been added to the one panel. This must be called as the last thing in the initComponents. -
initComponents
Description copied from class:LnPanel2nd stage of initialization, invoked after the constructor is complete.This needs to be connected to the initContext() method in implementing classes.
- Specified by:
initComponentsin interfaceLnPanelInterface- Overrides:
initComponentsin classLnPanel- Parameters:
memo- aLocoNetSystemConnectionMemoobject
-
initComponents
Description copied from class:JmriPanel2nd stage of initialization, invoked after the constructor is complete.- Overrides:
initComponentsin classJmriPanel
-
setBoardIdValue
Set the Board ID number (also known as board address number)- Parameters:
boardId- board ID number to be accessed
-
getBoardIdValue
-
provideAddressing
Creates a JPanel to allow the user to specify a board address. Includes a previously-defined board type name within the panel, or, if none has been previously provided, a default board-type name.- Returns:
- a JPanel with address entry
-
provideAddressing
Creates a JPanel to allow the user to specify a board address and to read and write the device. The "read" and "write" buttons have text which uses the specified "board type name" from the method parameter.- Parameters:
boardTypeName- device type name, to be included in read and write GUI buttons- Returns:
- JPanel containing a JTextField and read and write JButtons
-
provideStatusLine
Create the status line for the GUI.- Returns:
- JComponent which will display status updates
-
setStatus
Update the status line.- Parameters:
msg- to be displayed on the status line
-
appendLine
Handle GUI layout details during construction. Adds items as lines onto JPanel.- Parameters:
c- component to put on a single line
-
readAll
Provides a mechanism to read several OpSw values in a sequence. The sequence is defined by thenextState(int)method. -
setTypeWord
Configure the type word in the LocoNet messages.Known values:
- 0x70 - PM4
- 0x71 - BDL16
- 0x72 - SE8
- 0x73 - DS64
- Parameters:
type- board type number, per list above
-
setAddress
Convert the GUI text field containing the address into a valid integer address, and handles user-input errors as needed.- Parameters:
maxValid- highest Board ID number allowed for the given device type- Throws:
JmriException- when the board address is invalid
-
copyToOpsw
Copy from the GUI to the opsw array.Used before a write operation is started.
-
updateDisplay
Update the GUI based on the contents of opsw[].This method is executed after completion of a read operation sequence.
-
nextState
Compute the next OpSw number to be accessed, based on the current OpSw number.- Parameters:
state- current OpSw number- Returns:
- computed next OpSw nubmer
-
writeAll
Provide a mechanism to write several OpSw values in a sequence. The sequence is defined by thenextState(int)method. -
writeOne
writeOne() is intended to provide a mechanism to write a single OpSw value, rather than a sequence of OpSws as done by writeAll(). The value to be written is taken from the appropriate entry in booleans[].- Parameters:
opswIndex- OpSw number- See Also:
-
message
Processes incoming LocoNet message m for OpSw responses to read and write operation messages, and automatically advances to the next OpSw operation as directed bynextState(int).- Specified by:
messagein interfaceLocoNetListener- Parameters:
m- incoming LocoNet message
-
doTheNextThing
Helps continue sequences of OpSw accesses.Handles aborting a sequence of reads or writes when the GUI Read button or the GUI Write button (as appropriate for the current operation) is de-selected.
-
dispose
-