Package jmri

Interface Logix

  • All Superinterfaces:
    java.lang.Comparable<NamedBean>, NamedBean, PropertyChangeProvider
    All Known Implementing Classes:
    DefaultLogix

    public interface Logix
    extends NamedBean
    A Logix is a group of Conditionals that monitor one or more conditions (internal or on the layout). It services these Conditionals by installing and deinstalling the proper listeners for their variables.

    A Logix can be enabled or not. It passes this attribute to its Conditionals. By default it is enabled. When not enabled, a Conditional will still respond to callbacks from its listeners and calculate its state, however it will not execute its actions. Enabled is a bound property of a Logix.

    A Logix can be deactivated or not. When deactivated, the listeners of the Conditional variables are deinstalled.

    A Logix does not have a "state", however, each of its Conditionals does.


    This file is part of JMRI.

    JMRI is free 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

      • setEnabled

        void setEnabled​(boolean state)
        Set enabled status. Enabled is a bound property All conditionals are set to UNKNOWN state and recalculated when the Logix is enabled, provided the Logix has been previously activated.
        Parameters:
        state - true if Logix should be enabled; false otherwise
      • getEnabled

        boolean getEnabled()
        Get enabled status.
        Returns:
        true if enabled; false otherwise
      • getNumConditionals

        int getNumConditionals()
        Get number of Conditionals for this Logix.
        Returns:
        the number of conditionals
      • swapConditional

        void swapConditional​(int nextInOrder,
                             int row)
        Move 'row' to 'nextInOrder' and shift all between 'nextInOrder' and 'row' up one position. Requires row > nextInOrder.
        Parameters:
        nextInOrder - target order for Conditional at row
        row - position of Conditional to move
      • getConditionalByNumberOrder

        java.lang.String getConditionalByNumberOrder​(int order)
        Returns the system name of the conditional that will calculate in the specified order. This is also the order the Conditional is listed in the Add/Edit Logix dialog. If 'order' is greater than the number of Conditionals for this Logix, and empty String is returned.
        Parameters:
        order - order in which the Conditional calculates
        Returns:
        system name of conditional or an empty String
      • addConditional

        boolean addConditional​(java.lang.String systemName,
                               int order)
        Add a Conditional name and sequence number to this Logix.
        Parameters:
        systemName - The Conditional system name
        order - the order this conditional should calculate in if order is negative, the conditional is added at the end of current group of conditionals
        Returns:
        true if the Conditional was added, false otherwise (most likely false indicates that maximum number of Conditionals was exceeded)
      • addConditional

        boolean addConditional​(java.lang.String systemName,
                               Conditional conditional)
        Add a child Conditional to the parent Logix.
        Parameters:
        systemName - The system name for the Conditional object.
        conditional - The Conditional object.
        Returns:
        true if the Conditional was added, false otherwise.
        Since:
        4.7.4
      • getConditional

        Conditional getConditional​(java.lang.String systemName)
        Get a Conditional belonging to this Logix.
        Parameters:
        systemName - The name of the Conditional object.
        Returns:
        the Conditional object or null if not found.
        Since:
        4.7.4
      • deleteConditional

        java.lang.String[] deleteConditional​(java.lang.String systemName)
        Delete a Conditional from this Logix.

        Note: Since each Logix must have at least one Conditional, the last Conditional will not be deleted.

        Returns An array of names used in an error message explaining why Conditional should not be deleted.

        Parameters:
        systemName - The Conditional system name
        Returns:
        names of objects blocking deletion or null; note that null does not exclusively indicate successful deletion
      • calculateConditionals

        void calculateConditionals()
        Calculate all Conditionals, triggering action if the user specified conditions are met, and the Logix is enabled.
      • activateLogix

        void activateLogix()
        Activate the Logix, starts Logix processing by connecting all inputs that are included the Conditionals in this Logix.

        A Logix must be activated before it will calculate any of its Conditionals.

      • deActivateLogix

        void deActivateLogix()
        Deactivate the Logix. This method disconnects the Logix from all input objects and stops it from being triggered to calculate.

        A Logix must be deactivated before its Conditionals are changed.

      • setGuiNames

        void setGuiNames()
        ConditionalVariables only have a single name field. For user interface purposes a gui name is used for the referenced conditional user name. This is not used for other object types.

        In addition to setting the GUI name, any state variable references are changed to conditional system names. This converts the XML system/user name field to the system name for conditional references. It does not affect other objects such as sensors, turnouts, etc.

        Since:
        4.7.4