Package jmri.jmrix.can.cbus
Class CbusEventDataElements
- java.lang.Object
-
- jmri.jmrix.can.cbus.CbusEventDataElements
-
- Direct Known Subclasses:
CbusEvent
public class CbusEventDataElements extends java.lang.Object
Class to enable storage and OPC calculation according to CBUS Event Data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CbusEventDataElements.EvState
ENUM of the event state.
-
Constructor Summary
Constructors Constructor Description CbusEventDataElements()
Create Data Elements for a CBUS Event
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CanMessage
getCanMessage(int canId, int nn, int en, CbusEventDataElements.EvState state)
Get a ready-to-send CanMessage with event details.int
getData(int index)
Get value of a single event Data Byte.static CbusEventDataElements.EvState
getEvState(AbstractMessage m)
Get the event state from a CAN Frame.static java.lang.String
getJmriString(int nn, int en)
int
getNumElements()
Get Number of Event Data Elements (bytes).static int
getNumEventDataElements(AbstractMessage m)
void
setData(int index, int value)
Set value of a single event Data Byte.void
setDataFromFrame(AbstractMessage m)
Set Event Data from CAN Frame.void
setNumElements(int elements)
Set Number of Event Data Elements (bytes).
-
-
-
Constructor Detail
-
CbusEventDataElements
public CbusEventDataElements()
Create Data Elements for a CBUS Event
-
-
Method Detail
-
getCanMessage
public CanMessage getCanMessage(int canId, int nn, int en, @Nonnull CbusEventDataElements.EvState state)
Get a ready-to-send CanMessage with event details.- Parameters:
canId
- CAN IDnn
- Node Numberen
- Event Numberstate
- Event State- Returns:
- ready to send CanMessage
-
setNumElements
public void setNumElements(int elements)
Set Number of Event Data Elements (bytes).- Parameters:
elements
- 0-3
-
getNumElements
public int getNumElements()
Get Number of Event Data Elements (bytes).- Returns:
- Number of Data Bytes
-
setData
public void setData(int index, int value)
Set value of a single event Data Byte.- Parameters:
index
- Event Index: 1, 2 or 3value
- Byte value 0-255
-
getData
public int getData(int index)
Get value of a single event Data Byte.- Parameters:
index
- Event Index: 1, 2 or 3- Returns:
- Byte value 0-255 , -1 for unset
-
getNumEventDataElements
public static int getNumEventDataElements(AbstractMessage m)
-
setDataFromFrame
public void setDataFromFrame(AbstractMessage m)
Set Event Data from CAN Frame.- Parameters:
m
- CanMessage or CanReply
-
getEvState
public static final CbusEventDataElements.EvState getEvState(AbstractMessage m)
Get the event state from a CAN Frame.- Parameters:
m
- CanMessage or CanReply- Returns:
- Event State ENUM of Off, On or Request
-
getJmriString
public static java.lang.String getJmriString(int nn, int en)
-
-