Class AbstractLight
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractLight
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>,PropertyChangeProvider,DigitalIO,Light,NamedBean
- Direct Known Subclasses:
AbstractVariableLight,AcelaLight,CbusLight,DCCppLight,IpocsLight,JMRIClientLight,LnLight,NceLight,OlcbLight,SerialLight,SerialLight,SerialLight,SerialLight,SerialLight,XBeeLight,XNetLight
public abstract class AbstractLight extends AbstractNamedBean implements Light
Abstract class providing partial implementation 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 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 java.util.List<LightControl>lightControlListSystem independent instance variables (saved between runs).protected booleanmActiveprotected doublemCurrentIntensitySystem independent operational instance variables (not saved between runs).protected booleanmEnabledprotected doublemMaxIntensityprotected doublemMinIntensityprotected intmState-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.Light
FAST_CLOCK_CONTROL, INTERMEDIATE, NO_CONTROL, PROPERTY_TARGET_INTENSITY, 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_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description AbstractLight(java.lang.String systemName)AbstractLight(java.lang.String systemName, java.lang.String userName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateLight()Activate a light activating all its LightControl objects.voidaddLightControl(LightControl c)Add a LightControl to this Light.voidclearLightControls()Clears (removes) all LightControl objects for this lightvoiddeactivateLight()Deactivate a light by deactivating each of its LightControl objects.java.lang.StringdescribeState(int state)Provide human-readable, localized version of state value.protected voiddoNewState(int oldState, int newState)Implement the specific change of state needed by hardware.java.lang.StringgetBeanType()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.booleangetEnabled()Get enabled status.java.util.List<LightControl>getLightControlList()intgetState()Get the current state of the Light's output.java.util.List<NamedBeanUsageReport>getUsageReport(NamedBean bean)Get a list of references for the specified bean.protected voidnotifyStateChange(int oldState, int newState)Change the stored state value and do notification, but don't change anything in the hardware.protected voidnotifyTargetIntensityChange(double intensity)Change the stored target intensity value and do notification, but don't change anything in the hardware.voidsetEnabled(boolean v)Set enabled status.voidsetState(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, 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, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
lightControlList
protected java.util.List<LightControl> lightControlList
System independent instance variables (saved between runs).
-
mMaxIntensity
protected double mMaxIntensity
-
mMinIntensity
protected double mMinIntensity
-
mCurrentIntensity
protected double mCurrentIntensity
System independent operational instance variables (not saved between runs).
-
mActive
protected boolean mActive
-
mEnabled
protected boolean mEnabled
-
mState
protected int mState
-
-
Constructor Detail
-
AbstractLight
public AbstractLight(java.lang.String systemName, java.lang.String userName)
-
AbstractLight
public AbstractLight(java.lang.String systemName)
-
-
Method Detail
-
getBeanType
public java.lang.String getBeanType()
Description copied from interface:NamedBeanFor 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:
getBeanTypein interfaceNamedBean- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
describeState
@Nonnull public java.lang.String describeState(int state)
Description copied from class:AbstractNamedBeanProvide human-readable, localized version of state value.This method is intended for use when presenting to a human operator.
- Specified by:
describeStatein interfaceNamedBean- Overrides:
describeStatein classAbstractNamedBean- Parameters:
state- the state to describe- Returns:
- the state in localized form
-
getEnabled
public boolean getEnabled()
Get enabled status.- Specified by:
getEnabledin interfaceLight- Returns:
- enabled status
-
setEnabled
public void setEnabled(boolean v)
Set enabled status.- Specified by:
setEnabledin interfaceLight- Parameters:
v- status to set
-
setState
public void setState(int newState)
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
protected void notifyTargetIntensityChange(double intensity)
Change the stored target intensity value and do notification, but don't change anything in the hardware.- Parameters:
intensity- intensity value
-
notifyStateChange
protected void notifyStateChange(int oldState, int newState)
Change the stored state value and do notification, but don't change anything in the hardware.- Parameters:
oldState- old valuenewState- new value
-
doNewState
protected void doNewState(int oldState, int newState)
Implement the specific change of state needed by hardware.- Parameters:
oldState- old statenewState- new state
-
getState
public int getState()
Description copied from interface:LightGet the current state of the Light's output.
-
activateLight
public void activateLight()
Activate a light activating all its LightControl objects.- Specified by:
activateLightin interfaceLight
-
deactivateLight
public void deactivateLight()
Deactivate a light by deactivating each of its LightControl objects.- Specified by:
deactivateLightin interfaceLight
-
clearLightControls
public void clearLightControls()
Description copied from interface:LightClears (removes) all LightControl objects for this light- Specified by:
clearLightControlsin interfaceLight
-
addLightControl
public void addLightControl(LightControl c)
Add a LightControl to this Light.Duplicates are considered the same, hence not added
- Specified by:
addLightControlin interfaceLight- Parameters:
c- the light control to add.
-
getLightControlList
public java.util.List<LightControl> getLightControlList()
- Specified by:
getLightControlListin interfaceLight- Returns:
- a list of all LightControls
-
getUsageReport
public java.util.List<NamedBeanUsageReport> getUsageReport(NamedBean bean)
Description copied from interface:NamedBeanGet a list of references for the specified bean.- Specified by:
getUsageReportin interfaceNamedBean- Parameters:
bean- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-
-