Class AbstractLight
- All Implemented Interfaces:
Comparable<NamedBean>
,PropertyChangeProvider
,DigitalIO
,Light
,NamedBean
- Direct Known Subclasses:
AbstractVariableLight
,AcelaLight
,CbusLight
,DCCppLight
,IpocsLight
,JMRIClientLight
,LnLight
,MqttLight
,NceLight
,OlcbLight
,SerialLight
,SerialLight
,SerialLight
,SerialLight
,SerialLight
,XBeeLight
,XNetLight
public abstract class AbstractLight extends AbstractNamedBean implements Light
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 editing 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
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
Field Summary
Fields Modifier and Type Field Description protected List<LightControl>
lightControlList
System independent instance variables (saved between runs).protected boolean
mActive
protected double
mCurrentIntensity
System independent operational instance variables (not saved between runs).protected boolean
mEnabled
protected double
mMaxIntensity
protected double
mMinIntensity
protected int
mState
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
Fields inherited from interface jmri.Light
FAST_CLOCK_CONTROL, INTERMEDIATE, NO_CONTROL, SENSOR_CONTROL, TIMED_ON_CONTROL, TRANSITIONING, TRANSITIONINGHIGHER, TRANSITIONINGLOWER, TRANSITIONINGTOFULLOFF, TRANSITIONINGTOFULLON, TURNOUT_STATUS_CONTROL, TWO_SENSOR_CONTROL
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
Constructor Summary
Constructors Constructor Description AbstractLight(String systemName)
AbstractLight(String systemName, String userName)
-
Method Summary
Modifier and Type Method Description void
activateLight()
Activate a light activating all its LightControl objects.void
addLightControl(LightControl c)
Add a LightControl to this Light.void
clearLightControls()
Clears (removes) all LightControl objects for this lightvoid
deactivateLight()
Deactivate a light by deactivating each of its LightControl objects.String
describeState(int state)
Provide human-readable, localized version of state value.protected void
doNewState(int oldState, int newState)
Implement the specific change of state needed by hardware.String
getBeanType()
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.boolean
getEnabled()
Get enabled status.List<LightControl>
getLightControlList()
int
getState()
Get the current state of the Light's output.List<NamedBeanUsageReport>
getUsageReport(NamedBean bean)
Get a list of references for the specified bean.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
setState(int newState)
Handle a request for a state change.Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef, vetoableChange
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface jmri.Light
getCommandedState, getKnownState, isConsistentState, requestUpdateFromLayout, setCommandedState
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, dispose, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChange
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
lightControlList
System independent instance variables (saved between runs). -
mMaxIntensity
-
mMinIntensity
-
mCurrentIntensity
System independent operational instance variables (not saved between runs). -
mActive
-
mEnabled
-
mState
-
-
Constructor Details
-
Method Details
-
getBeanType
Description copied from interface:NamedBean
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
describeState
Description copied from interface:NamedBean
Provide human-readable, localized version of state value.This method is intended for use when presenting to a human operator.
- Specified by:
describeState
in interfaceNamedBean
- Overrides:
describeState
in classAbstractNamedBean
- Parameters:
state
- the state to describe- Returns:
- the state in localized form
-
getEnabled
Get enabled status.- Specified by:
getEnabled
in interfaceLight
- Returns:
- enabled status
-
setEnabled
Set enabled status.- Specified by:
setEnabled
in interfaceLight
- Parameters:
v
- status to set
-
setState
Handle a request for a state change. For these lights, ON and OFF just transition immediately between MinIntensity and MaxIntensity. Ignores any outputDelay setting for connection. -
notifyTargetIntensityChange
Change the stored target intensity value and do notification, but don't change anything in the hardware.- Parameters:
intensity
- intensity value
-
notifyStateChange
Change the stored state value and do notification, but don't change anything in the hardware.- Parameters:
oldState
- old valuenewState
- new value
-
doNewState
Implement the specific change of state needed by hardware.- Parameters:
oldState
- old statenewState
- new state
-
getState
Description copied from interface:Light
Get the current state of the Light's output. -
activateLight
Activate a light activating all its LightControl objects.- Specified by:
activateLight
in interfaceLight
-
deactivateLight
Deactivate a light by deactivating each of its LightControl objects.- Specified by:
deactivateLight
in interfaceLight
-
clearLightControls
Description copied from interface:Light
Clears (removes) all LightControl objects for this light- Specified by:
clearLightControls
in interfaceLight
-
addLightControl
Add a LightControl to this Light.Duplicates are considered the same, hence not added
- Specified by:
addLightControl
in interfaceLight
- Parameters:
c
- the light control to add.
-
getLightControlList
- Specified by:
getLightControlList
in interfaceLight
- Returns:
- a list of all LightControls
-
getUsageReport
Description copied from interface:NamedBean
Get a list of references for the specified bean.- Specified by:
getUsageReport
in interfaceNamedBean
- Parameters:
bean
- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-