Class MultiIndexProgrammerFacade
- java.lang.Object
- 
- jmri.jmrix.AbstractProgrammerFacade
- 
- jmri.implementation.MultiIndexProgrammerFacade
 
 
- 
- All Implemented Interfaces:
- java.util.EventListener,- Disposable,- 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
 
 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 ProgrammerFacadeSelectorfor how the decoder file contents and default (preferences) interact.State Diagram for read and write operations (click to magnify):  - See Also:
- ProgrammerFacadeSelector
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description (package private) static classMultiIndexProgrammerFacade.ProgState- 
Nested classes/interfaces inherited from interface jmri.ProgrammerProgrammer.Configurator, Programmer.WriteConfirmMode
 
- 
 - 
Field SummaryFields Modifier and Type Field Description (package private) java.lang.String_cv(package private) int_startVal(package private) int_val(package private) booleancvFirst(package private) java.lang.StringdefaultIndexPI(package private) java.lang.StringdefaultIndexSI(package private) java.lang.StringindexPI(package private) java.lang.StringindexSI(package private) longlastOpTime(package private) intlastValuePI(package private) intlastValueSI(package private) longmaxDelay(package private) booleanskipDupIndexWrite(package private) MultiIndexProgrammerFacade.ProgStatestate(package private) intvaluePI(package private) intvalueSI- 
Fields inherited from class jmri.jmrix.AbstractProgrammerFacadeprog
 - 
Fields inherited from interface jmri.ProgListenerCommError, ConfirmFailed, FailedTimeout, NoAck, NoLocoDetected, NotImplemented, OK, ProgrammerBusy, ProgrammingShort, SequenceError, UnknownError, UserAborted
 
- 
 - 
Constructor SummaryConstructors Constructor Description MultiIndexProgrammerFacade(Programmer prog, java.lang.String indexPI, java.lang.String indexSI, boolean cvFirst, boolean skipDupIndexWrite)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfirmCV(java.lang.String CV, int val, ProgListener p)Confirm the value of a CV using the specified programming mode.(package private) java.lang.StringgetAlternateAddress(java.lang.String cv)(package private) intgetAlternateValue(java.lang.String cv)(package private) booleanhasAlternateAddress(java.lang.String cv)(package private) voidparseCV(java.lang.String cv)voidprogrammingOpReply(int value, int status)Receive a callback at the end of a programming operation.voidreadCV(java.lang.String CV, ProgListener p)Perform a CV read in the system-specific manner, and using the specified programming mode.voidreadCV(java.lang.String CV, ProgListener p, int startVal)Perform a CV read in the system-specific manner, and using the specified programming mode, possibly using a hint of the current value to speed up programming.(package private) booleanuseCachePiSi()Check if the last-written PI and SI values can still be counted on.protected voiduseProgrammer(ProgListener p)voidwriteCV(java.lang.String CV, int val, ProgListener p)Perform a CV write in the system-specific manner, and using the specified programming mode.- 
Methods inherited from class jmri.jmrix.AbstractProgrammerFacadeaddPropertyChangeListener, decodeErrorCode, getCanRead, getCanRead, getCanWrite, getCanWrite, getMode, getSupportedModes, getWriteConfirmMode, removePropertyChangeListener, setMode
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jmri.Programmerdispose, getConfigurator, notifyProgListenerEnd
 
- 
 
- 
- 
- 
Field Detail- 
defaultIndexPIjava.lang.String defaultIndexPI 
 - 
defaultIndexSIjava.lang.String defaultIndexSI 
 - 
indexPIjava.lang.String indexPI 
 - 
indexSIjava.lang.String indexSI 
 - 
cvFirstboolean cvFirst 
 - 
skipDupIndexWriteboolean skipDupIndexWrite 
 - 
maxDelaylong maxDelay 
 - 
_valint _val 
 - 
_cvjava.lang.String _cv 
 - 
valuePIint valuePI 
 - 
valueSIint valueSI 
 - 
_startValint _startVal 
 - 
lastValuePIint lastValuePI 
 - 
lastValueSIint lastValueSI 
 - 
lastOpTimelong lastOpTime 
 
- 
 - 
Constructor Detail- 
MultiIndexProgrammerFacadepublic MultiIndexProgrammerFacade(Programmer prog, java.lang.String indexPI, java.lang.String indexSI, boolean cvFirst, boolean skipDupIndexWrite) - Parameters:
- prog- the programmer to which this facade is attached
- indexPI- CV to which the first value is to be written for NN.NN and NN.NN.NN forms
- indexSI- CV to which the second value is to be written for NN.NN.NN forms
- cvFirst- true if first value in parsed CV is to be written; false if second value is to be written
- skipDupIndexWrite- true if heuristics can be used to skip PI and SI writes; false requires them to be written each time.
 
 
- 
 - 
Method Detail- 
parseCVvoid parseCV(java.lang.String cv) 
 - 
hasAlternateAddressboolean hasAlternateAddress(java.lang.String cv) 
 - 
getAlternateAddressjava.lang.String getAlternateAddress(java.lang.String cv) 
 - 
getAlternateValueint getAlternateValue(java.lang.String cv) 
 - 
useCachePiSiboolean useCachePiSi() Check if the last-written PI and SI values can still be counted on.- Returns:
- true if last-written values are reliable; false otherwise
 
 - 
writeCVpublic void writeCV(java.lang.String CV, int val, ProgListener p) throws ProgrammerException Description copied from class:AbstractProgrammerFacadePerform a CV write in the system-specific manner, and using the specified programming mode.Handles a general address space through a String address. Each programmer defines the acceptable formats. Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. For simplicity, expect the return to be on the GUI thread. Exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier) - Specified by:
- writeCVin interface- Programmer
- Overrides:
- writeCVin class- AbstractProgrammerFacade
- Parameters:
- CV- the CV to write
- val- the value to write
- p- the listener that will be notified of the write
- Throws:
- ProgrammerException- if unable to communicate
 
 - 
readCVpublic void readCV(java.lang.String CV, ProgListener p) throws ProgrammerException Description copied from class:AbstractProgrammerFacadePerform a CV read in the system-specific manner, and using the specified programming mode.Handles a general address space through a String address. Each programmer defines the acceptable formats. Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. For simplicity, expect the return to be on the GUI thread. Exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier) - Specified by:
- readCVin interface- Programmer
- Overrides:
- readCVin class- AbstractProgrammerFacade
- Parameters:
- CV- the CV to read
- p- the listener that will be notified of the read
- Throws:
- ProgrammerException- if unable to communicate
 
 - 
readCVpublic void readCV(java.lang.String CV, ProgListener p, int startVal) throws ProgrammerException Description copied from interface:ProgrammerPerform a CV read in the system-specific manner, and using the specified programming mode, possibly using a hint of the current value to speed up programming.Handles a general address space through a String address. Each programmer defines the acceptable formats. On systems that support it, the startVal is a hint as to what the current value of the CV might be (e.g. the value from the roster). This could be verified immediately in direct byte mode to speed up the read process. Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. For simplicity, expect the return to be on the GUI thread. Defaults to the normal read method if not overridden in a specific implementation. Exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier) - Specified by:
- readCVin interface- Programmer
- Parameters:
- CV- the CV to read
- p- the listener that will be notified of the read
- startVal- a hint of what the current value might be, or 0
- Throws:
- ProgrammerException- if unable to communicate
 
 - 
confirmCVpublic void confirmCV(java.lang.String CV, int val, ProgListener p) throws ProgrammerException Description copied from class:AbstractProgrammerFacadeConfirm the value of a CV using the specified programming mode. On some systems, this is faster than a read.Handles a general address space through a String address. Each programmer defines the acceptable formats. Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. For simplicity, expect the return to be on the GUI thread. Exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier) - Specified by:
- confirmCVin interface- Programmer
- Overrides:
- confirmCVin class- AbstractProgrammerFacade
- Parameters:
- CV- the CV to confirm
- val- the value to confirm
- p- the listener that will be notified of the confirmation
- Throws:
- ProgrammerException- if unable to communicate
 
 - 
useProgrammerprotected void useProgrammer(ProgListener p) throws ProgrammerException - Throws:
- ProgrammerException
 
 - 
programmingOpReplypublic void programmingOpReply(int value, int status) Description copied from interface:ProgListenerReceive a callback at the end of a programming operation.- Specified by:
- programmingOpReplyin interface- ProgListener
- Parameters:
- value- Value from a read operation, or value written on a write
- status- Denotes the completion code. Note that this is a bitwise combination of the various status coded defined in this interface.
 
 
- 
 
-