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 intNONECode for read activity needed.protected intREADprotected intREADINGMODEprotected intREADINGVALUE1protected intREADINGVALUE2protected intREADMODEprotected intREADVALUE1protected intREADVALUE2protected javax.swing.Timertimerprotected intWRITEprotected intWRITEMODEprotected intWRITEVALUE1Code for write activity needed.protected intWRITEVALUE2protected intWRITINGMODEprotected intWRITINGVALUE1protected intWRITINGVALUE2-
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 voidcaptureValues(int channel)voiddispose()intgetAddr(int channel)java.lang.StringgetLBVersion()LocoIOModegetLIM(int channel)java.lang.StringgetLIOVersion()LocoIOModeListgetLocoIOModeList()java.lang.StringgetMode(int channel)java.lang.StringgetStatus()intgetSV(int channel)intgetUnitAddress()intgetUnitConfig()intgetUnitSubAddress()intgetV1(int channel)intgetV2(int channel)protected inthighPart(int value)protected voidissueNextOperation()Look through the table to find the next thing that needs to be read.protected intlowPart(int value)voidmessage(LocoNetMessage m)Listen to the LocoNet.voidpropertyChange(java.beans.PropertyChangeEvent evt)voidreadAll()Start reading all rows back.voidreadValues(int channel)protected voidreplyReceived()A valid reply has been received, so the read/write worked, and the state should be advanced.protected voidrestartTimer(int delay)Internal routine to handle timer starts and restarts.(package private) voidsendReadCommand(int locoIOAddress, int locoIOSubAddress, int cv)Read an SV from a given LocoIO device.(package private) voidsendWriteCommand(int locoIOAddress, int locoIOSubAddress, int cv, int data)Write an SV to a given LocoIO device.voidsetAddr(int channel, int value)Set new value in addr field (for the address info used in each LocoIO channel).voidsetLBVersion(java.lang.String version)voidsetLIM(int channel)voidsetLIM(int channel, java.lang.String s)voidsetLIM(int channel, LocoIOMode m)voidsetLIOVersion(java.lang.String version)voidsetMode(int channel, java.lang.String m)voidsetStatus(java.lang.String msg)voidsetSV(int channel, int value)voidsetUnitAddress(int unit)voidsetUnitAddress(int unit, int unitSub)Address and SubAddress of this device.voidsetUnitConfig(int portRefresh, int altCodePBs, int isServo, int blinkRate)No LocoIO Board level configuration.voidsetUnitSubAddress(int unitSub)voidsetV1(int channel, int value)voidsetV1(int channel, LocoIOMode l, int address)voidsetV2(int channel, int value)voidsetV2(int channel, LocoIOMode l, int address)protected voidstartTimer()Internal routine to start timer to protect the mode-change.protected voidstopTimer()Internal routine to stop timer, as all is well.protected voidtimeout()Internal routine to handle a timeout during read/write by retrying the same operation.voidwriteAll()Start writing all rows out.voidwriteValues(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:
propertyChangein 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:
messagein 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()
-
-