Class DefaultSystemConnectionMemo
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.jmrix.DefaultSystemConnectionMemo
-
- All Implemented Interfaces:
BeanInterface
,PropertyChangeFirer
,PropertyChangeProvider
,Disposable
,SystemConnectionMemo
- Direct Known Subclasses:
AcelaSystemConnectionMemo
,AnymaDMX_SystemConnectionMemo
,BiDiBSystemConnectionMemo
,CanSystemConnectionMemo
,CaptiveSystemConnectionMemo
,CMRISystemConnectionMemo
,Dcc4PcSystemConnectionMemo
,DCCppSystemConnectionMemo
,DirectSystemConnectionMemo
,EasyDccSystemConnectionMemo
,EcosSystemConnectionMemo
,GrapevineSystemConnectionMemo
,IEEE802154SystemConnectionMemo
,InternalSystemConnectionMemo
,IpocsSystemConnectionMemo
,JMRIClientSystemConnectionMemo
,LocoNetSystemConnectionMemo
,MapleSystemConnectionMemo
,MarklinSystemConnectionMemo
,MqttSystemConnectionMemo
,MrcSystemConnectionMemo
,Mx1SystemConnectionMemo
,NceSystemConnectionMemo
,OakTreeSystemConnectionMemo
,QsiSystemConnectionMemo
,RaspberryPiSystemConnectionMemo
,RfidSystemConnectionMemo
,RpsSystemConnectionMemo
,SecsiSystemConnectionMemo
,SerialSystemConnectionMemo
,SpeedoSystemConnectionMemo
,SprogSystemConnectionMemo
,SRCPBusConnectionMemo
,SRCPSystemConnectionMemo
,TamsSystemConnectionMemo
,TmccSystemConnectionMemo
,XNetSystemConnectionMemo
,XpaSystemConnectionMemo
,Z21SystemConnectionMemo
public abstract class DefaultSystemConnectionMemo extends Bean implements SystemConnectionMemo, Disposable
Lightweight abstract class to denote that a system is active, and provide general information.Objects of specific subtypes of this are registered in the
InstanceManager
to activate their particular system.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Class<?>,java.lang.Object>
classObjectMap
-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
Fields inherited from interface jmri.SystemConnectionMemo
DEREGISTER, DISABLED, INTERVAL, STORE, SYSTEM_PREFIX, USER_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultSystemConnectionMemo(java.lang.String prefix, java.lang.String userName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> void
deregister(T item, java.lang.Class<T> type)
Remove a class object from the system connection memo classObjectMap.void
dispose()
Dispose of System Connection.<T> T
get(java.lang.Class<T> type)
Get a manager for a specific type.StartupActionFactory
getActionFactory()
Provide a factory for getting startup actions.protected abstract java.util.ResourceBundle
getActionModelResourceBundle()
ConsistManager
getConsistManager()
Provide access to the ConsistManager for this particular connection.int
getDefaultOutputInterval()
Default interval 250ms.boolean
getDisabled()
Get if the System Connection is currently Disabled.abstract <B extends NamedBean>
java.util.Comparator<B>getNamedBeanComparator(java.lang.Class<B> type)
Get the Comparator to be used for two NamedBeans.int
getOutputInterval()
Get the connection specific OutputInterval (in ms) to wait between/before commands are sent, configured in AdapterConfig.java.lang.String
getSystemPrefix()
Provide access to the system prefix string.java.lang.String
getUserName()
Provide access to the system user name string.boolean
isDirty()
Get if connection is dirty.boolean
isRestartRequired()
boolean
provides(java.lang.Class<?> c)
Check if this connection provides a specific manager type.void
register()
Register with the SystemConnectionMemoManager and InstanceManager with proper ID for later retrieval as a generic system.void
setConsistManager(ConsistManager c)
void
setDisabled(boolean disabled)
Set if the System Connection is currently Disabled.void
setOutputInterval(int newInterval)
boolean
setSystemPrefix(java.lang.String systemPrefix)
Set the system prefix.boolean
setUserName(java.lang.String userName)
Set the user name for the system connection.<T> void
store(T item, java.lang.Class<T> type)
Store a class object to the system connection memo.-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
classObjectMap
protected java.util.Map<java.lang.Class<?>,java.lang.Object> classObjectMap
-
-
Constructor Detail
-
DefaultSystemConnectionMemo
protected DefaultSystemConnectionMemo(@Nonnull java.lang.String prefix, @Nonnull java.lang.String userName)
-
-
Method Detail
-
register
public void register()
Register with the SystemConnectionMemoManager and InstanceManager with proper ID for later retrieval as a generic system.This operation should occur only when the SystemConnectionMemo is ready for use.
- Specified by:
register
in interfaceSystemConnectionMemo
-
getSystemPrefix
public java.lang.String getSystemPrefix()
Provide access to the system prefix string.This was previously called the "System letter".
- Specified by:
getSystemPrefix
in interfaceSystemConnectionMemo
- Returns:
- System prefix
-
setSystemPrefix
public final boolean setSystemPrefix(@Nonnull java.lang.String systemPrefix)
Set the system prefix.- Specified by:
setSystemPrefix
in interfaceSystemConnectionMemo
- Parameters:
systemPrefix
- prefix to use for this system connection- Returns:
- true if the system prefix could be set
- Throws:
java.lang.NullPointerException
- if systemPrefix is null
-
getUserName
public java.lang.String getUserName()
Provide access to the system user name string.This was previously fixed at configuration time.
- Specified by:
getUserName
in interfaceSystemConnectionMemo
- Returns:
- User name of the connection
-
setUserName
public final boolean setUserName(@Nonnull java.lang.String userName)
Set the user name for the system connection.- Specified by:
setUserName
in interfaceSystemConnectionMemo
- Parameters:
userName
- user name to use for this system connection- Returns:
- true if the user name could be set.
- Throws:
java.lang.NullPointerException
- if name is null
-
provides
@OverridingMethodsMustInvokeSuper public boolean provides(java.lang.Class<?> c)
Check if this connection provides a specific manager type. This method must return false if a manager for the specific type is not provided, and must return true if a manager for the specific type is provided.- Specified by:
provides
in interfaceSystemConnectionMemo
- Parameters:
c
- The class type for the manager to be provided- Returns:
- true if the specified manager is provided
- See Also:
get(java.lang.Class)
-
get
@OverridingMethodsMustInvokeSuper public <T> T get(java.lang.Class<T> type)
Get a manager for a specific type. This method must return a non-null value ifprovides(java.lang.Class)
is true for the type, and must return null if provides() is false for the type.- Specified by:
get
in interfaceSystemConnectionMemo
- Type Parameters:
T
- Type of manager to get- Parameters:
type
- Type of manager to get- Returns:
- The manager or null if provides() is false for T
- See Also:
provides(java.lang.Class)
-
dispose
public void dispose()
Dispose of System Connection.Removes objects from classObjectMap after calling dispose if Disposable. Removes these objects from InstanceManager.
- Specified by:
dispose
in interfaceDisposable
- Specified by:
dispose
in interfaceSystemConnectionMemo
-
getDisabled
public boolean getDisabled()
Get if the System Connection is currently Disabled.- Specified by:
getDisabled
in interfaceSystemConnectionMemo
- Returns:
- true if Disabled, else false.
-
setDisabled
public void setDisabled(boolean disabled)
Set if the System Connection is currently Disabled.disabledAsLoaded is only set once. Sends PropertyChange on change of disabled status.
- Specified by:
setDisabled
in interfaceSystemConnectionMemo
- Parameters:
disabled
- true to disable, false to enable.
-
getNamedBeanComparator
public abstract <B extends NamedBean> java.util.Comparator<B> getNamedBeanComparator(java.lang.Class<B> type)
Get the Comparator to be used for two NamedBeans. This is typically anNamedBeanComparator
, but may be any Comparator that works for this connection type.- Specified by:
getNamedBeanComparator
in interfaceSystemConnectionMemo
- Type Parameters:
B
- the type of NamedBean- Parameters:
type
- the class of NamedBean- Returns:
- the Comparator
-
getActionFactory
@Nonnull public StartupActionFactory getActionFactory()
Provide a factory for getting startup actions.This is a bound, read-only, property under the name "actionFactory".
- Specified by:
getActionFactory
in interfaceSystemConnectionMemo
- Returns:
- the factory
-
getActionModelResourceBundle
protected abstract java.util.ResourceBundle getActionModelResourceBundle()
-
isDirty
public boolean isDirty()
Get if connection is dirty. Checked fields are disabled, prefix, userName- Specified by:
isDirty
in interfaceSystemConnectionMemo
- Returns:
- true if changed since loaded
-
isRestartRequired
public boolean isRestartRequired()
- Specified by:
isRestartRequired
in interfaceSystemConnectionMemo
-
getConsistManager
public ConsistManager getConsistManager()
Provide access to the ConsistManager for this particular connection.- Returns:
- the provided ConsistManager or null if the connection does not provide a ConsistManager
-
setConsistManager
public void setConsistManager(ConsistManager c)
-
store
public <T> void store(@Nonnull T item, @Nonnull java.lang.Class<T> type)
Store a class object to the system connection memo.Does NOT register the class with InstanceManager.
On memo dispose, each class will be removed from InstanceManager, and if the class implements disposable, the dispose method is called.
- Type Parameters:
T
- Class type obtained from item object.- Parameters:
item
- the class object to store, eg. mySensorManagertype
- Class type, eg. SensorManager.class
-
deregister
public <T> void deregister(@Nonnull T item, @Nonnull java.lang.Class<T> type)
Remove a class object from the system connection memo classObjectMap.Does NOT remove the class from InstanceManager.
- Type Parameters:
T
- Class type obtained from item object.- Parameters:
item
- the class object to store, eg. mySensorManagertype
- Class type, eg. SensorManager.class
-
getDefaultOutputInterval
public int getDefaultOutputInterval()
Default interval 250ms. Get the Default connection specific OutputInterval to wait between/before commands are sent.- Specified by:
getDefaultOutputInterval
in interfaceSystemConnectionMemo
- Returns:
- the default output interval time in ms.
-
getOutputInterval
public int getOutputInterval()
Get the connection specific OutputInterval (in ms) to wait between/before commands are sent, configured in AdapterConfig. Used inAbstractTurnout.setCommandedStateAtInterval(int)
.- Specified by:
getOutputInterval
in interfaceSystemConnectionMemo
- Returns:
- the output interval time in ms
-
setOutputInterval
public void setOutputInterval(int newInterval)
- Specified by:
setOutputInterval
in interfaceSystemConnectionMemo
-
-