Package jmri.jmrit.symbolicprog
Class CvValue
- java.lang.Object
-
- jmri.jmrit.symbolicprog.AbstractValue
-
- jmri.jmrit.symbolicprog.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrit.symbolicprog.AbstractValue
AbstractValue.ValueState
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.awt.Color_defaultColor(package private) javax.swing.JTextField_tableEntry-
Fields inherited from class jmri.jmrit.symbolicprog.AbstractValue
prop
-
Fields inherited from interface jmri.ProgListener
CommError, ConfirmFailed, FailedTimeout, NoAck, NoLocoDetected, NotImplemented, OK, ProgrammerBusy, ProgrammingShort, SequenceError, UnknownError, UserAborted
-
-
Constructor Summary
Constructors Constructor Description CvValue(java.lang.String num, java.lang.String cvName, Programmer pProgrammer)CvValue(java.lang.String num, Programmer pProgrammer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfirm(javax.swing.JLabel status)java.lang.StringcvName()voiddispose()(package private) voiderrorTimeout()(package private) java.awt.ColorgetColor()intgetDecoderValue()Get the decoder value read during compare.(package private) java.awt.ColorgetDefaultColor()booleangetInfoOnly()Retrieve bean keeping track of whether this CV is intended to be used as info-only.booleangetReadOnly()Retrieve bean keeping track of whether this CV is intended to be read-only.AbstractValue.ValueStategetState()(package private) javax.swing.JTextFieldgetTableEntry()intgetValue()booleangetWriteOnly()Retrieve bean keeping track of whether this CV is intended to be used as write-only.booleanisBusy()booleanisToRead()Ask whether this object needs to be read.booleanisToWrite()Ask whether this object needs to be written.protected voidnotifyValueChange(int value)java.lang.Stringnumber()voidprogrammingOpReply(int value, int retval)Receive a callback at the end of a programming operation.voidread(javax.swing.JLabel status)voidread(javax.swing.JLabel status, long number, long total, long cvReadStartTime)(package private) voidsetColor(java.awt.Color c)Method to handle color changes for states.voidsetInfoOnly(boolean is)Set bean keeping track of whether this CV is intended to be used as info-only.(package private) voidsetProgrammer(Programmer p)voidsetReadOnly(boolean is)Set bean keeping track of whether this CV is intended to be read-only.voidsetState(AbstractValue.ValueState state)Set state value and send notification.Also sets GUI color as needed.voidsetToRead(boolean state)Mark whether this object needs to be read.voidsetToWrite(boolean state)Mark whether this object needs to be written.voidsetValue(int value)Edit a new value into the CV.voidsetWriteOnly(boolean is)Set bean keeping track of whether this CV is intended to be used as write-only.java.lang.StringtoString()voidwrite(javax.swing.JLabel status)-
Methods inherited from class jmri.jmrit.symbolicprog.AbstractValue
addPropertyChangeListener, getAvailable, removePropertyChangeListener, setAvailable
-
-
-
-
Field Detail
-
_defaultColor
java.awt.Color _defaultColor
-
_tableEntry
javax.swing.JTextField _tableEntry
-
-
Constructor Detail
-
CvValue
public CvValue(java.lang.String num, Programmer pProgrammer)
-
CvValue
public CvValue(java.lang.String num, java.lang.String cvName, Programmer pProgrammer)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setProgrammer
void setProgrammer(Programmer p)
-
number
public java.lang.String number()
-
cvName
public java.lang.String cvName()
-
getValue
public int getValue()
-
getDefaultColor
java.awt.Color getDefaultColor()
-
getColor
java.awt.Color getColor()
-
notifyValueChange
protected void notifyValueChange(int value)
-
setValue
public void setValue(int value)
Edit a new value into the CV. Fires listenersOnly 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
public AbstractValue.ValueState 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(java.awt.Color c)
Description copied from class:AbstractValueMethod to handle color changes for states.- Specified by:
setColorin classAbstractValue- Parameters:
c- the desired colour
-
getTableEntry
javax.swing.JTextField 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:AbstractValueMark whether this object needs to be read.- Overrides:
setToReadin classAbstractValue- Parameters:
state- true if the object needs to be read, false otherwise- See Also:
AbstractValue
-
isToRead
public boolean isToRead()
Description copied from class:AbstractValueAsk whether this object needs to be read.- Overrides:
isToReadin classAbstractValue- Returns:
- true if the object needs to be read, false otherwise
- See Also:
AbstractValue
-
setToWrite
public void setToWrite(boolean state)
Description copied from class:AbstractValueMark whether this object needs to be written.- Overrides:
setToWritein classAbstractValue- Parameters:
state- true if the object needs to be written, false otherwise- See Also:
AbstractValue
-
isToWrite
public boolean isToWrite()
Description copied from class:AbstractValueAsk whether this object needs to be written.- Overrides:
isToWritein classAbstractValue- Returns:
- true if the object needs to be written, false otherwise
- See Also:
AbstractValue
-
read
public void read(javax.swing.JLabel status)
-
read
public void read(javax.swing.JLabel status, long number, long total, long cvReadStartTime)
-
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:ProgListenerReceive a callback at the end of a programming operation.- Specified by:
programmingOpReplyin interfaceProgListener- Parameters:
value- Value from a read operation, or value written on a writeretval- 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()
-
-