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
FieldsModifier and TypeFieldDescriptionprotected ConfigurationManager.ProgModeSwitchprotected Stringprotected ConfigurationManager.SubProtocolprotected boolean(package private) ComponentFactorystatic final Stringprotected TrafficControllerFields inherited from class jmri.jmrix.DefaultSystemConnectionMemo
classObjectMapFields inherited from class jmri.beans.Bean
propertyChangeSupportFields inherited from interface jmri.SystemConnectionMemo
DEREGISTER, DISABLED, INTERVAL, STORE, SYSTEM_PREFIX, USER_NAME -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new CanSystemConnectionMemo.CanSystemConnectionMemo(String prefix) Create a new CanSystemConnectionMemo. -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure the common managers for Can connections.voiddispose()Dispose of System Connection.<T> TGet a manager for a specific type.protected ResourceBundleintCustom interval of 100ms.<T> TgetFromMap(Class<?> T) Get a class directly from the memo Class Object Map.<B extends NamedBean>
Comparator<B>getNamedBeanComparator(Class<B> type) Get the Comparator to be used for two NamedBeans.Get the state of the programming mode switch which indicates what combination of service and/or ops mode programming is supported by the connection.Get the Protocol in use by the CAN Connection.getProtocolAllOptions(String protocol) Get all options we have set (saved in the connection XML) for a given protocol type.getProtocolOption(String protocol, String option) Get a single option of a single protocol, or null if not present.Enumerate all protocols that have options set.Get ENUM of the sub protocol.Get Connection Traffic Controller.booleanSome 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.booleanbooleanGet the behaviour on ARST opcodebooleanCheck if this connection provides a specific manager type.voidsetMultipleThrottles(boolean b) voidsetPowerOnArst(boolean b) voidvoidsetProtocol(String protocol) Set the protocol in use by the connection.voidsetProtocolOption(String protocol, String option, String value) Sets a protocol option.voidSet the sub protocol ENUM.voidsetSupportsCVHints(boolean b) voidSet Connection Traffic Controller.protected final voidbooleanGet the CV hint support flagMethods inherited from class jmri.jmrix.DefaultSystemConnectionMemo
deregister, getActionFactory, getConsistManager, getDisabled, getOutputInterval, getSystemPrefix, getUserName, register, setConsistManager, setDisabled, setOutputInterval, setSystemPrefix, setUserName, storeMethods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.SystemConnectionMemo
getActionFactory, getDisabled, getOutputInterval, getSystemPrefix, getUserName, register, setDisabled, setOutputInterval, setSystemPrefix, setUserName
-
Field Details
-
DEFAULT_USERNAME
- See Also:
-
_protocol
-
_subProtocol
-
_progModeSwitch
-
_supportsCVHints
-
cf
-
tm
-
-
Constructor Details
-
CanSystemConnectionMemo
public CanSystemConnectionMemo()Create a new CanSystemConnectionMemo. Default prefix: M Default Username: CAN -
CanSystemConnectionMemo
Create a new CanSystemConnectionMemo. Allows for default systemPrefix other than "M" Default Username: CAN- Parameters:
prefix- System prefix to use, e.g. M.
-
-
Method Details
-
storeCanMemotoInstance
-
setTrafficController
Set Connection Traffic Controller.- Parameters:
tm- System Connection Traffic Controller
-
getTrafficController
Get Connection Traffic Controller.- Returns:
- System Connection Traffic Controller
-
provides
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:
-
get
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:
-
getFromMap
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
Get the Protocol in use by the CAN Connection. e.g. ConfigurationManager.SPROGCBUS- Returns:
- ConfigurationManager constant of protocol.
-
setProtocol
Set the protocol in use by the connection.- Parameters:
protocol- e.g. ConfigurationManager.SPROGCBUS
-
getSubProtocol
Get ENUM of the sub protocol.- Returns:
- the sub protocol in use, e.g. SubProtocol.CBUS
-
setSubProtocol
Set the sub protocol ENUM.- Parameters:
sp- e.g. SubProtocol.CBUS
-
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
-
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
-
supportsCVHints
Get the CV hint support flag- Returns:
- true if CV hints are supported
-
setSupportsCVHints
-
powerOnArst
Get the behaviour on ARST opcode- Returns:
- true if track power is on after ARST
-
setPowerOnArst
-
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
- Specified by:
getActionModelResourceBundlein classDefaultSystemConnectionMemo
-
getNamedBeanComparator
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
Enumerate all protocols that have options set.- Returns:
- set of protocol names.
-
getProtocolAllOptions
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
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
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
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
- Specified by:
isRestartRequiredin interfaceSystemConnectionMemo- Overrides:
isRestartRequiredin classDefaultSystemConnectionMemo
-
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
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
-