Package jmri

Class BlockManager

    • Method Detail

      • getXMLOrder

        @CheckReturnValue
        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<Block>
        Returns:
        write order for this Manager; larger is later.
      • getNamedBeanClass

        public java.lang.Class<BlockgetNamedBeanClass()
        Description copied from interface: Manager
        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<Block>
        Returns:
        the class supported by this Manager.
      • createNewBlock

        @CheckForNull
        public Block createNewBlock​(@Nonnull
                                    java.lang.String systemName,
                                    @CheckForNull
                                    java.lang.String userName)
        Create a new Block, only if it does not exist.
        Parameters:
        systemName - the system name
        userName - the user name
        Returns:
        null if a Block with the same systemName or userName already exists, or if there is trouble creating a new Block
      • createNewBlock

        @CheckForNull
        public Block createNewBlock​(@CheckForNull
                                    java.lang.String userName)
        Create a new Block using an automatically incrementing system name.
        Parameters:
        userName - the user name for the new Block
        Returns:
        null if a Block with the same systemName or userName already exists, or if there is trouble creating a new Block.
      • provideBlock

        @Nonnull
        public Block provideBlock​(@Nonnull
                                  java.lang.String name)
        If the Block exists, return it, otherwise create a new one and return it. If the argument starts with the system prefix and type letter, usually "IB", then the argument is considered a system name, otherwise it's considered a user name and a system name is automatically created.
        Parameters:
        name - the system name or the user name for the block
        Returns:
        a new or existing Block
        Throws:
        java.lang.IllegalArgumentException - if cannot create block or no name supplied; never returns null
      • getBlock

        @CheckReturnValue
        @CheckForNull
        public Block getBlock​(@Nonnull
                              java.lang.String name)
        Get an existing Block. First looks up assuming that name is a User Name. If this fails looks up assuming that name is a System Name. If both fail, returns null.
        Parameters:
        name - the name of an existing block
        Returns:
        a Block or null if none found
      • setDefaultSpeed

        public void setDefaultSpeed​(@Nonnull
                                    java.lang.String speed)
        Parameters:
        speed - the speed
        Throws:
        java.lang.IllegalArgumentException - if provided speed is invalid
      • getBeanTypeHandled

        @CheckReturnValue
        @Nonnull
        public java.lang.String getBeanTypeHandled​(boolean plural)
        Description copied from interface: Manager
        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<Block>
        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
      • getBlocksOccupiedByRosterEntry

        @CheckReturnValue
        @Nonnull
        public java.util.List<BlockgetBlocksOccupiedByRosterEntry​(@Nonnull
                                                                    BasicRosterEntry re)
        Get a list of blocks which the supplied roster entry appears to be occupying. A block is assumed to contain this roster entry if its value is the RosterEntry itself, or a string with the entry's id or dcc address.
        Parameters:
        re - the roster entry
        Returns:
        list of block system names
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Listen for changes to the power state from any power managers in use in order to track how long it's been since power was applied to the layout. This information is used in Block.goingActive() when deciding whether to restore a block's last value. Also listen for additions/removals or PowerManagers
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Overrides:
        propertyChange in class AbstractManager<Block>
        Parameters:
        e - the change event
      • timeSinceLastLayoutPowerOn

        public long timeSinceLastLayoutPowerOn()
        Get the amount of time since the layout was last powered up, in milliseconds. If the layout has not been powered up as far as JMRI knows it returns a very long time indeed.
        Returns:
        long int