Package jmri.jmrix.acela
Class AcelaAddress
java.lang.Object
jmri.jmrix.acela.AcelaAddress
Utility Class supporting parsing and testing of addresses for Acela.
One address format is supported: Atxxxx where: 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 (0-16383) examples: AT2 (bit 2), AS1003 (bit 1003), AL134 (bit134).
Note: Not fully supporting long system connection prefix yet
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final int(package private) static final int(package private) static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertSystemNameToAlternate(String systemName, String prefix) Public static method to convert one format Acela system name for the alternate format.static intgetBitFromSystemName(String systemName, String prefix) Public static method to parse an Acela system name and return the bit number.static intgetNodeAddressFromSystemName(String systemName, AcelaSystemConnectionMemo memo) Public static method to parse an Acela system name and return the Acela Node Address.static AcelaNodegetNodeFromSystemName(String systemName, AcelaSystemConnectionMemo memo) Public static method to parse an Acela system name.static StringgetUserNameFromSystemName(String systemName, String prefix) Public static method to check the user name for a valid system name.static StringmakeSystemName(String type, int nAddress, int bitNum, AcelaSystemConnectionMemo memo) Public static method to construct an Acela system name from type character, node address, and bit number.static StringnormalizeSystemName(String systemName, String prefix) Public static method to normalize an Acela system name.static booleanvalidSystemNameConfig(String systemName, char type, AcelaSystemConnectionMemo memo) Public static method to validate Acela system name for configuration.static booleanvalidSystemNameConfig(String systemName, AcelaSystemConnectionMemo memo) static Manager.NameValidityvalidSystemNameFormat(String systemName, char type, String prefix) Public static method to validate system name format.
-
Field Details
-
MINSENSORADDRESS
- See Also:
-
MAXSENSORADDRESS
- See Also:
-
MINOUTPUTADDRESS
- See Also:
-
MAXOUTPUTADDRESS
- See Also:
-
-
Constructor Details
-
AcelaAddress
public AcelaAddress()
-
-
Method Details
-
getNodeAddressFromSystemName
Public static method to parse an Acela system name and return the Acela Node Address.Note: Returns '-1' if illegal systemName format or if the node is not found. Nodes are numbered from 0 - 1024.
- Parameters:
systemName- system name.memo- system connection.- Returns:
- node address number.
-
getNodeFromSystemName
Public static method to parse an Acela system name.- Parameters:
systemName- system name to parse.memo- system connection.- Returns:
- the Acela Node number, return 'null' if illegal systemName format or if the node is not found
-
getBitFromSystemName
Public static method to parse an Acela system name and return the bit number. Note: Bits are numbered from 1.- Parameters:
systemName- system name.prefix- bean type, S, T, L or H.- Returns:
- the bit number, return -1 if an error is found (0 is a valid bit?)
-
validSystemNameFormat
public static Manager.NameValidity validSystemNameFormat(@Nonnull String systemName, char type, String prefix) Public static method to validate system name format. Logging of handled cases no higher than WARN.- Parameters:
systemName- system name to validate.type- bean type, S, T or L.prefix- system prefix.- Returns:
- 'true' if system name has a valid format, else return 'false'
-
validSystemNameConfig
public static boolean validSystemNameConfig(String systemName, char type, AcelaSystemConnectionMemo memo) Public static method to validate Acela system name for configuration.- Parameters:
systemName- system name to validate.type- bean type, S, T or L.memo- system connection.- Returns:
- 'true' if system name has a valid meaning in current configuration, else return 'false'
-
validSystemNameConfig
-
convertSystemNameToAlternate
Public static method to convert one format Acela system name for the alternate format.- Parameters:
systemName- system name to convert.prefix- system prefix.- Returns:
- name (string) in alternate format, or empty string if the supplied system name does not have a valid format, or if there is no representation in the alternate naming scheme.
-
normalizeSystemName
Public static method to normalize an Acela system name.This routine is used to ensure that each system name is uniquely linked to one Acela bit, by removing extra zeros inserted by the user.
- Parameters:
systemName- system name to normalize.prefix- system prefix.- Returns:
- a normalized name is returned in the same format as the input name, or an empty string if the supplied system name does not have a valid format.
-
makeSystemName
public static String makeSystemName(String type, int nAddress, int bitNum, AcelaSystemConnectionMemo memo) Public static method to construct an Acela system name from type character, node address, and bit number.- Parameters:
type- bean type letter, S, T or L.nAddress- node address.bitNum- bit number.memo- system connection.- Returns:
- a system name in the ALxxxx, ATxxxx, or ASxxxx format. The returned name is normalized. Return the null string "" if the supplied character is not valid, or if the node address is out of the 0 - 127 range, or the bit number is out of the 1 - 2048 range and an error message is logged.
-
getUserNameFromSystemName
Public static method to check the user name for a valid system name.- Parameters:
systemName- system name to check.prefix- bean prefix, S, T or L.- Returns:
- "" (null string) if the system name is not valid or does not exist
-