jmri.jmrix.loconet.locoio
Class LocoIOData

Show UML class diagram
java.lang.Object
  extended by jmri.jmrix.loconet.locoio.LocoIOData
All Implemented Interfaces:
PropertyChangeListener, EventListener, LocoNetListener

public class LocoIOData
extends Object
implements LocoNetListener, PropertyChangeListener


Field Summary
(package private) static org.slf4j.Logger log
           
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  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
           
 
Constructor Summary
LocoIOData(int unitAddr, int unitSubAddr, LnTrafficController tc)
          Creates a new instance of LocoIOData
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener pcl)
           
 void captureValues(int channel)
           
 void dispose()
           
 int getAddr(int channel)
           
 String getLBVersion()
           
 LocoIOMode getLIM(int channel)
           
 String getLIOVersion()
           
 LocoIOModeList getLocoIOModeList()
           
 String getMode(int channel)
           
 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(PropertyChangeEvent evt)
           
 void readAll()
          Start reading all rows back
 void readValues(int channel)
           
 void removePropertyChangeListener(PropertyChangeListener pcl)
           
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 & restarts
(package private)  void sendReadCommand(int locoIOAddress, int locoIOSubAddress, int cv)
          Read a 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)
          The addr field (for the address info used in each LocoIO channel)
 void setLBVersion(String version)
           
 void setLIM(int channel)
           
 void setLIM(int channel, LocoIOMode m)
           
 void setLIM(int channel, String s)
           
 void setLIOVersion(String version)
           
 void setMode(int channel, String m)
           
 void setStatus(String msg)
           
 void setSV(int channel, int value)
           
 void setUnitAddress(int unit)
           
 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
 void setUnitConfig(int portRefresh, int altCodePBs, int isServo, int blinkRate)
          TODO: 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
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 Timer timer

log

static org.slf4j.Logger log
Constructor Detail

LocoIOData

public LocoIOData(int unitAddr,
                  int unitSubAddr,
                  LnTrafficController tc)
Creates a new instance of LocoIOData

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface 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


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)
TODO: 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


getUnitConfig

public int getUnitConfig()

setLBVersion

public void setLBVersion(String version)

getLBVersion

public String getLBVersion()

setLIOVersion

public void setLIOVersion(String version)

getLIOVersion

public String getLIOVersion()

setStatus

public void setStatus(String msg)

getStatus

public 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)
The 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)

getAddr

public int getAddr(int channel)

setMode

public void setMode(int channel,
                    String m)

getMode

public String getMode(int channel)

setLIM

public void setLIM(int channel,
                   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 interface LocoNetListener
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 & restarts


sendReadCommand

void sendReadCommand(int locoIOAddress,
                     int locoIOSubAddress,
                     int cv)
Read a SV from a given LocoIO device

Parameters:
locoIOAddress -
locoIOSubAddress -
cv -

sendWriteCommand

void sendWriteCommand(int locoIOAddress,
                      int locoIOSubAddress,
                      int cv,
                      int data)
Write an SV to a given LocoIO device

Parameters:
locoIOAddress -
locoIOSubAddress -
cv -
data -

dispose

public void dispose()


Copyright © 1997-2014 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads