Package jmri.jmrix.zimo
Class Mx1Message
java.lang.Object
jmri.jmrix.NetMessage
jmri.jmrix.zimo.Mx1Message
- All Implemented Interfaces:
Serializable
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:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final int(package private) static final int(package private) boolean(package private) static final booleanIndicates the message source is a command station.(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final intMessage to/from Command Station MX1(package private) static final intMessage to/from Accessory module MX8(package private) static final intMessage to/from Track Section module MX9(package private) static final int(package private) static final booleanIndicates the message source is a command station.(package private) static final int(package private) static final int(package private) boolean(package private) byte[](package private) static final int(package private) int(package private) long(package private) static final int -
Constructor Summary
ConstructorsConstructorDescriptionMx1Message(byte[] contents) Mx1Message(int len) Mx1Message(int len, boolean protocol) Create a new object, representing a specific-length message.Mx1Message(Integer[] contents) -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the message has a valid parity (actually check for CR or LF as end of message).static Mx1Messageintstatic Mx1MessagegetDecProgCmd(int locoAddress, int cv, int value, boolean dcc) Create a message to read or write a CV.(package private) StringgetErrorCode(int i) int(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.booleanintintIndicates where the message is to/from in the header byte.intprotected byte[]intgetRetry()intstatic Mx1MessagegetSwitchMsg(int accAddress, int setting, boolean dcc) protected longstatic Mx1MessagebooleanbooleanIndicates the source of the message.booleanvoidvoidSet parity to be correct for this implementation.static Mx1MessageSet Track Power Off/Emergency Stopstatic Mx1MessagevoidsetRawPacket(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 Details
-
protocol
boolean protocol -
PRIMARY
- See Also:
-
ACKREP1
- See Also:
-
REPLY2
- See Also:
-
ACK2
- See Also:
-
MX1
Message to/from Command Station MX1- See Also:
-
MX8
Message to/from Accessory module MX8- See Also:
-
MX9
Message to/from Track Section module MX9- See Also:
-
CS
Indicates the message source is a command station. true- See Also:
-
PC
Indicates the message source is a command station. false- See Also:
-
timeStamp
long timeStamp -
retries
int retries -
rawPacket
byte[] rawPacket -
crcError
boolean crcError -
NO_ERROR
- See Also:
-
ERR_ADDRESS
- See Also:
-
ERR_INDEX
- See Also:
-
ERR_FORWARD
- See Also:
-
ERR_BUSY
- See Also:
-
ERR_NO_MOT
- See Also:
-
ERR_NO_DCC
- See Also:
-
ERR_CV_ADDRESS
- See Also:
-
ERR_SECTION
- See Also:
-
ERR_NO_MODUL
- See Also:
-
ERR_MESSAGE
- See Also:
-
ERR_SPEED
- See Also:
-
TRACKCTL
- See Also:
-
PROGCMD
- See Also:
-
LOCOCMD
- See Also:
-
ACCCMD
- See Also:
-
-
Constructor Details
-
Mx1Message
-
Mx1Message
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
-
Mx1Message
-
-
Method Details
-
getLongMessage
-
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
-
getPrimaryMessage
-
messageSource
Indicates the source of the message. -
getTimeStamp
-
setTimeStamp
-
getRetry
-
setRetries
-
replyL1Expected
-
setRawPacket
-
getRawPacket
-
setSequenceNo
-
getSequenceNo
-
setCRCError
-
isCRCError
-
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
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
-
getLocoAddress
-
getCvValue
-
getLocoAddress
-
getErrorCode
-
getCmdStnDetails
-
setPowerOff
Set Track Power Off/Emergency Stop- Returns:
- MrcMessage
-
setPowerOn
-
getTrackStatus
-
getDecProgCmd
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
-