Class DCCppTurnout

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.lang.Comparable<NamedBean>, java.util.EventListener, PropertyChangeProvider, DigitalIO, AbstractMRListener, DCCppListener, NamedBean, Turnout, VariableControlSpanBean

    public class DCCppTurnout
    extends AbstractTurnout
    implements DCCppListener
    Extends jmri.AbstractTurnout for DCCpp layouts

    Turnouts on DCC++ are controlled (as of V1.5 Firmware) with unidirectional Stationary Decoder commands, or with bidirectional (predefined) Turnout commands, or with bidirectional (predefined) Output commands. DCC++ Has three ways to activate a turnout (output)

    • Accessory Command "a" : sends a DCC packet to a stationary decoder out there on the bus somewhere. NO RETURN VALUE to JMRI.
    • Turnout Command "T" : Looks up a DCC address from an internal table in the Base Station and sends that Stationary Decoder a packet. Returns a (basically faked) "H" response to JMRI indicating the (supposed) current state of the turnout. Or "X" if the indexed turnout is not in the list.
    • Output Command "z" : Looks up a Base Station Arduino Pin number from an internal lookup table, and sets/toggles the state of that pin. Returns a "Y" response indicating the actual state of the pin. Or "X" if the indexed pin is not in the list.
    The DCCppTurnout supports three types of feedback:
    • DIRECT: No actual feedback, uses Stationary Decoder command and fakes the response.
    • MONITORING: Uses the Turnout command, lets the Base Station fake the response :)
    • EXACT: Uses the Output command to directly address an Arduino pin.
    It also supports "NO FEEDBACK" by treating it like "DIRECT". Turnout operation on DCC++ based systems goes through the following sequence:
    • set the commanded state, and, Send request to command station to start sending DCC operations packet to track
    • Method Detail

      • forwardCommandChangeToLayout

        protected void forwardCommandChangeToLayout​(int s)
        Handle a request to change state, typically by sending a message to the layout in some child class. Public version (used by TurnoutOperator) sends the current commanded state without changing it. Implementing classes will typically check the value of s and send a system specific sendMessage command. Sends a DCC++ command.
        Specified by:
        forwardCommandChangeToLayout in class AbstractTurnout
        Parameters:
        s - new state value
      • initmessage

        void initmessage​(DCCppReply l)
        initmessage is a package proteceted class which allows the Manger to send a feedback message at initialization without changing the state of the turnout with respect to whether or not a feedback request was sent. This is used only when the turnout is created by on layout feedback.
        Parameters:
        l - Init message
      • message

        public void message​(DCCppReply l)
        Description copied from interface: DCCppListener
        Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.
        Specified by:
        message in interface DCCppListener
        Parameters:
        l - The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
      • message

        public void message​(DCCppMessage l)
        Description copied from interface: DCCppListener
        Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout. Normally, this function will do nothing.
        Specified by:
        message in interface DCCppListener
        Parameters:
        l - The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
      • notifyTimeout

        public void notifyTimeout​(DCCppMessage msg)
        Description copied from interface: DCCppListener
        Member function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.
        Specified by:
        notifyTimeout in interface DCCppListener
        Parameters:
        msg - the message that timed out.
      • dispose

        public void dispose()
        Description copied from class: AbstractTurnout
        Deactivate this object, so that it releases as many resources as possible and no longer effects others.

        For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

        It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

        Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.

        Specified by:
        dispose in interface NamedBean
        Overrides:
        dispose in class AbstractTurnout