|
||||||||||
| 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 basic logic 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 editting these instance variables.
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
| 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 | |
|---|---|
AbstractLight(String systemName)
|
|
AbstractLight(String systemName,
String userName)
|
|
| Method Summary | |
|---|---|
void |
activateLight()
Activates a light by control type. |
void |
deactivateLight()
Deactivates a light by control type. |
protected void |
doNewState(int oldState,
int newState)
Implement the specific change of state needed by hardware |
String |
getControlSensorName()
Return the controlling Sensor if there is one, else null |
int |
getControlSensorSense()
Return the controlling Sensor Sense. |
String |
getControlTimedOnSensorName()
Return the trigger Sensor system name. |
String |
getControlTurnoutName()
Return the controlling Turnout if there is one, else null. |
int |
getControlTurnoutState()
Return the state of the controlling Turnout that corresponds to this light being ON. |
int |
getControlType()
Return the control type of this Light |
double |
getCurrentIntensity()
Get the current intensity value. |
boolean |
getEnabled()
Get enabled status |
int |
getFastClockOffHour()
|
int |
getFastClockOffMin()
|
int |
getFastClockOnHour()
Return the On/Off Schedule if FAST_CLOCK_CONTROL |
int |
getFastClockOnMin()
|
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. |
int |
getTimedOnDuration()
Return the duration (milliseconds) light is to remain ON after it has been triggered. |
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 |
setControlSensor(String sensorName)
Set the controlling Sensor if there is one, else null |
void |
setControlSensorSense(int sense)
Set the controlling Sensor Sense. |
void |
setControlTimedOnSensor(String sensorName)
Set the trigger Sensor system name. |
void |
setControlTurnout(String turnoutName)
Set the controlling Turnout. |
void |
setControlTurnoutState(int ts)
Set the state of the controlling Turnout that corresponds to this light being ON. |
void |
setControlType(int controlType)
Set the control type of this Light |
void |
setEnabled(boolean v)
Set enabled status |
void |
setFastClockControlSchedule(int onHour,
int onMin,
int offHour,
int offMin)
Set the On/Off Schedule if FAST_CLOCK_CONTROL |
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 |
setTimedOnDuration(int duration)
Set the duration (milliseconds) light is to remain ON after it has been triggered. |
void |
setTransitionTime(double minutes)
Set the fast-clock duration for a transition from full ON to full OFF or vice-versa. |
void |
updateClockControlLight()
Updates the status of a Light under FAST_CLOCK_CONTROL. |
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 jmri.implementation.AbstractNamedBean |
|---|
addPropertyChangeListener, dispose, firePropertyChange, getComment, getDisplayName, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, 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, getDisplayName, getNumPropertyChangeListeners, getProperty, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName |
| Field Detail |
|---|
protected int mControlType
protected int mControlSensorSense
protected String mControlSensorName
protected int mFastClockOnHour
protected int mFastClockOnMin
protected int mFastClockOffHour
protected int mFastClockOffMin
protected String mControlTurnoutName
protected int mTurnoutState
protected String mTimedSensorName
protected int mTimeOnDuration
protected double mMaxIntensity
protected double mMinIntensity
protected boolean mActive
protected Sensor mControlSensor
protected PropertyChangeListener mSensorListener
protected PropertyChangeListener mTimebaseListener
protected Timebase mClock
protected int mTimeOn
protected int mTimeOff
protected Turnout mControlTurnout
protected PropertyChangeListener mTurnoutListener
protected boolean mTimedActive
protected Sensor mTimedControlSensor
protected PropertyChangeListener mTimedSensorListener
protected Timer mTimedControlTimer
protected ActionListener mTimedControlListener
protected boolean mLightOnTimerActive
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 int getControlType()
getControlType in interface Lightpublic void setControlType(int controlType)
setControlType in interface Lightpublic String getControlSensorName()
getControlSensorName in interface Lightpublic void setControlSensor(String sensorName)
setControlSensor in interface Lightpublic int getControlSensorSense()
getControlSensorSense in interface Lightpublic void setControlSensorSense(int sense)
setControlSensorSense in interface Lightpublic int getFastClockOnHour()
getFastClockOnHour in interface Lightpublic int getFastClockOnMin()
getFastClockOnMin in interface Lightpublic int getFastClockOffHour()
getFastClockOffHour in interface Lightpublic int getFastClockOffMin()
getFastClockOffMin in interface Light
public void setFastClockControlSchedule(int onHour,
int onMin,
int offHour,
int offMin)
setFastClockControlSchedule in interface Lightpublic String getControlTurnoutName()
getControlTurnoutName in interface Lightpublic void setControlTurnout(String turnoutName)
setControlTurnout in interface Lightpublic int getControlTurnoutState()
getControlTurnoutState in interface Lightpublic void setControlTurnoutState(int ts)
setControlTurnoutState in interface Lightpublic String getControlTimedOnSensorName()
getControlTimedOnSensorName in interface Lightpublic void setControlTimedOnSensor(String sensorName)
setControlTimedOnSensor in interface Lightpublic int getTimedOnDuration()
getTimedOnDuration in interface Lightpublic void setTimedOnDuration(int duration)
setTimedOnDuration 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 updateClockControlLight()
public void activateLight()
activateLight in interface Lightpublic void deactivateLight()
deactivateLight in interface Light
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||