jmri.implementation
Class AbstractVariableLight

Show UML class diagram
java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.implementation.AbstractLight
          extended by jmri.implementation.AbstractVariableLight
All Implemented Interfaces:
Serializable, Light, NamedBean
Direct Known Subclasses:
SerialLight

public abstract class AbstractVariableLight
extends AbstractLight
implements Serializable

Abstract class providing partial implementation of the logic of the Light interface when the Intensity is variable.

Now it includes the transition code, but it only does the steps on the fast minute clock. Later it may do it's own timing but this was simple to piggy back on the fast minute listener.

The structure is in part dictated by the limitations of the X10 protocol and implementations. However, it is not limited to X10 devices only. Other interfaces that have a way to provide a dimmable light should use it. X10 has on/off commands, and separate commands for setting a variable intensity via "dim" commands. Some X10 implementations use relative dimming, some use absolute dimming. Some people set the dim level of their Lights and then just use on/off to turn control the lamps; in that case we don't want to send dim commands. Further, X10 communications is very slow, and sending a complete set of dim operations can take a long time. So the algorithm is:

  1. Until the intensity has been explicitly set different from 1.0 or 0.0, no intensity commands are to be sent over the power line.

    Unlike the parent class, this stores CurrentIntensity and TargetIntensity in separate variables.

    See Also:
    Serialized Form

    Field Summary
     
    Fields inherited from interface jmri.Light
    FAST_CLOCK_CONTROL, INTERMEDIATE, NO_CONTROL, OFF, ON, SENSOR_CONTROL, TIMED_ON_CONTROL, TRANSITIONING, TRANSITIONINGHIGHER, TRANSITIONINGLOWER, TRANSITIONINGTOFULLOFF, TRANSITIONINGTOFULLON, TURNOUT_STATUS_CONTROL, TWO_SENSOR_CONTROL
     
    Fields inherited from interface jmri.NamedBean
    INCONSISTENT, UNKNOWN
     
    Constructor Summary
    AbstractVariableLight(String systemName)
               
    AbstractVariableLight(String systemName, String userName)
               
     
    Method Summary
     double getTransitionTime()
              Get the number of fastclock minutes taken by a transition from full ON to full OFF or vice versa.
     boolean isIntensityVariable()
              Check if this object can handle variable intensity.
     boolean isTransitionAvailable()
              Can the Light change it's intensity setting slowly?
     boolean isTransitioning()
              Convenience method for checking if the intensity of the light is currently changing due to a transition.
     void setState(int newState)
              Handle a request for a state change.
     void setTargetIntensity(double intensity)
              Set the intended new intensity value for the Light.
     void setTransitionTime(double minutes)
              Set the fast-clock duration for a transition from full ON to full OFF or vice-versa.
     
    Methods inherited from class jmri.implementation.AbstractLight
    activateLight, addLightControl, clearLightControls, deactivateLight, getCurrentIntensity, getEnabled, getLightControlList, getMaxIntensity, getMinIntensity, getState, getTargetIntensity, setEnabled, setMaxIntensity, setMinIntensity
     
    Methods inherited from class jmri.implementation.AbstractNamedBean
    addPropertyChangeListener, dispose, getComment, getDisplayName, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface jmri.NamedBean
    addPropertyChangeListener, dispose, getComment, getDisplayName, getNumPropertyChangeListeners, getProperty, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName
     

    Constructor Detail

    AbstractVariableLight

    public AbstractVariableLight(String systemName,
                                 String userName)

    AbstractVariableLight

    public AbstractVariableLight(String systemName)
    Method Detail

    setState

    public void setState(int newState)
    Handle a request for a state change. ON and OFF go to the MaxIntensity and MinIntensity, specifically, and all others are not permitted

    ON and OFF avoid use of variable intensity if MaxIntensity = 1.0 or MinIntensity = 0.0, and no transition is being used.

    Specified by:
    setState in interface Light
    Specified by:
    setState in interface NamedBean
    Overrides:
    setState in class AbstractLight

    setTargetIntensity

    public void setTargetIntensity(double intensity)
    Set the intended new intensity value for the Light. If transitions are in use, they will be applied.

    Bound property between 0 and 1.

    A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.

    Values at or below the minIntensity property will result in the Light going to the OFF state immediately. Values at or above the maxIntensity property will result in the Light going to the ON state immediately.

    Specified by:
    setTargetIntensity in interface Light
    Overrides:
    setTargetIntensity in class AbstractLight
    Throws:
    IllegalArgumentException - when intensity is less than 0.0 or more than 1.0

    isIntensityVariable

    public boolean isIntensityVariable()
    Check if this object can handle variable intensity.

    Specified by:
    isIntensityVariable in interface Light
    Overrides:
    isIntensityVariable in class AbstractLight
    Returns:
    true, as this abstract class implements variable intensity.

    isTransitionAvailable

    public boolean isTransitionAvailable()
    Can the Light change it's intensity setting slowly?

    If true, this Light supports a non-zero value of the transitionTime property, which controls how long the Light will take to change from one intensity level to another.

    Unbound property

    Specified by:
    isTransitionAvailable in interface Light
    Overrides:
    isTransitionAvailable in class AbstractLight

    setTransitionTime

    public void setTransitionTime(double minutes)
    Set the fast-clock duration for a transition from full ON to full OFF or vice-versa.

    Bound property

    Specified by:
    setTransitionTime in interface Light
    Overrides:
    setTransitionTime in class AbstractLight
    Throws:
    IllegalArgumentException - if minutes is not valid

    getTransitionTime

    public double getTransitionTime()
    Get the number of fastclock minutes taken by a transition from full ON to full OFF or vice versa.

    Specified by:
    getTransitionTime in interface Light
    Overrides:
    getTransitionTime in class AbstractLight
    Returns:
    0.0 if the output intensity transition is instantaneous

    isTransitioning

    public boolean isTransitioning()
    Convenience method for checking if the intensity of the light is currently changing due to a transition.

    Bound property so that listeners can conveniently learn when the transition is over.

    Specified by:
    isTransitioning in interface Light
    Overrides:
    isTransitioning in class AbstractLight


    Copyright © 1997 - 2010 JMRI Community.
    JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

    Additional information on copyright, trademarks and licenses is linked here.
    Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads