|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Light
Represent a single visible Light on the physical layout.
Lights have a state and an intensity.
The intensity of the hardware output is represented by the range from 0.0 to 1.0, with 1.0 being brightest.
The primary states are:
The light has a TargetIntensity property which can be set directly. In addition, it has a CurrentIntensity property which may differ from TargetIntensity while the Light is being moved from one intensity to another.
Intensity is limited by MinIntensity and MaxIntensity parameters. Setting the state to ON sets the TargetIntensity to MinIntensity, and to OFF sets the TargetIntensity to MaxIntensity. Attempting to directly set the TargetIntensity outside the values of MinIntensity and MaxIntensity (inclusive) will result in the TargetIntensity being set to the relevant limit.
Because the actual light hardware has only finite resolution, the intensity value is mapped to the nearest setting. For example, in the special case of a two-state (on/off) Light, setting a TargetIntensity of more than 0.5 will turn the Light on, less than 0.5 will turn the light off.
Specific implementations will describe how the settings map to the particular hardware commands.
The transition rate is absolute; the intensity changes at a constant rate regardless of whether the change is a big one or a small one.
JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
| Field Summary | |
|---|---|
static int |
FAST_CLOCK_CONTROL
|
static int |
INTERMEDIATE
State value indicating output intensity is less than maxIntensity and more than minIntensity, and no transition is in progress |
static int |
NO_CONTROL
|
static int |
OFF
State value indicating output intensity is at or below minIntensity |
static int |
ON
State value indicating output intensity is at or above maxIntensity |
static int |
SENSOR_CONTROL
|
static int |
TIMED_ON_CONTROL
|
static int |
TRANSITIONING
State value mask representing status where output is changing due to a request to transition. |
static int |
TRANSITIONINGHIGHER
State value indicating output intensity is currently changing toward higher intensity. |
static int |
TRANSITIONINGLOWER
State value indicating output intensity is currently changing toward lower intensity. |
static int |
TRANSITIONINGTOFULLOFF
State value indicating output intensity is currently changing toward lower intensity, and will continue until full OFF is reached |
static int |
TRANSITIONINGTOFULLON
State value indicating output intensity is currently changing toward higher intensity, and will continue until full ON is reached |
static int |
TURNOUT_STATUS_CONTROL
|
| Fields inherited from interface jmri.NamedBean |
|---|
INCONSISTENT, UNKNOWN |
| Method Summary | |
|---|---|
void |
activateLight()
Activates a light by control type. |
void |
deactivateLight()
Deactivates a light by control type. |
String |
getControlSensorName()
Control type information, valid by control type |
int |
getControlSensorSense()
|
String |
getControlTimedOnSensorName()
|
String |
getControlTurnoutName()
|
int |
getControlTurnoutState()
|
int |
getControlType()
Control type is an instance variable. |
double |
getCurrentIntensity()
Get the current intensity value. |
boolean |
getEnabled()
Get the Enabled property, which determines whether the control logic built in the light object is operating or not. |
int |
getFastClockOffHour()
|
int |
getFastClockOffMin()
|
int |
getFastClockOnHour()
|
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()
|
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 |
setControlSensor(String sensorSystemName)
|
void |
setControlSensorSense(int sense)
|
void |
setControlTimedOnSensor(String sensorSystemName)
|
void |
setControlTurnout(String turnoutSystemName)
|
void |
setControlTurnoutState(int ts)
|
void |
setControlType(int controlType)
|
void |
setEnabled(boolean state)
Set the Enabled property, which determines whether the control logic built in the light object is operating or not. |
void |
setFastClockControlSchedule(int onHour,
int onMin,
int offHour,
int offMin)
|
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)
Set the demanded output state. |
void |
setTargetIntensity(double intensity)
Set the intended new intensity value for the Light. |
void |
setTimedOnDuration(int duration)
|
void |
setTransitionTime(double minutes)
Set the fast-clock duration for a transition from full ON to full OFF or vice-versa. |
| Methods inherited from interface jmri.NamedBean |
|---|
addPropertyChangeListener, dispose, getComment, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setUserName |
| Field Detail |
|---|
static final int ON
static final int OFF
static final int INTERMEDIATE
static final int TRANSITIONINGTOFULLON
static final int TRANSITIONINGHIGHER
static final int TRANSITIONINGLOWER
static final int TRANSITIONINGTOFULLOFF
static final int TRANSITIONING
static final int SENSOR_CONTROL
static final int FAST_CLOCK_CONTROL
static final int TURNOUT_STATUS_CONTROL
static final int TIMED_ON_CONTROL
static final int NO_CONTROL
| Method Detail |
|---|
void setState(int newState)
Bound parameter.
Note that the state may have other values, such as INTERMEDIATE or a form of transitioning, but that these may not be directly set.
setState in interface NamedBeanIllegalArgumentException - if invalid newState providedint getState()
getState in interface NamedBeanint getControlType()
void setControlType(int controlType)
boolean isIntensityVariable()
Unbound property.
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.
Attempting to set a value below the MinIntensity property value will result in MinIntensity being set. Similarly, setting a value above MaxIntensity will result in MaxINtensity being set.
Setting the intensity to the value of the MinIntensity property will result in the Light going to the OFF state at the end of the transition. Similarly, setting the intensity to the MaxIntensity value will result in the Light going to the ON state at the end of the transition.
All others result in the INTERMEDIATE state.
Light implementations with isIntensityVariable false may not have their TargetIntensity set to values between MinIntensity and MaxIntensity, which would result in the INTERMEDIATE state, as that is invalid for them.
If a non-zero value is set in the transitionTime property, the state will be one of TRANSITIONTOFULLON, TRANSITIONHIGHER, TRANSITIONLOWER or TRANSITIONTOFULLOFF until the transition is complete.
IllegalArgumentException - when intensity is less than 0.0 or more than 1.0
IllegalArgumentException - if isIntensityVariable is false
and the new value is between MaxIntensity and MinIntensitydouble getCurrentIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
double getTargetIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
Bound property
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.
IllegalArgumentException - 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 propertydouble getMaxIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
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.
IllegalArgumentException - 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 propertydouble getMinIntensity()
A value of 0.0 corresponds to full off, and a value of 1.0 corresponds to full on.
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
void setTransitionTime(double minutes)
Note there is no guarantee of how this scales when other changes in intensity take place. In particular, some Light implementations will change at a constant fraction per fastclock minute and some will take a fixed duration regardless of the size of the intensity change.
Bound property
IllegalArgumentException - if isTransitionAvailable() is false and minutes is not 0.0
IllegalArgumentException - if minutes is negativedouble getTransitionTime()
boolean isTransitioning()
Bound property so that listeners can conveniently learn when the transition is over.
String getControlSensorName()
int getControlSensorSense()
int getFastClockOnHour()
int getFastClockOnMin()
int getFastClockOffHour()
int getFastClockOffMin()
String getControlTurnoutName()
int getControlTurnoutState()
String getControlTimedOnSensorName()
int getTimedOnDuration()
void setControlSensor(String sensorSystemName)
void setControlSensorSense(int sense)
void setFastClockControlSchedule(int onHour,
int onMin,
int offHour,
int offMin)
void setControlTurnout(String turnoutSystemName)
void setControlTurnoutState(int ts)
void setControlTimedOnSensor(String sensorSystemName)
void setTimedOnDuration(int duration)
void setEnabled(boolean state)
boolean getEnabled()
void activateLight()
void deactivateLight()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||