Package jmri.jmrix.sprog
Class SprogMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.sprog.SprogMessage
-
- All Implemented Interfaces:
Message
public class SprogMessage extends AbstractMRMessage
Encode a message to an SPROG command station.The
SprogReply
class handles the response from the command station.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_id
static int
CR
static int
DLE
static int
ER_FLASH
static int
ETX
static int
LF
static int
MAXSIZE
static int
RD_VER
static int
STX
static int
WT_EEDATA
static int
WT_FLASH
-
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description SprogMessage(byte[] packet)
Create a new SprogMessage containing a byte array to represent a packet to output.SprogMessage(int i)
SprogMessage(java.lang.String s)
SprogMessage(SprogMessage m)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SprogMessage
getEnableMain()
static SprogMessage
getEraseFlash(int addr, int rows)
byte[]
getFormattedMessage(SprogConstants.SprogState sprogState)
Get formatted message for direct output to stream - this is the final format of the message as a byte array.int
getId()
static SprogMessage
getKillMain()
static SprogMessage
getPacketMessage(byte[] bytes)
Get a message containing a DCC packet.static SprogMessage
getReadBootVersion()
static SprogMessage
getReadCV(int cv, ProgrammingMode mode)
static SprogMessage
getReadCV(int cv, ProgrammingMode mode, int startVal)
static SprogMessage
getReadRegister(int reg)
static SprogMessage
getReset()
static SprogMessage
getStatus()
static SprogMessage
getWriteCV(int cv, int val, ProgrammingMode mode)
static SprogMessage
getWriteEE(int addr, int[] data)
static SprogMessage
getWriteFlash(int addr, int[] data, int blockLen)
static SprogMessage
getWriteRegister(int reg, int val)
boolean
isEnableMain()
boolean
isKillMain()
protected static int
newMsgId()
Get next message id For modules that need to match their own message/reply pairs in strict sequence, e.g., SprogCommandStation, return a unique message id.void
setElement(int n, int v)
Set a single Data Element at a particular index.java.lang.String
toString()
java.lang.String
toString(boolean isSIIBootMode)
-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCode, getOpCodeHex, getRetries, getTimeout, isBinary, replyExpected, setBinary, setNeededMode, setOpCode, setRetries, setTimeout
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.Message
toMonitorString
-
-
-
-
Field Detail
-
STX
public static final int STX
- See Also:
- Constant Field Values
-
DLE
public static final int DLE
- See Also:
- Constant Field Values
-
ETX
public static final int ETX
- See Also:
- Constant Field Values
-
CR
public static final int CR
- See Also:
- Constant Field Values
-
LF
public static final int LF
- See Also:
- Constant Field Values
-
RD_VER
public static final int RD_VER
- See Also:
- Constant Field Values
-
WT_FLASH
public static final int WT_FLASH
- See Also:
- Constant Field Values
-
ER_FLASH
public static final int ER_FLASH
- See Also:
- Constant Field Values
-
WT_EEDATA
public static final int WT_EEDATA
- See Also:
- Constant Field Values
-
MAXSIZE
public static final int MAXSIZE
- See Also:
- Constant Field Values
-
_id
protected int _id
-
-
Constructor Detail
-
SprogMessage
public SprogMessage(int i)
-
SprogMessage
public SprogMessage(byte[] packet)
Create a new SprogMessage containing a byte array to represent a packet to output.- Parameters:
packet
- The contents of the packet
-
SprogMessage
public SprogMessage(java.lang.String s)
-
SprogMessage
public SprogMessage(SprogMessage m)
-
-
Method Detail
-
newMsgId
protected static int newMsgId()
Get next message id For modules that need to match their own message/reply pairs in strict sequence, e.g., SprogCommandStation, return a unique message id. The id wraps at a suitably large value.- Returns:
- the message id
-
getId
public int getId()
-
setElement
public void setElement(int n, int v)
Description copied from class:AbstractMessage
Set a single Data Element at a particular index.- Specified by:
setElement
in interfaceMessage
- Overrides:
setElement
in classAbstractMessage
- Parameters:
n
- index of element.v
- value of element.
-
toString
public java.lang.String toString()
Description copied from interface:Message
- Specified by:
toString
in interfaceMessage
- Overrides:
toString
in classAbstractMRMessage
-
toString
public java.lang.String toString(boolean isSIIBootMode)
-
getFormattedMessage
public byte[] getFormattedMessage(SprogConstants.SprogState sprogState)
Get formatted message for direct output to stream - this is the final format of the message as a byte array.- Parameters:
sprogState
- a SprogState variable representing the current state of the Sprog- Returns:
- the formatted message as a byte array
-
isKillMain
public boolean isKillMain()
-
isEnableMain
public boolean isEnableMain()
-
getEnableMain
public static SprogMessage getEnableMain()
-
getKillMain
public static SprogMessage getKillMain()
-
getStatus
public static SprogMessage getStatus()
-
getReadCV
public static SprogMessage getReadCV(int cv, ProgrammingMode mode)
-
getReadCV
public static SprogMessage getReadCV(int cv, ProgrammingMode mode, int startVal)
-
getWriteCV
public static SprogMessage getWriteCV(int cv, int val, ProgrammingMode mode)
-
getReadRegister
public static SprogMessage getReadRegister(int reg)
-
getWriteRegister
public static SprogMessage getWriteRegister(int reg, int val)
-
getPacketMessage
public static SprogMessage getPacketMessage(byte[] bytes)
Get a message containing a DCC packet.- Parameters:
bytes
- byte[]- Returns:
- SprogMessage
-
getReadBootVersion
public static SprogMessage getReadBootVersion()
-
getWriteFlash
public static SprogMessage getWriteFlash(int addr, int[] data, int blockLen)
-
getEraseFlash
public static SprogMessage getEraseFlash(int addr, int rows)
-
getWriteEE
public static SprogMessage getWriteEE(int addr, int[] data)
-
getReset
public static SprogMessage getReset()
-
-