Package jmri.jmrix.loconet.locoio
Class LocoIOData
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.jmrix.loconet.locoio.LocoIOData
- All Implemented Interfaces:
PropertyChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,LocoNetListener
public class LocoIOData
extends PropertyChangeSupport
implements LocoNetListener, PropertyChangeListener
Data associated with a LocoIO device.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intCode for read activity needed.protected final intprotected final intprotected final intprotected final intprotected final intprotected final intprotected final intprotected Timerprotected final intprotected final intprotected final intCode for write activity needed.protected final intprotected final intprotected final intprotected final intFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionLocoIOData(int unitAddr, int unitSubAddr, LnTrafficController tc) Create a new instance of LocoIOData. -
Method Summary
Modifier and TypeMethodDescriptionvoidcaptureValues(int channel) voiddispose()intgetAddr(int channel) getLIM(int channel) getMode(int channel) intgetSV(int channel) intintintintgetV1(int channel) intgetV2(int channel) protected inthighPart(int value) protected voidLook through the table to find the next thing that needs to be read.protected intlowPart(int value) voidListen to the LocoNet.voidvoidreadAll()Start reading all rows back.voidreadValues(int channel) protected voidA 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(String version) voidsetLIM(int channel) voidvoidsetLIM(int channel, LocoIOMode m) voidsetLIOVersion(String version) voidvoidvoidsetSV(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 voidInternal routine to start timer to protect the mode-change.protected voidInternal 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 Details
-
NONE
Code for read activity needed. See states NONE, READMODE, READINGMODE, READVALUE1, READINGVALUE1, READVALUE2, READINGVALUE2- See Also:
-
READVALUE1
- See Also:
-
READINGVALUE1
- See Also:
-
READVALUE2
- See Also:
-
READINGVALUE2
- See Also:
-
READMODE
- See Also:
-
READINGMODE
- See Also:
-
READ
- See Also:
-
WRITEVALUE1
Code for write activity needed. See states NONE, WRITEMODE, WRITINGMODE, WRITEVALUE1, WRITINGVALUE1, WRITEVALUE2, WRITINGVALUE2- See Also:
-
WRITINGVALUE1
- See Also:
-
WRITEVALUE2
- See Also:
-
WRITINGVALUE2
- See Also:
-
WRITEMODE
- See Also:
-
WRITINGMODE
- See Also:
-
WRITE
- See Also:
-
timer
-
-
Constructor Details
-
LocoIOData
Create a new instance of LocoIOData.- Parameters:
unitAddr- unit address.unitSubAddr- unit SubAddress.tc- system connection traffic controller.
-
-
Method Details
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
setUnitAddress
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
-
setUnitSubAddress
-
getUnitAddress
-
getUnitSubAddress
-
setUnitConfig
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
-
setLBVersion
-
getLBVersion
-
setLIOVersion
-
getLIOVersion
-
setStatus
-
getStatus
-
setSV
-
getSV
-
setV1
-
setV1
-
getV1
-
setV2
-
setV2
-
getV2
-
setAddr
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
-
setMode
-
getMode
-
setLIM
-
setLIM
-
setLIM
-
getLIM
-
readValues
-
captureValues
-
writeValues
-
readAll
Start reading all rows back. -
writeAll
Start writing all rows out. -
getLocoIOModeList
-
highPart
-
lowPart
-
message
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
A valid reply has been received, so the read/write worked, and the state should be advanced. -
issueNextOperation
Look through the table to find the next thing that needs to be read. -
timeout
Internal routine to handle a timeout during read/write by retrying the same operation. -
startTimer
Internal routine to start timer to protect the mode-change. -
stopTimer
Internal routine to stop timer, as all is well. -
restartTimer
Internal routine to handle timer starts and restarts.- Parameters:
delay- Milliseconds to wait
-
sendReadCommand
Read an SV from a given LocoIO device.- Parameters:
locoIOAddress- primary board addresslocoIOSubAddress- subaddress within boardcv- CV number to access
-
sendWriteCommand
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
-