Package jmri.jmrix.zimo
Class Mx1Message
- java.lang.Object
-
- jmri.jmrix.NetMessage
-
- jmri.jmrix.zimo.Mx1Message
-
- All Implemented Interfaces:
java.io.Serializable
public class Mx1Message extends NetMessage
Represents a single command or response to the Zimo Binary Protocol.Content is represented with ints to avoid the problems with sign-extension that bytes have, and because a Java char is actually a variable number of bytes in Unicode.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intACCCMD(package private) static intACK2(package private) static intACKREP1(package private) booleancrcError(package private) static booleanCSIndicates the message source is a command station.(package private) static intERR_ADDRESS(package private) static intERR_BUSY(package private) static intERR_CV_ADDRESS(package private) static intERR_FORWARD(package private) static intERR_INDEX(package private) static intERR_MESSAGE(package private) static intERR_NO_DCC(package private) static intERR_NO_MODUL(package private) static intERR_NO_MOT(package private) static intERR_SECTION(package private) static intERR_SPEED(package private) static intLOCOCMD(package private) static intMX1Message to/from Command Station MX1(package private) static intMX8Message to/from Accessory module MX8(package private) static intMX9Message to/from Track Section module MX9(package private) static intNO_ERROR(package private) static booleanPCIndicates the message source is a command station.(package private) static intPRIMARY(package private) static intPROGCMD(package private) booleanprotocol(package private) byte[]rawPacket(package private) static intREPLY2(package private) intretries(package private) longtimeStamp(package private) static intTRACKCTL
-
Constructor Summary
Constructors Constructor Description Mx1Message(byte[] contents)Mx1Message(int len)Mx1Message(int len, boolean protocol)Create a new object, representing a specific-length message.Mx1Message(java.lang.Integer[] contents)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckParity()Check if the message has a valid parity (actually check for CR or LF as end of message).static Mx1MessagegetCmdStnDetails()intgetCvValue()static Mx1MessagegetDecProgCmd(int locoAddress, int cv, int value, boolean dcc)Create a message to read or write a CV.(package private) java.lang.StringgetErrorCode(int i)intgetLocoAddress()(package private) intgetLocoAddress(int hi, int lo)static Mx1MessagegetLocoControl(int locoAddress, int speed, boolean dcc, int cData1, int cData2, int cData3)Create a locomotive control message.booleangetLongMessage()intgetMessageType()intgetModule()Indicates where the message is to/from in the header byte.intgetPrimaryMessage()protected byte[]getRawPacket()intgetRetry()intgetSequenceNo()java.lang.StringgetStringMsg()static Mx1MessagegetSwitchMsg(int accAddress, int setting, boolean dcc)protected longgetTimeStamp()static Mx1MessagegetTrackStatus()booleanisCRCError()booleanmessageSource()Indicates the source of the message.booleanreplyL1Expected()voidsetCRCError()voidsetParity()Set parity to be correct for this implementation.static Mx1MessagesetPowerOff()Set Track Power Off/Emergency Stopstatic Mx1MessagesetPowerOn()voidsetRawPacket(byte[] b)voidsetRetries(int i)voidsetSequenceNo(byte s)protected voidsetTimeStamp(long ts)-
Methods inherited from class jmri.jmrix.NetMessage
getElement, getNumDataElements, getOpCode, getOpCodeHex, highByte, lowByte, setElement, setOpCode, toString
-
-
-
-
Field Detail
-
protocol
boolean protocol
-
PRIMARY
static final int PRIMARY
- See Also:
- Constant Field Values
-
ACKREP1
static final int ACKREP1
- See Also:
- Constant Field Values
-
REPLY2
static final int REPLY2
- See Also:
- Constant Field Values
-
ACK2
static final int ACK2
- See Also:
- Constant Field Values
-
MX1
static final int MX1
Message to/from Command Station MX1- See Also:
- Constant Field Values
-
MX8
static final int MX8
Message to/from Accessory module MX8- See Also:
- Constant Field Values
-
MX9
static final int MX9
Message to/from Track Section module MX9- See Also:
- Constant Field Values
-
CS
static final boolean CS
Indicates the message source is a command station. true- See Also:
messageSource(), Constant Field Values
-
PC
static final boolean PC
Indicates the message source is a command station. false- See Also:
messageSource(), Constant Field Values
-
timeStamp
long timeStamp
-
retries
int retries
-
rawPacket
byte[] rawPacket
-
crcError
boolean crcError
-
NO_ERROR
static final int NO_ERROR
- See Also:
- Constant Field Values
-
ERR_ADDRESS
static final int ERR_ADDRESS
- See Also:
- Constant Field Values
-
ERR_INDEX
static final int ERR_INDEX
- See Also:
- Constant Field Values
-
ERR_FORWARD
static final int ERR_FORWARD
- See Also:
- Constant Field Values
-
ERR_BUSY
static final int ERR_BUSY
- See Also:
- Constant Field Values
-
ERR_NO_MOT
static final int ERR_NO_MOT
- See Also:
- Constant Field Values
-
ERR_NO_DCC
static final int ERR_NO_DCC
- See Also:
- Constant Field Values
-
ERR_CV_ADDRESS
static final int ERR_CV_ADDRESS
- See Also:
- Constant Field Values
-
ERR_SECTION
static final int ERR_SECTION
- See Also:
- Constant Field Values
-
ERR_NO_MODUL
static final int ERR_NO_MODUL
- See Also:
- Constant Field Values
-
ERR_MESSAGE
static final int ERR_MESSAGE
- See Also:
- Constant Field Values
-
ERR_SPEED
static final int ERR_SPEED
- See Also:
- Constant Field Values
-
TRACKCTL
static final int TRACKCTL
- See Also:
- Constant Field Values
-
PROGCMD
static final int PROGCMD
- See Also:
- Constant Field Values
-
LOCOCMD
static final int LOCOCMD
- See Also:
- Constant Field Values
-
ACCCMD
static final int ACCCMD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Mx1Message
public Mx1Message(int len)
-
Mx1Message
public Mx1Message(int len, boolean protocol)
Create a new object, representing a specific-length message.- Parameters:
len- Total bytes in message, including opcode and error-detection byte.protocol- one ofMx1TrafficController.ASCIIorMx1TrafficController.BINARY
-
Mx1Message
public Mx1Message(java.lang.Integer[] contents)
-
Mx1Message
public Mx1Message(byte[] contents)
-
-
Method Detail
-
getLongMessage
public boolean getLongMessage()
-
getModule
public int getModule()
Indicates where the message is to/from in the header byte.Up to JMRI 4.3.5, this was doing
((mod & MX1) == MX1)for the first test, which is really 0 == 0 and always true. At that point it was changed to just check the bottom two bits.
-
getMessageType
public int getMessageType()
-
getPrimaryMessage
public int getPrimaryMessage()
-
messageSource
public boolean messageSource()
Indicates the source of the message.
-
getTimeStamp
protected long getTimeStamp()
-
setTimeStamp
protected void setTimeStamp(long ts)
-
getRetry
public int getRetry()
-
setRetries
public void setRetries(int i)
-
replyL1Expected
public boolean replyL1Expected()
-
setRawPacket
public void setRawPacket(byte[] b)
-
getRawPacket
protected byte[] getRawPacket()
-
setSequenceNo
public void setSequenceNo(byte s)
-
getSequenceNo
public int getSequenceNo()
-
setCRCError
public void setCRCError()
-
isCRCError
public boolean isCRCError()
-
checkParity
public boolean checkParity()
Check if the message has a valid parity (actually check for CR or LF as end of message).- Specified by:
checkParityin classNetMessage- Returns:
- true if message has correct parity bit
-
setParity
public void setParity()
Description copied from class:NetMessageSet parity to be correct for this implementation. Note that parity is really a stand-in for whatever error checking, etc needs to be done- Specified by:
setParityin classNetMessage
-
getStringMsg
public java.lang.String getStringMsg()
-
getLocoAddress
public int getLocoAddress()
-
getCvValue
public int getCvValue()
-
getLocoAddress
int getLocoAddress(int hi, int lo)
-
getErrorCode
java.lang.String getErrorCode(int i)
-
getCmdStnDetails
public static Mx1Message getCmdStnDetails()
-
setPowerOff
public static Mx1Message setPowerOff()
Set Track Power Off/Emergency Stop- Returns:
- MrcMessage
-
setPowerOn
public static Mx1Message setPowerOn()
-
getTrackStatus
public static Mx1Message getTrackStatus()
-
getDecProgCmd
public static Mx1Message getDecProgCmd(int locoAddress, int cv, int value, boolean dcc)
Create a message to read or write a CV.- Parameters:
locoAddress- address of the lococv- CV to read or writevalue- value to write to CV, if -1 CV is readdcc- true if decoder is DCC; false if decoder is Motorola- Returns:
- a message to read or write a CV
-
getLocoControl
public static Mx1Message getLocoControl(int locoAddress, int speed, boolean dcc, int cData1, int cData2, int cData3)
Create a locomotive control message.- Parameters:
locoAddress- address of the locospeed- Speed Step in the actual Speed Step Systemdcc- true if decoder is DCC; false if decoder is MotorolacData1- ???cData2- functions output 0-7cData3- functions output 9-12- Returns:
- message controlling a locomotive
-
getSwitchMsg
public static Mx1Message getSwitchMsg(int accAddress, int setting, boolean dcc)
-
-