jmri.jmrix.nce
Class NceMessage

java.lang.Object
  extended by jmri.jmrix.AbstractMessage
      extended by jmri.jmrix.AbstractMRMessage
          extended by jmri.jmrix.nce.NceMessage
All Implemented Interfaces:
Message

public class NceMessage
extends AbstractMRMessage

Encodes a message to an NCE command station.

The NceReply class handles the response from the command station.

The NCE protocol has "binary" and "ASCII" command sets. Depending on the version of the EPROM it contains, NCE command stations have different support for command sets:

See the setCommandOptions(int) method for more information.

Apparently the binary "exitProgrammingMode" command can crash the command station if the EPROM was built before 2006. This class uses a static state flag (ncsProgMode) to detect whether a command to enter program mode has been generated, and presumably sent, when using the later EPROMS.

Author:
Bob Jacobsen Copyright (C) 2001, Daniel Boudreau Copyright (C) 2007

Field Summary
static int ENABLE_MAIN_CMD
           
static int ENTER_PROG_CMD
           
static int EXIT_PROG_CMD
           
static int KILL_MAIN_CMD
           
protected static int NCE_DIRECT_CV_TIMEOUT
           
protected static int NCE_PAGED_CV_TIMEOUT
           
protected static boolean ncsProgMode
           
static int NOP_CMD
           
static int OPTION_1999
          Create commands compatible with the 1999 EPROM.
static int OPTION_2004
          Create commands compatible with the 2004 EPROM.
static int OPTION_2006
          Create commands compatible with the 2006 EPROM.
static int OPTION_FORCE_ASCII
          Create all commands in the ASCII format.
static int OPTION_FORCE_BINARY
          Create all commands in the binary format.
static int QUEUEn_BYTES_CMD
           
static int READ_DIR_CV_CMD
           
static int READ_PAGED_CV_CMD
           
static int READ_REG_CMD
           
static int SENDn_BYTES_CMD
           
protected static int SHORT_TIMEOUT
           
static int WRITE_DIR_CV_CMD
           
static int WRITE_PAGED_CV_CMD
           
static int WRITE_REG_CMD
           
 
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT
 
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
 
Constructor Summary
NceMessage()
           
NceMessage(int i)
           
NceMessage(NceMessage m)
           
NceMessage(String m)
           
 
Method Summary
static NceMessage createBinaryMessage(byte[] bytes)
           
static NceMessage createBinaryMessage(byte[] bytes, int replyLen)
           
static int getCommandOptions()
          Determine which command format should be used for various commands: ASCII or binary.
static NceMessage getEnableMain()
           
static NceMessage getExitProgMode()
           
static NceMessage getKillMain()
           
static NceMessage getProgMode()
           
static NceMessage getReadDirectCV(int cv)
           
static NceMessage getReadPagedCV(int cv)
           
static NceMessage getReadRegister(int reg)
           
 int getReplyLen()
           
static NceMessage getWriteDirectCV(int cv, int val)
           
static NceMessage getWritePagedCV(int cv, int val)
           
static NceMessage getWriteRegister(int reg, int val)
           
 boolean isEnableMain()
           
 boolean isKillMain()
           
static NceMessage queuePacketMessage(byte[] bytes)
           
static NceMessage sendPacketMessage(byte[] bytes)
           
static NceMessage sendPacketMessage(byte[] bytes, int retries)
           
static void setCommandOptions(int val)
          Control which command format should be used for various commands: ASCII or binary.
 void setReplyLen(int len)
          Set the number of characters expected back from the command station.
 
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCode, getOpCodeHex, getRetries, getTimeout, isBinary, replyExpected, setBinary, setNeededMode, setOpCode, setRetries, setTimeout, toString
 
Methods inherited from class jmri.jmrix.AbstractMessage
getElement, getNumDataElements, setElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOP_CMD

public static final int NOP_CMD
See Also:
Constant Field Values

ENTER_PROG_CMD

public static final int ENTER_PROG_CMD
See Also:
Constant Field Values

EXIT_PROG_CMD

public static final int EXIT_PROG_CMD
See Also:
Constant Field Values

WRITE_PAGED_CV_CMD

public static final int WRITE_PAGED_CV_CMD
See Also:
Constant Field Values

READ_PAGED_CV_CMD

public static final int READ_PAGED_CV_CMD
See Also:
Constant Field Values

WRITE_REG_CMD

public static final int WRITE_REG_CMD
See Also:
Constant Field Values

READ_REG_CMD

public static final int READ_REG_CMD
See Also:
Constant Field Values

WRITE_DIR_CV_CMD

public static final int WRITE_DIR_CV_CMD
See Also:
Constant Field Values

READ_DIR_CV_CMD

public static final int READ_DIR_CV_CMD
See Also:
Constant Field Values

ENABLE_MAIN_CMD

public static final int ENABLE_MAIN_CMD
See Also:
Constant Field Values

KILL_MAIN_CMD

public static final int KILL_MAIN_CMD
See Also:
Constant Field Values

SENDn_BYTES_CMD

public static final int SENDn_BYTES_CMD
See Also:
Constant Field Values

QUEUEn_BYTES_CMD

public static final int QUEUEn_BYTES_CMD
See Also:
Constant Field Values

NCE_PAGED_CV_TIMEOUT

protected static int NCE_PAGED_CV_TIMEOUT

NCE_DIRECT_CV_TIMEOUT

protected static int NCE_DIRECT_CV_TIMEOUT

SHORT_TIMEOUT

protected static int SHORT_TIMEOUT

ncsProgMode

protected static boolean ncsProgMode

OPTION_FORCE_ASCII

public static final int OPTION_FORCE_ASCII
Create all commands in the ASCII format.

See Also:
Constant Field Values

OPTION_1999

public static final int OPTION_1999
Create commands compatible with the 1999 EPROM.

This is binary for everything except service-mode CV programming operations.

See Also:
Constant Field Values

OPTION_2004

public static final int OPTION_2004
Create commands compatible with the 2004 EPROM.

This is binary for everything except service-mode CV programming operations.

See Also:
Constant Field Values

OPTION_2006

public static final int OPTION_2006
Create commands compatible with the 2006 EPROM.

This is binary for everything, including service-mode CV programming operations.

See Also:
Constant Field Values

OPTION_FORCE_BINARY

public static final int OPTION_FORCE_BINARY
Create all commands in the binary format.

See Also:
Constant Field Values
Constructor Detail

NceMessage

public NceMessage()

NceMessage

public NceMessage(int i)

NceMessage

public NceMessage(NceMessage m)

NceMessage

public NceMessage(String m)
Method Detail

setReplyLen

public void setReplyLen(int len)
Set the number of characters expected back from the command station. Used in binary mode, where there's no end-of-reply string to look for.


getReplyLen

public int getReplyLen()

isKillMain

public boolean isKillMain()

isEnableMain

public boolean isEnableMain()

getEnableMain

public static NceMessage getEnableMain()

getKillMain

public static NceMessage getKillMain()

getProgMode

public static NceMessage getProgMode()

getExitProgMode

public static NceMessage getExitProgMode()

getReadPagedCV

public static NceMessage getReadPagedCV(int cv)

getWritePagedCV

public static NceMessage getWritePagedCV(int cv,
                                         int val)

getReadRegister

public static NceMessage getReadRegister(int reg)

getWriteRegister

public static NceMessage getWriteRegister(int reg,
                                          int val)

getReadDirectCV

public static NceMessage getReadDirectCV(int cv)

getWriteDirectCV

public static NceMessage getWriteDirectCV(int cv,
                                          int val)

sendPacketMessage

public static NceMessage sendPacketMessage(byte[] bytes)

sendPacketMessage

public static NceMessage sendPacketMessage(byte[] bytes,
                                           int retries)

createBinaryMessage

public static NceMessage createBinaryMessage(byte[] bytes)

createBinaryMessage

public static NceMessage createBinaryMessage(byte[] bytes,
                                             int replyLen)

queuePacketMessage

public static NceMessage queuePacketMessage(byte[] bytes)

setCommandOptions

public static void setCommandOptions(int val)
Control which command format should be used for various commands: ASCII or binary.

The valid argument values are the class "OPTION" contants, which are interpreted in the various methods to get a particular message.


getCommandOptions

public static int getCommandOptions()
Determine which command format should be used for various commands: ASCII or binary.

The valid return values are the class "OPTION" contants, which are interpreted in the various methods to get a particular message.



Copyright © 1997 - 2008 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: SourceForge_Logo