Interface LocoNetInterface
-
- All Known Implementing Classes:
IBLnPacketizer
,LnOverTcpPacketizer
,LnPacketizer
,LnPacketizerStrict
,LnPr2Packetizer
,LnStreamPortPacketizer
,LnTrafficController
,LnTrafficRouter
,LocoNetThrottledTransmitter
,UhlenbrockPacketizer
,Z21LnStreamPortPacketizer
public interface LocoNetInterface
LocoNetInterface defines the general connection to a LocoNet layout.Use this interface to send messages to a LocoNet layout. Classes implementing the LocoNetListener interface can register here to receive incoming LocoNet messages as events.
The jmri.jrmix.loconet.LnTrafficController provides the first implementation of this interface.
How do you locate an implemenation of this interface? That's an interesting question. This is inherently LocoNet specific, so it would be inappropriate to put it in the jmri.InterfaceManager. And Java interfaces can't have static members, so we can't provide an implementation() member. For now, we use a static implementation member in the LnTrafficManager implementation to locate _any_ implementation; this clearly needs to be improved.
LocoNetListener implementations registering for traffic updates cannot assume that messages will be returned in any particular thread. See the LocoNetListener doc for more background.
- See Also:
LocoNetListener
,LnTrafficController
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL
Mask value to request notification of all incoming messagesstatic int
POWER
Mask value to request notification of messages associated with layout powerstatic int
PROGRAMMING
Mask value to request notification of messages associated with programmingstatic int
SENSORS
Mask value to request notification of messages indicating changes in sensor statusstatic int
SLOTINFO
Mask value to request notification of messages effecting slot status, including the programming slotstatic int
TURNOUTS
Mask value to request notification of messages indicating changes in turnout status
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addLocoNetListener(int mask, LocoNetListener listener)
Request notification of things happening on the LocoNet.LocoNetSystemConnectionMemo
getSystemConnectionMemo()
Get the system connection memo associated with this connection.void
removeLocoNetListener(int mask, LocoNetListener listener)
void
sendLocoNetMessage(LocoNetMessage msg)
void
setSystemConnectionMemo(LocoNetSystemConnectionMemo m)
Set the system connection memo associated with this connection.boolean
status()
Check whether an implementation is operational.
-
-
-
Field Detail
-
ALL
static final int ALL
Mask value to request notification of all incoming messages- See Also:
- Constant Field Values
-
SLOTINFO
static final int SLOTINFO
Mask value to request notification of messages effecting slot status, including the programming slot- See Also:
- Constant Field Values
-
PROGRAMMING
static final int PROGRAMMING
Mask value to request notification of messages associated with programming- See Also:
- Constant Field Values
-
TURNOUTS
static final int TURNOUTS
Mask value to request notification of messages indicating changes in turnout status- See Also:
- Constant Field Values
-
SENSORS
static final int SENSORS
Mask value to request notification of messages indicating changes in sensor status- See Also:
- Constant Field Values
-
POWER
static final int POWER
Mask value to request notification of messages associated with layout power- See Also:
- Constant Field Values
-
-
Method Detail
-
sendLocoNetMessage
void sendLocoNetMessage(LocoNetMessage msg)
-
addLocoNetListener
void addLocoNetListener(int mask, LocoNetListener listener)
Request notification of things happening on the LocoNet.The same listener can register multiple times with different masks. (Multiple registrations with a single mask value are equivalent to a single registration) Mask values are defined as class constants. Note that these are bit masks, and should be OR'd, not added, if multiple values are desired.
The event notification contains the received message as source, not this object, so that we can notify of an incoming message to multiple places and then move on.
- Parameters:
mask
- The OR of the key values of messages to be reported (to reduce traffic, provide for listeners interested in different things)listener
- Object to be notified of new messages as they arrive.
-
removeLocoNetListener
void removeLocoNetListener(int mask, LocoNetListener listener)
-
status
boolean status()
Check whether an implementation is operational. Returns true if operational.- Returns:
- true if implementation is operational.
-
setSystemConnectionMemo
void setSystemConnectionMemo(LocoNetSystemConnectionMemo m)
Set the system connection memo associated with this connection.- Parameters:
m
- associated systemConnectionMemo object
-
getSystemConnectionMemo
LocoNetSystemConnectionMemo getSystemConnectionMemo()
Get the system connection memo associated with this connection.- Returns:
- the associated systemConnectionMemo object
-
-