Interface DCCppInterface
- All Known Implementing Classes:
DCCppEthernetPacketizer,DCCppOverTcpPacketizer,DCCppPacketizer,DCCppTrafficController,SerialDCCppPacketizer
Use this interface to send messages to a DCC++ layout. Classes implementing the DCCppListener interface can register here to receive incoming DCC++ messages as events.
The jmri.jrmix.dccpp.DCCppTrafficControler provides the first implementation of this interface.
How do you locate an implemenation of this interface? That's an interesting question. This is inherently DCC++ 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 DCCppTrafficController implementation to locate _any_ implementation; this clearly needs to be improved.
DCCppListener implementations registering for traffic updates cannot assume that messages will be returned in any particular thread. See the DCCppListener doc for more background.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMask value to request notification of all incoming messagesstatic final intMask value to request notification of communications related messages generated by the computer interfacestatic final intMask value to request notification of messages associated with consistsstatic final intMask value to request notification of Command Station informational messages This includes all broadcast messages, except for the feedback broadcast and all programming messagesstatic final intMask value to request notification of FeedBack (i.e. sensor) related messagesstatic final intMask value to request notification of messages associated with consistsstatic final intMask value to request notification of messages associated with programmingstatic final intMask value to request notification of messages associated with throttle status -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDCCppListener(int mask, DCCppListener l) Request notification of things happening on the DCC++.voidremoveDCCppListener(int mask, DCCppListener listener) Stop notification of things happening on the XNet.voidsendDCCppMessage(DCCppMessage msg, DCCppListener replyTo) Request a message be sent to the attached DCC++.booleanstatus()Check whether an implementation is operational.
-
Field Details
-
ALL
Mask value to request notification of all incoming messages- See Also:
-
COMMINFO
Mask value to request notification of communications related messages generated by the computer interface- See Also:
-
CS_INFO
Mask value to request notification of Command Station informational messages This includes all broadcast messages, except for the feedback broadcast and all programming messages- See Also:
-
PROGRAMMING
Mask value to request notification of messages associated with programming- See Also:
-
FEEDBACK
Mask value to request notification of FeedBack (i.e. sensor) related messages- See Also:
-
THROTTLE
Mask value to request notification of messages associated with throttle status- See Also:
-
CONSIST
Mask value to request notification of messages associated with consists- See Also:
-
INTERFACE
Mask value to request notification of messages associated with consists- See Also:
-
-
Method Details
-
sendDCCppMessage
Request a message be sent to the attached DCC++. Return is immediate, with the message being queued for eventual sending. If you're interested in a reply, you need to register a DCCppListener object to watch the message stream. When sending, you specify (in 2nd parameter) who you are, so you're not redundantly notified of this message.- Parameters:
msg- message to send.replyTo- listener to receive replies.
-
addDCCppListener
Request notification of things happening on the DCC++.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)l- Object to be notified of new messages as they arrive.
-
removeDCCppListener
Stop notification of things happening on the XNet. Note that mask and XNetListener must match a previous request exactly.- 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 removal.
-
status
boolean status()Check whether an implementation is operational. True indicates OK.- Returns:
- true if implementation is operational.
-