Class SerialAddress


  • public class SerialAddress
    extends java.lang.Object
    Utility Class supporting parsing and testing of addresses

    Two address formats are supported:

    • Vtnnnxxx where:
      • V is the system connection prefix with optional index
      • t is the type code: 'T' for turnouts, 'S' for sensors, and 'L' for lights
      • nn is the node address (0-127)
      • xxx is a bit number of the input or
      • output bit (001-999) nnxxx = (node address x 1000) + bit number.
      Examples: VT2 (node address 0, bit 2), V2S1003 (node address 1, bit 3), VL11234 (node address 11, bit234)
    • VtnnnBxxxx where:
      • V is the system connection prefix with optional index
      • t is the type code: 'T' for turnouts, 'S' for sensors, and 'L' for lights
      • nnn is the node address of the input or output bit (0-127)
      • xxxx is a bit number of the input or output bit (1-999).
      Examples: VT0B2 (node address 0, bit 2), VS1B3 (node address 1, bit 3), VL11B234 (node address 11, bit234)
    • Constructor Summary

      Constructors 
      Constructor Description
      SerialAddress()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String convertSystemNameToAlternate​(java.lang.String systemName, java.lang.String prefix)
      Public static method to convert one format system name for the alternate format.
      static int getBitFromSystemName​(java.lang.String systemName, java.lang.String prefix)
      Parse a system name and return the bit number.
      static SerialNode getNodeFromSystemName​(java.lang.String systemName, SerialTrafficController tc)
      Parse a system name and return the Serial Node.
      static java.lang.String normalizeSystemName​(java.lang.String systemName, java.lang.String prefix)
      Normalize a system name.
      static java.lang.String validateSystemNameFormat​(java.lang.String systemName, java.lang.String prefix, java.util.Locale locale)
      Validate system name format.
      static boolean validSystemNameConfig​(java.lang.String systemName, char type, SerialTrafficController tc)
      Public static method to validate system name for configuration.
      static Manager.NameValidity validSystemNameFormat​(java.lang.String systemName, char type, java.lang.String prefix)
      Public static method to validate system name format.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getNodeFromSystemName

        public static SerialNode getNodeFromSystemName​(java.lang.String systemName,
                                                       SerialTrafficController tc)
        Parse a system name and return the Serial Node.
        Parameters:
        systemName - system name.
        tc - system connection traffic controller.
        Returns:
        '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)
        Parse a system name and return the bit number.

        Note: Bits are numbered from 1.

        Parameters:
        systemName - system name.
        prefix - system prefix.
        Returns:
        the bit number, 0 if an error occurred
      • validateSystemNameFormat

        public static java.lang.String validateSystemNameFormat​(java.lang.String systemName,
                                                                java.lang.String prefix,
                                                                java.util.Locale locale)
                                                         throws java.lang.IllegalArgumentException
        Validate system name format. Does not check whether that node is defined on current system.
        Parameters:
        systemName - the system name
        prefix - the system connection prefix
        locale - the Locale for user messages
        Returns:
        systemName unmodified
        Throws:
        java.lang.IllegalArgumentException - if unable to validate systemName
      • 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.
        type - Letter indicating device type expected
        prefix - system prefix.
        Returns:
        'true' if system name has a valid format, else returns 'false'
      • validSystemNameConfig

        public static boolean validSystemNameConfig​(java.lang.String systemName,
                                                    char type,
                                                    SerialTrafficController tc)
        Public static method to validate system name for configuration.
        Parameters:
        systemName - system name.
        type - bean type, e.g. S for Sensor, T for Turnout.
        tc - system traffic controller.
        Returns:
        'true' if system name has a valid meaning in current configuration, else returns 'false'
      • convertSystemNameToAlternate

        public static java.lang.String convertSystemNameToAlternate​(java.lang.String systemName,
                                                                    java.lang.String prefix)
        Public static method to convert one format system name for the alternate format.
        Parameters:
        systemName - system name.
        prefix - system prefix.
        Returns:
        an 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)
        Normalize a system name.

        This routine is used to ensure that each system name is uniquely linked to one bit, by removing extra zeros inserted by the user.

        Parameters:
        systemName - system name.
        prefix - system prefix.
        Returns:
        an 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.