Class AbstractLightManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.beans.VetoableChangeSupport
-
- jmri.managers.AbstractManager<Light>
-
- jmri.managers.AbstractLightManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.beans.VetoableChangeListener,java.util.EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,LightManager,Manager<Light>,NameIncrementingManager,ProvidingManager<Light>
- Direct Known Subclasses:
AcelaLightManager,BiDiBLightManager,CbusLightManager,DCCppLightManager,InternalLightManager,IpocsLightManager,JMRIClientLightManager,LnLightManager,MqttLightManager,NceLightManager,OlcbLightManager,SerialLightManager,SerialLightManager,SerialLightManager,SerialLightManager,SerialLightManager,SerialLightManager,UsbLightManager,XBeeLightManager,XNetLightManager
public abstract class AbstractLightManager extends AbstractManager<Light> implements LightManager
Abstract partial implementation of a LightManager.Based on AbstractSignalHeadManager.java and AbstractSensorManager.java
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.Manager
Manager.ManagerDataEvent<E extends NamedBean>, Manager.ManagerDataListener<E extends NamedBean>, Manager.NameValidity
-
-
Field Summary
-
Fields inherited from class jmri.managers.AbstractManager
_beans, _tsys, _tuser, lastAutoNamedBeanRef, memo, paddedNumber, silenceableProperties, silencedProperties
-
Fields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupport
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
Fields inherited from interface jmri.Manager
ANALOGIOS, AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, CTCDATA, ENTRYEXIT, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXNG_ANALOG_ACTIONS, LOGIXNG_ANALOG_EXPRESSIONS, LOGIXNG_CONDITIONALNGS, LOGIXNG_DIGITAL_ACTIONS, LOGIXNG_DIGITAL_BOOLEAN_ACTIONS, LOGIXNG_DIGITAL_EXPRESSIONS, LOGIXNG_GLOBAL_VARIABLES, LOGIXNG_MODULES, LOGIXNG_STRING_ACTIONS, LOGIXNG_STRING_EXPRESSIONS, LOGIXNG_TABLES, LOGIXNGS, LOGIXS, MEMORIES, METERFRAMES, METERS, OBLOCKS, PANELFILES, PROPERTY_BEANS, PROPERTY_CAN_DELETE, PROPERTY_DISPLAY_LIST_NAME, PROPERTY_DO_DELETE, PROPERTY_DO_NOT_DELETE, PROPERTY_LENGTH, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS
-
-
Constructor Summary
Constructors Constructor Description AbstractLightManager(SystemConnectionMemo memo)Create a new LightManager instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidactivateAllLights()Activate the control mechanism for each Light controlled by this LightManager.java.lang.StringconvertSystemNameToAlternate(java.lang.String systemName)Convert the system name to a normalized alternate name.protected abstract LightcreateNewLight(java.lang.String systemName, java.lang.String userName)Internal method to invoke the factory, after all the logic for returning an existing Light has been invoked.java.lang.StringgetBeanTypeHandled(boolean plural)Get bean type handled.java.lang.StringgetEntryToolTip()Get a manager-specific tool tip for adding an entry to the manager.LightgetLight(java.lang.String name)Get an existing Light or return null if it doesn't exist.java.lang.Class<Light>getNamedBeanClass()Get the class of NamedBean supported by this Manager.intgetXMLOrder()Determine the order that types should be written when storing panel files.LightnewLight(java.lang.String systemName, java.lang.String userName)Lookup Light by UserName, then provide by SystemName.LightprovideLight(java.lang.String name)Get the Light with the user name, then system name if needed; if that fails, create a new Light.booleansupportsVariableLights(java.lang.String systemName)Test if system in the given name can support a variable light.chartypeLetter()-
Methods inherited from class jmri.managers.AbstractManager
addDataListener, checkNumeric, createSystemName, deleteBean, deregister, dispose, fireDataListenersAdded, fireDataListenersRemoved, fireVetoableChange, getAutoSystemName, getBySystemName, getBySystemName, getByUserName, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getOuterBean, getSystemPrefix, handleUserNameUniqueness, makeSystemName, propertyChange, register, registerSelf, registerUserName, removeDataListener, setDataListenerMute, setPropertyChangesSilenced, setRegisterSelf, updateAutoNumber, validSystemNameFormat, vetoableChange
-
Methods inherited from class jmri.beans.VetoableChangeSupport
addVetoableChangeListener, addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.LightManager
createSystemName, dispose, getBySystemName, getByUserName, provide, validSystemNameConfig
-
Methods inherited from interface jmri.Manager
addDataListener, deleteBean, deregister, getBeanTypeHandled, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getSubSystemNamePrefix, getSystemNamePrefix, getSystemPrefix, isValidSystemNameFormat, makeSystemName, makeSystemName, makeSystemName, register, removeDataListener, setDataListenerMute, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormat, validSystemNameFormat
-
Methods inherited from interface jmri.NameIncrementingManager
allowMultipleAdditions, getNextValidSystemName
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.beans.SilenceablePropertyChangeProvider
setPropertyChangesSilenced
-
Methods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Constructor Detail
-
AbstractLightManager
public AbstractLightManager(SystemConnectionMemo memo)
Create a new LightManager instance.- Parameters:
memo- the system connection
-
-
Method Detail
-
getXMLOrder
public int getXMLOrder()
Determine the order that types should be written when storing panel files. Uses one of the constants defined in this class.Yes, that's an overly-centralized methodology, but it works for now.
- Specified by:
getXMLOrderin interfaceManager<Light>- Returns:
- write order for this Manager; larger is later.
-
typeLetter
public char typeLetter()
- Specified by:
typeLetterin interfaceManager<Light>- Returns:
- The type letter for a specific implementation
-
provideLight
@Nonnull public Light provideLight(@Nonnull java.lang.String name)
Get the Light with the user name, then system name if needed; if that fails, create a new Light. If the name is a valid system name, it will be used for the new Light. Otherwise, theManager.makeSystemName(java.lang.String)method will attempt to turn it into a valid system name.This provides the same function as
ProvidingManager.provide(java.lang.String)which has a more generic form.- Specified by:
provideLightin interfaceLightManager- Parameters:
name- User name, system name, or address which can be promoted to system name- Returns:
- Never null under normal circumstances
-
getLight
@CheckForNull public Light getLight(@Nonnull java.lang.String name)
Get an existing Light or return null if it doesn't exist.Locates via user name, then system name if needed.
- Specified by:
getLightin interfaceLightManager- Parameters:
name- User name, system name, or address which can be promoted to system name- Returns:
- Light, or null if no existing Light.
-
newLight
@Nonnull public Light newLight(@Nonnull java.lang.String systemName, @CheckForNull java.lang.String userName) throws java.lang.IllegalArgumentException
Lookup Light by UserName, then provide by SystemName. Return a Light with the specified user or system name. Lookup Light by UserName, then Provide New Light by SystemName. Note that two calls with the same arguments will get the same instance; there is only one Light object representing a given physical Light and therefore only one with a specific system or user name.This will always return a valid object reference; a new object will be created if necessary. In that case:
- If a null reference is given for user name, no user name will be associated with the Light object created; a valid system name must be provided
- If both names are provided, the system name defines the hardware access of the desired sensor, and the user address is associated with it. The system name must be valid.
- Specified by:
newLightin interfaceLightManager- Parameters:
systemName- the desired system nameuserName- the desired user name- Returns:
- requested Light object (never null)
- Throws:
java.lang.IllegalArgumentException- if cannot create the Light due to e.g. an illegal name or name that can't be parsed.
-
createNewLight
@Nonnull protected abstract Light createNewLight(@Nonnull java.lang.String systemName, java.lang.String userName) throws java.lang.IllegalArgumentException
Internal method to invoke the factory, after all the logic for returning an existing Light has been invoked.- Parameters:
systemName- the system name to use for this lightuserName- the user name to use for this light- Returns:
- the new light or null if unsuccessful
- Throws:
java.lang.IllegalArgumentException- something failed in the names
-
activateAllLights
public void activateAllLights()
Activate the control mechanism for each Light controlled by this LightManager. Note that some Lights don't require any activation. The activateLight method in AbstractLight.java determines what needs to be done for each Light.- Specified by:
activateAllLightsin interfaceLightManager
-
convertSystemNameToAlternate
@Nonnull public java.lang.String convertSystemNameToAlternate(@Nonnull java.lang.String systemName)
Convert the system name to a normalized alternate name.This routine is to allow testing to ensure that two Lights with alternate names that refer to the same output bit are not created.
This routine is implemented in AbstractLightManager to return "". If a system implementation has alternate names, the system specific Light Manager should override this routine and supply the alternate name.
- Specified by:
convertSystemNameToAlternatein interfaceLightManager- Parameters:
systemName- the system name to convert- Returns:
- an alternate name
-
supportsVariableLights
public boolean supportsVariableLights(@Nonnull java.lang.String systemName)
Test if system in the given name can support a variable light.- Specified by:
supportsVariableLightsin interfaceLightManager- Parameters:
systemName- the system name- Returns:
- true if variable lights are supported; false otherwise
-
getBeanTypeHandled
@Nonnull public java.lang.String getBeanTypeHandled(boolean plural)
Get bean type handled.- Specified by:
getBeanTypeHandledin interfaceManager<Light>- Parameters:
plural- true to return plural form of the type; false to return singular form- Returns:
- a string for the type of object handled by this manager
-
getNamedBeanClass
public java.lang.Class<Light> getNamedBeanClass()
Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.- Specified by:
getNamedBeanClassin interfaceManager<Light>- Returns:
- the class supported by this Manager.
-
getEntryToolTip
@CheckForNull public java.lang.String getEntryToolTip()
Get a manager-specific tool tip for adding an entry to the manager.- Specified by:
getEntryToolTipin interfaceManager<Light>- Returns:
- the tool tip or null to disable the tool tip
-
-