Class CMRISystemConnectionMemo

    • Method Detail

      • setTrafficController

        public void setTrafficController​(SerialTrafficController s)
        Set the traffic controller instance associated with this connection memo.
        Parameters:
        s - jmri.jmrix.cmri.serial.SerialTrafficController object to use.
      • getUserNameFromSystemName

        public java.lang.String getUserNameFromSystemName​(java.lang.String systemName)
        Get the user name for a valid system name.
        Parameters:
        systemName - the system name
        Returns:
        "" (null string) if the system name is not valid or does not exist
      • getBitFromSystemName

        public int getBitFromSystemName​(java.lang.String systemName)
        Get the bit number from a C/MRI system name. Bits are numbered from 1. Does not check whether that node is defined on current system.
        Parameters:
        systemName - the system name
        Returns:
        0 if an error is found
      • checkSystemPrefix

        public int checkSystemPrefix​(java.lang.String systemName)
        Check and skip the System Prefix string on a system name.
        Parameters:
        systemName - the system name
        Returns:
        offset of the 1st character past the prefix, or -1 if not valid for this connection
      • isOutputBitFree

        public java.lang.String isOutputBitFree​(int nAddress,
                                                int bitNum)
        Test if a C/MRI output bit is free for assignment. Test is not performed if the node address or bit number is invalid.
        Parameters:
        nAddress - the node address
        bitNum - the output bit number
        Returns:
        "" (empty string) if the specified output bit is free for assignment, else returns the system name of the conflicting assignment.
      • normalizeSystemName

        public java.lang.String normalizeSystemName​(java.lang.String systemName)
        Normalize a C/MRI system name.

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

        Parameters:
        systemName - the system name
        Returns:
        "" (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.
      • convertSystemNameToAlternate

        public java.lang.String convertSystemNameToAlternate​(java.lang.String systemName)
        Convert one format C/MRI system name to the alternate format.
        Parameters:
        systemName - the system name
        Returns:
        "" (empty string) if the supplied system name does not have a valid format, or if there is no representation in the alternate naming scheme
      • validSystemNameFormat

        public Manager.NameValidity validSystemNameFormat​(@Nonnull
                                                          java.lang.String systemName,
                                                          char type)
        Validate system name format. Does not check whether that node is defined on current system.
        Parameters:
        systemName - the system name
        type - the device type
        Returns:
        enum indicating current validity, which might be just as a prefix
      • validateSystemNameFormat

        public java.lang.String validateSystemNameFormat​(java.lang.String systemName,
                                                         char type,
                                                         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
        type - the device type
        locale - the Locale for user messages
        Returns:
        systemName unmodified
        Throws:
        java.lang.IllegalArgumentException - if unable to validate systemName
      • isInputBitFree

        public java.lang.String isInputBitFree​(int nAddress,
                                               int bitNum)
        Test if a C/MRI input bit is free for assignment. Test is not performed if the node address is invalid or bit number is greater than 2048.
        Parameters:
        nAddress - the address to test
        bitNum - the bit number to tests
        Returns:
        "" (empty string) if the specified input bit is free for assignment, else returns the system name of the conflicting assignment.
      • makeSystemName

        public java.lang.String makeSystemName​(java.lang.String type,
                                               int nAddress,
                                               int bitNum)
        Construct a C/MRI system name from type character, node address, and bit number.

        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.

        Parameters:
        type - the device type
        nAddress - the address to use
        bitNum - the bit number to assign
        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.
      • getNodeFromSystemName

        public AbstractNode getNodeFromSystemName​(java.lang.String systemName,
                                                  SerialTrafficController tc)
        Get the serial node from a C/MRI system name.
        Parameters:
        systemName - the system name
        tc - the controller for the node
        Returns:
        the node or null if invalid systemName format or if the node is not found
      • validSystemNameConfig

        public boolean validSystemNameConfig​(java.lang.String systemName,
                                             char type,
                                             SerialTrafficController tc)
        Validate C/MRI system name for configuration. Validates node number and system prefix.
        Parameters:
        systemName - the system name to check
        type - the device type
        tc - the controller for the device
        Returns:
        true if system name has a valid meaning in current configuration; otherwise false
      • getNodeAddressFromSystemName

        public int getNodeAddressFromSystemName​(java.lang.String systemName)
        Get the serial node address from a C/MRI system name.

        Nodes are numbered from 0 - 127. Does not check whether that node is defined on current system.

        Parameters:
        systemName - the name containing the node
        Returns:
        '-1' if invalid systemName format or if the node is not found.