Class AutoTurnouts


  • public class AutoTurnouts
    extends java.lang.Object
    Handles automatic checking and setting of turnouts when Dispatcher allocates a Section in a specific direction.

    This file is part of JMRI.

    JMRI is open source software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

    JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    • Method Detail

      • checkTurnoutsInSection

        protected java.util.List<LayoutTrackExpectedState<LayoutTurnout>> checkTurnoutsInSection​(Section s,
                                                                                                 int seqNum,
                                                                                                 Section nextSection,
                                                                                                 ActiveTrain at,
                                                                                                 Section prevSection)
        Check that all turnouts are correctly set for travel in the designated Section to the next Section. NOTE: This method requires use of the connectivity stored in a Layout Editor panel. NOTE: This method removes the need to specify the LayoutEditor panel.
        Parameters:
        s - the section to check
        seqNum - sequence number for the section
        nextSection - the following section
        at - the associated train
        prevSection - the prior section
        Returns:
        list of turnouts and their expected states if affected turnouts are correctly set; null otherwise.
      • setTurnoutsInSection

        protected java.util.List<LayoutTrackExpectedState<LayoutTurnout>> setTurnoutsInSection​(Section s,
                                                                                               int seqNum,
                                                                                               Section nextSection,
                                                                                               ActiveTrain at,
                                                                                               boolean trustKnownTurnouts,
                                                                                               Section prevSection)
        Set all turnouts for travel in the designated Section to the next Section. Checks that all turnouts are correctly set for travel in this Section to the next Section, and sets any turnouts that are not correct. The Section must be FREE to set its turnouts. Testing for FREE only occurs if a command needs to be issued. For a command to be issued to set a turnout, the Block containing that turnout must be unoccupied. NOTE: This method does not wait for turnout feedback--it assumes the turnout will be set correctly if a command is issued. NOTE: This method removes the need to specify the LayoutEditor panel.
        Parameters:
        s - the section to check
        seqNum - sequence number for the section
        nextSection - the following section
        at - the associated train
        trustKnownTurnouts - true to trust known turnouts
        prevSection - the prior section
        Returns:
        list of turnouts and their expected states if affected turnouts are correctly set or commands have been issued to set any that aren't set correctly; null if a needed command could not be issued because the turnout's Block is occupied