Class DefaultLogixNGManager

    • Method Detail

      • getXMLOrder

        public int getXMLOrder()
        Description copied from interface: Manager
        Determine the order that types should be written when storing panel files. Uses one of the constants defined in this class.

        Yes, that's an overly-centralized methodology, but it works for now.

        Specified by:
        getXMLOrder in interface Manager<LogixNG>
        Returns:
        write order for this Manager; larger is later.
      • createLogixNG

        public LogixNG createLogixNG​(java.lang.String systemName,
                                     java.lang.String userName)
                              throws java.lang.IllegalArgumentException
        Method to create a new LogixNG if the LogixNG does not exist.

        Returns null if a Logix with the same systemName or userName already exists, or if there is trouble creating a new LogixNG.

        Specified by:
        createLogixNG in interface LogixNG_Manager
        Parameters:
        systemName - the system name
        userName - the user name
        Returns:
        a new LogixNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • createLogixNG

        public LogixNG createLogixNG​(java.lang.String systemName,
                                     java.lang.String userName,
                                     boolean inline)
                              throws java.lang.IllegalArgumentException
        Method to create a new LogixNG if the LogixNG does not exist.

        Returns null if a Logix with the same systemName or userName already exists, or if there is trouble creating a new LogixNG.

        Specified by:
        createLogixNG in interface LogixNG_Manager
        Parameters:
        systemName - the system name
        userName - the user name
        inline - true if this LogixNG is an inline LogixNG
        Returns:
        a new LogixNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • createLogixNG

        public LogixNG createLogixNG​(java.lang.String userName)
                              throws java.lang.IllegalArgumentException
        Description copied from interface: LogixNG_Manager
        For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.
        Specified by:
        createLogixNG in interface LogixNG_Manager
        Parameters:
        userName - the user name
        Returns:
        a new LogixNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • createLogixNG

        public LogixNG createLogixNG​(java.lang.String userName,
                                     boolean inline)
                              throws java.lang.IllegalArgumentException
        Description copied from interface: LogixNG_Manager
        For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.
        Specified by:
        createLogixNG in interface LogixNG_Manager
        Parameters:
        userName - the user name
        inline - true if this LogixNG is an inline LogixNG
        Returns:
        a new LogixNG or null if unable to create
        Throws:
        java.lang.IllegalArgumentException
      • getLogixNG

        public LogixNG getLogixNG​(java.lang.String name)
        Description copied from interface: LogixNG_Manager
        Locate via user name, then system name if needed. Does not create a new one if nothing found
        Specified by:
        getLogixNG in interface LogixNG_Manager
        Parameters:
        name - User name or system name to match
        Returns:
        null if no match found
      • getBeanTypeHandled

        public java.lang.String getBeanTypeHandled​(boolean plural)
        Get the user-readable name of the type of NamedBean handled by this manager.

        For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.

        Specified by:
        getBeanTypeHandled in interface Manager<LogixNG>
        Parameters:
        plural - true to return plural form of the type; false to return singular form
        Returns:
        a string of the bean type that the manager handles, eg Turnout, Sensor etc
      • setLoadDisabled

        public void setLoadDisabled​(boolean value)
        Should the LogixNGs be disabled when the configuration file is loaded?
        Specified by:
        setLoadDisabled in interface LogixNG_Manager
        Parameters:
        value - true if they should be disabled, false otherwise.
      • startLogixNGsOnLoad

        public void startLogixNGsOnLoad​(boolean value)
        Should the LogixNGs be started when the configuration file is loaded?
        Specified by:
        startLogixNGsOnLoad in interface LogixNG_Manager
        Parameters:
        value - true if they should be started, false otherwise.
      • activateAllLogixNGs

        public void activateAllLogixNGs()
        Activate all LogixNGs, starts LogixNG processing by connecting all inputs that are included the ConditionalNGs in this LogixNG.

        A LogixNG must be activated before it will calculate any of its ConditionalNGs.

        Specified by:
        activateAllLogixNGs in interface LogixNG_Manager
      • activateAllLogixNGs

        public void activateAllLogixNGs​(boolean runDelayed,
                                        boolean runOnSeparateThread)
        Activate all LogixNGs, starts LogixNG processing by connecting all inputs that are included the ConditionalNGs in this LogixNG.

        A LogixNG must be activated before it will calculate any of its ConditionalNGs.

        Specified by:
        activateAllLogixNGs in interface LogixNG_Manager
        Parameters:
        runDelayed - true if execute() should run on LogixNG thread delayed, false otherwise.
        runOnSeparateThread - true if the activation should run on a separate thread, false otherwise
      • deActivateAllLogixNGs

        public void deActivateAllLogixNGs()
        DeActivate all LogixNGs, stops LogixNG processing by disconnecting all inputs that are included the ConditionalNGs in this LogixNG.

        A LogixNG must be activated before it will calculate any of its ConditionalNGs.

        Specified by:
        deActivateAllLogixNGs in interface LogixNG_Manager
      • isActive

        public boolean isActive()
        Is LogixNGs active?
        Specified by:
        isActive in interface LogixNG_Manager
        Returns:
        true if LogixNGs are active, false otherwise
      • deleteLogixNG

        public void deleteLogixNG​(LogixNG x)
        Delete LogixNG by removing it from the manager. The LogixNG must first be deactivated so it stops processing.
        Specified by:
        deleteLogixNG in interface LogixNG_Manager
        Parameters:
        x - the LogixNG to delete
      • printTree

        public void printTree​(Base.PrintTreeSettings settings,
                              java.io.PrintWriter writer,
                              java.lang.String indent,
                              MutableInt lineNumber)
        Print the tree to a stream.
        Specified by:
        printTree in interface LogixNG_Manager
        Parameters:
        settings - settings for what to print
        writer - the stream to print the tree to
        indent - the indentation of each level
        lineNumber - the line number
      • printTree

        public void printTree​(Base.PrintTreeSettings settings,
                              java.util.Locale locale,
                              java.io.PrintWriter writer,
                              java.lang.String indent,
                              MutableInt lineNumber)
        Print the tree to a stream.
        Specified by:
        printTree in interface LogixNG_Manager
        Parameters:
        settings - settings for what to print
        locale - The locale to be used
        writer - the stream to print the tree to
        indent - the indentation of each level
        lineNumber - the line number
      • getNamedBeanClass

        public java.lang.Class<LogixNGgetNamedBeanClass()
        Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.
        Specified by:
        getNamedBeanClass in interface Manager<LogixNG>
        Returns:
        the class supported by this Manager.
      • fireVetoableChange

        @OverridingMethodsMustInvokeSuper
        public void fireVetoableChange​(java.lang.String p,
                                       java.lang.Object old)
                                throws java.beans.PropertyVetoException
        Inform all registered listeners of a vetoable change.If the propertyName is "CanDelete" ALL listeners with an interest in the bean will throw an exception, which is recorded returned back to the invoking method, so that it can be presented back to the user.However if a listener decides that the bean can not be deleted then it should throw an exception with a property name of "DoNotDelete", this is thrown back up to the user and the delete process should be aborted.
        Parameters:
        p - The programmatic name of the property that is to be changed. "CanDelete" will inquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item.
        old - The old value of the property.
        Throws:
        java.beans.PropertyVetoException - If the recipients wishes the delete to be aborted (see above)
      • deleteBean

        public final void deleteBean​(@Nonnull
                                     LogixNG logixNG,
                                     @Nonnull
                                     java.lang.String property)
                              throws java.beans.PropertyVetoException
        Method for a UI to delete a bean.

        The UI should first request a "CanDelete", this will return a list of locations (and descriptions) where the bean is in use via throwing a VetoException, then if that comes back clear, or the user agrees with the actions, then a "DoDelete" can be called which inform the listeners to delete the bean, then it will be deregistered and disposed of.

        If a property name of "DoNotDelete" is thrown back in the VetoException then the delete process should be aborted.

        Specified by:
        deleteBean in interface Manager<LogixNG>
        Overrides:
        deleteBean in class AbstractManager<LogixNG>
        Parameters:
        logixNG - The NamedBean to be deleted
        property - The programmatic name of the request. "CanDelete" will enquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item
        Throws:
        java.beans.PropertyVetoException - If the recipients wishes the delete to be aborted (see above)
      • propertyChange

        @OverridingMethodsMustInvokeSuper
        public void propertyChange​(java.beans.PropertyChangeEvent e)
        The PropertyChangeListener interface in this class is intended to keep track of user name changes to individual NamedBeans. It is not completely implemented yet. In particular, listeners are not added to newly registered objects.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Overrides:
        propertyChange in class AbstractManager<LogixNG>
        Parameters:
        e - the event