Package jmri.jmrix.can.cbus
Class CbusEvent
- java.lang.Object
-
- jmri.jmrix.can.cbus.CbusEventDataElements
-
- jmri.jmrix.can.cbus.CbusEvent
-
- Direct Known Subclasses:
CbusBasicNodeEvent
,CbusEventRequestMonitorEvent
,CbusTableEvent
public class CbusEvent extends CbusEventDataElements
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.can.cbus.CbusEventDataElements
CbusEventDataElements.EvState
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_name
protected CbusEventDataElements.EvState
_state
-
Constructor Summary
Constructors Constructor Description CbusEvent(int nn, int en)
Create a new eventCbusEvent(CanSystemConnectionMemo memo, int nn, int en)
Create a new event by Connection
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
int
getEn()
Get event event numberjava.lang.String
getName()
Get event name.int
getNn()
Get event node number.java.lang.String
getNodeName()
Get Node name.CbusEventDataElements.EvState
getState()
Get state of the eventint
hashCode()
boolean
matches(int nn, int en)
Test if a node and event number combination matches this event.void
sendEvent(CbusEventDataElements.EvState state)
Send event CAN frame via ENUM.void
sendOff()
Send OFF event CAN frame.void
sendOn()
Send ON event CAN frame.void
sendRequest()
Send event status request CAN frame.void
setEn(int en)
Set event event number.void
setName(java.lang.String name)
Set event name.void
setNameIfNoName(java.lang.String name)
Set event name only if there is no existing name.void
setNn(int nn)
Set event node number.void
setState(CbusEventDataElements.EvState newval)
Set current state of the event.java.lang.String
toString()
Get a String with event overview.-
Methods inherited from class jmri.jmrix.can.cbus.CbusEventDataElements
getCanMessage, getData, getEvState, getJmriString, getNumElements, getNumEventDataElements, setData, setDataFromFrame, setNumElements
-
-
-
-
Field Detail
-
_state
protected CbusEventDataElements.EvState _state
-
_name
protected java.lang.String _name
-
-
Constructor Detail
-
CbusEvent
public CbusEvent(int nn, int en)
Create a new eventNew events have an unknown on or off status
- Parameters:
nn
- Node Numberen
- Event Number
-
CbusEvent
public CbusEvent(CanSystemConnectionMemo memo, int nn, int en)
Create a new event by ConnectionNew events have an unknown on or off status
- Parameters:
memo
- System Connectionnn
- Node Numberen
- Event Number
-
-
Method Detail
-
getState
public CbusEventDataElements.EvState getState()
Get state of the event- Returns:
- the enum event state, on off or unknown.
-
setState
public void setState(CbusEventDataElements.EvState newval)
Set current state of the event.Does NOT send update to layout.
- Parameters:
newval
- the enum event state ie ON, OFF, UNKNOWN
-
getEn
public int getEn()
Get event event number- Returns:
- event Number
-
getNn
public int getNn()
Get event node number.- Returns:
- node Number
-
setEn
public void setEn(int en)
Set event event number.- Parameters:
en
- Event Number, not restricted so can be -1 for unknown
-
setNn
public void setNn(int nn)
Set event node number.- Parameters:
nn
- Node Number, not restricted so can be -1 for unknown
-
setName
public void setName(java.lang.String name)
Set event name.- Parameters:
name
- new Event Name
-
setNameIfNoName
public void setNameIfNoName(@Nonnull java.lang.String name)
Set event name only if there is no existing name.- Parameters:
name
- Event Name
-
getNodeName
public java.lang.String getNodeName()
Get Node name.Helper method, node name not stored in event, retrieved via @CbusNameService
- Returns:
- Node Name
-
matches
public boolean matches(int nn, int en)
Test if a node and event number combination matches this event.- Parameters:
nn
- Node Numberen
- Event Number- Returns:
- true on match, else false
-
equals
public boolean equals(java.lang.Object o)
Custom method to compare Node Number and Event Number.
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
sendOn
public void sendOn()
Send ON event CAN frame.Long event if Node num greater than 0, else short.
-
sendOff
public void sendOff()
Send OFF event CAN frame.Long event if Node num greater than 0, else short.
-
sendRequest
public void sendRequest()
Send event status request CAN frame.Long request if Node num greater than 0, else short.
-
sendEvent
public void sendEvent(CbusEventDataElements.EvState state)
Send event CAN frame via ENUM.Also updates the event status as per the enum value.
If current state unknown, toggle sends event off.
Long event if Node num greater than 0, else short.
- Parameters:
state
- The enum state requested to be sent, ie ON, OFF, REQUEST, TOGGLE
-
toString
public java.lang.String toString()
Get a String with event overview.- Overrides:
toString
in classjava.lang.Object
- Returns:
- includes event name and node name if known
-
-