Package jmri.jmrix.loconet.locoio
Class LocoIOData
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrix.loconet.locoio.LocoIOData
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
,LocoNetListener
public class LocoIOData extends PropertyChangeSupport implements LocoNetListener, java.beans.PropertyChangeListener
Data associated with a LocoIO device.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
NONE
Code for read activity needed.protected int
READ
protected int
READINGMODE
protected int
READINGVALUE1
protected int
READINGVALUE2
protected int
READMODE
protected int
READVALUE1
protected int
READVALUE2
protected javax.swing.Timer
timer
protected int
WRITE
protected int
WRITEMODE
protected int
WRITEVALUE1
Code for write activity needed.protected int
WRITEVALUE2
protected int
WRITINGMODE
protected int
WRITINGVALUE1
protected int
WRITINGVALUE2
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description LocoIOData(int unitAddr, int unitSubAddr, LnTrafficController tc)
Create a new instance of LocoIOData.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
captureValues(int channel)
void
dispose()
int
getAddr(int channel)
java.lang.String
getLBVersion()
LocoIOMode
getLIM(int channel)
java.lang.String
getLIOVersion()
LocoIOModeList
getLocoIOModeList()
java.lang.String
getMode(int channel)
java.lang.String
getStatus()
int
getSV(int channel)
int
getUnitAddress()
int
getUnitConfig()
int
getUnitSubAddress()
int
getV1(int channel)
int
getV2(int channel)
protected int
highPart(int value)
protected void
issueNextOperation()
Look through the table to find the next thing that needs to be read.protected int
lowPart(int value)
void
message(LocoNetMessage m)
Listen to the LocoNet.void
propertyChange(java.beans.PropertyChangeEvent evt)
void
readAll()
Start reading all rows back.void
readValues(int channel)
protected void
replyReceived()
A valid reply has been received, so the read/write worked, and the state should be advanced.protected void
restartTimer(int delay)
Internal routine to handle timer starts and restarts.(package private) void
sendReadCommand(int locoIOAddress, int locoIOSubAddress, int cv)
Read an SV from a given LocoIO device.(package private) void
sendWriteCommand(int locoIOAddress, int locoIOSubAddress, int cv, int data)
Write an SV to a given LocoIO device.void
setAddr(int channel, int value)
Set new value in addr field (for the address info used in each LocoIO channel).void
setLBVersion(java.lang.String version)
void
setLIM(int channel)
void
setLIM(int channel, java.lang.String s)
void
setLIM(int channel, LocoIOMode m)
void
setLIOVersion(java.lang.String version)
void
setMode(int channel, java.lang.String m)
void
setStatus(java.lang.String msg)
void
setSV(int channel, int value)
void
setUnitAddress(int unit)
void
setUnitAddress(int unit, int unitSub)
Address and SubAddress of this device.void
setUnitConfig(int portRefresh, int altCodePBs, int isServo, int blinkRate)
No LocoIO Board level configuration.void
setUnitSubAddress(int unitSub)
void
setV1(int channel, int value)
void
setV1(int channel, LocoIOMode l, int address)
void
setV2(int channel, int value)
void
setV2(int channel, LocoIOMode l, int address)
protected void
startTimer()
Internal routine to start timer to protect the mode-change.protected void
stopTimer()
Internal routine to stop timer, as all is well.protected void
timeout()
Internal routine to handle a timeout during read/write by retrying the same operation.void
writeAll()
Start writing all rows out.void
writeValues(int channel)
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
NONE
protected final int NONE
Code for read activity needed. See states NONE, READMODE, READINGMODE, READVALUE1, READINGVALUE1, READVALUE2, READINGVALUE2- See Also:
- Constant Field Values
-
READVALUE1
protected final int READVALUE1
- See Also:
- Constant Field Values
-
READINGVALUE1
protected final int READINGVALUE1
- See Also:
- Constant Field Values
-
READVALUE2
protected final int READVALUE2
- See Also:
- Constant Field Values
-
READINGVALUE2
protected final int READINGVALUE2
- See Also:
- Constant Field Values
-
READMODE
protected final int READMODE
- See Also:
- Constant Field Values
-
READINGMODE
protected final int READINGMODE
- See Also:
- Constant Field Values
-
READ
protected final int READ
- See Also:
- Constant Field Values
-
WRITEVALUE1
protected final int WRITEVALUE1
Code for write activity needed. See states NONE, WRITEMODE, WRITINGMODE, WRITEVALUE1, WRITINGVALUE1, WRITEVALUE2, WRITINGVALUE2- See Also:
- Constant Field Values
-
WRITINGVALUE1
protected final int WRITINGVALUE1
- See Also:
- Constant Field Values
-
WRITEVALUE2
protected final int WRITEVALUE2
- See Also:
- Constant Field Values
-
WRITINGVALUE2
protected final int WRITINGVALUE2
- See Also:
- Constant Field Values
-
WRITEMODE
protected final int WRITEMODE
- See Also:
- Constant Field Values
-
WRITINGMODE
protected final int WRITINGMODE
- See Also:
- Constant Field Values
-
WRITE
protected final int WRITE
- See Also:
- Constant Field Values
-
timer
protected javax.swing.Timer timer
-
-
Constructor Detail
-
LocoIOData
public LocoIOData(int unitAddr, int unitSubAddr, LnTrafficController tc)
Create a new instance of LocoIOData.- Parameters:
unitAddr
- unit address.unitSubAddr
- unit SubAddress.tc
- system connection traffic controller.
-
-
Method Detail
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
setUnitAddress
public void setUnitAddress(int unit, int unitSub)
Address and SubAddress of this device.High byte of the Address is fixed to 0x01
Low byte Address must be in the range of 0x01 .. 0x4F, 0x51 .. 0x7F
(0x50 is reserved for the LocoBuffer)
The subAddress is in the range of 0x01 .. 0x7E
(0x7F is reserved)- Parameters:
unit
- unit address.unitSub
- unit subAddress.
-
setUnitAddress
public void setUnitAddress(int unit)
-
setUnitSubAddress
public void setUnitSubAddress(int unitSub)
-
getUnitAddress
public int getUnitAddress()
-
getUnitSubAddress
public int getUnitSubAddress()
-
setUnitConfig
public void setUnitConfig(int portRefresh, int altCodePBs, int isServo, int blinkRate)
No LocoIO Board level configuration.Bit 0: 0 = default, 1 = Port Refresh Bit 1: 0 = Fixed code PBs, 1 = Alternated code PBs Bit 2: 0 = default - Not used Bit 3: 0 = default, 1 = Ports 5-12 are Servo Ports Bit 4-7: Blink Rate Add/support the additional config options for HDL boards - Work has moved to xml decoder definition Public_Domain_HDL_LocoIO, is included there since 4.21.2
- Parameters:
portRefresh
- port refresh value, bit 0.altCodePBs
- alternated code PBs, bit 1.isServo
- servo port, bit 3.blinkRate
- blink rate, bits 4-7.
-
getUnitConfig
public int getUnitConfig()
-
setLBVersion
public void setLBVersion(java.lang.String version)
-
getLBVersion
public java.lang.String getLBVersion()
-
setLIOVersion
public void setLIOVersion(java.lang.String version)
-
getLIOVersion
public java.lang.String getLIOVersion()
-
setStatus
public void setStatus(java.lang.String msg)
-
getStatus
public java.lang.String getStatus()
-
setSV
public void setSV(int channel, int value)
-
getSV
public int getSV(int channel)
-
setV1
public void setV1(int channel, LocoIOMode l, int address)
-
setV1
public void setV1(int channel, int value)
-
getV1
public int getV1(int channel)
-
setV2
public void setV2(int channel, LocoIOMode l, int address)
-
setV2
public void setV2(int channel, int value)
-
getV2
public int getV2(int channel)
-
setAddr
public void setAddr(int channel, int value)
Set new value in addr field (for the address info used in each LocoIO channel).- Parameters:
channel
- integer value of the addresses in use for this row (0 = invalid)value
- channel value.
-
getAddr
public int getAddr(int channel)
-
setMode
public void setMode(int channel, java.lang.String m)
-
getMode
public java.lang.String getMode(int channel)
-
setLIM
public void setLIM(int channel, java.lang.String s)
-
setLIM
public void setLIM(int channel)
-
setLIM
public void setLIM(int channel, LocoIOMode m)
-
getLIM
public LocoIOMode getLIM(int channel)
-
readValues
public void readValues(int channel)
-
captureValues
public void captureValues(int channel)
-
writeValues
public void writeValues(int channel)
-
readAll
public void readAll()
Start reading all rows back.
-
writeAll
public void writeAll()
Start writing all rows out.
-
getLocoIOModeList
public LocoIOModeList getLocoIOModeList()
-
highPart
protected int highPart(int value)
-
lowPart
protected int lowPart(int value)
-
message
public void message(LocoNetMessage m)
Listen to the LocoNet. We're listening for incoming OPC_PEER_XFR messages, which might be part of a read or write sequence. We're also _sometimes_ listening for commands as part of a "capture" operation.The incoming LocoNet OPC_PEER_XFR messages don't retain any information about the CV number or whether it was a read or write operation. We store the data regardless of whether it was read or write, but we need to remember the cv number in the lastOpCv member.
- Specified by:
message
in interfaceLocoNetListener
- Parameters:
m
- Incoming message
-
replyReceived
protected void replyReceived()
A valid reply has been received, so the read/write worked, and the state should be advanced.
-
issueNextOperation
protected void issueNextOperation()
Look through the table to find the next thing that needs to be read.
-
timeout
protected void timeout()
Internal routine to handle a timeout during read/write by retrying the same operation.
-
startTimer
protected void startTimer()
Internal routine to start timer to protect the mode-change.
-
stopTimer
protected void stopTimer()
Internal routine to stop timer, as all is well.
-
restartTimer
protected void restartTimer(int delay)
Internal routine to handle timer starts and restarts.- Parameters:
delay
- Milliseconds to wait
-
sendReadCommand
void sendReadCommand(int locoIOAddress, int locoIOSubAddress, int cv)
Read an SV from a given LocoIO device.- Parameters:
locoIOAddress
- primary board addresslocoIOSubAddress
- subaddress within boardcv
- CV number to access
-
sendWriteCommand
void sendWriteCommand(int locoIOAddress, int locoIOSubAddress, int cv, int data)
Write an SV to a given LocoIO device.- Parameters:
locoIOAddress
- primary board addresslocoIOSubAddress
- subaddress within boardcv
- CV number to accessdata
- value to be written
-
dispose
public void dispose()
-
-