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 void
confirm(javax.swing.JLabel status)
java.lang.String
cvName()
void
dispose()
(package private) void
errorTimeout()
(package private) java.awt.Color
getColor()
int
getDecoderValue()
Get the decoder value read during compare.(package private) java.awt.Color
getDefaultColor()
boolean
getInfoOnly()
Retrieve bean keeping track of whether this CV is intended to be used as info-only.boolean
getReadOnly()
Retrieve bean keeping track of whether this CV is intended to be read-only.AbstractValue.ValueState
getState()
(package private) javax.swing.JTextField
getTableEntry()
int
getValue()
boolean
getWriteOnly()
Retrieve bean keeping track of whether this CV is intended to be used as write-only.boolean
isBusy()
boolean
isToRead()
Ask whether this object needs to be read.boolean
isToWrite()
Ask whether this object needs to be written.protected void
notifyValueChange(int value)
java.lang.String
number()
void
programmingOpReply(int value, int retval)
Receive a callback at the end of a programming operation.void
read(javax.swing.JLabel status)
void
read(javax.swing.JLabel status, long number, long total, long cvReadStartTime)
(package private) void
setColor(java.awt.Color c)
Method to handle color changes for states.void
setInfoOnly(boolean is)
Set bean keeping track of whether this CV is intended to be used as info-only.(package private) void
setProgrammer(Programmer p)
void
setReadOnly(boolean is)
Set bean keeping track of whether this CV is intended to be read-only.void
setState(AbstractValue.ValueState state)
Set state value and send notification.Also sets GUI color as needed.void
setToRead(boolean state)
Mark whether this object needs to be read.void
setToWrite(boolean state)
Mark whether this object needs to be written.void
setValue(int value)
Edit a new value into the CV.void
setWriteOnly(boolean is)
Set bean keeping track of whether this CV is intended to be used as write-only.java.lang.String
toString()
void
write(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:
toString
in 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:AbstractValue
Method to handle color changes for states.- Specified by:
setColor
in 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:AbstractValue
Mark whether this object needs to be read.- Overrides:
setToRead
in classAbstractValue
- Parameters:
state
- true if the object needs to be read, false otherwise- See Also:
AbstractValue
-
isToRead
public boolean isToRead()
Description copied from class:AbstractValue
Ask whether this object needs to be read.- Overrides:
isToRead
in 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:AbstractValue
Mark whether this object needs to be written.- Overrides:
setToWrite
in classAbstractValue
- Parameters:
state
- true if the object needs to be written, false otherwise- See Also:
AbstractValue
-
isToWrite
public boolean isToWrite()
Description copied from class:AbstractValue
Ask whether this object needs to be written.- Overrides:
isToWrite
in 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:ProgListener
Receive a callback at the end of a programming operation.- Specified by:
programmingOpReply
in 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()
-
-