jmri.jmrix.tmcc
Class SerialAddress

java.lang.Object
  extended by jmri.jmrix.tmcc.SerialAddress

public class SerialAddress
extends Object

Utility Class supporting parsing and testing of addresses for TMCC

Two address formats are supported: Ttnnnxxx where: 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: CT2 (node address 0, bit 2), CS1003 (node address 1, bit 3), CL11234 (node address 11, bit234) TtnnnBxxxx where: 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-2048) examples: CT0B2 (node address 0, bit 2), CS1B3 (node address 1, bit 3), CL11B234 (node address 11, bit234)


Field Summary
(package private) static org.slf4j.Logger log
           
 
Constructor Summary
SerialAddress()
           
 
Method Summary
static String convertSystemNameToAlternate(String systemName)
          Public static method to convert one format system name for the alternate format.
static int getBitFromSystemName(String systemName)
          Public static method to parse a TMCC system name and return the bit number Notes: Bits are numbered from 1.
static int getNodeAddressFromSystemName(String systemName)
          Public static method to parse a C/MRI system name and return the Serial Node Address Note: Returns '-1' if illegal systemName format or if the node is not found.
static String makeSystemName(String type, int nAddress, int bitNum)
          Public static method to construct a C/MRI system name from type character, node address, and bit number This routine returns a system name in the CLnnnxxx, CTnnnxxx, or CSnnnxxx format if the bit number is 1 - 999.
static String normalizeSystemName(String systemName)
          Public static method to 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.
static boolean validSystemNameConfig(String systemName, char type)
          Public static method to validate system name for configuration returns 'true' if system name has a valid meaning in current configuration, else returns 'false'
static boolean validSystemNameFormat(String systemName, char type)
          Public static method to validate system name format returns 'true' if system name has a valid format, else returns 'false'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.slf4j.Logger log
Constructor Detail

SerialAddress

public SerialAddress()
Method Detail

getNodeAddressFromSystemName

public static int getNodeAddressFromSystemName(String systemName)
Public static method to parse a C/MRI system name and return the Serial Node Address Note: Returns '-1' if illegal systemName format or if the node is not found. Nodes are numbered from 0 - 127.


getBitFromSystemName

public static int getBitFromSystemName(String systemName)
Public static method to parse a TMCC system name and return the bit number Notes: Bits are numbered from 1. If an error is found, 0 is returned.


validSystemNameFormat

public static boolean validSystemNameFormat(String systemName,
                                            char type)
Public static method to validate system name format returns 'true' if system name has a valid format, else returns 'false'


validSystemNameConfig

public static boolean validSystemNameConfig(String systemName,
                                            char type)
Public static method to validate system name for configuration returns 'true' if system name has a valid meaning in current configuration, else returns 'false'


convertSystemNameToAlternate

public static String convertSystemNameToAlternate(String systemName)
Public static method to convert one format system name for the alternate format. If the supplied system name does not have a valid format, or if there is no representation in the alternate naming scheme, an empty string is returned.


normalizeSystemName

public static String normalizeSystemName(String systemName)
Public static method to 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.

If the supplied system name does not have a valid format, 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 nAddress,
                                    int bitNum)
Public static method to construct a C/MRI system name from type character, node address, and bit number

This routine returns a system name in the CLnnnxxx, CTnnnxxx, or CSnnnxxx format if the bit number is 1 - 999. If the bit number is 1000 - 2048, the system name is returned in the CLnnnBxxxx, CTnnnBxxxx, or CSnnnBxxxx format. The returned name is normalized.

If the supplied character is not valid, or the node address is out of the 0 - 127 range, or the bit number is out of the 1 - 2048 range, an error message is logged and the null string "" is returned.



Copyright © 1997-2013 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads