|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrix.loconet.LocoNetMessage
public class LocoNetMessage
Represents a single command or response on the LocoNet.
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.
Note that this class does not manage the upper bit of the message. By convention, most LocoNet messages have the upper bit set on the first byte, and on no other byte; but not all of them do, and that must be managed elsewhere.
Note that many specific message types are created elsewhere. In general, if more than one tool will need to use a particular format, it's useful to refactor it to here.
Some of the message formats used in this class are Copyright Digitrax, 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 Digitrax Inc for separate permission.
NceMessage,
Serialized Form| Constructor Summary | |
|---|---|
LocoNetMessage(byte[] contents)
|
|
LocoNetMessage(int len)
Create a new object, representing a specific-length message. |
|
LocoNetMessage(int[] contents)
Create a message with specified contents |
|
LocoNetMessage(LocoNetMessage original)
|
|
| Method Summary | |
|---|---|
boolean |
checkParity()
check whether the message has a valid parity |
boolean |
equals(LocoNetMessage m)
Two messages are the same if their entire data content is the same. |
int |
getElement(int n)
|
int |
getNumDataElements()
Get length, including op code and error-detection byte |
int |
getOpCode()
|
String |
getOpCodeHex()
Get a String representation of the op code in hex |
int[] |
getPeerXfrData()
Get the 8 data bytes from an OPC_PEER_XFR message |
protected static boolean |
highBit(int val)
Check if a high bit is set, usually used to store it in some other location (LocoNet does not allow the high bit to be set in data bytes) |
protected static int |
highByte(int val)
|
int |
inputRepAddr()
If this is an OPC_INPUT_REP, return the 0-n address, else -1 |
protected static int |
lowByte(int val)
|
static LocoNetMessage |
makePeerXfr(int src,
int dst,
int[] d,
int code)
Return a newly created OPC_PEER_XFR message. |
int |
sensorAddr()
Sensor-format 0-n address |
void |
setElement(int n,
int v)
|
void |
setOpCode(int i)
|
void |
setParity()
Set the parity byte(s) of this message |
String |
toString()
Get a String representation of the entire message in hex |
int |
turnoutAddr()
Return the 1-N turnout address |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LocoNetMessage(int len)
len - Total bytes in message, including opcode and error-detection byte.public LocoNetMessage(int[] contents)
contents - The array of contents for the message. The error
check word must be present, e.g. a 4-byte message must have
four values in the arraypublic LocoNetMessage(byte[] contents)
public LocoNetMessage(LocoNetMessage original)
| Method Detail |
|---|
public void setOpCode(int i)
public int getOpCode()
public String getOpCodeHex()
public int getNumDataElements()
public int getElement(int n)
public void setElement(int n,
int v)
public String toString()
toString in class Objectpublic void setParity()
public boolean checkParity()
public int[] getPeerXfrData()
public boolean equals(LocoNetMessage m)
m -
public static LocoNetMessage makePeerXfr(int src,
int dst,
int[] d,
int code)
src - Source addressdst - Destination addressd - int[8] for the data contents or nullcode - The instruction code placed in the pcxt1 pcxt2 bytes
protected static boolean highBit(int val)
val -
protected static int lowByte(int val)
protected static int highByte(int val)
public int sensorAddr()
public int inputRepAddr()
public int turnoutAddr()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||