Class AbstractBoardProgPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, 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
  • Field Details

  • Constructor Details

    • AbstractBoardProgPanel

      protected AbstractBoardProgPanel​(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, 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, 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, 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 Details

    • 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.
    • initComponents

      Description copied from class: LnPanel
      2nd stage of initialization, invoked after the constuctor is complete.

      This needs to be connected to the initContext() method in implementing classes.

      Specified by:
      initComponents in interface LnPanelInterface
      Overrides:
      initComponents in class LnPanel
      Parameters:
      memo - a LocoNetSystemConnectionMemo object
    • initComponents

      public void initComponents()
      Description copied from class: JmriPanel
      2nd stage of initialization, invoked after the constructor is complete.
      Overrides:
      initComponents in class JmriPanel
    • setBoardIdValue

      public void setBoardIdValue​(Integer boardId)
      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

      protected JPanel provideAddressing​(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

      Create the status line for the GUI.
      Returns:
      JComponent which will display status updates
    • setStatus

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

      protected void appendLine​(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.

    • dispose

      public void dispose()
      Overrides:
      dispose in class JmriPanel