Package jmri.jmrix.can
Class CanSystemConnectionMemo
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.jmrix.DefaultSystemConnectionMemo
-
- jmri.jmrix.can.CanSystemConnectionMemo
-
- All Implemented Interfaces:
BeanInterface,PropertyChangeFirer,PropertyChangeProvider,Disposable,ConfiguringSystemConnectionMemo,SystemConnectionMemo
public class CanSystemConnectionMemo extends DefaultSystemConnectionMemo implements ConfiguringSystemConnectionMemo
Lightweight class to denote that a system is active, and provide general information.As various CAN adapters, can work with different CAN Bus systems, the adapter memo is generic for all adapters, it then uses a ConfigurationManager for each of the CAN Bus systems. Any requests for provision or configuration is passed on to the relevant ConfigurationManager to handle.
-
-
Field Summary
Fields Modifier and Type Field Description protected ConfigurationManager.ProgModeSwitch_progModeSwitchprotected java.lang.String_protocolprotected ConfigurationManager.SubProtocol_subProtocolprotected boolean_supportsCVHints(package private) ComponentFactorycfstatic java.lang.StringDEFAULT_USERNAMEprotected TrafficControllertm-
Fields inherited from class jmri.jmrix.DefaultSystemConnectionMemo
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 Constructor Description CanSystemConnectionMemo()Create a new CanSystemConnectionMemo.CanSystemConnectionMemo(java.lang.String prefix)Create a new CanSystemConnectionMemo.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigureManagers()Configure the common managers for Can connections.voiddispose()Dispose of System Connection.<T> Tget(java.lang.Class<T> T)Get a manager for a specific type.protected java.util.ResourceBundlegetActionModelResourceBundle()intgetDefaultOutputInterval()Custom interval of 100ms.<T> TgetFromMap(java.lang.Class<?> T)Get a class directly from the memo Class Object Map.<B extends NamedBean>
java.util.Comparator<B>getNamedBeanComparator(java.lang.Class<B> type)Get the Comparator to be used for two NamedBeans.ConfigurationManager.ProgModeSwitchgetProgModeSwitch()Get the state of the programming mode switch which indicates what combination of service and/or ops mode programming is supported by the connection.java.lang.StringgetProtocol()Get the Protocol in use by the CAN Connection.java.util.Map<java.lang.String,java.lang.String>getProtocolAllOptions(java.lang.String protocol)Get all options we have set (saved in the connection XML) for a given protocol type.java.lang.StringgetProtocolOption(java.lang.String protocol, java.lang.String option)Get a single option of a single protocol, or null if not present.java.util.Set<java.lang.String>getProtocolsWithOptions()Enumerate all protocols that have options set.ConfigurationManager.SubProtocolgetSubProtocol()Get ENUM of the sub protocol.TrafficControllergetTrafficController()Get Connection Traffic Controller.booleanhasMultipleThrottles()Some connections support only a single throttle, e.g., a service mode programmer that allows for test running of a single loco.booleanisDirty()Get if connection is dirty.booleanisRestartRequired()booleanpowerOnArst()Get the behaviour on ARST opcodebooleanprovides(java.lang.Class<?> type)Check if this connection provides a specific manager type.voidsetMultipleThrottles(boolean b)voidsetPowerOnArst(boolean b)voidsetProgModeSwitch(ConfigurationManager.ProgModeSwitch pms)voidsetProtocol(java.lang.String protocol)Set the protocol in use by the connection.voidsetProtocolOption(java.lang.String protocol, java.lang.String option, java.lang.String value)Sets a protocol option.voidsetSubProtocol(ConfigurationManager.SubProtocol sp)Set the sub protocol ENUM.voidsetSupportsCVHints(boolean b)voidsetTrafficController(TrafficController tm)Set Connection Traffic Controller.protected voidstoreCanMemotoInstance()booleansupportsCVHints()Get the CV hint support flag-
Methods inherited from class jmri.jmrix.DefaultSystemConnectionMemo
deregister, getActionFactory, getConsistManager, getDisabled, getOutputInterval, getSystemPrefix, getUserName, register, setConsistManager, setDisabled, setOutputInterval, setSystemPrefix, setUserName, store
-
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
-
Methods inherited from interface jmri.SystemConnectionMemo
getActionFactory, getDisabled, getOutputInterval, getSystemPrefix, getUserName, register, setDisabled, setOutputInterval, setSystemPrefix, setUserName
-
-
-
-
Field Detail
-
DEFAULT_USERNAME
public static final java.lang.String DEFAULT_USERNAME
- See Also:
- Constant Field Values
-
_protocol
protected java.lang.String _protocol
-
_subProtocol
protected ConfigurationManager.SubProtocol _subProtocol
-
_progModeSwitch
protected ConfigurationManager.ProgModeSwitch _progModeSwitch
-
_supportsCVHints
protected boolean _supportsCVHints
-
tm
protected TrafficController tm
-
-
Constructor Detail
-
CanSystemConnectionMemo
public CanSystemConnectionMemo()
Create a new CanSystemConnectionMemo. Default prefix: M Default Username: CAN
-
CanSystemConnectionMemo
public CanSystemConnectionMemo(java.lang.String prefix)
Create a new CanSystemConnectionMemo. Allows for default systemPrefix other than "M" Default Username: CAN- Parameters:
prefix- System prefix to use, e.g. M.
-
-
Method Detail
-
storeCanMemotoInstance
protected final void storeCanMemotoInstance()
-
setTrafficController
public void setTrafficController(TrafficController tm)
Set Connection Traffic Controller.- Parameters:
tm- System Connection Traffic Controller
-
getTrafficController
public TrafficController getTrafficController()
Get Connection Traffic Controller.- Returns:
- System Connection Traffic Controller
-
provides
public boolean provides(java.lang.Class<?> type)
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. Searches ConfigurationManager for class before super.- Specified by:
providesin interfaceSystemConnectionMemo- Overrides:
providesin classDefaultSystemConnectionMemo- Parameters:
type- The class type for the manager to be provided- Returns:
- true if the specified manager is provided
- See Also:
DefaultSystemConnectionMemo.get(java.lang.Class)
-
get
public <T> T get(java.lang.Class<T> T)
Get a manager for a specific type. This method must return a non-null value ifDefaultSystemConnectionMemo.provides(java.lang.Class)is true for the type, and must return null if provides() is false for the type. Searches ConfigurationManager for class before super.- Specified by:
getin interfaceSystemConnectionMemo- Overrides:
getin classDefaultSystemConnectionMemo- Type Parameters:
T- Type of manager to get- Parameters:
T- Type of manager to get- Returns:
- The manager or null if provides() is false for T
- See Also:
DefaultSystemConnectionMemo.provides(java.lang.Class)
-
getFromMap
public <T> T getFromMap(java.lang.Class<?> T)
Get a class directly from the memo Class Object Map.- Type Parameters:
T- Class type- Parameters:
T- Class type- Returns:
- object in class object map, or null if not present.
-
getProtocol
public java.lang.String getProtocol()
Get the Protocol in use by the CAN Connection. e.g. ConfigurationManager.SPROGCBUS- Returns:
- ConfigurationManager constant of protocol.
-
setProtocol
public void setProtocol(java.lang.String protocol)
Set the protocol in use by the connection.- Parameters:
protocol- e.g. ConfigurationManager.SPROGCBUS
-
getSubProtocol
public ConfigurationManager.SubProtocol getSubProtocol()
Get ENUM of the sub protocol.- Returns:
- the sub protocol in use, e.g. SubProtocol.CBUS
-
setSubProtocol
public void setSubProtocol(ConfigurationManager.SubProtocol sp)
Set the sub protocol ENUM.- Parameters:
sp- e.g. SubProtocol.CBUS
-
getProgModeSwitch
public ConfigurationManager.ProgModeSwitch getProgModeSwitch()
Get the state of the programming mode switch which indicates what combination of service and/or ops mode programming is supported by the connection.- Returns:
- the supported modes
-
setProgModeSwitch
public void setProgModeSwitch(ConfigurationManager.ProgModeSwitch pms)
-
hasMultipleThrottles
public boolean hasMultipleThrottles()
Some connections support only a single throttle, e.g., a service mode programmer that allows for test running of a single loco.- Returns:
- true if mutltiple throttles are available
-
setMultipleThrottles
public void setMultipleThrottles(boolean b)
-
supportsCVHints
public boolean supportsCVHints()
Get the CV hint support flag- Returns:
- true if CV hints are supported
-
setSupportsCVHints
public void setSupportsCVHints(boolean b)
-
powerOnArst
public boolean powerOnArst()
Get the behaviour on ARST opcode- Returns:
- true if track power is on after ARST
-
setPowerOnArst
public void setPowerOnArst(boolean b)
-
configureManagers
public void configureManagers()
Configure the common managers for Can connections. Configure the common managers associated with the System Connection memo. Calls ConfigurationManager.configureManagers Stores Can Memo to Instance to indicate available.- Specified by:
configureManagersin interfaceConfiguringSystemConnectionMemo
-
getActionModelResourceBundle
protected java.util.ResourceBundle getActionModelResourceBundle()
- Specified by:
getActionModelResourceBundlein classDefaultSystemConnectionMemo
-
getNamedBeanComparator
public <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:
getNamedBeanComparatorin interfaceSystemConnectionMemo- Specified by:
getNamedBeanComparatorin classDefaultSystemConnectionMemo- Type Parameters:
B- the type of NamedBean- Parameters:
type- the class of NamedBean- Returns:
- the Comparator
-
getProtocolsWithOptions
public java.util.Set<java.lang.String> getProtocolsWithOptions()
Enumerate all protocols that have options set.- Returns:
- set of protocol names.
-
getProtocolAllOptions
@Nonnull public java.util.Map<java.lang.String,java.lang.String> getProtocolAllOptions(java.lang.String protocol)
Get all options we have set (saved in the connection XML) for a given protocol type.- Parameters:
protocol- String name of the protocol.- Returns:
- map of known protocol options to values, or empty map.
-
getProtocolOption
public java.lang.String getProtocolOption(java.lang.String protocol, java.lang.String option)
Get a single option of a single protocol, or null if not present.- Parameters:
protocol- name of the protocol.option- name of the option.- Returns:
- null if option has never been set; or the option value if set.
-
setProtocolOption
public void setProtocolOption(java.lang.String protocol, java.lang.String option, java.lang.String value)
Sets a protocol option. This list will be persisted when the connection gets saved.- Parameters:
protocol- name of the protocoloption- name of the optionvalue- option value
-
isDirty
public boolean isDirty()
Description copied from class:DefaultSystemConnectionMemoGet if connection is dirty. Checked fields are disabled, prefix, userName- Specified by:
isDirtyin interfaceSystemConnectionMemo- Overrides:
isDirtyin classDefaultSystemConnectionMemo- Returns:
- true if changed since loaded
-
isRestartRequired
public boolean isRestartRequired()
- Specified by:
isRestartRequiredin interfaceSystemConnectionMemo- Overrides:
isRestartRequiredin classDefaultSystemConnectionMemo
-
getDefaultOutputInterval
public int getDefaultOutputInterval()
Custom interval of 100ms. Default interval 250ms. Get the Default connection specific OutputInterval to wait between/before commands are sent.- Specified by:
getDefaultOutputIntervalin interfaceSystemConnectionMemo- Overrides:
getDefaultOutputIntervalin classDefaultSystemConnectionMemo- Returns:
- the default output interval time in ms.
-
dispose
public void dispose()
Dispose of System Connection.Removes objects from classObjectMap after calling dispose if Disposable. Removes these objects from InstanceManager.
- Specified by:
disposein interfaceDisposable- Specified by:
disposein interfaceSystemConnectionMemo- Overrides:
disposein classDefaultSystemConnectionMemo
-
-