Class TurnoutNumberMapHandler

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener

    public class TurnoutNumberMapHandler
    extends java.lang.Object
    implements java.beans.PropertyChangeListener
    Handle the mapping from a Z21 turnout number to a JMRI Named Bean. This is not restricted to just JMRI turnouts, the mapping works for: - Turnouts - Lights (thrown = ON, closed = OFF - Routes (thrown sets the route, closed does nothing) - Signal Masts and Signal Heads (closed = HELD, thrown = not HELD, the aspect/appearance itself can not be modified) - Sensors (thrown = ACTIVE, closed = INACTIVE). Used to triggers all actions bound to the sensor If a component should be used by a Z21 turnout number, the number will be stored in a property of the bean.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String beanProperty  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()
      on destruction of the instance - would probably never occur...
      static TurnoutNumberMapHandler getInstance()  
      static java.lang.Class<?>[] getManagerClassList()  
      int getStateForNumber​(int turnoutNumber)
      Get the state of a component given by the Z21 Turnout Number.
      void loadNumberList()
      Load our local hash map, so we have a cache
      void propertyChange​(java.beans.PropertyChangeEvent e)
      Property change listener.
      void setStateForNumber​(int turnoutNumber, int state)
      Set the state of a component identified by the mapped number from a turnout state (THROWN or CLOSED)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getStateForNumber

        public int getStateForNumber​(int turnoutNumber)
        Get the state of a component given by the Z21 Turnout Number. Get the the component from the hash map. The state is either THROWN, CLOSED or UNKNOWN. For other components than turnouts, their state will be converted into a turnout state.
        Parameters:
        turnoutNumber - - the Z21 Turnout Number
        Returns:
        the current state converted to a turnout state
      • setStateForNumber

        public void setStateForNumber​(int turnoutNumber,
                                      int state)
        Set the state of a component identified by the mapped number from a turnout state (THROWN or CLOSED)
        Parameters:
        turnoutNumber - - the Z21 Turnout Number
        state - - a turnout state
      • loadNumberList

        public void loadNumberList()
        Load our local hash map, so we have a cache
      • dispose

        public void dispose()
        on destruction of the instance - would probably never occur...
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Property change listener. (Re-)loads the cache from all mapped components. Also called from the UI if the mapping has been changed by the user.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Parameters:
        e - is the propery change event