Class CMRISystemConnectionMemo

All Implemented Interfaces:
BeanInterface, PropertyChangeFirer, PropertyChangeProvider, Disposable, ConfiguringSystemConnectionMemo, SystemConnectionMemo

Minimal SystemConnectionMemo for C/MRI systems.
  • Field Details

  • Constructor Details

  • Method Details

    • setTrafficController

      Set the traffic controller instance associated with this connection memo.
      Parameters:
      s - jmri.jmrix.cmri.serial.SerialTrafficController object to use.
    • getTrafficController

      Get the traffic controller instance associated with this connection memo.
      Returns:
      the traffic controller, created if needed
    • getUserNameFromSystemName

      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(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(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 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 String normalizeSystemName(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

      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 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 String validateSystemNameFormat(String systemName, char type, Locale locale) throws 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:
      IllegalArgumentException - if unable to validate systemName
    • isInputBitFree

      public 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 String makeSystemName(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

      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(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(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.
    • compareSystemNameSuffix

      See NamedBean.compareSystemNameSuffix(java.lang.String, java.lang.String, jmri.NamedBean) for background. This is a common implementation for C/MRI Lights, Sensors and Turnouts of the comparison method.
      Parameters:
      suffix1 - suffix to compare.
      suffix2 - suffix to compare.
      Returns:
      CMRI comparison of suffixes.
    • configureManagers

      public void configureManagers()
      Configure the common managers for CMRI connections. This puts the common manager config in one place.
      Specified by:
      configureManagers in interface ConfiguringSystemConnectionMemo
    • getTurnoutManager

    • getSensorManager

    • getLightManager

    • getActionModelResourceBundle

      Specified by:
      getActionModelResourceBundle in class DefaultSystemConnectionMemo
    • getNamedBeanComparator

      public <B extends NamedBean> Comparator<B> getNamedBeanComparator(Class<B> type)
      Description copied from class: DefaultSystemConnectionMemo
      Get the Comparator to be used for two NamedBeans. This is typically an NamedBeanComparator, but may be any Comparator that works for this connection type.
      Specified by:
      getNamedBeanComparator in interface SystemConnectionMemo
      Specified by:
      getNamedBeanComparator in class DefaultSystemConnectionMemo
      Type Parameters:
      B - the type of NamedBean
      Parameters:
      type - the class of NamedBean
      Returns:
      the Comparator
    • dispose

      public void dispose()
      Description copied from class: DefaultSystemConnectionMemo
      Dispose of System Connection.

      Removes objects from classObjectMap after calling dispose if Disposable. Removes these objects from InstanceManager.

      Specified by:
      dispose in interface Disposable
      Specified by:
      dispose in interface SystemConnectionMemo
      Overrides:
      dispose in class DefaultSystemConnectionMemo