|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.AbstractNamedBean
jmri.AbstractLight
jmri.AbstractVariableLight
public abstract class AbstractVariableLight
Abstract class providing partial implementation of the logic of the Light interface when the Intensity is variable.
Eventually, this class will include transition code, but it isn't here yet, so the default setTransitionRate() implementation is inherited from AbstractLight
The structure is in part dictated by the limitations of the X10 protocol and implementations. 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:
Unlike the parent class, this stores CurrentIntensity and TargetIntensity in separate variables.
| Field Summary | |
|---|---|
protected Timer |
alarmSyncUpdate
|
protected Timebase |
internalClock
|
protected PropertyChangeListener |
minuteChangeListener
|
protected Date |
mLastTransitionDate
|
protected long |
mNextTransitionTs
|
protected double |
mTransitionDuration
Variables needed for saved values |
protected double |
mTransitionTargetIntensity
Variables needed but not saved to files/panels |
| 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 |
| 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. |
protected void |
notifyTargetIntensityChange(double intensity)
Change the stored target intensity value and do notification, but don't change anything in the hardware |
protected abstract void |
sendIntensity(double intensity)
Send a Dim/Bright commands to the hardware to reach a specific intensity. |
protected abstract void |
sendOnOffCommand(int newState)
Send a On/Off Command to the hardware |
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. |
protected void |
startTransition(double intensity)
Set up to start a transition |
| Methods inherited from class jmri.AbstractNamedBean |
|---|
addPropertyChangeListener, dispose, firePropertyChange, getComment, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setUserName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface jmri.NamedBean |
|---|
addPropertyChangeListener, dispose, getComment, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setUserName |
| Field Detail |
|---|
protected double mTransitionDuration
protected double mTransitionTargetIntensity
protected Date mLastTransitionDate
protected long mNextTransitionTs
protected Timebase internalClock
protected Timer alarmSyncUpdate
protected PropertyChangeListener minuteChangeListener
| Constructor Detail |
|---|
public AbstractVariableLight(String systemName, String userName)
public AbstractVariableLight(String systemName)
| Method Detail |
|---|
public void setState(int newState)
ON and OFF avoid use of variable intensity if MaxIntensity = 1.0 or MinIntensity = 0.0, and no transition is being used.
public void setTargetIntensity(double intensity)
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.
setTargetIntensity in interface LightsetTargetIntensity in class AbstractLightIllegalArgumentException - when intensity is less than 0.0 or more than 1.0protected void startTransition(double intensity)
protected abstract void sendIntensity(double intensity)
protected abstract void sendOnOffCommand(int newState)
protected void notifyTargetIntensityChange(double intensity)
notifyTargetIntensityChange in class AbstractLightpublic boolean isIntensityVariable()
isIntensityVariable in interface LightisIntensityVariable in class AbstractLightpublic boolean isTransitionAvailable()
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
isTransitionAvailable in interface LightisTransitionAvailable in class AbstractLightpublic void setTransitionTime(double minutes)
Bound property
setTransitionTime in interface LightsetTransitionTime in class AbstractLightIllegalArgumentException - if minutes is not validpublic double getTransitionTime()
getTransitionTime in interface LightgetTransitionTime in class AbstractLightpublic boolean isTransitioning()
Bound property so that listeners can conveniently learn when the transition is over.
isTransitioning in interface LightisTransitioning in class AbstractLight
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||