Class AcelaAddress


  • public class AcelaAddress
    extends java.lang.Object
    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

    • Method Detail

      • getNodeAddressFromSystemName

        public static int getNodeAddressFromSystemName​(java.lang.String systemName,
                                                       AcelaSystemConnectionMemo memo)
        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 AcelaNode getNodeFromSystemName​(java.lang.String systemName,
                                                      AcelaSystemConnectionMemo memo)
        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 int getBitFromSystemName​(java.lang.String systemName,
                                               java.lang.String prefix)
        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
                                                                 java.lang.String systemName,
                                                                 char type,
                                                                 java.lang.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​(java.lang.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'
      • convertSystemNameToAlternate

        public static java.lang.String convertSystemNameToAlternate​(java.lang.String systemName,
                                                                    java.lang.String prefix)
        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 java.lang.String normalizeSystemName​(java.lang.String systemName,
                                                           java.lang.String prefix)
        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 java.lang.String makeSystemName​(java.lang.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 java.lang.String getUserNameFromSystemName​(java.lang.String systemName,
                                                                 java.lang.String prefix)
        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