[wpilib] Remove LiveWindow (#7733)

This will be replaced by a different mechanism, but removing it eases
the initial implementation burden of a new Telemetry/Sendable framework.
This commit is contained in:
Peter Johnson
2025-01-25 10:52:19 -08:00
committed by GitHub
parent adbe95e610
commit eee30c49e2
88 changed files with 85 additions and 1356 deletions

View File

@@ -135,7 +135,7 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
setRange(range);
HAL.report(tResourceType.kResourceType_ADXL345, tInstances.kADXL345_I2C);
SendableRegistry.addLW(this, "ADXL345_I2C", port.value);
SendableRegistry.add(this, "ADXL345_I2C", port.value);
}
/**

View File

@@ -26,7 +26,7 @@ public class AnalogAccelerometer implements Sendable, AutoCloseable {
/** Common initialization. */
private void initAccelerometer() {
HAL.report(tResourceType.kResourceType_Accelerometer, m_analogChannel.getChannel() + 1);
SendableRegistry.addLW(this, "Accelerometer", m_analogChannel.getChannel());
SendableRegistry.add(this, "Accelerometer", m_analogChannel.getChannel());
}
/**

View File

@@ -83,7 +83,7 @@ public class AnalogEncoder implements Sendable, AutoCloseable {
m_fullRange = fullRange;
m_expectedZero = expectedZero;
SendableRegistry.addLW(this, "Analog Encoder", m_analogInput.getChannel());
SendableRegistry.add(this, "Analog Encoder", m_analogInput.getChannel());
}
private double mapSensorRange(double pos) {

View File

@@ -29,7 +29,7 @@ public class AnalogGyro implements Sendable, AutoCloseable {
/** Initialize the gyro. Calibration is handled by calibrate(). */
private void initGyro() {
HAL.report(tResourceType.kResourceType_Gyro, m_analog.getChannel() + 1);
SendableRegistry.addLW(this, "AnalogGyro", m_analog.getChannel());
SendableRegistry.add(this, "AnalogGyro", m_analog.getChannel());
}
/**

View File

@@ -42,7 +42,7 @@ public class AnalogInput implements Sendable, AutoCloseable {
m_port = AnalogJNI.initializeAnalogInputPort(portHandle);
HAL.report(tResourceType.kResourceType_AnalogChannel, channel + 1);
SendableRegistry.addLW(this, "AnalogInput", channel);
SendableRegistry.add(this, "AnalogInput", channel);
}
@Override

View File

@@ -56,7 +56,7 @@ public class AnalogPotentiometer implements Sendable, AutoCloseable {
*/
@SuppressWarnings("this-escape")
public AnalogPotentiometer(final AnalogInput input, double fullRange, double offset) {
SendableRegistry.addLW(this, "AnalogPotentiometer", input.getChannel());
SendableRegistry.add(this, "AnalogPotentiometer", input.getChannel());
m_analogInput = input;
m_initAnalogInput = false;

View File

@@ -52,7 +52,7 @@ public class AnalogTrigger implements Sendable, AutoCloseable {
int index = getIndex();
HAL.report(tResourceType.kResourceType_AnalogTrigger, index + 1);
SendableRegistry.addLW(this, "AnalogTrigger", index);
SendableRegistry.add(this, "AnalogTrigger", index);
}
/**
@@ -69,7 +69,7 @@ public class AnalogTrigger implements Sendable, AutoCloseable {
int index = getIndex();
HAL.report(tResourceType.kResourceType_AnalogTrigger, index + 1);
SendableRegistry.addLW(this, "AnalogTrigger", index);
SendableRegistry.add(this, "AnalogTrigger", index);
}
@Override

View File

@@ -45,7 +45,7 @@ public class Compressor implements Sendable, AutoCloseable {
m_module.enableCompressorDigital();
HAL.report(tResourceType.kResourceType_Compressor, module + 1);
SendableRegistry.addLW(this, "Compressor", module);
SendableRegistry.add(this, "Compressor", module);
}
/**

View File

@@ -85,7 +85,7 @@ public class Counter implements CounterBase, Sendable, AutoCloseable {
setMaxPeriod(0.5);
HAL.report(tResourceType.kResourceType_Counter, m_index + 1, mode.value + 1);
SendableRegistry.addLW(this, "Counter", m_index);
SendableRegistry.add(this, "Counter", m_index);
}
/**

View File

@@ -35,7 +35,7 @@ public class DigitalInput extends DigitalSource implements Sendable {
m_handle = DIOJNI.initializeDIOPort(HAL.getPort((byte) channel), true);
HAL.report(tResourceType.kResourceType_DigitalInput, channel + 1);
SendableRegistry.addLW(this, "DigitalInput", channel);
SendableRegistry.add(this, "DigitalInput", channel);
}
@Override

View File

@@ -37,7 +37,7 @@ public class DigitalOutput extends DigitalSource implements Sendable {
m_handle = DIOJNI.initializeDIOPort(HAL.getPort((byte) channel), false);
HAL.report(tResourceType.kResourceType_DigitalOutput, channel + 1);
SendableRegistry.addLW(this, "DigitalOutput", channel);
SendableRegistry.add(this, "DigitalOutput", channel);
}
@Override

View File

@@ -99,7 +99,7 @@ public class DoubleSolenoid implements Sendable, AutoCloseable {
tResourceType.kResourceType_Solenoid, forwardChannel + 1, m_module.getModuleNumber() + 1);
HAL.report(
tResourceType.kResourceType_Solenoid, reverseChannel + 1, m_module.getModuleNumber() + 1);
SendableRegistry.addLW(this, "DoubleSolenoid", m_module.getModuleNumber(), forwardChannel);
SendableRegistry.add(this, "DoubleSolenoid", m_module.getModuleNumber(), forwardChannel);
successfulCompletion = true;
} finally {
if (!successfulCompletion) {
@@ -210,7 +210,6 @@ public class DoubleSolenoid implements Sendable, AutoCloseable {
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Double Solenoid");
builder.setActuator(true);
builder.setSafeState(() -> set(Value.kOff));
builder.addStringProperty(
"Value",
() -> get().name().substring(1),

View File

@@ -36,7 +36,7 @@ public class DutyCycle implements Sendable, AutoCloseable {
m_channel = channel;
HAL.report(tResourceType.kResourceType_DutyCycle, channel + 1);
SendableRegistry.addLW(this, "Duty Cycle", channel);
SendableRegistry.add(this, "Duty Cycle", channel);
}
/** Close the DutyCycle and free all resources. */

View File

@@ -93,7 +93,7 @@ public class DutyCycleEncoder implements Sendable, AutoCloseable {
m_fullRange = fullRange;
m_expectedZero = expectedZero;
SendableRegistry.addLW(this, "DutyCycle Encoder", m_dutyCycle.getSourceChannel());
SendableRegistry.add(this, "DutyCycle Encoder", m_dutyCycle.getSourceChannel());
}
private double mapSensorRange(double pos) {

View File

@@ -84,7 +84,7 @@ public class Encoder implements CounterBase, Sendable, AutoCloseable {
int fpgaIndex = getFPGAIndex();
HAL.report(tResourceType.kResourceType_Encoder, fpgaIndex + 1, type.value + 1);
SendableRegistry.addLW(this, "Encoder", fpgaIndex);
SendableRegistry.add(this, "Encoder", fpgaIndex);
}
/**

View File

@@ -5,13 +5,9 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.DriverStationJNI;
import edu.wpi.first.hal.FRCNetComm.tInstances;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import java.util.ConcurrentModificationException;
/**
* IterativeRobotBase implements a specific type of robot program framework, extending the RobotBase
@@ -71,7 +67,6 @@ public abstract class IterativeRobotBase extends RobotBase {
private final double m_period;
private final Watchdog m_watchdog;
private boolean m_ntFlushEnabled = true;
private boolean m_lwEnabledInTest;
private boolean m_calledDsConnected;
/**
@@ -259,34 +254,6 @@ public abstract class IterativeRobotBase extends RobotBase {
m_ntFlushEnabled = enabled;
}
private boolean m_reportedLw;
/**
* Sets whether LiveWindow operation is enabled during test mode. Calling
*
* @param testLW True to enable, false to disable. Defaults to false.
* @throws ConcurrentModificationException if this is called during test mode.
*/
public void enableLiveWindowInTest(boolean testLW) {
if (isTestEnabled()) {
throw new ConcurrentModificationException("Can't configure test mode while in test mode!");
}
if (!m_reportedLw && testLW) {
HAL.report(tResourceType.kResourceType_SmartDashboard, tInstances.kSmartDashboard_LiveWindow);
m_reportedLw = true;
}
m_lwEnabledInTest = testLW;
}
/**
* Whether LiveWindow operation is enabled during test mode.
*
* @return whether LiveWindow should be enabled in test mode.
*/
public boolean isLiveWindowEnabledInTest() {
return m_lwEnabledInTest;
}
/**
* Gets time period between calls to Periodic() functions.
*
@@ -327,12 +294,7 @@ public abstract class IterativeRobotBase extends RobotBase {
case kDisabled -> disabledExit();
case kAutonomous -> autonomousExit();
case kTeleop -> teleopExit();
case kTest -> {
if (m_lwEnabledInTest) {
LiveWindow.setEnabled(false);
}
testExit();
}
case kTest -> testExit();
default -> {
// NOP
}
@@ -353,9 +315,6 @@ public abstract class IterativeRobotBase extends RobotBase {
m_watchdog.addEpoch("teleopInit()");
}
case kTest -> {
if (m_lwEnabledInTest) {
LiveWindow.setEnabled(true);
}
testInit();
m_watchdog.addEpoch("testInit()");
}
@@ -399,8 +358,6 @@ public abstract class IterativeRobotBase extends RobotBase {
SmartDashboard.updateValues();
m_watchdog.addEpoch("SmartDashboard.updateValues()");
LiveWindow.updateValues();
m_watchdog.addEpoch("LiveWindow.updateValues()");
if (isSimulation()) {
HAL.simPeriodicBefore();

View File

@@ -40,7 +40,7 @@ public class PWM implements Sendable, AutoCloseable {
* <p>Checks channel value range and allocates the appropriate channel. The allocation is only
* done to help users ensure that they don't double assign channels.
*
* <p>By default, adds itself to SendableRegistry and LiveWindow.
* <p>By default, adds itself to SendableRegistry.
*
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port
*/
@@ -52,7 +52,7 @@ public class PWM implements Sendable, AutoCloseable {
* Allocate a PWM given a channel.
*
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port
* @param registerSendable If true, adds this instance to SendableRegistry and LiveWindow
* @param registerSendable If true, adds this instance to SendableRegistry
*/
@SuppressWarnings("this-escape")
public PWM(final int channel, final boolean registerSendable) {
@@ -67,7 +67,7 @@ public class PWM implements Sendable, AutoCloseable {
HAL.report(tResourceType.kResourceType_PWM, channel + 1);
if (registerSendable) {
SendableRegistry.addLW(this, "PWM", channel);
SendableRegistry.add(this, "PWM", channel);
}
}
@@ -244,7 +244,6 @@ public class PWM implements Sendable, AutoCloseable {
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("PWM");
builder.setActuator(true);
builder.setSafeState(this::setDisabled);
builder.addDoubleProperty(
"Value", this::getPulseTimeMicroseconds, value -> setPulseTimeMicroseconds((int) value));
builder.addDoubleProperty("Speed", this::getSpeed, this::setSpeed);

View File

@@ -57,7 +57,7 @@ public class PowerDistribution implements Sendable, AutoCloseable {
} else {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_REV);
}
SendableRegistry.addLW(this, "PowerDistribution", m_module);
SendableRegistry.add(this, "PowerDistribution", m_module);
}
/**
@@ -76,7 +76,7 @@ public class PowerDistribution implements Sendable, AutoCloseable {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_REV);
}
SendableRegistry.addLW(this, "PowerDistribution", m_module);
SendableRegistry.add(this, "PowerDistribution", m_module);
}
@Override

View File

@@ -17,7 +17,6 @@ import edu.wpi.first.networktables.MultiSubscriber;
import edu.wpi.first.networktables.NetworkTableEvent;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.util.WPIUtilJNI;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.util.WPILibVersion;
import java.io.File;
import java.io.IOException;
@@ -224,8 +223,6 @@ public abstract class RobotBase implements AutoCloseable {
}
}
});
LiveWindow.setEnabled(false);
}
/**

View File

@@ -89,7 +89,7 @@ public class SharpIR implements Sendable, AutoCloseable {
m_minCM = minCM;
m_maxCM = maxCM;
SendableRegistry.addLW(this, "SharpIR", channel);
SendableRegistry.add(this, "SharpIR", channel);
m_simDevice = SimDevice.create("SharpIR", m_sensor.getChannel());
if (m_simDevice != null) {

View File

@@ -57,7 +57,7 @@ public class Solenoid implements Sendable, AutoCloseable {
}
HAL.report(tResourceType.kResourceType_Solenoid, channel + 1, m_module.getModuleNumber() + 1);
SendableRegistry.addLW(this, "Solenoid", m_module.getModuleNumber(), channel);
SendableRegistry.add(this, "Solenoid", m_module.getModuleNumber(), channel);
}
@Override
@@ -148,7 +148,6 @@ public class Solenoid implements Sendable, AutoCloseable {
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Solenoid");
builder.setActuator(true);
builder.setSafeState(() -> set(false));
builder.addBooleanProperty("Value", this::get, this::set);
}
}

View File

@@ -107,7 +107,7 @@ public class Ultrasonic implements Sendable, AutoCloseable {
m_instances++;
HAL.report(tResourceType.kResourceType_Ultrasonic, m_instances);
SendableRegistry.addLW(this, "Ultrasonic", m_echoChannel.getChannel());
SendableRegistry.add(this, "Ultrasonic", m_echoChannel.getChannel());
}
/**

View File

@@ -60,7 +60,7 @@ public class ExternalDirectionCounter implements Sendable, AutoCloseable {
int intIndex = index.getInt();
HAL.report(tResourceType.kResourceType_Counter, intIndex + 1);
SendableRegistry.addLW(this, "External Direction Counter", intIndex);
SendableRegistry.add(this, "External Direction Counter", intIndex);
}
/**

View File

@@ -49,7 +49,7 @@ public class Tachometer implements Sendable, AutoCloseable {
int intIndex = index.getInt();
HAL.report(tResourceType.kResourceType_Counter, intIndex + 1);
SendableRegistry.addLW(this, "Tachometer", intIndex);
SendableRegistry.add(this, "Tachometer", intIndex);
}
@Override

View File

@@ -63,7 +63,7 @@ public class UpDownCounter implements Sendable, AutoCloseable {
int intIndex = index.getInt();
HAL.report(tResourceType.kResourceType_Counter, intIndex + 1);
SendableRegistry.addLW(this, "UpDown Counter", intIndex);
SendableRegistry.add(this, "UpDown Counter", intIndex);
}
@Override

View File

@@ -127,7 +127,7 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC
m_leftMotor = leftMotor;
m_rightMotor = rightMotor;
instances++;
SendableRegistry.addLW(this, "DifferentialDrive", instances);
SendableRegistry.add(this, "DifferentialDrive", instances);
}
@Override
@@ -367,7 +367,6 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("DifferentialDrive");
builder.setActuator(true);
builder.setSafeState(this::stopMotor);
builder.addDoubleProperty("Left Motor Speed", () -> m_leftOutput, m_leftMotor);
builder.addDoubleProperty("Right Motor Speed", () -> m_rightOutput, m_rightMotor);
}

View File

@@ -158,7 +158,7 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
m_frontRightMotor = frontRightMotor;
m_rearRightMotor = rearRightMotor;
instances++;
SendableRegistry.addLW(this, "MecanumDrive", instances);
SendableRegistry.add(this, "MecanumDrive", instances);
}
@Override
@@ -317,7 +317,6 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("MecanumDrive");
builder.setActuator(true);
builder.setSafeState(this::stopMotor);
builder.addDoubleProperty("Front Left Motor Speed", () -> m_frontLeftOutput, m_frontLeftMotor);
builder.addDoubleProperty(
"Front Right Motor Speed", () -> m_frontRightOutput, m_frontRightMotor);

View File

@@ -1,247 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.livewindow;
import edu.wpi.first.networktables.BooleanPublisher;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.networktables.StringPublisher;
import edu.wpi.first.networktables.StringTopic;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableRegistry;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
/**
* The LiveWindow class is the public interface for putting sensors and actuators on the LiveWindow.
*/
public final class LiveWindow {
private static final class Component implements AutoCloseable {
@Override
public void close() {
if (m_namePub != null) {
m_namePub.close();
m_namePub = null;
}
if (m_typePub != null) {
m_typePub.close();
m_typePub = null;
}
}
boolean m_firstTime = true;
boolean m_telemetryEnabled;
StringPublisher m_namePub;
StringPublisher m_typePub;
}
private static final String kSmartDashboardType = "LW Subsystem";
private static final int dataHandle = SendableRegistry.getDataHandle();
private static final NetworkTable liveWindowTable =
NetworkTableInstance.getDefault().getTable("LiveWindow");
private static final NetworkTable statusTable = liveWindowTable.getSubTable(".status");
private static final BooleanPublisher enabledPub =
statusTable.getBooleanTopic("LW Enabled").publish();
private static boolean startLiveWindow;
private static boolean liveWindowEnabled;
private static boolean telemetryEnabled;
private static Runnable enabledListener;
private static Runnable disabledListener;
static {
SendableRegistry.setLiveWindowBuilderFactory(SendableBuilderImpl::new);
enabledPub.set(false);
}
private static Component getOrAdd(Sendable sendable) {
Component data = (Component) SendableRegistry.getData(sendable, dataHandle);
if (data == null) {
data = new Component();
SendableRegistry.setData(sendable, dataHandle, data);
}
return data;
}
private LiveWindow() {
throw new UnsupportedOperationException("This is a utility class!");
}
/**
* Sets function to be called when LiveWindow is enabled.
*
* @param runnable function (or null for none)
*/
public static synchronized void setEnabledListener(Runnable runnable) {
enabledListener = runnable;
}
/**
* Sets function to be called when LiveWindow is disabled.
*
* @param runnable function (or null for none)
*/
public static synchronized void setDisabledListener(Runnable runnable) {
disabledListener = runnable;
}
/**
* Returns true if LiveWindow is enabled.
*
* @return True if LiveWindow is enabled.
*/
public static synchronized boolean isEnabled() {
return liveWindowEnabled;
}
/**
* Set the enabled state of LiveWindow.
*
* <p>If it's being enabled, turn off the scheduler and remove all the commands from the queue and
* enable all the components registered for LiveWindow. If it's being disabled, stop all the
* registered components and re-enable the scheduler.
*
* <p>TODO: add code to disable PID loops when enabling LiveWindow. The commands should re-enable
* the PID loops themselves when they get rescheduled. This prevents arms from starting to move
* around, etc. after a period of adjusting them in LiveWindow mode.
*
* @param enabled True to enable LiveWindow.
*/
public static synchronized void setEnabled(boolean enabled) {
if (liveWindowEnabled != enabled) {
startLiveWindow = enabled;
liveWindowEnabled = enabled;
updateValues(); // Force table generation now to make sure everything is defined
if (enabled) {
System.out.println("Starting live window mode.");
if (enabledListener != null) {
enabledListener.run();
}
} else {
System.out.println("stopping live window mode.");
SendableRegistry.foreachLiveWindow(
dataHandle, cbdata -> ((SendableBuilderImpl) cbdata.builder).stopLiveWindowMode());
if (disabledListener != null) {
disabledListener.run();
}
}
enabledPub.set(enabled);
}
}
/**
* Enable telemetry for a single component.
*
* @param sendable component
*/
public static synchronized void enableTelemetry(Sendable sendable) {
// Re-enable global setting in case disableAllTelemetry() was called.
telemetryEnabled = true;
getOrAdd(sendable).m_telemetryEnabled = true;
}
/**
* Disable telemetry for a single component.
*
* @param sendable component
*/
public static synchronized void disableTelemetry(Sendable sendable) {
getOrAdd(sendable).m_telemetryEnabled = false;
}
/** Disable ALL telemetry. */
public static synchronized void disableAllTelemetry() {
telemetryEnabled = false;
SendableRegistry.foreachLiveWindow(
dataHandle,
cbdata -> {
if (cbdata.data == null) {
cbdata.data = new Component();
}
((Component) cbdata.data).m_telemetryEnabled = false;
});
}
/** Enable ALL telemetry. */
public static synchronized void enableAllTelemetry() {
telemetryEnabled = true;
SendableRegistry.foreachLiveWindow(
dataHandle,
cbdata -> {
if (cbdata.data == null) {
cbdata.data = new Component();
}
((Component) cbdata.data).m_telemetryEnabled = true;
});
}
/**
* Tell all the sensors to update (send) their values.
*
* <p>Actuators are handled through callbacks on their value changing from the SmartDashboard
* widgets.
*/
public static synchronized void updateValues() {
// Only do this if either LiveWindow mode or telemetry is enabled.
if (!liveWindowEnabled && !telemetryEnabled) {
return;
}
SendableRegistry.foreachLiveWindow(
dataHandle,
cbdata -> {
if (cbdata.sendable == null || cbdata.parent != null) {
return;
}
if (cbdata.data == null) {
cbdata.data = new Component();
}
Component component = (Component) cbdata.data;
if (!liveWindowEnabled && !component.m_telemetryEnabled) {
return;
}
if (component.m_firstTime) {
// By holding off creating the NetworkTable entries, it allows the
// components to be redefined. This allows default sensor and actuator
// values to be created that are replaced with the custom names from
// users calling setName.
if (cbdata.name.isEmpty()) {
return;
}
NetworkTable ssTable = liveWindowTable.getSubTable(cbdata.subsystem);
NetworkTable table;
// Treat name==subsystem as top level of subsystem
if (cbdata.name.equals(cbdata.subsystem)) {
table = ssTable;
} else {
table = ssTable.getSubTable(cbdata.name);
}
component.m_namePub = new StringTopic(table.getTopic(".name")).publish();
component.m_namePub.set(cbdata.name);
((SendableBuilderImpl) cbdata.builder).setTable(table);
cbdata.sendable.initSendable(cbdata.builder);
component.m_typePub =
new StringTopic(ssTable.getTopic(".type"))
.publishEx(
StringTopic.kTypeString,
"{\"SmartDashboard\":\"" + kSmartDashboardType + "\"}");
component.m_typePub.set(kSmartDashboardType);
component.m_firstTime = false;
}
if (startLiveWindow) {
((SendableBuilderImpl) cbdata.builder).startLiveWindowMode();
}
cbdata.builder.update();
});
startLiveWindow = false;
}
}

View File

@@ -53,7 +53,7 @@ public class MotorControllerGroup implements MotorController, Sendable, AutoClos
SendableRegistry.addChild(this, controller);
}
instances++;
SendableRegistry.addLW(this, "MotorControllerGroup", instances);
SendableRegistry.add(this, "MotorControllerGroup", instances);
}
@Override
@@ -111,7 +111,6 @@ public class MotorControllerGroup implements MotorController, Sendable, AutoClos
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Motor Controller");
builder.setActuator(true);
builder.setSafeState(this::stopMotor);
builder.addDoubleProperty("Value", this::get, this::set);
}
}

View File

@@ -46,7 +46,7 @@ public class NidecBrushless extends MotorSafety
SendableRegistry.addChild(this, m_pwm);
HAL.report(tResourceType.kResourceType_NidecBrushless, pwmChannel + 1);
SendableRegistry.addLW(this, "Nidec Brushless", pwmChannel);
SendableRegistry.add(this, "Nidec Brushless", pwmChannel);
}
@Override
@@ -139,7 +139,6 @@ public class NidecBrushless extends MotorSafety
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Nidec Brushless");
builder.setActuator(true);
builder.setSafeState(this::stopMotor);
builder.addDoubleProperty("Value", this::get, this::set);
}
}

View File

@@ -32,7 +32,7 @@ public abstract class PWMMotorController extends MotorSafety
@SuppressWarnings("this-escape")
protected PWMMotorController(final String name, final int channel) {
m_pwm = new PWM(channel, false);
SendableRegistry.addLW(this, name, channel);
SendableRegistry.add(this, name, channel);
}
/** Free the resource associated with the PWM channel and set the value to 0. */
@@ -161,7 +161,6 @@ public abstract class PWMMotorController extends MotorSafety
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Motor Controller");
builder.setActuator(true);
builder.setSafeState(this::disable);
builder.addDoubleProperty("Value", this::get, this::set);
}
}

View File

@@ -98,7 +98,6 @@ public class SendableBuilderImpl implements NTSendableBuilder {
}
private final List<Property<?, ?>> m_properties = new ArrayList<>();
private Runnable m_safeState;
private final List<Runnable> m_updateTables = new ArrayList<>();
private NetworkTable m_table;
private boolean m_controllable;
@@ -205,28 +204,6 @@ public class SendableBuilderImpl implements NTSendableBuilder {
}
}
/**
* Start LiveWindow mode by hooking the setters for all properties. Also calls the safeState
* function if one was provided.
*/
public void startLiveWindowMode() {
if (m_safeState != null) {
m_safeState.run();
}
startListeners();
}
/**
* Stop LiveWindow mode by unhooking the setters for all properties. Also calls the safeState
* function if one was provided.
*/
public void stopLiveWindowMode() {
stopListeners();
if (m_safeState != null) {
m_safeState.run();
}
}
/** Clear properties. */
@Override
public void clearProperties() {
@@ -274,17 +251,6 @@ public class SendableBuilderImpl implements NTSendableBuilder {
m_actuator = value;
}
/**
* Set the function that should be called to set the Sendable into a safe state. This is called
* when entering and exiting Live Window mode.
*
* @param func function
*/
@Override
public void setSafeState(Runnable func) {
m_safeState = func;
}
/**
* Set the function that should be called to update the network table for things other than
* properties. Note this function is not passed the network table object; instead it should use