jmri.jmrix.lenz
Class XNetProgrammer

java.lang.Object
  extended by jmri.jmrix.AbstractProgrammer
      extended by jmri.jmrix.lenz.XNetProgrammer
All Implemented Interfaces:
EventListener, AbstractMRListener, XNetListener, Programmer
Direct Known Subclasses:
EliteXNetProgrammer, LI100XNetProgrammer

public class XNetProgrammer
extends AbstractProgrammer
implements XNetListener

Programmer support for Lenz XpressNet.

The read operation state sequence is:

Author:
Bob Jacobsen Copyright (c) 2002, 2007, Paul Bender Copyright (c) 2003-2010, Giorgio Terdina Copyright (c) 2007

Field Summary
protected  int _cv
           
protected  int _mode
           
protected  boolean _progRead
           
protected  boolean _service_mode
           
protected  int _val
           
protected static int INQUIRESENT
           
protected static int NOTPROGRAMMING
           
protected  int progState
           
protected static int REQUESTSENT
           
protected static int XNetProgrammerTimeout
           
 
Fields inherited from class jmri.jmrix.AbstractProgrammer
LONG_TIMEOUT, propListeners, SHORT_TIMEOUT
 
Fields inherited from interface jmri.Programmer
ADDRESSMODE, CBUSNODEVARMODE, DIRECTBITMODE, DIRECTBYTEMODE, NONE, OPSACCBITMODE, OPSACCBYTEMODE, OPSACCEXTBITMODE, OPSACCEXTBYTEMODE, OPSBITMODE, OPSBYTEMODE, PAGEMODE, REGISTERMODE
 
Constructor Summary
XNetProgrammer(XNetTrafficController tc)
           
 
Method Summary
 void confirmCV(int CV, int val, ProgListener p)
          Confirm the value of a CV using the specified programming mode.
protected  XNetTrafficController controller()
           
 boolean getCanRead()
           
 int getMode()
          Get the current programming mode
 boolean hasMode(int mode)
          Signifies mode's available
 void message(XNetMessage l)
          Member function that will be invoked by a XNetInterface implementation to forward a XNet message sent to the layout.
 void message(XNetReply m)
          Member function that will be invoked by a XNetInterface implementation to forward a XNet message from the layout.
protected  void notifyProgListenerEnd(int value, int status)
           
protected  void notifyPropertyChange(String name, int oldval, int newval)
           
 void notifyTimeout(XNetMessage msg)
          Member function invoked by an XNetInterface implementation to notify * a sender that an outgoing message timed out and was dropped from the * queue.
 boolean programmerBusy()
           
 void readCV(int CV, ProgListener p)
          Perform a CV read in the system-specific manner, and using the specified programming mode.
 void setMode(int mode)
          Switch to a new programming mode.
protected  void timeout()
          Internal routine to handle a timeout
protected  void useProgrammer(ProgListener p)
           
 void writeCV(int CV, int val, ProgListener p)
          Perform a CV write in the system-specific manner, and using the specified programming mode.
 
Methods inherited from class jmri.jmrix.AbstractProgrammer
addPropertyChangeListener, decodeErrorCode, registerFromCV, removePropertyChangeListener, restartTimer, startLongTimer, startShortTimer, stopTimer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XNetProgrammerTimeout

protected static final int XNetProgrammerTimeout
See Also:
Constant Field Values

_service_mode

protected boolean _service_mode

_mode

protected int _mode

progState

protected int progState

NOTPROGRAMMING

protected static final int NOTPROGRAMMING
See Also:
Constant Field Values

REQUESTSENT

protected static final int REQUESTSENT
See Also:
Constant Field Values

INQUIRESENT

protected static final int INQUIRESENT
See Also:
Constant Field Values

_progRead

protected boolean _progRead

_val

protected int _val

_cv

protected int _cv
Constructor Detail

XNetProgrammer

public XNetProgrammer(XNetTrafficController tc)
Method Detail

setMode

public void setMode(int mode)
Switch to a new programming mode. Lenz can now only do register, page, and direct mode. If you attempt to switch to any others, the new mode will set & notify, then set back to the original. This lets the listeners know that a change happened, and then was undone.

Specified by:
setMode in interface Programmer
Parameters:
mode - The new mode, use values from the jmri.Programmer interface

getMode

public int getMode()
Description copied from interface: Programmer
Get the current programming mode

Specified by:
getMode in interface Programmer
Returns:
one of the class constants identifying a mode

hasMode

public boolean hasMode(int mode)
Signifies mode's available

Specified by:
hasMode in interface Programmer
Parameters:
mode -
Returns:
True if paged,register,or Direct Mode (Bit or Byte) mode

getCanRead

public boolean getCanRead()
Specified by:
getCanRead in interface Programmer

notifyPropertyChange

protected void notifyPropertyChange(String name,
                                    int oldval,
                                    int newval)

writeCV

public void writeCV(int CV,
                    int val,
                    ProgListener p)
             throws ProgrammerException
Description copied from interface: Programmer
Perform a CV write in the system-specific manner, and using the specified programming mode. Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. The exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier)

Specified by:
writeCV in interface Programmer
Throws:
ProgrammerException

confirmCV

public void confirmCV(int CV,
                      int val,
                      ProgListener p)
               throws ProgrammerException
Description copied from interface: Programmer
Confirm the value of a CV using the specified programming mode. On some systems, this is faster than a read. Note that this returns before the confirm is complete; you have to provide a ProgListener to hear about completion. The exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier)

Specified by:
confirmCV in interface Programmer
Throws:
ProgrammerException

readCV

public void readCV(int CV,
                   ProgListener p)
            throws ProgrammerException
Description copied from interface: Programmer
Perform a CV read in the system-specific manner, and using the specified programming mode. Note that this returns before the read is complete; you have to provide a ProgListener to hear about completion. The exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier)

Specified by:
readCV in interface Programmer
Throws:
ProgrammerException

useProgrammer

protected void useProgrammer(ProgListener p)
                      throws ProgrammerException
Throws:
ProgrammerException

message

public void message(XNetReply m)
Description copied from interface: XNetListener
Member function that will be invoked by a XNetInterface implementation to forward a XNet message from the layout.

Specified by:
message in interface XNetListener
Parameters:
m - The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.

message

public void message(XNetMessage l)
Description copied from interface: XNetListener
Member function that will be invoked by a XNetInterface implementation to forward a XNet message sent to the layout. Normally, this function will do nothing.

Specified by:
message in interface XNetListener
Parameters:
l - The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.

notifyTimeout

public void notifyTimeout(XNetMessage msg)
Description copied from interface: XNetListener
Member function invoked by an XNetInterface implementation to notify * a sender that an outgoing message timed out and was dropped from the * queue.

Specified by:
notifyTimeout in interface XNetListener

programmerBusy

public boolean programmerBusy()

timeout

protected void timeout()
Internal routine to handle a timeout

Specified by:
timeout in class AbstractProgrammer

notifyProgListenerEnd

protected void notifyProgListenerEnd(int value,
                                     int status)

controller

protected XNetTrafficController controller()


Copyright © 1997 - 2011 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