Class GridConnectMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.can.adapters.gridconnect.GridConnectMessage
-
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
GridConnectDoubledMessage
,MergMessage
public class GridConnectMessage extends AbstractMRMessage
Class for GridConnect messages for a CAN hardware adapter.The GridConnect protocol encodes messages as an ASCII string of up to 24 characters of the form: :ShhhhNd0d1d2d3d4d5d6d7;
The S indicates a standard CAN frame :XhhhhhhhhNd0d1d2d3d4d5d6d7; The X indicates an extended CAN frame hhhh is the two byte header 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 inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description GridConnectMessage()
Create a new instance of GridConnectMessage.GridConnectMessage(CanMessage m)
Create a new GridConnectMessage from CanMessage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getElement(int n)
Get a particular element in a Message.int
getNumDataElements()
Get the number of data elements in a Message.boolean
isExtended()
Get if the GC Message is Extended.void
setByte(int val, int n)
Set a byte as two ASCII hex digits.void
setData(int[] d)
Set data from array.void
setElement(int n, int v)
Set a single Data Element at a particular index.void
setExtended(boolean extended)
Set the GC Message as Extended.void
setHeader(int header)
Set the header.protected void
setHexDigit(int val, int n)
Set a hex digit at offset n in _dataChars.void
setNumDataElements(int n)
Set Number of Data Elements.void
setRtr(boolean rtr)
Set CAN Frame as RtR.-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCode, getOpCodeHex, getRetries, getTimeout, isBinary, replyExpected, setBinary, setNeededMode, setOpCode, setRetries, setTimeout, toString
-
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
-
-
-
-
Constructor Detail
-
GridConnectMessage
public GridConnectMessage()
Create a new instance of GridConnectMessage.
-
GridConnectMessage
public GridConnectMessage(CanMessage m)
Create a new GridConnectMessage from CanMessage.- Parameters:
m
- CanMessage outgoing from JMRI.
-
-
Method Detail
-
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.- Parameters:
n
- number Elements. Max 28.
-
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 classAbstractMessage
- Parameters:
n
- index of element.v
- value of element.
-
setData
public void setData(int[] d)
Set data from array.- Parameters:
d
- array, max length 24.
-
setExtended
public void setExtended(boolean extended)
Set the GC Message as Extended.- Parameters:
extended
- true for extended, else false
-
isExtended
public boolean isExtended()
Get if the GC Message is Extended.- Returns:
- true for extended, else false
-
setHeader
public void setHeader(int header)
Set the header.- Parameters:
header
- A valid CAN header value.
-
setRtr
public void setRtr(boolean rtr)
Set CAN Frame as RtR.- Parameters:
rtr
- true to set rtr, else false.
-
setByte
public void setByte(int val, int n)
Set a byte as two ASCII hex digits.Data bytes are encoded as two ASCII hex digits starting at byte 7 of the message.
- Parameters:
val
- the value to set.n
- the index of the byte to be set.
-
setHexDigit
protected void setHexDigit(int val, int n)
Set a hex digit at offset n in _dataChars.- Parameters:
val
- min 0, max value 15.n
- _dataChars Array Index.
-
-