Class BooleanTelemetry<F>
java.lang.Object
yams.core.telemetry.BooleanTelemetry<F>
- Type Parameters:
F- Enum type identifying which field this telemetry entry represents.
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<BooleanTelemetryField> atSpeed = new BooleanTelemetry<>(
"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 -
Constructor Summary
ConstructorsConstructorDescriptionBooleanTelemetry(String keyString, boolean defaultVal, F field, boolean tunable) Setup boolean telemetry for a field. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the telemetry field.voiddisable()Disable the telemetry.voiddisplay(boolean state) Display the telemetry.voidenable()Enable the telemetry.voidforceSet(boolean value) Forcibly overwrite the tunable value in NetworkTables, bypassing the subscriber-must-match guard inset(boolean).booleanget()Get the value.getField()Get the field.booleanset(boolean value) Set the value of the publisher, checking to see if the value is the same as the subscriber.voidsetDefaultValue(boolean value) Set the default value.voidsetupDataLog(String prefix) Setup the DataLog entry for this telemetry field.voidsetupNetworkTable(org.wpilib.networktables.NetworkTable dataTable) Setup network tables.voidsetupNetworkTables(org.wpilib.networktables.NetworkTable dataTable, org.wpilib.networktables.NetworkTable tuningTable) Setup network tables.booleantunable()Check to see if the value has changed.
-
Field Details
-
enabled
protected boolean enabledEnabled?
-
-
Constructor Details
-
BooleanTelemetry
-
-
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
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 inset(boolean). Used to enforce mutual exclusion between tunable modes that share the same underlying drive/mechanism. The nexttunable()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- ifsetupNetworkTables(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
-
setDefaultValue
public void setDefaultValue(boolean value) Set the default value.- Parameters:
value- Default value.
-
close
public void close()Close the telemetry field.
-