Class CvValue

All Implemented Interfaces:
EventListener, ProgListener

public class CvValue extends AbstractValue implements ProgListener
Encapsulate a single CV value and provide programming access to the decoder.

Since this is a single CV in a single decoder, the Programmer used to get access is part of the state. This allows us to specify a specific ops-mode programmer aimed at a particular decoder.

There are three relevant parameters: Busy, Value, State. Busy == true means that a read or write operation is going on. When it transitions to "false", the operation is complete, and the Value and State are stable. During a read operation, Value changes before State, so you can assume that Value is stable if notified of a State change.

  • Field Details

  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setProgrammer

    • number

      public String number()
    • cvName

      public String cvName()
    • getValue

      public int getValue()
    • getDefaultColor

    • getColor

    • notifyValueChange

      protected void notifyValueChange(int value)
    • setValue

      public void setValue(int value)
      Edit a new value into the CV. Fires listeners

      Only use this for external edits, e.g. set from a GUI. Not for internal uses, as it sets the state to EDITED.

      Parameters:
      value - new CV value.
    • getDecoderValue

      public int getDecoderValue()
      Get the decoder value read during compare.
      Returns:
      _decoderValue
    • getState

    • setState

      public void setState(AbstractValue.ValueState state)
      Set state value and send notification.Also sets GUI color as needed.
      Parameters:
      state - new state, e.g READ, UNKNOWN, SAME.
    • isBusy

      public boolean isBusy()
    • setColor

      void setColor(Color c)
      Description copied from class: AbstractValue
      Method to handle color changes for states.
      Specified by:
      setColor in class AbstractValue
      Parameters:
      c - the desired colour
    • getTableEntry

    • setReadOnly

      public void setReadOnly(boolean is)
      Set bean keeping track of whether this CV is intended to be read-only. Does not otherwise affect behaviour! Default is "false".
      Parameters:
      is - read-only flag, true or false.
    • getReadOnly

      public boolean getReadOnly()
      Retrieve bean keeping track of whether this CV is intended to be read-only. Does not otherwise affect behaviour! Default is "false".
      Returns:
      read-only flag.
    • setInfoOnly

      public void setInfoOnly(boolean is)
      Set bean keeping track of whether this CV is intended to be used as info-only. Does not otherwise affect behaviour! Default is "false".
      Parameters:
      is - info-only flag, true or false.
    • getInfoOnly

      public boolean getInfoOnly()
      Retrieve bean keeping track of whether this CV is intended to be used as info-only. Does not otherwise affect behaviour! Default is "false".
      Returns:
      write-only flag.
    • setWriteOnly

      public void setWriteOnly(boolean is)
      Set bean keeping track of whether this CV is intended to be used as write-only. Does not otherwise affect behaviour! Default is "false".
      Parameters:
      is - write-only flag, true or false.
    • getWriteOnly

      public boolean getWriteOnly()
      Retrieve bean keeping track of whether this CV is intended to be used as write-only.

      Does not otherwise affect behaviour! Default is "false".

      Returns:
      write-only flag.
    • setToRead

      public void setToRead(boolean state)
      Description copied from class: AbstractValue
      Mark whether this object needs to be read.
      Overrides:
      setToRead in class AbstractValue
      Parameters:
      state - true if the object needs to be read, false otherwise
      See Also:
    • isToRead

      public boolean isToRead()
      Description copied from class: AbstractValue
      Ask whether this object needs to be read.
      Overrides:
      isToRead in class AbstractValue
      Returns:
      true if the object needs to be read, false otherwise
      See Also:
    • setToWrite

      public void setToWrite(boolean state)
      Description copied from class: AbstractValue
      Mark whether this object needs to be written.
      Overrides:
      setToWrite in class AbstractValue
      Parameters:
      state - true if the object needs to be written, false otherwise
      See Also:
    • isToWrite

      public boolean isToWrite()
      Description copied from class: AbstractValue
      Ask whether this object needs to be written.
      Overrides:
      isToWrite in class AbstractValue
      Returns:
      true if the object needs to be written, false otherwise
      See Also:
    • read

      public void read(JLabel status)
    • read

      public void read(JLabel status, long number, long total, long cvReadStartTime)
    • confirm

      public void confirm(JLabel status)
    • write

      public void write(JLabel status)
    • programmingOpReply

      public void programmingOpReply(int value, int retval)
      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
      retval - Denotes the completion code. Note that this is a bitwise combination of the various status coded defined in this interface.
    • errorTimeout

      void errorTimeout()
    • dispose

      public void dispose()