Package jmri.jmrix.cmri
Class CMRISystemConnectionMemo
java.lang.Object
jmri.beans.UnboundBean
jmri.beans.Bean
jmri.jmrix.DefaultSystemConnectionMemo
jmri.jmrix.cmri.CMRISystemConnectionMemo
- All Implemented Interfaces:
BeanInterface,PropertyChangeFirer,PropertyChangeProvider,Disposable,ConfiguringSystemConnectionMemo,SystemConnectionMemo
public class CMRISystemConnectionMemo
extends DefaultSystemConnectionMemo
implements ConfiguringSystemConnectionMemo
Minimal SystemConnectionMemo for C/MRI systems.
-
Field Summary
FieldsFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcheckSystemPrefix(String systemName) Check and skip the System Prefix string on a system name.static intcompareSystemNameSuffix(String suffix1, String suffix2) voidConfigure the common managers for CMRI connections.convertSystemNameToAlternate(String systemName) Convert one format C/MRI system name to the alternate format.voiddispose()Dispose of System Connection.protected ResourceBundleintgetBitFromSystemName(String systemName) Get the bit number from a C/MRI system name.<B extends NamedBean>
Comparator<B>getNamedBeanComparator(Class<B> type) Get the Comparator to be used for two NamedBeans.intgetNodeAddressFromSystemName(String systemName) Get the serial node address from a C/MRI system name.getNodeFromSystemName(String systemName, SerialTrafficController tc) Get the serial node from a C/MRI system name.Get the traffic controller instance associated with this connection memo.getUserNameFromSystemName(String systemName) Get the user name for a valid system name.isInputBitFree(int nAddress, int bitNum) Test if a C/MRI input bit is free for assignment.isOutputBitFree(int nAddress, int bitNum) Test if a C/MRI output bit is free for assignment.makeSystemName(String type, int nAddress, int bitNum) Construct a C/MRI system name from type character, node address, and bit number.normalizeSystemName(String systemName) Normalize a C/MRI system name.voidSet the traffic controller instance associated with this connection memo.validateSystemNameFormat(String systemName, char type, Locale locale) Validate system name format.booleanvalidSystemNameConfig(String systemName, char type, SerialTrafficController tc) Validate C/MRI system name for configuration.validSystemNameFormat(String systemName, char type) Validate system name format.Methods inherited from class jmri.jmrix.DefaultSystemConnectionMemo
deregister, get, getActionFactory, getConsistManager, getDefaultOutputInterval, getDisabled, getOutputInterval, getSystemPrefix, getUserName, isDirty, isRestartRequired, provides, 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
get, getActionFactory, getDefaultOutputInterval, getDisabled, getOutputInterval, getSystemPrefix, getUserName, isDirty, isRestartRequired, provides, register, setDisabled, setOutputInterval, setSystemPrefix, setUserName
-
Field Details
-
cf
-
-
Constructor Details
-
CMRISystemConnectionMemo
public CMRISystemConnectionMemo() -
CMRISystemConnectionMemo
-
-
Method Details
-
setTrafficController
Set the traffic controller instance associated with this connection memo.- Parameters:
s- jmri.jmrix.cmri.serial.SerialTrafficController object to use.
-
getTrafficController
Get the traffic controller instance associated with this connection memo.- Returns:
- the traffic controller, created if needed
-
getUserNameFromSystemName
Get the user name for a valid system name.- Parameters:
systemName- the system name- Returns:
- "" (null string) if the system name is not valid or does not exist
-
getBitFromSystemName
Get the bit number from a C/MRI system name. Bits are numbered from 1. Does not check whether that node is defined on current system.- Parameters:
systemName- the system name- Returns:
- 0 if an error is found
-
checkSystemPrefix
Check and skip the System Prefix string on a system name.- Parameters:
systemName- the system name- Returns:
- offset of the 1st character past the prefix, or -1 if not valid for this connection
-
isOutputBitFree
Test if a C/MRI output bit is free for assignment. Test is not performed if the node address or bit number is invalid.- Parameters:
nAddress- the node addressbitNum- the output bit number- Returns:
- "" (empty string) if the specified output bit is free for assignment, else returns the system name of the conflicting assignment.
-
normalizeSystemName
Normalize a C/MRI system name.This routine is used to ensure that each system name is uniquely linked to one C/MRI bit, by removing extra zeros inserted by the user.
- Parameters:
systemName- the system name- Returns:
- "" (empty string) if the supplied system name does not have a valid format. Otherwise a normalized name is returned in the same format as the input name.
-
convertSystemNameToAlternate
Convert one format C/MRI system name to the alternate format.- Parameters:
systemName- the system name- Returns:
- "" (empty string) if the supplied system name does not have a valid format, or if there is no representation in the alternate naming scheme
-
validSystemNameFormat
Validate system name format. Does not check whether that node is defined on current system.- Parameters:
systemName- the system nametype- the device type- Returns:
- enum indicating current validity, which might be just as a prefix
-
validateSystemNameFormat
public String validateSystemNameFormat(String systemName, char type, Locale locale) throws IllegalArgumentException Validate system name format. Does not check whether that node is defined on current system.- Parameters:
systemName- the system nametype- the device typelocale- the Locale for user messages- Returns:
- systemName unmodified
- Throws:
IllegalArgumentException- if unable to validate systemName
-
isInputBitFree
Test if a C/MRI input bit is free for assignment. Test is not performed if the node address is invalid or bit number is greater than 2048.- Parameters:
nAddress- the address to testbitNum- the bit number to tests- Returns:
- "" (empty string) if the specified input bit is free for assignment, else returns the system name of the conflicting assignment.
-
makeSystemName
Construct a C/MRI system name from type character, node address, and bit number.If the supplied character is not valid, or the node address is out of the 0 - 127 range, or the bit number is out of the 1 - 2048 range, an error message is logged and the null string "" is returned.
- Parameters:
type- the device typenAddress- the address to usebitNum- the bit number to assign- Returns:
- a system name in the CLnnnxxx, CTnnnxxx, or CSnnnxxx format if the bit number is 1 - 999. If the bit number is 1000 - 2048, the system name is returned in the CLnnnBxxxx, CTnnnBxxxx, or CSnnnBxxxx format. The returned name is normalized.
-
getNodeFromSystemName
Get the serial node from a C/MRI system name.- Parameters:
systemName- the system nametc- the controller for the node- Returns:
- the node or null if invalid systemName format or if the node is not found
-
validSystemNameConfig
Validate C/MRI system name for configuration. Validates node number and system prefix.- Parameters:
systemName- the system name to checktype- the device typetc- the controller for the device- Returns:
- true if system name has a valid meaning in current configuration; otherwise false
-
getNodeAddressFromSystemName
Get the serial node address from a C/MRI system name.Nodes are numbered from 0 - 127. Does not check whether that node is defined on current system.
- Parameters:
systemName- the name containing the node- Returns:
- '-1' if invalid systemName format or if the node is not found.
-
compareSystemNameSuffix
@CheckReturnValue public static int compareSystemNameSuffix(@Nonnull String suffix1, @Nonnull String suffix2) SeeNamedBean.compareSystemNameSuffix(java.lang.String, java.lang.String, jmri.NamedBean)for background. This is a common implementation for C/MRI Lights, Sensors and Turnouts of the comparison method.- Parameters:
suffix1- suffix to compare.suffix2- suffix to compare.- Returns:
- CMRI comparison of suffixes.
-
configureManagers
Configure the common managers for CMRI connections. This puts the common manager config in one place.- Specified by:
configureManagersin interfaceConfiguringSystemConnectionMemo
-
getTurnoutManager
-
getSensorManager
-
getLightManager
-
getActionModelResourceBundle
- Specified by:
getActionModelResourceBundlein classDefaultSystemConnectionMemo
-
getNamedBeanComparator
Description copied from class:DefaultSystemConnectionMemoGet 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
-
dispose
Description copied from class:DefaultSystemConnectionMemoDispose 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
-