Class BooleanTelemetry<F>

java.lang.Object
yams.core.telemetry.BooleanTelemetry<F>
Type Parameters:
F - Enum type identifying which field this telemetry entry represents.

public class BooleanTelemetry<F> extends Object
Boolean Telemetry for SmartMotorControllers.

A lightweight wrapper that publishes a single boolean value to NetworkTables and/or a WPILib DataLog. It is used internally by SmartMotorControllerTelemetry to track flags such as limit-switch states, active feedforward type, and motor inversion but it can also be constructed directly when you need a standalone boolean entry.

Example

// Create and publish a boolean entry for "at speed" under the Shooter table.
BooleanTelemetry&lt;BooleanTelemetryField&gt; atSpeed = new BooleanTelemetry&lt;&gt;(
    "atSpeed",                                        // NetworkTables key
    false,                                            // default value
    SmartMotorControllerTelemetry.BooleanTelemetryField.VelocityControl,
    false);                                           // not tunable

NetworkTable shooterTable = NetworkTableInstance.getDefault().getTable("Shooter");
atSpeed.enable();
atSpeed.setupNetworkTable(shooterTable);

// In periodic:
atSpeed.set(shooter.isAtSpeed());
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Enabled?
  • Constructor Summary

    Constructors
    Constructor
    Description
    BooleanTelemetry(String keyString, boolean defaultVal, F field, boolean tunable)
    Setup boolean telemetry for a field.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the telemetry field.
    void
    Disable the telemetry.
    void
    display(boolean state)
    Display the telemetry.
    void
    Enable the telemetry.
    void
    forceSet(boolean value)
    Forcibly overwrite the tunable value in NetworkTables, bypassing the subscriber-must-match guard in set(boolean).
    boolean
    get()
    Get the value.
    Get the field.
    boolean
    set(boolean value)
    Set the value of the publisher, checking to see if the value is the same as the subscriber.
    void
    setDefaultValue(boolean value)
    Set the default value.
    void
    Setup the DataLog entry for this telemetry field.
    void
    setupNetworkTable(org.wpilib.networktables.NetworkTable dataTable)
    Setup network tables.
    void
    setupNetworkTables(org.wpilib.networktables.NetworkTable dataTable, org.wpilib.networktables.NetworkTable tuningTable)
    Setup network tables.
    boolean
    Check to see if the value has changed.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • enabled

      protected boolean enabled
      Enabled?
  • Constructor Details

    • BooleanTelemetry

      public BooleanTelemetry(String keyString, boolean defaultVal, F field, boolean tunable)
      Setup boolean telemetry for a field.
      Parameters:
      keyString - Networks table key.
      defaultVal - Default value.
      field - Field representing.
      tunable - Tunable?
  • Method Details

    • setupNetworkTables

      public void setupNetworkTables(org.wpilib.networktables.NetworkTable dataTable, org.wpilib.networktables.NetworkTable tuningTable)
      Setup network tables.
      Parameters:
      dataTable - Data tables.
      tuningTable - Tuning table.
    • setupDataLog

      public void setupDataLog(String prefix)
      Setup the DataLog entry for this telemetry field.
      Parameters:
      prefix - Prefix of the entry.
    • setupNetworkTable

      public void setupNetworkTable(org.wpilib.networktables.NetworkTable dataTable)
      Setup network tables.
      Parameters:
      dataTable - Data tables.
    • set

      public boolean set(boolean value)
      Set the value of the publisher, checking to see if the value is the same as the subscriber.
      Parameters:
      value - Value to set.
      Returns:
      True if value was able to be set.
    • forceSet

      public void forceSet(boolean value)
      Forcibly overwrite the tunable value in NetworkTables, bypassing the subscriber-must-match guard in set(boolean). Used to enforce mutual exclusion between tunable modes that share the same underlying drive/mechanism. The next tunable() reports the change, as if it was made on the dashboard.
      Parameters:
      value - Value to force onto the tuning topic.
    • get

      public boolean get()
      Get the value.
      Returns:
      Value.
      Throws:
      RuntimeException - if this field is not tunable, so no tuning subscriber exists.
      RuntimeException - if setupNetworkTables(NetworkTable, NetworkTable) was not called with a non-null tuning table, so no tuning subscriber exists.
    • tunable

      public boolean tunable()
      Check to see if the value has changed.
      Returns:
      True if the value has changed.
    • enable

      public void enable()
      Enable the telemetry.
    • disable

      public void disable()
      Disable the telemetry.
    • display

      public void display(boolean state)
      Display the telemetry.
      Parameters:
      state - Enable or disable.
    • getField

      public F getField()
      Get the field.
      Returns:
      field.
    • setDefaultValue

      public void setDefaultValue(boolean value)
      Set the default value.
      Parameters:
      value - Default value.
    • close

      public void close()
      Close the telemetry field.