Class SendableRegistry


  • public class SendableRegistry
    extends Object
    The SendableRegistry class is the public interface for registering sensors and actuators for use on dashboards and LiveWindow.
    • Method Detail

      • add

        public static void add​(Sendable sendable,
                               String name)
        Adds an object to the registry.
        Parameters:
        sendable - object to add
        name - component name
      • add

        public static void add​(Sendable sendable,
                               String moduleType,
                               int channel)
        Adds an object to the registry.
        Parameters:
        sendable - object to add
        moduleType - A string that defines the module name in the label for the value
        channel - The channel number the device is plugged into
      • add

        public static void add​(Sendable sendable,
                               String moduleType,
                               int moduleNumber,
                               int channel)
        Adds an object to the registry.
        Parameters:
        sendable - object to add
        moduleType - A string that defines the module name in the label for the value
        moduleNumber - The number of the particular module type
        channel - The channel number the device is plugged into
      • add

        public static void add​(Sendable sendable,
                               String subsystem,
                               String name)
        Adds an object to the registry.
        Parameters:
        sendable - object to add
        subsystem - subsystem name
        name - component name
      • addLW

        public static void addLW​(Sendable sendable,
                                 String name)
        Adds an object to the registry and LiveWindow.
        Parameters:
        sendable - object to add
        name - component name
      • addLW

        public static void addLW​(Sendable sendable,
                                 String moduleType,
                                 int channel)
        Adds an object to the registry and LiveWindow.
        Parameters:
        sendable - object to add
        moduleType - A string that defines the module name in the label for the value
        channel - The channel number the device is plugged into
      • addLW

        public static void addLW​(Sendable sendable,
                                 String moduleType,
                                 int moduleNumber,
                                 int channel)
        Adds an object to the registry and LiveWindow.
        Parameters:
        sendable - object to add
        moduleType - A string that defines the module name in the label for the value
        moduleNumber - The number of the particular module type
        channel - The channel number the device is plugged into
      • addLW

        public static void addLW​(Sendable sendable,
                                 String subsystem,
                                 String name)
        Adds an object to the registry and LiveWindow.
        Parameters:
        sendable - object to add
        subsystem - subsystem name
        name - component name
      • addChild

        public static void addChild​(Sendable parent,
                                    Object child)
        Adds a child object to an object. Adds the child object to the registry if it's not already present.
        Parameters:
        parent - parent object
        child - child object
      • remove

        public static boolean remove​(Sendable sendable)
        Removes an object from the registry.
        Parameters:
        sendable - object to remove
        Returns:
        true if the object was removed; false if it was not present
      • contains

        public static boolean contains​(Sendable sendable)
        Determines if an object is in the registry.
        Parameters:
        sendable - object to check
        Returns:
        True if in registry, false if not.
      • getName

        public static String getName​(Sendable sendable)
        Gets the name of an object.
        Parameters:
        sendable - object
        Returns:
        Name (empty if object is not in registry)
      • setName

        public static void setName​(Sendable sendable,
                                   String name)
        Sets the name of an object.
        Parameters:
        sendable - object
        name - name
      • setName

        public static void setName​(Sendable sendable,
                                   String moduleType,
                                   int channel)
        Sets the name of an object with a channel number.
        Parameters:
        sendable - object
        moduleType - A string that defines the module name in the label for the value
        channel - The channel number the device is plugged into
      • setName

        public static void setName​(Sendable sendable,
                                   String moduleType,
                                   int moduleNumber,
                                   int channel)
        Sets the name of an object with a module and channel number.
        Parameters:
        sendable - object
        moduleType - A string that defines the module name in the label for the value
        moduleNumber - The number of the particular module type
        channel - The channel number the device is plugged into
      • setName

        public static void setName​(Sendable sendable,
                                   String subsystem,
                                   String name)
        Sets both the subsystem name and device name of an object.
        Parameters:
        sendable - object
        subsystem - subsystem name
        name - device name
      • getSubsystem

        public static String getSubsystem​(Sendable sendable)
        Gets the subsystem name of an object.
        Parameters:
        sendable - object
        Returns:
        Subsystem name (empty if object is not in registry)
      • setSubsystem

        public static void setSubsystem​(Sendable sendable,
                                        String subsystem)
        Sets the subsystem name of an object.
        Parameters:
        sendable - object
        subsystem - subsystem name
      • getDataHandle

        public static int getDataHandle()
        Gets a unique handle for setting/getting data with setData() and getData().
        Returns:
        Handle
      • setData

        public static Object setData​(Sendable sendable,
                                     int handle,
                                     Object data)
        Associates arbitrary data with an object in the registry.
        Parameters:
        sendable - object
        handle - data handle returned by getDataHandle()
        data - data to set
        Returns:
        Previous data (may be null)
      • getData

        public static Object getData​(Sendable sendable,
                                     int handle)
        Gets arbitrary data associated with an object in the registry.
        Parameters:
        sendable - object
        handle - data handle returned by getDataHandle()
        Returns:
        data (may be null if none associated)
      • enableLiveWindow

        public static void enableLiveWindow​(Sendable sendable)
        Enables LiveWindow for an object.
        Parameters:
        sendable - object
      • disableLiveWindow

        public static void disableLiveWindow​(Sendable sendable)
        Disables LiveWindow for an object.
        Parameters:
        sendable - object
      • publish

        public static void publish​(Sendable sendable,
                                   SendableBuilder builder)
        Publishes an object in the registry to a builder.
        Parameters:
        sendable - object
        builder - sendable builder
      • update

        public static void update​(Sendable sendable)
        Updates network table information from an object.
        Parameters:
        sendable - object
      • foreachLiveWindow

        public static void foreachLiveWindow​(int dataHandle,
                                             Consumer<SendableRegistry.CallbackData> callback)
        Iterates over LiveWindow-enabled objects in the registry. It is *not* safe to call other SendableRegistry functions from the callback.
        Parameters:
        dataHandle - data handle to get data object passed to callback
        callback - function to call for each object