Class AbstractLight

java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.implementation.AbstractLight
All Implemented Interfaces:
Comparable<NamedBean>, PropertyChangeProvider, DigitalIO, Light, NamedBean
Direct Known Subclasses:
AbstractVariableLight, AcelaLight, CbusLight, DCCppLight, IpocsLight, JMRIClientLight, LnLight, NceLight, OlcbLight, SerialLight, SerialLight, SerialLight, SerialLight, SerialLight, XBeeLight, XNetLight

public abstract class AbstractLight extends AbstractNamedBean implements Light
Abstract class providing partial implementation of the Light interface.

Light objects require a number of instance variables. Since Light objects are created using the standard JMRI systemName/userName concept, accessor routines are provided for setting and editing these instance variables.

Each Light may have one or more control mechanisms, of the types defined in the Light interface. A Light may also not have any control mechanisms defined.

Information for each control mechanism is held in LightControl objects, which also implement the logic for control. A list of LightControls, if any, is kept here, and activation and deactivation of LightControls is through this module.

Instance variables are divided into system-independent and system dependent categories. System independent instance variables are defined here, and their accessor routines are implemented here.

This implementation provides a notional implementation of intensity and transitions. The user can set intensity so long as it's at least the max value (default 1.0) or no more than the minimum value (default 0.0). In that case, the setTargetIntensity operations become a setState to ON or OFF. Setting a target intensity between the min and max is an error, because this type of Light does not support a true analog intensity. Transitions never happen, and setting a TransitionTime greater than 0.0 gives an exception.

Since this form of Light does not do variable intensity nor transitions, it stores both CurrentIntensity and TargetIntensity in a single location, forcing them to be the same

  • Field Details

  • Constructor Details

  • Method Details

    • getBeanType

      public String getBeanType()
      Description copied from interface: NamedBean
      For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.
      Specified by:
      getBeanType in interface NamedBean
      Returns:
      a string of the bean type, eg Turnout, Sensor etc
    • describeState

      @Nonnull public String describeState(int state)
      Description copied from class: AbstractNamedBean
      Provide human-readable, localized version of state value.

      This method is intended for use when presenting to a human operator.

      Specified by:
      describeState in interface NamedBean
      Overrides:
      describeState in class AbstractNamedBean
      Parameters:
      state - the state to describe
      Returns:
      the state in localized form
    • getEnabled

      public boolean getEnabled()
      Get enabled status.
      Specified by:
      getEnabled in interface Light
      Returns:
      enabled status
    • setEnabled

      public void setEnabled(boolean v)
      Set enabled status.
      Specified by:
      setEnabled in interface Light
      Parameters:
      v - status to set
    • setState

      public void setState(int newState)
      Handle a request for a state change. For these lights, ON and OFF just transition immediately between MinIntensity and MaxIntensity. Ignores any outputDelay setting for connection.
      Specified by:
      setState in interface Light
      Specified by:
      setState in interface NamedBean
      Parameters:
      newState - new state
    • notifyTargetIntensityChange

      protected void notifyTargetIntensityChange(double intensity)
      Change the stored target intensity value and do notification, but don't change anything in the hardware.
      Parameters:
      intensity - intensity value
    • notifyStateChange

      protected void notifyStateChange(int oldState, int newState)
      Change the stored state value and do notification, but don't change anything in the hardware.
      Parameters:
      oldState - old value
      newState - new value
    • doNewState

      protected void doNewState(int oldState, int newState)
      Implement the specific change of state needed by hardware.
      Parameters:
      oldState - old state
      newState - new state
    • getState

      public int getState()
      Description copied from interface: Light
      Get the current state of the Light's output.
      Specified by:
      getState in interface Light
      Specified by:
      getState in interface NamedBean
      Returns:
      the state
    • activateLight

      public void activateLight()
      Activate a light activating all its LightControl objects.
      Specified by:
      activateLight in interface Light
    • deactivateLight

      public void deactivateLight()
      Deactivate a light by deactivating each of its LightControl objects.
      Specified by:
      deactivateLight in interface Light
    • clearLightControls

      public void clearLightControls()
      Description copied from interface: Light
      Clears (removes) all LightControl objects for this light
      Specified by:
      clearLightControls in interface Light
    • addLightControl

      public void addLightControl(LightControl c)
      Add a LightControl to this Light.

      Duplicates are considered the same, hence not added

      Specified by:
      addLightControl in interface Light
      Parameters:
      c - the light control to add.
    • getLightControlList

      Specified by:
      getLightControlList in interface Light
      Returns:
      a list of all LightControls
    • getUsageReport

      Description copied from interface: NamedBean
      Get a list of references for the specified bean.
      Specified by:
      getUsageReport in interface NamedBean
      Parameters:
      bean - The bean to be checked.
      Returns:
      a list of NamedBeanUsageReports or an empty ArrayList.