Class SerialAddress

java.lang.Object
jmri.jmrix.maple.SerialAddress

public class SerialAddress
extends Object
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)
Note: with Maple, all panels (nodes) have the same address space, so there is no node number in the address.
  • Constructor Details

  • Method Details

    • getBitFromSystemName

      public static int getBitFromSystemName​(String systemName, String prefix)
      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 validate
      manager - the manager requesting validation
      locale - the locale for user messages
      Returns:
      the name; unchanged
      Throws:
      IllegalArgumentException - if name is not valid
      See Also:
      Manager.validateSystemNameFormat(java.lang.String, java.util.Locale)
    • 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 String normalizeSystemName​(String systemName, String prefix)
      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 String makeSystemName​(String type, int bitNum, String prefix)
      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 String isOutputBitFree​(int bitNum, String prefix)
      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 String isInputBitFree​(int bitNum, String prefix)
      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 String getUserNameFromSystemName​(String systemName, String prefix)
      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