Package jmri.jmrix.mrc
Class MrcMessage
- java.lang.Object
-
- jmri.jmrix.mrc.MrcMessage
-
public class MrcMessage extends java.lang.Object
Encodes and decoders messages to an MRC command station.Some of the message formats used in this class are Copyright MRC, Inc. and used with permission as part of the JMRI project. That permission does not extend to uses in other software products. If you wish to use this code, algorithm or these message formats outside of JMRI, please contact MRC Inc for separate permission.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) byte[]
byteStream
(package private) boolean
inError
protected static int
LONG_TIMEOUT
(package private) int
msgClass
(package private) boolean
replyExpected
(package private) int
retries
(package private) int
SHORT_PROG_TIMEOUT
(package private) int
SHORT_TIMEOUT
(package private) MrcTrafficListener
source
(package private) int
timeout
-
Constructor Summary
Constructors Constructor Description MrcMessage(byte[] contents)
MrcMessage(int len)
MrcMessage(int[] contents)
MrcMessage(MrcMessage original)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAccAddress()
int
getAccState()
(package private) byte[]
getByteStream()
(package private) static int
getCheckSum(int addressHi, int addressLo, int data1, int data2)
int
getElement(int n)
int
getLocoAddress()
int
getMessageClass()
int
getNumDataElements()
static MrcMessage
getPOM(int addressLo, int addressHi, int cv, int val)
static MrcMessage
getReadCV(int cv)
int
getRetries()
(package private) static MrcMessage
getRouteMsg(int address, boolean closed)
static MrcMessage
getSendFunction(int group, int addressLo, int addressHi, int data)
static MrcMessage
getSendSpeed128(int addressLo, int addressHi, int speed)
static MrcMessage
getSendSpeed28(int addressLo, int addressHi, int speed, boolean fwd)
MrcTrafficListener
getSource()
(package private) static MrcMessage
getSwitchMsg(int address, boolean closed)
Get a message for a "Switch Position Normal" command to a specific accessory decoder on the layout.int
getTimeout()
static MrcMessage
getWriteCV(int cv, int val)
boolean
isPacketInError()
boolean
isReplyExpected()
(package private) int
putHeader(int[] insert)
void
replyNotExpected()
(package private) void
setByteStream()
static MrcMessage
setClockAmPm()
Toggle the AM/PM vs 24 hour modestatic MrcMessage
setClockRatio(int ratio)
set the fast clock ratio ratio is integer and max of 60 and min of 1static MrcMessage
setClockTime(int hour, int minute)
set the fast time clockvoid
setElement(int n, int v)
(package private) void
setMessageClass(int i)
void
setMessageInError()
static MrcMessage
setNoData()
static MrcMessage
setPowerOff()
Set Track Power Off/Emergency Stopstatic MrcMessage
setPowerOn()
void
setRetries(int i)
void
setSource(MrcTrafficListener s)
(package private) void
setTimeout(int i)
java.lang.String
toString()
boolean
validCheckSum()
int
value()
-
-
-
Field Detail
-
source
MrcTrafficListener source
-
msgClass
int msgClass
-
replyExpected
boolean replyExpected
-
SHORT_TIMEOUT
int SHORT_TIMEOUT
-
SHORT_PROG_TIMEOUT
int SHORT_PROG_TIMEOUT
-
timeout
int timeout
-
retries
int retries
-
inError
boolean inError
-
LONG_TIMEOUT
protected static final int LONG_TIMEOUT
- See Also:
- Constant Field Values
-
byteStream
byte[] byteStream
-
-
Constructor Detail
-
MrcMessage
public MrcMessage(int len)
-
MrcMessage
public MrcMessage(MrcMessage original)
-
MrcMessage
public MrcMessage(int[] contents)
-
MrcMessage
public MrcMessage(byte[] contents)
-
-
Method Detail
-
setSource
public void setSource(MrcTrafficListener s)
-
getSource
public MrcTrafficListener getSource()
-
setMessageClass
void setMessageClass(int i)
-
getMessageClass
public int getMessageClass()
-
replyNotExpected
public void replyNotExpected()
-
isReplyExpected
public boolean isReplyExpected()
-
setTimeout
void setTimeout(int i)
-
getTimeout
public int getTimeout()
-
getRetries
public int getRetries()
-
setRetries
public void setRetries(int i)
-
setMessageInError
public void setMessageInError()
-
isPacketInError
public boolean isPacketInError()
-
putHeader
int putHeader(int[] insert)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getSendSpeed128
public static MrcMessage getSendSpeed128(int addressLo, int addressHi, int speed)
-
getSendSpeed28
public static MrcMessage getSendSpeed28(int addressLo, int addressHi, int speed, boolean fwd)
-
getSendFunction
public static MrcMessage getSendFunction(int group, int addressLo, int addressHi, int data)
-
getCheckSum
static int getCheckSum(int addressHi, int addressLo, int data1, int data2)
-
getReadCV
public static MrcMessage getReadCV(int cv)
-
getPOM
public static MrcMessage getPOM(int addressLo, int addressHi, int cv, int val)
-
getWriteCV
public static MrcMessage getWriteCV(int cv, int val)
-
validCheckSum
public boolean validCheckSum()
-
value
public int value()
-
getLocoAddress
public int getLocoAddress()
-
getAccAddress
public int getAccAddress()
-
getAccState
public int getAccState()
-
setClockRatio
public static MrcMessage setClockRatio(int ratio)
set the fast clock ratio ratio is integer and max of 60 and min of 1- Parameters:
ratio
- value to set new clock speed- Returns:
- new message to set the clock speed ratio
-
setClockTime
public static MrcMessage setClockTime(int hour, int minute)
set the fast time clock- Parameters:
hour
- hour value for fast clockminute
- minute value for fast clock- Returns:
- new message to set the hour/minutes of the fast clock
-
setClockAmPm
public static MrcMessage setClockAmPm()
Toggle the AM/PM vs 24 hour mode- Returns:
- MrcMessage
-
setPowerOff
public static MrcMessage setPowerOff()
Set Track Power Off/Emergency Stop- Returns:
- MrcMessage
-
setPowerOn
public static MrcMessage setPowerOn()
-
getSwitchMsg
static MrcMessage getSwitchMsg(int address, boolean closed)
Get a message for a "Switch Position Normal" command to a specific accessory decoder on the layout.- Parameters:
address
- address of turnoutclosed
- position for the turnout- Returns:
- new message for getting switch posistion
-
getRouteMsg
static MrcMessage getRouteMsg(int address, boolean closed)
-
setNoData
public static MrcMessage setNoData()
-
setByteStream
void setByteStream()
-
getByteStream
byte[] getByteStream()
-
getElement
public int getElement(int n)
-
getNumDataElements
public int getNumDataElements()
-
setElement
public void setElement(int n, int v)
-
-