|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.implementation.AbstractNamedBean
jmri.implementation.AbstractLight
public abstract class AbstractLight
Abstract class providing partial implementation of the 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 editting 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 Summary | |
|---|---|
protected ArrayList<LightControl> |
lightControlList
System independent instance variables (saved between runs) |
protected boolean |
mActive
System independent operational instance variables (not saved between runs) |
protected double |
mCurrentIntensity
|
protected boolean |
mEnabled
|
protected double |
mMaxIntensity
|
protected double |
mMinIntensity
|
protected int |
mState
|
| Fields inherited from class jmri.implementation.AbstractNamedBean |
|---|
listenerRefs, log, mSystemName, mUserName, parameters, pcs, register |
| 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 | |
|---|---|
AbstractLight(String systemName)
|
|
AbstractLight(String systemName,
String userName)
|
|
| Method Summary | |
|---|---|
void |
activateLight()
Activates a light activating all its LightControl objects. |
void |
addLightControl(LightControl c)
|
void |
clearLightControls()
LightControl management methods |
void |
deactivateLight()
Deactivates a light by deactivating each of its LightControl objects. |
protected void |
doNewState(int oldState,
int newState)
Implement the specific change of state needed by hardware |
double |
getCurrentIntensity()
Get the current intensity value. |
boolean |
getEnabled()
Get enabled status |
ArrayList<LightControl> |
getLightControlList()
|
double |
getMaxIntensity()
Get the current value of the maxIntensity property. |
double |
getMinIntensity()
Get the current value of the minIntensity property. |
int |
getState()
Get the current state of the Light's output. |
double |
getTargetIntensity()
Get the target intensity value for the current transition, if any. |
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 |
notifyStateChange(int oldState,
int newState)
Change the stored state value and do notification, but don't change anything in the hardware |
protected void |
notifyTargetIntensityChange(double intensity)
Change the stored target intensity value and do notification, but don't change anything in the hardware |
void |
setEnabled(boolean v)
Set enabled status |
void |
setMaxIntensity(double intensity)
Set the value of the maxIntensity property. |
void |
setMinIntensity(double intensity)
Set the value of the minIntensity property. |
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 |
updateIntensityHigh(double intensity)
Method for further implementation of setTargetIntensity at or above the maximum Does not change state. |
protected void |
updateIntensityIntermediate(double intensity)
Method for further implementation of setTargetIntensity between min and max Does not change state. |
protected void |
updateIntensityLow(double intensity)
Method for further implementation of setTargetIntensity at or below the minimum. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ArrayList<LightControl> lightControlList
protected double mMaxIntensity
protected double mMinIntensity
protected boolean mActive
protected boolean mEnabled
protected double mCurrentIntensity
protected int mState
| Constructor Detail |
|---|
public AbstractLight(String systemName,
String userName)
public AbstractLight(String systemName)
| Method Detail |
|---|
public boolean getEnabled()
getEnabled in interface Lightpublic void setEnabled(boolean v)
setEnabled in interface Lightpublic boolean isIntensityVariable()
isIntensityVariable in interface LightAbstractVariableLight for
an abstract implementation of variable intensity.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.
All others result in an exception, instead of the INTERMEDIATE state, because this class does not implement analog intensity
setTargetIntensity in interface LightIllegalArgumentException - when intensity is less than 0.0 or more than 1.0
IllegalArgumentException - when intensity is more than MinIntensity and less than MaxIntensityprotected void updateIntensityLow(double intensity)
Does not change state.
protected void updateIntensityIntermediate(double intensity)
Does not change state.
protected void updateIntensityHigh(double intensity)
Does not change state.
public double getCurrentIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
getCurrentIntensity in interface Lightpublic double getTargetIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
Bound property
getTargetIntensity in interface Lightpublic void setMaxIntensity(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.
setMaxIntensity in interface LightIllegalArgumentException - when intensity is less than 0.0 or more than 1.0
IllegalArgumentException - when intensity is not greater than the current value of the minIntensity propertypublic double getMaxIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
getMaxIntensity in interface Lightpublic void setMinIntensity(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.
setMinIntensity in interface LightIllegalArgumentException - when intensity is less than 0.0 or more than 1.0
IllegalArgumentException - when intensity is not less than the current value of the maxIntensity propertypublic double getMinIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
getMinIntensity in interface Lightpublic 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 Lightpublic void setTransitionTime(double minutes)
This class does not implement transitions, so this property cannot be set from zero.
Bound property
setTransitionTime in interface LightIllegalArgumentException - if minutes is not 0.0public double getTransitionTime()
getTransitionTime in interface Lightpublic boolean isTransitioning()
Bound property so that listeners can conveniently learn when the transition is over.
isTransitioning in interface Lightpublic void setState(int newState)
setState in interface LightsetState in interface NamedBeanprotected void notifyTargetIntensityChange(double intensity)
protected void notifyStateChange(int oldState,
int newState)
protected void doNewState(int oldState,
int newState)
public int getState()
Light
getState in interface LightgetState in interface NamedBeanpublic void activateLight()
activateLight in interface Lightpublic void deactivateLight()
deactivateLight in interface Lightpublic void clearLightControls()
clearLightControls in interface Lightpublic void addLightControl(LightControl c)
addLightControl in interface Lightpublic ArrayList<LightControl> getLightControlList()
getLightControlList in interface Light
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||