Class AbstractBoardProgPanel

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, LocoNetListener, LnPanelInterface
    Direct Known Subclasses:
    BDL16Panel, Ds64TabbedPanel, PM4Panel, SE8Panel

    public abstract class AbstractBoardProgPanel
    extends LnPanel
    implements LocoNetListener
    Display and modify an Digitrax board configuration.

    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:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int address  
      javax.swing.JTextField addrField  
      (package private) boolean awaitingReply  
      (package private) javax.swing.JPanel contents  
      boolean onlyOneOperation  
      protected boolean[] opsw
      True is "closed", false is "thrown".
      javax.swing.Timer pacingTimer  
      boolean read  
      javax.swing.JToggleButton readAllButton  
      (package private) boolean readOnInit  
      (package private) int replyTryCount  
      javax.swing.Timer responseTimer  
      int state  
      (package private) javax.swing.JLabel status  
      (package private) int typeWord  
      javax.swing.JToggleButton writeAllButton  
      • Fields inherited from class jmri.jmrix.loconet.swing.LnPanel

        memo
      • Fields inherited from class javax.swing.JComponent

        listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractBoardProgPanel​(boolean readOnInit, java.lang.String boardTypeName)
      Constructor which accepts a boolean which specifies whether to automatically read the board, plus a string defining the "board type".
      protected AbstractBoardProgPanel​(int boardNum, boolean readOnInit, java.lang.String boardTypeName)
      Constructor which accepts parameters for the initial board number, whether to automatically read the board, and a "board type" string.
      protected AbstractBoardProgPanel​(int boardNum, java.lang.String boardTypeName)
      Constructor which allows the caller to pass in the board ID number and board type name
      protected AbstractBoardProgPanel​(java.lang.String boardTypeName)
      Constructor which accepts a "board type" string.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void appendLine​(javax.swing.JComponent c)
      Handle GUI layout details during construction.
      protected abstract void copyToOpsw()
      Copy from the GUI to the opsw array.
      void dispose()  
      void doTheNextThing()
      Helps continue sequences of OpSw accesses.
      java.lang.Integer getBoardIdValue()  
      void initComponents()
      2nd stage of initialization, invoked after the constructor is complete.
      void initComponents​(LocoNetSystemConnectionMemo memo)
      2nd stage of initialization, invoked after the constructor is complete.
      void message​(LocoNetMessage m)
      Processes incoming LocoNet message m for OpSw responses to read and write operation messages, and automatically advances to the next OpSw operation as directed by nextState(int).
      protected abstract int nextState​(int state)
      Compute the next OpSw number to be accessed, based on the current OpSw number.
      protected void 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.
      protected javax.swing.JPanel provideAddressing()
      Creates a JPanel to allow the user to specify a board address.
      protected javax.swing.JPanel provideAddressing​(java.lang.String boardTypeName)
      Creates a JPanel to allow the user to specify a board address and to read and write the device.
      protected javax.swing.JComponent provideStatusLine()
      Create the status line for the GUI.
      void readAll()
      Provides a mechanism to read several OpSw values in a sequence.
      (package private) void setAddress​(int maxValid)
      Convert the GUI text field containing the address into a valid integer address, and handles user-input errors as needed.
      void setBoardIdValue​(java.lang.Integer boardId)
      Set the Board ID number (also known as board address number)
      protected void setStatus​(java.lang.String msg)
      Update the status line.
      protected void setTypeWord​(int type)
      Configure the type word in the LocoNet messages.
      protected abstract void updateDisplay()
      Update the GUI based on the contents of opsw[].
      void writeAll()
      Provide a mechanism to write several OpSw values in a sequence.
      void writeOne​(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 javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods 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, update
      • Methods 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, validateTree
      • Methods 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractBoardProgPanel

        protected AbstractBoardProgPanel​(java.lang.String boardTypeName)
        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

        protected AbstractBoardProgPanel​(boolean readOnInit,
                                         java.lang.String boardTypeName)
        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 creation
        boardTypeName - device type name, to be included in read and write GUI buttons
      • AbstractBoardProgPanel

        protected AbstractBoardProgPanel​(int boardNum,
                                         boolean readOnInit,
                                         java.lang.String boardTypeName)
        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 creation
        readOnInit - true to read OpSw values of board 1 upon panel creation
        boardTypeName - device type name, to be included in read and write GUI buttons
      • AbstractBoardProgPanel

        protected AbstractBoardProgPanel​(int boardNum,
                                         java.lang.String boardTypeName)
        Constructor which allows the caller to pass in the board ID number and board type name
        Parameters:
        boardNum - default board ID number upon panel creation
        boardTypeName - device type name, to be included in read and write GUI buttons
    • Method Detail

      • panelToScroll

        protected void 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.
      • setBoardIdValue

        public void setBoardIdValue​(java.lang.Integer boardId)
        Set the Board ID number (also known as board address number)
        Parameters:
        boardId - board ID number to be accessed
      • provideAddressing

        protected javax.swing.JPanel 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

        protected javax.swing.JPanel provideAddressing​(java.lang.String boardTypeName)
        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

        protected javax.swing.JComponent provideStatusLine()
        Create the status line for the GUI.
        Returns:
        JComponent which will display status updates
      • setStatus

        protected void setStatus​(java.lang.String msg)
        Update the status line.
        Parameters:
        msg - to be displayed on the status line
      • appendLine

        protected void appendLine​(javax.swing.JComponent c)
        Handle GUI layout details during construction. Adds items as lines onto JPanel.
        Parameters:
        c - component to put on a single line
      • readAll

        public void readAll()
        Provides a mechanism to read several OpSw values in a sequence. The sequence is defined by the nextState(int) method.
      • setTypeWord

        protected void setTypeWord​(int type)
        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

        void setAddress​(int maxValid)
                 throws JmriException
        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

        protected abstract void copyToOpsw()
        Copy from the GUI to the opsw array.

        Used before a write operation is started.

      • updateDisplay

        protected abstract void updateDisplay()
        Update the GUI based on the contents of opsw[].

        This method is executed after completion of a read operation sequence.

      • nextState

        protected abstract int nextState​(int state)
        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

        public void writeAll()
        Provide a mechanism to write several OpSw values in a sequence. The sequence is defined by the nextState(int) method.
      • writeOne

        public void writeOne​(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(). The value to be written is taken from the appropriate entry in booleans[].
        Parameters:
        opswIndex - OpSw number
        See Also:
        writeAll()
      • message

        public void message​(LocoNetMessage m)
        Processes incoming LocoNet message m for OpSw responses to read and write operation messages, and automatically advances to the next OpSw operation as directed by nextState(int).
        Specified by:
        message in interface LocoNetListener
        Parameters:
        m - incoming LocoNet message
      • doTheNextThing

        public void 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.