[wpilib] Remove deprecated Sendable functions and SendableBase (#3210)

This commit is contained in:
Peter Johnson
2021-03-19 13:41:11 -07:00
committed by GitHub
parent d3e45c297c
commit 8afa596fdf
9 changed files with 3 additions and 193 deletions

View File

@@ -45,7 +45,6 @@ public abstract class CommandBase implements Sendable, Command {
*
* @param name name
*/
@Override
public void setName(String name) {
SendableRegistry.setName(this, name);
}
@@ -66,7 +65,6 @@ public abstract class CommandBase implements Sendable, Command {
*
* @return Subsystem name
*/
@Override
public String getSubsystem() {
return SendableRegistry.getSubsystem(this);
}
@@ -76,7 +74,6 @@ public abstract class CommandBase implements Sendable, Command {
*
* @param subsystem subsystem name
*/
@Override
public void setSubsystem(String subsystem) {
SendableRegistry.setSubsystem(this, subsystem);
}

View File

@@ -27,7 +27,6 @@ public abstract class SubsystemBase implements Subsystem, Sendable {
*
* @return Name
*/
@Override
public String getName() {
return SendableRegistry.getName(this);
}
@@ -37,7 +36,6 @@ public abstract class SubsystemBase implements Subsystem, Sendable {
*
* @param name name
*/
@Override
public void setName(String name) {
SendableRegistry.setName(this, name);
}
@@ -47,7 +45,6 @@ public abstract class SubsystemBase implements Subsystem, Sendable {
*
* @return Subsystem name
*/
@Override
public String getSubsystem() {
return SendableRegistry.getSubsystem(this);
}
@@ -57,7 +54,6 @@ public abstract class SubsystemBase implements Subsystem, Sendable {
*
* @param subsystem subsystem name
*/
@Override
public void setSubsystem(String subsystem) {
SendableRegistry.setSubsystem(this, subsystem);
}

View File

@@ -36,6 +36,7 @@ import java.util.Enumeration;
* @see CommandGroup
* @see IllegalUseOfCommandException
*/
@SuppressWarnings("PMD.GodClass")
public abstract class Command implements Sendable, AutoCloseable {
/** The time since this command was initialized. */
private double m_startTime = -1;
@@ -561,7 +562,6 @@ public abstract class Command implements Sendable, AutoCloseable {
*
* @return Name
*/
@Override
public String getName() {
return SendableRegistry.getName(this);
}
@@ -571,7 +571,6 @@ public abstract class Command implements Sendable, AutoCloseable {
*
* @param name name
*/
@Override
public void setName(String name) {
SendableRegistry.setName(this, name);
}
@@ -581,7 +580,6 @@ public abstract class Command implements Sendable, AutoCloseable {
*
* @return Subsystem name
*/
@Override
public String getSubsystem() {
return SendableRegistry.getSubsystem(this);
}
@@ -591,7 +589,6 @@ public abstract class Command implements Sendable, AutoCloseable {
*
* @param subsystem subsystem name
*/
@Override
public void setSubsystem(String subsystem) {
SendableRegistry.setSubsystem(this, subsystem);
}

View File

@@ -187,7 +187,6 @@ public abstract class Subsystem implements Sendable, AutoCloseable {
*
* @return Name
*/
@Override
public String getName() {
return SendableRegistry.getName(this);
}
@@ -197,7 +196,6 @@ public abstract class Subsystem implements Sendable, AutoCloseable {
*
* @param name name
*/
@Override
public void setName(String name) {
SendableRegistry.setName(this, name);
}
@@ -207,7 +205,6 @@ public abstract class Subsystem implements Sendable, AutoCloseable {
*
* @return Subsystem name
*/
@Override
public String getSubsystem() {
return SendableRegistry.getSubsystem(this);
}
@@ -217,7 +214,6 @@ public abstract class Subsystem implements Sendable, AutoCloseable {
*
* @param subsystem subsystem name
*/
@Override
public void setSubsystem(String subsystem) {
SendableRegistry.setSubsystem(this, subsystem);
}

View File

@@ -1,17 +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.
#include "frc/smartdashboard/SendableBase.h"
#include "frc/smartdashboard/SendableRegistry.h"
using namespace frc;
SendableBase::SendableBase(bool addLiveWindow) {
if (addLiveWindow) {
SendableRegistry::GetInstance().AddLW(this, "");
} else {
SendableRegistry::GetInstance().Add(this, "");
}
}

View File

@@ -1,27 +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.
#pragma once
#include <wpi/deprecated.h>
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
namespace frc {
class SendableBase : public Sendable, public SendableHelper<SendableBase> {
public:
/**
* Creates an instance of the sensor base
*
* @deprecated use Sendable and SendableHelper
*
* @param addLiveWindow if true, add this Sendable to LiveWindow
*/
WPI_DEPRECATED("use Sendable and SendableHelper")
explicit SendableBase(bool addLiveWindow = true);
};
} // namespace frc

View File

@@ -6,7 +6,7 @@
#include <wpi/StringRef.h>
#include "frc/smartdashboard/SendableBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableBuilder.h"
namespace frc {
@@ -14,7 +14,7 @@ namespace frc {
/**
* A mock sendable that marks itself as an actuator.
*/
class MockActuatorSendable : public SendableBase {
class MockActuatorSendable : public Sendable {
public:
explicit MockActuatorSendable(wpi::StringRef name);

View File

@@ -5,102 +5,9 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
/** The base interface for objects that can be sent over the network through network tables. */
public interface Sendable {
/**
* Gets the name of this {@link Sendable} object.
*
* @return Name
* @deprecated Use SendableRegistry.getName()
*/
@Deprecated(since = "2020", forRemoval = true)
default String getName() {
return SendableRegistry.getName(this);
}
/**
* Sets the name of this {@link Sendable} object.
*
* @param name name
* @deprecated Use SendableRegistry.setName()
*/
@Deprecated(since = "2020", forRemoval = true)
default void setName(String name) {
SendableRegistry.setName(this, name);
}
/**
* Sets both the subsystem name and device name of this {@link Sendable} object.
*
* @param subsystem subsystem name
* @param name device name
* @deprecated Use SendableRegistry.setName()
*/
@Deprecated(since = "2020", forRemoval = true)
default void setName(String subsystem, String name) {
SendableRegistry.setName(this, subsystem, name);
}
/**
* Sets the name of the sensor with a channel number.
*
* @param moduleType A string that defines the module name in the label for the value
* @param channel The channel number the device is plugged into
* @deprecated Use SendableRegistry.setName()
*/
@Deprecated(since = "2020", forRemoval = true)
default void setName(String moduleType, int channel) {
SendableRegistry.setName(this, moduleType, channel);
}
/**
* Sets the name of the sensor with a module and channel number.
*
* @param moduleType A string that defines the module name in the label for the value
* @param moduleNumber The number of the particular module type
* @param channel The channel number the device is plugged into (usually PWM)
* @deprecated Use SendableRegistry.setName()
*/
@Deprecated(since = "2020", forRemoval = true)
default void setName(String moduleType, int moduleNumber, int channel) {
SendableRegistry.setName(this, moduleType, moduleNumber, channel);
}
/**
* Gets the subsystem name of this {@link Sendable} object.
*
* @return Subsystem name
* @deprecated Use SendableRegistry.getSubsystem()
*/
@Deprecated(since = "2020", forRemoval = true)
default String getSubsystem() {
return SendableRegistry.getSubsystem(this);
}
/**
* Sets the subsystem name of this {@link Sendable} object.
*
* @param subsystem subsystem name
* @deprecated Use SendableRegistry.setSubsystem()
*/
@Deprecated(since = "2020", forRemoval = true)
default void setSubsystem(String subsystem) {
SendableRegistry.setSubsystem(this, subsystem);
}
/**
* Add a child component.
*
* @param child child component
* @deprecated Use SendableRegistry.addChild()
*/
@Deprecated(since = "2020", forRemoval = true)
default void addChild(Object child) {
SendableRegistry.addChild(this, child);
}
/**
* Initializes this {@link Sendable} object.
*

View File

@@ -1,39 +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;
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
/**
* Base class for all sensors. Stores most recent status information as well as containing utility
* functions for checking channels and error processing.
*
* @deprecated Use Sendable and SendableRegistry
*/
@Deprecated(since = "2020", forRemoval = true)
public abstract class SendableBase implements Sendable, AutoCloseable {
/** Creates an instance of the sensor base. */
public SendableBase() {
this(true);
}
/**
* Creates an instance of the sensor base.
*
* @param addLiveWindow if true, add this Sendable to LiveWindow
*/
public SendableBase(boolean addLiveWindow) {
if (addLiveWindow) {
SendableRegistry.addLW(this, "");
} else {
SendableRegistry.add(this, "");
}
}
@Override
public void close() {
SendableRegistry.remove(this);
}
}