Class GridConnectReply
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRReply
-
- jmri.jmrix.can.adapters.gridconnect.GridConnectReply
-
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
MergReply
public class GridConnectReply extends AbstractMRReply
Class for replies in a GridConnect based message/reply protocol.The GridConnect protocol encodes messages as an ASCII string of up to 24 characters of the form: :ShhhhNd0d1d2d3d4d5d6d7;
hhhh is the two byte (11 useful bits) header The S indicates a standard CAN frame :XhhhhhhhhNd0d1d2d3d4d5d6d7; The X indicates an extended CAN frame N or R indicates a normal or remote frame, in position 6 or 10 d0 - d7 are the (up to) 8 data bytes
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
_RTRoffset
(package private) static int
MAXLEN
-
Fields inherited from class jmri.jmrix.AbstractMRReply
DEFAULTMAXSIZE
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description GridConnectReply()
Creates a new instance of GridConnectReply.GridConnectReply(java.lang.String s)
Creates a new GridConnectReply from String.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
basicFormatCheck()
Check if this GCReply contains an Extended or Standard flag.CanReply
createReply()
Create a CanReply from a GridConnectReply.int
getByte(int b)
Get a hex data byte from the message.int
getElement(int n)
Get a particular element in a Message.int
getHeader()
Get the CAN header by using chars from 2 to up to 9.int
getNumBytes()
Get the number of data bytes.int
getNumDataElements()
Get the number of data elements in a Message.boolean
isExtended()
Get if the GridConnectReply is Extended.boolean
isRtr()
Get if the GridConnectReply is RtR.int
maxSize()
void
setData(int[] d)
Set the GridConnectReply data by Array.void
setElement(int n, int v)
Set a single Data Element at a particular index.void
setNumDataElements(int n)
Set Number of Data Elements.protected int
skipPrefix(int index)
-
Methods inherited from class jmri.jmrix.AbstractMRReply
flush, getOpCode, isBinary, isRetransmittableErrorMsg, isUnsolicited, match, pollValue, setBinary, setOpCode, setUnsolicited, skipWhiteSpace, toString, value
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.Message
toMonitorString
-
-
-
-
Field Detail
-
MAXLEN
static final int MAXLEN
- See Also:
- Constant Field Values
-
_RTRoffset
int _RTRoffset
-
-
Constructor Detail
-
GridConnectReply
public GridConnectReply()
Creates a new instance of GridConnectReply.
-
GridConnectReply
public GridConnectReply(java.lang.String s)
Creates a new GridConnectReply from String.- Parameters:
s
- String to use as basis for the GCReply.
-
-
Method Detail
-
createReply
public CanReply createReply()
Create a CanReply from a GridConnectReply.- Returns:
- new CanReply Outgoing message.
-
basicFormatCheck
protected boolean basicFormatCheck()
Check if this GCReply contains an Extended or Standard flag.- Returns:
- true if contains a flag, else false.
-
skipPrefix
protected int skipPrefix(int index)
- Specified by:
skipPrefix
in classAbstractMRReply
-
getNumDataElements
public int getNumDataElements()
Get the number of data elements in a Message.- Specified by:
getNumDataElements
in interfaceMessage
- Overrides:
getNumDataElements
in classAbstractMessage
- Returns:
- number elements.
-
setNumDataElements
public void setNumDataElements(int n)
Set Number of Data Elements. Max. length set by the MAXLEN constant.- Parameters:
n
- Number Elements.
-
getElement
public int getElement(int n)
Get a particular element in a Message.- Specified by:
getElement
in interfaceMessage
- Overrides:
getElement
in classAbstractMessage
- Parameters:
n
- Element Index.- Returns:
- single element of message.
-
setElement
public void setElement(int n, int v)
Set a single Data Element at a particular index.- Specified by:
setElement
in interfaceMessage
- Overrides:
setElement
in classAbstractMRReply
- Parameters:
n
- index of element.v
- value of element.
-
isExtended
public boolean isExtended()
Get if the GridConnectReply is Extended.- Returns:
- true if extended, else false.
-
isRtr
public boolean isRtr()
Get if the GridConnectReply is RtR.- Returns:
- true if RtR, else false.
-
maxSize
public int maxSize()
- Overrides:
maxSize
in classAbstractMRReply
-
setData
public void setData(int[] d)
Set the GridConnectReply data by Array.- Parameters:
d
- data array.
-
getHeader
public int getHeader()
Get the CAN header by using chars from 2 to up to 9.Right justify standard headers that had 4 digits.
- Returns:
- the CAN header as an int
-
getNumBytes
public int getNumBytes()
Get the number of data bytes.- Returns:
- number of bytes in reply.
-
getByte
public int getByte(int b)
Get a hex data byte from the message.Data bytes are encoded as two ASCII hex digits starting at byte 7 of the message.
- Parameters:
b
- The byte offset (0 - 7)- Returns:
- The value
-
-