Class MultiIndexProgrammerFacade

java.lang.Object
jmri.jmrix.AbstractProgrammerFacade
jmri.implementation.MultiIndexProgrammerFacade
All Implemented Interfaces:
EventListener, ProgListener, Programmer

public class MultiIndexProgrammerFacade
extends AbstractProgrammerFacade
implements ProgListener
Programmer facade for accessing CVs that require one or more "index CVs" to have specific values before doing the final read or write operation.

Currently supports direct access to CVs (the usual style), operations where one index CV (called PI, for primary index) must have a specific value first, and operations where two index CVs (called PI and SI, for secondary index) must have a specific value first.

Accepts two different address formats so that the CV addresses can be written in the same style as the decoder manufacturer's documentation:

  • If cvFirst is true:
    • 123 Do read or write directly to CV 123; this allows unindexed CVs to go through
    • 123.11 Writes 11 to PI, the index CV, then does the final read or write to CV 123
    • 123.11.12 Writes 11 to the first index CV, then 12 to the second index CV, then does the final read or write to CV 123
  • If cvFirst is false:
    • 123 Do read or write directly to CV 123; this allows unindexed CVs to go through
    • 11.123 Writes 11 to the first index CV, then does the final read or write to CV 123
    • 11.12.123 Writes 11 to the first index CV, then 12 to the second index CV, then does the final read or write to CV 123
QSI decoders generally use the 1st format, and ESU LokSound decoders the second.

The specific CV numbers for PI and SI are provided when constructing the object. They can be read from a decoder definition file by e.g. ProgrammerFacadeSelector.

Alternately the PI and/or SI CV numbers can be set by using a "nn=nn" syntax when specifying PI and/or SI. For example, using a cvFirst false syntax, "101=12.80" sets CV101 to 12 before accessing CV 80, regardless of the PI value configured into the facade.

If skipDupIndexWrite is true, sequential operations with the same PI and SI values (and only immediately sequential operations with both PI and SI unchanged) will skip writing of the PI and SI CVs. This might not work for some decoders, hence is configurable. See the logic in ProgrammerFacadeSelector for how the decoder file contents and default (preferences) interact.

State Diagram for read and write operations (click to magnify): UML State diagram

See Also:
ProgrammerFacadeSelector