Class DefaultLogixNGManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.beans.VetoableChangeSupport
-
- jmri.managers.AbstractManager<LogixNG>
-
- jmri.jmrit.logixng.implementation.DefaultLogixNGManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.beans.VetoableChangeListener,java.util.EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,LogixNG_Manager,Manager<LogixNG>
public class DefaultLogixNGManager extends AbstractManager<LogixNG> implements LogixNG_Manager
Class providing the basic logic of the LogixNG_Manager interface.
-
-
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 Modifier and Type Field Description (package private) static DefaultLogixNGManager_instance-
Fields inherited from class jmri.managers.AbstractManager
_beans, _tsys, _tuser, memo, silenceableProperties, silencedProperties
-
Fields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupport
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
Fields inherited from interface jmri.jmrit.logixng.LogixNG_Manager
ERROR_HANDLING_MODULE_NAME, PROPERTY_SETUP
-
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 DefaultLogixNGManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateAllLogixNGs()Activate all LogixNGs, starts LogixNG processing by connecting all inputs that are included the ConditionalNGs in this LogixNG.voidactivateAllLogixNGs(boolean runDelayed, boolean runOnSeparateThread)Activate all LogixNGs, starts LogixNG processing by connecting all inputs that are included the ConditionalNGs in this LogixNG.LogixNGcreateLogixNG(java.lang.String userName)For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.LogixNGcreateLogixNG(java.lang.String userName, boolean inline)For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.LogixNGcreateLogixNG(java.lang.String systemName, java.lang.String userName)Method to create a new LogixNG if the LogixNG does not exist.LogixNGcreateLogixNG(java.lang.String systemName, java.lang.String userName, boolean inline)Method to create a new LogixNG if the LogixNG does not exist.voiddeActivateAllLogixNGs()DeActivate all LogixNGs, stops LogixNG processing by disconnecting all inputs that are included the ConditionalNGs in this LogixNG.voiddeleteBean(LogixNG logixNG, java.lang.String property)Method for a UI to delete a bean.voiddeleteLogixNG(LogixNG x)Delete LogixNG by removing it from the manager.voidexecuteModule(Module module, java.lang.Object parameter)Executes a LogixNG Module.voidexecuteModule(Module module, java.util.Map<java.lang.String,java.lang.Object> parameters)Executes a LogixNG Module.voidfireVetoableChange(java.lang.String p, java.lang.Object old)Inform all registered listeners of a vetoable change.If the propertyName is "CanDelete" ALL listeners with an interest in the bean will throw an exception, which is recorded returned back to the invoking method, so that it can be presented back to the user.However if a listener decides that the bean can not be deleted then it should throw an exception with a property name of "DoNotDelete", this is thrown back up to the user and the delete process should be aborted.java.lang.StringgetBeanTypeHandled(boolean plural)Get the user-readable name of the type of NamedBean handled by this manager.LogixNGgetBySystemName(java.lang.String name)Locate an existing instance based on a system name.LogixNGgetByUserName(java.lang.String name)Locate an existing instance based on a user name.ClipboardgetClipboard()Get the clipboardFemaleSocketgetErrorHandlingModuleSocket()Get the female socket of the error handling module.LogixNGgetLogixNG(java.lang.String name)Locate via user name, then system name if needed.Manager<? extends MaleSocket>getManager(java.lang.String className)Get manager by class namejava.lang.Class<LogixNG>getNamedBeanClass()Get the class of NamedBean supported by this Manager.intgetXMLOrder()Determine the order that types should be written when storing panel files.static DefaultLogixNGManagerinstance()booleanisActive()Is LogixNGs active?booleanisErrorHandlingModuleEnabled()Is the error handling module enabled?booleanisStartLogixNGsOnLoad()Should the LogixNGs not be started when the configuration file is loaded?voidprintTree(Base.PrintTreeSettings settings, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)Print the tree to a stream.voidprintTree(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)Print the tree to a stream.voidpropertyChange(java.beans.PropertyChangeEvent e)The PropertyChangeListener interface in this class is intended to keep track of user name changes to individual NamedBeans.voidregisterManager(Manager<? extends MaleSocket> manager)Register a manager for later retrieval by getManager()voidregisterSetupTask(java.lang.Runnable task)Register a task to be run when setup LogixNGsvoidsetLoadDisabled(boolean value)Should the LogixNGs be disabled when the configuration file is loaded?voidsetupAllLogixNGs()Setup all LogixNGs.voidstartLogixNGsOnLoad(boolean value)Should the LogixNGs be started when the configuration file is loaded?chartypeLetter()Manager.NameValidityvalidSystemNameFormat(java.lang.String systemName)Test if parameter is a properly formatted system name.-
Methods inherited from class jmri.managers.AbstractManager
addDataListener, checkNumeric, createSystemName, deregister, dispose, fireDataListenersAdded, fireDataListenersRemoved, fireVetoableChange, getAutoSystemName, getBySystemName, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getOuterBean, getSystemPrefix, handleUserNameUniqueness, makeSystemName, register, registerSelf, registerUserName, removeDataListener, setDataListenerMute, setPropertyChangesSilenced, updateAutoNumber, 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.jmrit.logixng.LogixNG_Manager
getAutoSystemName, printTree, printTree
-
Methods inherited from interface jmri.Manager
addDataListener, deregister, dispose, getBeanTypeHandled, getEntryToolTip, 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
-
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
-
-
-
-
Field Detail
-
_instance
static volatile DefaultLogixNGManager _instance
-
-
Constructor Detail
-
DefaultLogixNGManager
public DefaultLogixNGManager()
-
-
Method Detail
-
getXMLOrder
public int getXMLOrder()
Description copied from interface:ManagerDetermine 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<LogixNG>- Returns:
- write order for this Manager; larger is later.
-
typeLetter
public char typeLetter()
- Specified by:
typeLetterin interfaceManager<LogixNG>- Returns:
- The type letter for a specific implementation
-
validSystemNameFormat
public Manager.NameValidity validSystemNameFormat(java.lang.String systemName)
Test if parameter is a properly formatted system name.- Specified by:
validSystemNameFormatin interfaceManager<LogixNG>- Overrides:
validSystemNameFormatin classAbstractManager<LogixNG>- Parameters:
systemName- the system name- Returns:
- enum indicating current validity, which might be just as a prefix
-
createLogixNG
public LogixNG createLogixNG(java.lang.String systemName, java.lang.String userName) throws java.lang.IllegalArgumentException
Method to create a new LogixNG if the LogixNG does not exist.Returns null if a Logix with the same systemName or userName already exists, or if there is trouble creating a new LogixNG.
- Specified by:
createLogixNGin interfaceLogixNG_Manager- Parameters:
systemName- the system nameuserName- the user name- Returns:
- a new LogixNG or null if unable to create
- Throws:
java.lang.IllegalArgumentException- when needed
-
createLogixNG
public LogixNG createLogixNG(java.lang.String systemName, java.lang.String userName, boolean inline) throws java.lang.IllegalArgumentException
Method to create a new LogixNG if the LogixNG does not exist.Returns null if a Logix with the same systemName or userName already exists, or if there is trouble creating a new LogixNG.
- Specified by:
createLogixNGin interfaceLogixNG_Manager- Parameters:
systemName- the system nameuserName- the user nameinline- true if this LogixNG is an inline LogixNG- Returns:
- a new LogixNG or null if unable to create
- Throws:
java.lang.IllegalArgumentException- when needed
-
createLogixNG
public LogixNG createLogixNG(java.lang.String userName) throws java.lang.IllegalArgumentException
Description copied from interface:LogixNG_ManagerFor use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.- Specified by:
createLogixNGin interfaceLogixNG_Manager- Parameters:
userName- the user name- Returns:
- a new LogixNG or null if unable to create
- Throws:
java.lang.IllegalArgumentException- when needed
-
createLogixNG
public LogixNG createLogixNG(java.lang.String userName, boolean inline) throws java.lang.IllegalArgumentException
Description copied from interface:LogixNG_ManagerFor use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.- Specified by:
createLogixNGin interfaceLogixNG_Manager- Parameters:
userName- the user nameinline- true if this LogixNG is an inline LogixNG- Returns:
- a new LogixNG or null if unable to create
- Throws:
java.lang.IllegalArgumentException- when needed
-
getLogixNG
public LogixNG getLogixNG(java.lang.String name)
Description copied from interface:LogixNG_ManagerLocate via user name, then system name if needed. Does not create a new one if nothing found- Specified by:
getLogixNGin interfaceLogixNG_Manager- Parameters:
name- User name or system name to match- Returns:
- null if no match found
-
getByUserName
public LogixNG getByUserName(java.lang.String name)
Description copied from class:AbstractManagerLocate an existing instance based on a user name.- Specified by:
getByUserNamein interfaceLogixNG_Manager- Specified by:
getByUserNamein interfaceManager<LogixNG>- Overrides:
getByUserNamein classAbstractManager<LogixNG>- Parameters:
name- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getBySystemName
public LogixNG getBySystemName(java.lang.String name)
Description copied from class:AbstractManagerLocate an existing instance based on a system name.- Specified by:
getBySystemNamein interfaceLogixNG_Manager- Specified by:
getBySystemNamein interfaceManager<LogixNG>- Overrides:
getBySystemNamein classAbstractManager<LogixNG>- Parameters:
name- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getBeanTypeHandled
public java.lang.String getBeanTypeHandled(boolean plural)
Get the user-readable name of the type of NamedBean handled by this manager.For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.
- Specified by:
getBeanTypeHandledin interfaceManager<LogixNG>- Parameters:
plural- true to return plural form of the type; false to return singular form- Returns:
- a string of the bean type that the manager handles, eg Turnout, Sensor etc
-
setLoadDisabled
public void setLoadDisabled(boolean value)
Should the LogixNGs be disabled when the configuration file is loaded?- Specified by:
setLoadDisabledin interfaceLogixNG_Manager- Parameters:
value- true if they should be disabled, false otherwise.
-
startLogixNGsOnLoad
public void startLogixNGsOnLoad(boolean value)
Should the LogixNGs be started when the configuration file is loaded?- Specified by:
startLogixNGsOnLoadin interfaceLogixNG_Manager- Parameters:
value- true if they should be started, false otherwise.
-
isStartLogixNGsOnLoad
public boolean isStartLogixNGsOnLoad()
Should the LogixNGs not be started when the configuration file is loaded?- Specified by:
isStartLogixNGsOnLoadin interfaceLogixNG_Manager- Returns:
- true if they should be started, false otherwise.
-
setupAllLogixNGs
public void setupAllLogixNGs()
Setup all LogixNGs. This method is called after a configuration file is loaded.- Specified by:
setupAllLogixNGsin interfaceLogixNG_Manager
-
activateAllLogixNGs
public void activateAllLogixNGs()
Activate all LogixNGs, starts LogixNG processing by connecting all inputs that are included the ConditionalNGs in this LogixNG.A LogixNG must be activated before it will calculate any of its ConditionalNGs.
- Specified by:
activateAllLogixNGsin interfaceLogixNG_Manager
-
activateAllLogixNGs
public void activateAllLogixNGs(boolean runDelayed, boolean runOnSeparateThread)
Activate all LogixNGs, starts LogixNG processing by connecting all inputs that are included the ConditionalNGs in this LogixNG.A LogixNG must be activated before it will calculate any of its ConditionalNGs.
- Specified by:
activateAllLogixNGsin interfaceLogixNG_Manager- Parameters:
runDelayed- true if execute() should run on LogixNG thread delayed, false otherwise.runOnSeparateThread- true if the activation should run on a separate thread, false otherwise
-
deActivateAllLogixNGs
public void deActivateAllLogixNGs()
DeActivate all LogixNGs, stops LogixNG processing by disconnecting all inputs that are included the ConditionalNGs in this LogixNG.A LogixNG must be activated before it will calculate any of its ConditionalNGs.
- Specified by:
deActivateAllLogixNGsin interfaceLogixNG_Manager
-
isActive
public boolean isActive()
Is LogixNGs active?- Specified by:
isActivein interfaceLogixNG_Manager- Returns:
- true if LogixNGs are active, false otherwise
-
deleteLogixNG
public void deleteLogixNG(LogixNG x)
Delete LogixNG by removing it from the manager. The LogixNG must first be deactivated so it stops processing.- Specified by:
deleteLogixNGin interfaceLogixNG_Manager- Parameters:
x- the LogixNG to delete
-
printTree
public void printTree(Base.PrintTreeSettings settings, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)
Print the tree to a stream.- Specified by:
printTreein interfaceLogixNG_Manager- Parameters:
settings- settings for what to printwriter- the stream to print the tree toindent- the indentation of each levellineNumber- the line number
-
printTree
public void printTree(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)
Print the tree to a stream.- Specified by:
printTreein interfaceLogixNG_Manager- Parameters:
settings- settings for what to printlocale- The locale to be usedwriter- the stream to print the tree toindent- the indentation of each levellineNumber- the line number
-
instance
@InvokeOnGuiThread public static DefaultLogixNGManager instance()
-
getNamedBeanClass
public java.lang.Class<LogixNG> 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<LogixNG>- Returns:
- the class supported by this Manager.
-
getClipboard
public Clipboard getClipboard()
Get the clipboard- Specified by:
getClipboardin interfaceLogixNG_Manager- Returns:
- the clipboard
-
registerManager
public void registerManager(Manager<? extends MaleSocket> manager)
Register a manager for later retrieval by getManager()- Specified by:
registerManagerin interfaceLogixNG_Manager- Parameters:
manager- the manager
-
getManager
public Manager<? extends MaleSocket> getManager(java.lang.String className)
Get manager by class name- Specified by:
getManagerin interfaceLogixNG_Manager- Parameters:
className- the class name of the manager- Returns:
- the manager
-
fireVetoableChange
@OverridingMethodsMustInvokeSuper public void fireVetoableChange(java.lang.String p, java.lang.Object old) throws java.beans.PropertyVetoException
Inform all registered listeners of a vetoable change.If the propertyName is "CanDelete" ALL listeners with an interest in the bean will throw an exception, which is recorded returned back to the invoking method, so that it can be presented back to the user.However if a listener decides that the bean can not be deleted then it should throw an exception with a property name of "DoNotDelete", this is thrown back up to the user and the delete process should be aborted.- Parameters:
p- The programmatic name of the property that is to be changed. "CanDelete" will inquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item.old- The old value of the property.- Throws:
java.beans.PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-
deleteBean
public final void deleteBean(@Nonnull LogixNG logixNG, @Nonnull java.lang.String property) throws java.beans.PropertyVetoException
Method for a UI to delete a bean.The UI should first request a "CanDelete", this will return a list of locations (and descriptions) where the bean is in use via throwing a VetoException, then if that comes back clear, or the user agrees with the actions, then a "DoDelete" can be called which inform the listeners to delete the bean, then it will be deregistered and disposed of.
If a property name of "DoNotDelete" is thrown back in the VetoException then the delete process should be aborted.
- Specified by:
deleteBeanin interfaceManager<LogixNG>- Overrides:
deleteBeanin classAbstractManager<LogixNG>- Parameters:
logixNG- The NamedBean to be deletedproperty- The programmatic name of the request. "CanDelete" will enquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item- Throws:
java.beans.PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-
registerSetupTask
public void registerSetupTask(java.lang.Runnable task)
Register a task to be run when setup LogixNGs- Specified by:
registerSetupTaskin interfaceLogixNG_Manager- Parameters:
task- the task
-
executeModule
public void executeModule(Module module, java.lang.Object parameter) throws java.lang.IllegalArgumentException
Executes a LogixNG Module. Note that the module must be a Digital Action Module.- Specified by:
executeModulein interfaceLogixNG_Manager- Parameters:
module- The module to be executedparameter- The parameter. The module must have exactly one parameter.- Throws:
java.lang.IllegalArgumentException- If module is null or if module is not a DigitalActionModule.
-
executeModule
public void executeModule(Module module, java.util.Map<java.lang.String,java.lang.Object> parameters) throws java.lang.IllegalArgumentException
Executes a LogixNG Module. Note that the module must be a Digital Action Module.- Specified by:
executeModulein interfaceLogixNG_Manager- Parameters:
module- The module to be executedparameters- The parameters- Throws:
java.lang.IllegalArgumentException- If module or parameters is null or if module is not a DigitalActionModule.
-
getErrorHandlingModuleSocket
public FemaleSocket getErrorHandlingModuleSocket()
Get the female socket of the error handling module.- Specified by:
getErrorHandlingModuleSocketin interfaceLogixNG_Manager- Returns:
- the socket.
-
isErrorHandlingModuleEnabled
public boolean isErrorHandlingModuleEnabled()
Is the error handling module enabled? It's enabled if it exists and the root socket is connected.- Specified by:
isErrorHandlingModuleEnabledin interfaceLogixNG_Manager- Returns:
- true if it's in use, false otherwise.
-
propertyChange
@OverridingMethodsMustInvokeSuper public void propertyChange(java.beans.PropertyChangeEvent e)
The PropertyChangeListener interface in this class is intended to keep track of user name changes to individual NamedBeans. It is not completely implemented yet. In particular, listeners are not added to newly registered objects.- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Overrides:
propertyChangein classAbstractManager<LogixNG>- Parameters:
e- the event
-
-