Package jmri.jmrix.maple
Class SerialAddress
java.lang.Object
jmri.jmrix.maple.SerialAddress
Utility Class supporting parsing and testing of Maple addresses.
One address format is supported: Ktxxxx where:
- K is (user configurable) system prefix for Maple
- t is the type code: 'T' for turnouts, 'S' for sensors, and 'L' for lights
- xxxx is a bit number of the input or output bit (001-9999)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetBitFromSystemName(String systemName, String prefix) Public static method to parse a Maple system name and return the bit number.static StringgetUserNameFromSystemName(String systemName, String prefix) Public static method to get the user name for a valid system name.static StringisInputBitFree(int bitNum, String prefix) Public static method to test if an input bit is free for assignment.static StringisOutputBitFree(int bitNum, String prefix) Public static method to test if an output bit is free for assignment.static StringmakeSystemName(String type, int bitNum, String prefix) Public static method to construct a system name from type character and bit number.static StringnormalizeSystemName(String systemName, String prefix) Public static method to normalize a system name.static StringvalidateSystemNameFormat(String name, Manager<?> manager, Locale locale) Validate the system name.static booleanvalidSystemNameConfig(String systemName, char type, MapleSystemConnectionMemo memo) Public static method to validate system name for configuration.static Manager.NameValidityvalidSystemNameFormat(String systemName, char type, String prefix) Public static method to validate system name format.
-
Constructor Details
-
SerialAddress
public SerialAddress()
-
-
Method Details
-
getBitFromSystemName
Public static method to parse a Maple system name and return the bit number.Notes: Bits are numbered from 1.
- Parameters:
systemName- system name.prefix- system prefix.- Returns:
- the bit number, return 0 if an error is found
-
validateSystemNameFormat
public static String validateSystemNameFormat(String name, Manager<?> manager, Locale locale) throws IllegalArgumentException Validate the system name.- Parameters:
name- the name to validatemanager- the manager requesting validationlocale- the locale for user messages- Returns:
- the name; unchanged
- Throws:
IllegalArgumentException- if name is not valid- See Also:
-
validSystemNameFormat
public static Manager.NameValidity validSystemNameFormat(@Nonnull String systemName, char type, String prefix) Public static method to validate system name format.- Parameters:
systemName- system name to validate.type- bean type, ie S for Sensor, T for Turnout.prefix- system prefix.- Returns:
- 'true' if system name has a valid format, else returns 'false'
-
validSystemNameConfig
public static boolean validSystemNameConfig(String systemName, char type, MapleSystemConnectionMemo memo) Public static method to validate system name for configuration.- Parameters:
systemName- system name to validate.type- bean type, ie S for Sensor, T for Turnout.memo- system connection.- Returns:
- 'true' if system name has a valid meaning in current configuration, else returns 'false'
-
normalizeSystemName
Public static method to normalize a system name.This routine is used to ensure that each system name is uniquely linked to a bit, by removing extra zeros inserted by the user. It's not applied to sensors (whick might be addressed using the KS3:5 format.
- Parameters:
systemName- systemname to normalize.prefix- system prefix.- Returns:
- if the supplied system name does not have a valid format, an empty string is returned. If the address in the system name is not within the legal maximum range for the type of item (L, T, or S), an empty string is returned. Otherwise a normalized name is returned in the same format as the input name.
-
makeSystemName
Public static method to construct a system name from type character and bit number.This routine returns a system name in the KLxxxx, KTxxxx, or KSxxxx format. The returned name is normalized.
- Parameters:
type- bean type, ie S Sensor, T Turnout.bitNum- bit number.prefix- system prefix.- Returns:
- "" (null string) if the supplied type character is not valid, or the bit number is out of the 1 - 9000 range, and an error message is logged.
-
isOutputBitFree
Public static method to test if an output bit is free for assignment.- Parameters:
bitNum- bit number.prefix- system prefix.- Returns:
- "" (null string) if the specified output bit is free for assignment, else returns the system name of the conflicting assignment. Test is not performed if the node address or bit number are valid.
-
isInputBitFree
Public static method to test if an input bit is free for assignment.- Parameters:
bitNum- bit number.prefix- system prefix.- Returns:
- "" (empty string) if the specified input bit is free for assignment, else returns the system name of the conflicting assignment. Test is not performed if the node address is illegal or bit number is valid.
-
getUserNameFromSystemName
Public static method to get the user name for a valid system name.- Parameters:
systemName- system name.prefix- system prefix.- Returns:
- "" (empty string) if the system name is not valid or does not exist
-