Class ResettingOffsetHighCvProgrammerFacade

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

Programmer facade, at this point just an example.

This is for decoders that have an alternate high-CV access method for command stations that can't address all 1024. It falls back to that mode if the CS can't directly address an requested CV address. In the fall back, CVs from 0 to "top" are addressed directly. Above the top CV, the upper part of the address is written to a specific CV, followed by an operation to just the lower part of the address. The upper and lower parts are calculated using a supplied modulus, e.g. 100, and an indicator value that's added in. Finally, the specific CV is reset to zero to end the offset operation.

For example, to write the value N to CV xyy, this will do (modulo = 100, indicator = 200):

  • Write 200+x*10 to CV7 where 10 is cvFactor, 200 is indicator and 7 is addrCV
  • Write N to CVyy
  • Write 0 to CV7

This method is used by some Zimo decoders

See Also:
  • Field Details

  • Constructor Details

    • ResettingOffsetHighCvProgrammerFacade

      public ResettingOffsetHighCvProgrammerFacade(Programmer prog, String top, String addrCV, String cvFactor, String modulo, String indicator)
      Parameters:
      prog - the programmer this facade is attached to
      top - CVs above this use the indirect method
      addrCV - CV to which the high part of address is to be written
      cvFactor - CV to which the low part of address is to be written
      modulo - modulus for determining high/low address parts
      indicator - value added to calculation to split high and low parts
  • Method Details

    • writeCV

      public void writeCV(String CV, int val, ProgListener p) throws ProgrammerException
      Description copied from class: AbstractProgrammerFacade
      Perform 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:
      writeCV in interface Programmer
      Overrides:
      writeCV in 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
    • readCV

      public void readCV(String CV, ProgListener p) throws ProgrammerException
      Description copied from class: AbstractProgrammerFacade
      Perform 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:
      readCV in interface Programmer
      Overrides:
      readCV in class AbstractProgrammerFacade
      Parameters:
      CV - the CV to read
      p - the listener that will be notified of the read
      Throws:
      ProgrammerException - if unable to communicate
    • readCV

      public void readCV(String CV, ProgListener p, int startVal) throws ProgrammerException
      Description copied from interface: Programmer
      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.

      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:
      readCV in 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
    • useProgrammer

      protected void useProgrammer(ProgListener p) throws ProgrammerException
      Throws:
      ProgrammerException
    • programmingOpReply

      public void programmingOpReply(int value, int status)
      Description copied from interface: ProgListener
      Receive a callback at the end of a programming operation.
      Specified by:
      programmingOpReply in 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.
    • getCanRead

      public boolean getCanRead()
      Description copied from class: AbstractProgrammerFacade
      Checks the general read capability, regardless of mode
      Specified by:
      getCanRead in interface Programmer
      Overrides:
      getCanRead in class AbstractProgrammerFacade
      Returns:
      true if the programmer is capable of reading; false otherwise
    • getCanRead

      public boolean getCanRead(String addr)
      Description copied from class: AbstractProgrammerFacade
      Checks the general read capability, regardless of mode, for a specific address
      Specified by:
      getCanRead in interface Programmer
      Overrides:
      getCanRead in class AbstractProgrammerFacade
      Parameters:
      addr - the address to read
      Returns:
      true if the address can be read; false otherwise
    • getCanWrite

      public boolean getCanWrite()
      Description copied from class: AbstractProgrammerFacade
      Checks the general write capability, regardless of mode
      Specified by:
      getCanWrite in interface Programmer
      Overrides:
      getCanWrite in class AbstractProgrammerFacade
      Returns:
      true if the programmer is capable of writing; false otherwise
    • getCanWrite

      public boolean getCanWrite(String addr)
      Description copied from class: AbstractProgrammerFacade
      Checks the general write capability, regardless of mode, for a specific address
      Specified by:
      getCanWrite in interface Programmer
      Overrides:
      getCanWrite in class AbstractProgrammerFacade
      Parameters:
      addr - the address to write to
      Returns:
      true if the address can be written to; false otherwise