Class TelemetryRegistry

java.lang.Object
org.wpilib.telemetry.TelemetryRegistry

public final class TelemetryRegistry extends Object
Global registry for telemetry handlers (type handlers and telemetry backends).
  • Method Details

    • setReportWarning

      public static void setReportWarning(BiConsumer<String,String> func)
      Set function used for reporting warning messages (e.g. type mismatches).

      The reporting function may be called concurrently and must not throw.

      Parameters:
      func - reporting function; parameters are path and message; pass null to use default
    • getReportWarning

      public static BiConsumer<String,String> getReportWarning()
      Get function used for reporting warning messages.
      Returns:
      reporting function
    • reportWarning

      public static void reportWarning(String path, String msg)
      Report a warning message (e.g. type mismatch).
      Parameters:
      path - entry path
      msg - warning message
    • registerTypeHandler

      public static <T> void registerTypeHandler(Class<T> cls, TelemetryRegistry.TypeHandler<T> handler)
      Registers a handler for logging objects of a particular type. The handler should populate the provided TelemetryTable name as appropriate for the object's data.
      Type Parameters:
      T - class
      Parameters:
      cls - class object
      handler - handler (accepts TelemetryTable, entry name, and object)
    • registerBackend

      public static void registerBackend(String prefix, TelemetryBackend backend)
      Registers a backend for creating telemetry entries. When calling getEntry(), the longest prefix match is used.
      Parameters:
      prefix - prefix for entries covered by this backend
      backend - backend
    • getTypeHandler

      public static <T> TelemetryRegistry.TypeHandler<T> getTypeHandler(T value)
      Gets the handler for logging an object. Should generally only be used by TelemetryTable.
      Type Parameters:
      T - class
      Parameters:
      value - value
      Returns:
      handler or null if no match
    • getBackend

      public static TelemetryBackend getBackend(String path)
      Gets the backend for logging an object. Should generally only be used internally or by custom backends.
      Parameters:
      path - full name
      Returns:
      telemetry backend, or a discard backend if no match
    • getTable

      public static TelemetryTable getTable(String path)
      Get a telemetry table for a particular name.
      Parameters:
      path - full name
      Returns:
      telemetry table
    • reset

      public static void reset()
      Clear all registered types and backends and closes all entries. Should typically only be used by unit test code.