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
-
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(String s)
SprogMessage(SprogMessage m)
-
Method Summary
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
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 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.String
toString()
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
-
Field Details
-
STX
- See Also:
- Constant Field Values
-
DLE
- See Also:
- Constant Field Values
-
ETX
- See Also:
- Constant Field Values
-
CR
- See Also:
- Constant Field Values
-
LF
- See Also:
- Constant Field Values
-
RD_VER
- See Also:
- Constant Field Values
-
WT_FLASH
- See Also:
- Constant Field Values
-
ER_FLASH
- See Also:
- Constant Field Values
-
WT_EEDATA
- See Also:
- Constant Field Values
-
MAXSIZE
- See Also:
- Constant Field Values
-
_id
-
-
Constructor Details
-
SprogMessage
-
SprogMessage
Create a new SprogMessage containing a byte array to represent a packet to output.- Parameters:
packet
- The contents of the packet
-
SprogMessage
-
SprogMessage
-
-
Method Details
-
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
-
setElement
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
Description copied from interface:Message
- Specified by:
toString
in interfaceMessage
- Overrides:
toString
in classAbstractMRMessage
-
toString
-
getFormattedMessage
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
-
isEnableMain
-
getEnableMain
-
getKillMain
-
getStatus
-
getReadCV
-
getWriteCV
-
getReadRegister
-
getWriteRegister
-
getPacketMessage
Get a message containing a DCC packet.- Parameters:
bytes
- byte[]- Returns:
- SprogMessage
-
getReadBootVersion
-
getWriteFlash
-
getEraseFlash
-
getWriteEE
-
getReset
-