Class CvValue

  • All Implemented Interfaces:
    java.util.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.

    • Constructor Detail

      • CvValue

        public CvValue​(java.lang.String num,
                       java.lang.String cvName,
                       Programmer pProgrammer)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • number

        public java.lang.String number()
      • cvName

        public java.lang.String cvName()
      • 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
      • 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​(java.awt.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
      • 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:
        AbstractValue
      • 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:
        AbstractValue
      • read

        public void read​(javax.swing.JLabel status)
      • confirm

        public void confirm​(javax.swing.JLabel status)
      • write

        public void write​(javax.swing.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.