Package jmri.jmrix.can.cbus.simulator
Class CbusSimCanListener
- java.lang.Object
-
- jmri.jmrix.can.cbus.node.CbusNodeCanListener
-
- jmri.jmrix.can.cbus.simulator.CbusSimCanListener
-
- All Implemented Interfaces:
java.util.EventListener
,AbstractMRListener
,CanListener
- Direct Known Subclasses:
CbusDummyCS
,CbusDummyNodeCanListener
,CbusEventResponder
public class CbusSimCanListener extends CbusNodeCanListener
Simulating event request responses.- Since:
- 4.15.2
- See Also:
CbusSimulator
-
-
Field Summary
Fields Modifier and Type Field Description CbusSend
send
-
Fields inherited from class jmri.jmrix.can.cbus.node.CbusNodeCanListener
memo
-
-
Constructor Summary
Constructors Constructor Description CbusSimCanListener(CanSystemConnectionMemo memo, CbusNode node)
Create a CanListener with Common Simulation setting attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Disconnects from networkint
getDelay()
Get the simulated network delay.boolean
getProcessIn()
Get if to Listen for CanReply Frames incoming to JMRI.boolean
getProcessOut()
Get if to Listen for CanMessage Frames outgoing to JMRI.boolean
getSendIn()
Get if to Send Frames from the Sim as Incoming CanReply.boolean
getSendOut()
Get if to Send Frames from the Sim as Outgoing CanMessage.void
message(CanMessage m)
Forwards non-extended CanMessage according to #getProcessOut Processes certain outgoing CAN Frames.void
reply(CanReply r)
Forwards non-extended CanReply according to #getProcessIn Processes all incoming and certain outgoing CAN Frames Called when an incoming CanFrame is received from the CAN Network.void
setDelay(int delay)
Set the simulated network delay.void
setProcessIn(boolean newval)
Set if to Listen for CanReply Frames incoming to JMRI.void
setProcessOut(boolean newval)
Set if to Listen for CanMessage Frames outgoing to JMRI.void
setSendIn(boolean newval)
Set if to Send Frames from the Sim as Incoming CanReply.void
setSendOut(boolean newval)
Set if to Send Frames from the Sim as Outgoing CanMessage.protected void
startProcessFrame(AbstractMessage m)
Method to be overridden by extending methods.-
Methods inherited from class jmri.jmrix.can.cbus.node.CbusNodeCanListener
setParamsFromSetup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.can.CanListener
addTc, addTc, removeTc, removeTc
-
-
-
-
Constructor Detail
-
CbusSimCanListener
public CbusSimCanListener(CanSystemConnectionMemo memo, CbusNode node)
Create a CanListener with Common Simulation setting attributes.- Parameters:
memo
- System Connectionnode
- Node ( if a CbusDummyNode ), else use null
-
-
Method Detail
-
setDelay
public final void setDelay(int delay)
Set the simulated network delay.- Parameters:
delay
- Delay in ms
-
getDelay
public final int getDelay()
Get the simulated network delay. Defaults to 50ms- Returns:
- delay in ms
-
setProcessIn
public final void setProcessIn(boolean newval)
Set if to Listen for CanReply Frames incoming to JMRI.- Parameters:
newval
- true to listen, else false
-
setProcessOut
public final void setProcessOut(boolean newval)
Set if to Listen for CanMessage Frames outgoing to JMRI.- Parameters:
newval
- true to listen, else false
-
setSendIn
public final void setSendIn(boolean newval)
Set if to Send Frames from the Sim as Incoming CanReply.- Parameters:
newval
- true to send as incoming
-
setSendOut
public final void setSendOut(boolean newval)
Set if to Send Frames from the Sim as Outgoing CanMessage.- Parameters:
newval
- true to send as outgoing
-
getProcessIn
public final boolean getProcessIn()
Get if to Listen for CanReply Frames incoming to JMRI. Defaults to false- Returns:
- true to listen, else false
-
getProcessOut
public final boolean getProcessOut()
Get if to Listen for CanMessage Frames outgoing to JMRI. Defaults to true- Returns:
- true to listen, else false
-
getSendIn
public final boolean getSendIn()
Get if to Send Frames from the Sim as Incoming CanReply. Defaults to true- Returns:
- true to send as incoming
-
getSendOut
public final boolean getSendOut()
Get if to Send Frames from the Sim as Outgoing CanMessage. Defaults to false- Returns:
- true to send as outgoing
-
startProcessFrame
protected void startProcessFrame(AbstractMessage m)
Method to be overridden by extending methods.- Parameters:
m
- CanFrame or CanReply to process
-
message
public final void message(CanMessage m)
Forwards non-extended CanMessage according to #getProcessOut Processes certain outgoing CAN Frames.We don't know if it's this JMRI instance or something external teaching the node so we monitor them the same Called when an outgoing message is sent to the CAN Network.
- Specified by:
message
in interfaceCanListener
- Overrides:
message
in classCbusNodeCanListener
- Parameters:
m
- the CanMessage being sent.
-
reply
public final void reply(CanReply r)
Forwards non-extended CanReply according to #getProcessIn Processes all incoming and certain outgoing CAN Frames Called when an incoming CanFrame is received from the CAN Network.- Specified by:
reply
in interfaceCanListener
- Overrides:
reply
in classCbusNodeCanListener
- Parameters:
r
- the CanReply being received.
-
dispose
@OverridingMethodsMustInvokeSuper public void dispose()
Disconnects from network- Overrides:
dispose
in classCbusNodeCanListener
-
-