mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
Removed functions that have been deprecated for at least one year (#551)
This commit is contained in:
committed by
Peter Johnson
parent
d2de94778e
commit
68b63632c4
@@ -23,6 +23,7 @@ class DigitalGlitchFilter;
|
||||
|
||||
/**
|
||||
* Class for counting the number of ticks on a digital input channel.
|
||||
*
|
||||
* This is a general purpose class for counting repetitive events. It can return
|
||||
* the number of counts, the period of the most recent cycle, and detect when
|
||||
* the signal being counted has stopped by supplying a maximum cycle time.
|
||||
@@ -44,8 +45,6 @@ class Counter : public SensorBase,
|
||||
explicit Counter(int channel);
|
||||
explicit Counter(DigitalSource* source);
|
||||
explicit Counter(std::shared_ptr<DigitalSource> source);
|
||||
WPI_DEPRECATED("Use pass-by-reference instead.")
|
||||
explicit Counter(AnalogTrigger* trigger);
|
||||
explicit Counter(const AnalogTrigger& trigger);
|
||||
Counter(EncodingType encodingType, DigitalSource* upSource,
|
||||
DigitalSource* downSource, bool inverted);
|
||||
|
||||
@@ -24,6 +24,7 @@ class DigitalGlitchFilter;
|
||||
|
||||
/**
|
||||
* Class to read quad encoders.
|
||||
*
|
||||
* Quadrature encoders are devices that count shaft rotation and can sense
|
||||
* direction. The output of the QuadEncoder class is an integer that can count
|
||||
* either up or down, and can go negative for reverse direction counting. When
|
||||
@@ -79,9 +80,6 @@ class Encoder : public SensorBase,
|
||||
double PIDGet() override;
|
||||
|
||||
void SetIndexSource(int channel, IndexingType type = kResetOnRisingEdge);
|
||||
WPI_DEPRECATED("Use pass-by-reference instead.")
|
||||
void SetIndexSource(DigitalSource* source,
|
||||
IndexingType type = kResetOnRisingEdge);
|
||||
void SetIndexSource(const DigitalSource& source,
|
||||
IndexingType type = kResetOnRisingEdge);
|
||||
|
||||
|
||||
@@ -50,9 +50,6 @@ class Preferences : public ErrorBase {
|
||||
void PutFloat(llvm::StringRef key, float value);
|
||||
void PutBoolean(llvm::StringRef key, bool value);
|
||||
void PutLong(llvm::StringRef key, int64_t value);
|
||||
WPI_DEPRECATED(
|
||||
"Saving is now automatically performed by the NetworkTables server.")
|
||||
void Save();
|
||||
bool ContainsKey(llvm::StringRef key);
|
||||
void Remove(llvm::StringRef key);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include "support/deprecated.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -62,10 +61,6 @@ class SerialPort : public ErrorBase {
|
||||
void DisableTermination();
|
||||
int GetBytesReceived();
|
||||
int Read(char* buffer, int count);
|
||||
WPI_DEPRECATED(
|
||||
"Potential for unexpected behavior. Please use StringRef overload for "
|
||||
"custom length buffers using std::string")
|
||||
int Write(const std::string& buffer, int count);
|
||||
int Write(const char* buffer, int count);
|
||||
int Write(llvm::StringRef buffer);
|
||||
void SetTimeout(double timeout);
|
||||
|
||||
@@ -87,22 +87,6 @@ Counter::Counter(int channel) : Counter(kTwoPulse) {
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a Counter object.
|
||||
*
|
||||
* Create an instance of a simple up-Counter given an analog trigger.
|
||||
* Use the trigger state output from the analog trigger.
|
||||
*
|
||||
* The counter will start counting immediately.
|
||||
*
|
||||
* @param trigger The pointer to the existing AnalogTrigger object.
|
||||
*/
|
||||
WPI_DEPRECATED("Use pass-by-reference instead.")
|
||||
Counter::Counter(AnalogTrigger* trigger) : Counter(kTwoPulse) {
|
||||
SetUpSource(trigger->CreateOutput(AnalogTriggerType::kState));
|
||||
ClearDownSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a Counter object.
|
||||
*
|
||||
|
||||
@@ -222,12 +222,11 @@ void Encoder::Reset() {
|
||||
/**
|
||||
* Returns the period of the most recent pulse.
|
||||
*
|
||||
* Returns the period of the most recent Encoder pulse in seconds.
|
||||
* This method compensates for the decoding type.
|
||||
* Returns the period of the most recent Encoder pulse in seconds. This method
|
||||
* compensates for the decoding type.
|
||||
*
|
||||
* @deprecated Use GetRate() in favor of this method. This returns unscaled
|
||||
* periods and GetRate() scales using value from
|
||||
* SetDistancePerPulse().
|
||||
* Warning: This returns unscaled periods. Use GetRate() for rates that are
|
||||
* scaled using the value from SetDistancePerPulse().
|
||||
*
|
||||
* @return Period in seconds of the most recent pulse.
|
||||
*/
|
||||
@@ -451,21 +450,7 @@ double Encoder::PIDGet() {
|
||||
void Encoder::SetIndexSource(int channel, Encoder::IndexingType type) {
|
||||
// Force digital input if just given an index
|
||||
m_indexSource = std::make_unique<DigitalInput>(channel);
|
||||
SetIndexSource(m_indexSource.get(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the index source for the encoder.
|
||||
*
|
||||
* When this source is activated, the encoder count automatically resets.
|
||||
*
|
||||
* @param channel A digital source to set as the encoder index
|
||||
* @param type The state that will cause the encoder to reset
|
||||
*/
|
||||
WPI_DEPRECATED("Use pass-by-reference instead.")
|
||||
void Encoder::SetIndexSource(DigitalSource* source,
|
||||
Encoder::IndexingType type) {
|
||||
SetIndexSource(*source, type);
|
||||
SetIndexSource(*m_indexSource.get(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,14 +201,6 @@ void Preferences::PutLong(llvm::StringRef key, int64_t value) {
|
||||
m_table->SetPersistent(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is no longer required, as NetworkTables automatically
|
||||
* saves persistent values (which all Preferences values are) periodically
|
||||
* when running as a server.
|
||||
* @deprecated backwards compatibility shim
|
||||
*/
|
||||
void Preferences::Save() {}
|
||||
|
||||
/**
|
||||
* Returns whether or not there is a key with the given name.
|
||||
*
|
||||
|
||||
@@ -135,21 +135,6 @@ int SerialPort::Read(char* buffer, int count) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write raw bytes to the buffer. Deprecated, please use StringRef overload. Use
|
||||
* Write({data, len}) to get a buffer that is shorter then the length of the
|
||||
* std::string.
|
||||
*
|
||||
* @param buffer Pointer to the buffer to read the bytes from. If string.size()
|
||||
* is less then count, only the length of string.size() will be sent.
|
||||
* @param count The maximum number of bytes to write.
|
||||
* @return The number of bytes actually written into the port.
|
||||
*/
|
||||
int SerialPort::Write(const std::string& buffer, int count) {
|
||||
return Write(llvm::StringRef(
|
||||
buffer.data(), std::min(static_cast<int>(buffer.size()), count)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write raw bytes to the buffer.
|
||||
*
|
||||
@@ -164,6 +149,9 @@ int SerialPort::Write(const char* buffer, int count) {
|
||||
/**
|
||||
* Write raw bytes to the buffer.
|
||||
*
|
||||
* Use Write({data, len}) to get a buffer that is shorter than the length of the
|
||||
* string.
|
||||
*
|
||||
* @param buffer StringRef to the buffer to read the bytes from.
|
||||
* @return The number of bytes actually written into the port.
|
||||
*/
|
||||
|
||||
@@ -76,7 +76,6 @@ TEST(PreferencesTest, WritePreferencesToFile) {
|
||||
preferences->PutFloat("testFilePutFloat", 0.25f);
|
||||
preferences->PutBoolean("testFilePutBoolean", true);
|
||||
preferences->PutLong("testFilePutLong", 1000000000000000000ll);
|
||||
preferences->Save();
|
||||
|
||||
Wait(kSaveTime);
|
||||
|
||||
|
||||
@@ -799,38 +799,4 @@ public class CameraServer {
|
||||
m_sources.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the image to use. Use the public kSize constants to set the correct mode, or
|
||||
* set it directly on a camera and call the appropriate startAutomaticCapture method.
|
||||
*
|
||||
* @deprecated Use setResolution on the UsbCamera returned by startAutomaticCapture() instead.
|
||||
* @param size The size to use
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSize(int size) {
|
||||
VideoSource source = null;
|
||||
synchronized (this) {
|
||||
if (m_primarySourceName == null) {
|
||||
return;
|
||||
}
|
||||
source = m_sources.get(m_primarySourceName);
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (size) {
|
||||
case kSize640x480:
|
||||
source.setResolution(640, 480);
|
||||
break;
|
||||
case kSize320x240:
|
||||
source.setResolution(320, 240);
|
||||
break;
|
||||
case kSize160x120:
|
||||
source.setResolution(160, 120);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported size: " + size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,11 @@ import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable;
|
||||
import edu.wpi.first.wpilibj.tables.ITable;
|
||||
|
||||
/**
|
||||
* Class for counting the number of ticks on a digital input channel. This is a general purpose
|
||||
* class for counting repetitive events. It can return the number of counts, the period of the most
|
||||
* recent cycle, and detect when the signal being counted has stopped by supplying a maximum cycle
|
||||
* time.
|
||||
* Class for counting the number of ticks on a digital input channel.
|
||||
*
|
||||
* <p>This is a general purpose class for counting repetitive events. It can return the number of
|
||||
* counts, the period of the most recent cycle, and detect when the signal being counted has
|
||||
* stopped by supplying a maximum cycle time.
|
||||
*
|
||||
* <p>All counters will immediately start counting - reset() them if you need them to be zeroed
|
||||
* before use.
|
||||
|
||||
@@ -90,35 +90,6 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable {
|
||||
DIOJNI.pulse(m_handle, pulseLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a single pulse. Write a pulse to the specified digital output channel. There can only
|
||||
* be a single pulse going at any time.
|
||||
*
|
||||
* @param channel Unused
|
||||
* @param pulseLength The length of the pulse.
|
||||
* @deprecated Use {@link #pulse(double)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("PMD.UnusedFormalParameter")
|
||||
public void pulse(final int channel, final double pulseLength) {
|
||||
DIOJNI.pulse(m_handle, pulseLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param channel Unused
|
||||
* @param pulseLength The length of the pulse.
|
||||
* @deprecated Generate a single pulse. Write a pulse to the specified digital output channel.
|
||||
* There can only be a single pulse going at any time.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("PMD.UnusedFormalParameter")
|
||||
public void pulse(final int channel, final int pulseLength) {
|
||||
double convertedPulse = pulseLength / 1.0e9 * (DIOJNI.getLoopTiming() * 25);
|
||||
System.err
|
||||
.println("You should use the double version of pulse for portability. This is deprecated");
|
||||
DIOJNI.pulse(m_handle, convertedPulse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the pulse is still going. Determine if a previously started pulse is still going.
|
||||
*
|
||||
|
||||
@@ -16,13 +16,14 @@ import edu.wpi.first.wpilibj.tables.ITable;
|
||||
import edu.wpi.first.wpilibj.util.AllocationException;
|
||||
|
||||
/**
|
||||
* Class to read quadrature encoders. Quadrature encoders are devices that count shaft rotation and
|
||||
* can sense direction. The output of the Encoder class is an integer that can count either up or
|
||||
* down, and can go negative for reverse direction counting. When creating Encoders, a direction
|
||||
* can be supplied that inverts the sense of the output to make code more readable if the encoder is
|
||||
* mounted such that forward movement generates negative values. Quadrature encoders have two
|
||||
* digital outputs, an A Channel and a B Channel, that are out of phase with each other for
|
||||
* direction sensing.
|
||||
* Class to read quadrature encoders.
|
||||
*
|
||||
* <p>Quadrature encoders are devices that count shaft rotation and can sense direction. The output
|
||||
* of the Encoder class is an integer that can count either up or down, and can go negative for
|
||||
* reverse direction counting. When creating Encoders, a direction can be supplied that inverts the
|
||||
* sense of the output to make code more readable if the encoder is mounted such that forward
|
||||
* movement generates negative values. Quadrature encoders have two digital outputs, an A Channel
|
||||
* and a B Channel, that are out of phase with each other for direction sensing.
|
||||
*
|
||||
* <p>All encoders will immediately start counting - reset() them if you need them to be zeroed
|
||||
* before use.
|
||||
@@ -377,8 +378,8 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW
|
||||
* Returns the period of the most recent pulse. Returns the period of the most recent Encoder
|
||||
* pulse in seconds. This method compensates for the decoding type.
|
||||
*
|
||||
* <p><b>Warning:</b> This returns unscaled periods and getRate() scales using value from
|
||||
* setDistancePerPulse().
|
||||
* <p><b>Warning:</b> This returns unscaled periods. Use getRate() for rates that are scaled using
|
||||
* the value from setDistancePerPulse().
|
||||
*
|
||||
* @return Period in seconds of the most recent pulse.
|
||||
* @deprecated Use getRate() in favor of this method.
|
||||
|
||||
@@ -92,25 +92,6 @@ public class PWM extends SensorBase implements LiveWindowSendable {
|
||||
PWMJNI.setPWMEliminateDeadband(m_handle, eliminateDeadband);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bounds on the PWM values. This sets the bounds on the PWM values for a particular each
|
||||
* type of controller. The values determine the upper and lower speeds as well as the deadband
|
||||
* bracket.
|
||||
*
|
||||
* @param max The Minimum pwm value
|
||||
* @param deadbandMax The high end of the deadband range
|
||||
* @param center The center speed (off)
|
||||
* @param deadbandMin The low end of the deadband range
|
||||
* @param min The minimum pwm value
|
||||
* @deprecated Recommended to set bounds in ms using {@link #setBounds(double, double, double,
|
||||
* double, double)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRawBounds(final int max, final int deadbandMax, final int center,
|
||||
final int deadbandMin, final int min) {
|
||||
PWMJNI.setPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bounds on the PWM pulse widths. This sets the bounds on the PWM values for a particular
|
||||
* type of controller. The values determine the upper and lower speeds as well as the deadband
|
||||
|
||||
@@ -247,14 +247,4 @@ public class Preferences {
|
||||
public long getLong(String key, long backup) {
|
||||
return (long) m_table.getNumber(key, backup);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is no longer required, as NetworkTables automatically saves persistent values
|
||||
* (which all Preferences values are) periodically when running as a server.
|
||||
*
|
||||
* @deprecated backwards compatibility shim
|
||||
*/
|
||||
@Deprecated
|
||||
public void save() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,18 +584,6 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll
|
||||
return m_buf.size() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the percentage error which is considered tolerable for use with OnTarget. (Input of 15.0 =
|
||||
* 15 percent).
|
||||
*
|
||||
* @param percent error which is tolerable
|
||||
* @deprecated Use {@link #setPercentTolerance} or {@link #setAbsoluteTolerance} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public synchronized void setTolerance(double percent) {
|
||||
m_tolerance = new PercentageTolerance(percent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the PID tolerance using a Tolerance object. Tolerance can be specified as a percentage of
|
||||
* the range or as an absolute value. The Tolerance object encapsulates those options in an
|
||||
@@ -681,16 +669,6 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if PIDController is enabled.
|
||||
*
|
||||
* @deprecated Call {@link #isEnabled()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public synchronized boolean isEnable() {
|
||||
return isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if PIDController is enabled.
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,6 @@ package edu.wpi.first.wpilibj.smartdashboard;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Hashtable;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.wpi.first.wpilibj.HLUsageReporting;
|
||||
@@ -18,7 +17,6 @@ import edu.wpi.first.wpilibj.Sendable;
|
||||
import edu.wpi.first.wpilibj.networktables.NetworkTable;
|
||||
import edu.wpi.first.wpilibj.networktables.NetworkTableKeyNotDefined;
|
||||
import edu.wpi.first.wpilibj.tables.ITable;
|
||||
import edu.wpi.first.wpilibj.tables.TableKeyNotDefinedException;
|
||||
|
||||
/**
|
||||
* The {@link SmartDashboard} class is the bridge between robot programs and the SmartDashboard on
|
||||
@@ -208,20 +206,6 @@ public class SmartDashboard {
|
||||
return table.setDefaultBoolean(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boolean the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getBoolean(String, boolean)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean getBoolean(String key) throws TableKeyNotDefinedException {
|
||||
return table.getBoolean(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boolean the key maps to. If the key does not exist or is of
|
||||
* different type, it will return the default value.
|
||||
@@ -254,20 +238,6 @@ public class SmartDashboard {
|
||||
return table.setDefaultNumber(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getNumber(String, double)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static double getNumber(String key) throws TableKeyNotDefinedException {
|
||||
return table.getNumber(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number the key maps to. If the key does not exist or is of
|
||||
* different type, it will return the default value.
|
||||
@@ -300,20 +270,6 @@ public class SmartDashboard {
|
||||
return table.setDefaultString(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getString(String, String)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getString(String key) throws TableKeyNotDefinedException {
|
||||
return table.getString(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string the key maps to. If the key does not exist or is of
|
||||
* different type, it will return the default value.
|
||||
@@ -366,20 +322,6 @@ public class SmartDashboard {
|
||||
return table.setDefaultBooleanArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boolean array the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getBooleanArray(String, boolean[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean[] getBooleanArray(String key) throws TableKeyNotDefinedException {
|
||||
return table.getBooleanArray(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boolean array the key maps to. If the key does not exist or is
|
||||
* of different type, it will return the default value.
|
||||
@@ -444,20 +386,6 @@ public class SmartDashboard {
|
||||
return table.setDefaultNumberArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number array the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getNumberArray(String, double[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public double[] getNumberArray(String key) throws TableKeyNotDefinedException {
|
||||
return table.getNumberArray(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number array the key maps to. If the key does not exist or is
|
||||
* of different type, it will return the default value.
|
||||
@@ -502,20 +430,6 @@ public class SmartDashboard {
|
||||
return table.setDefaultStringArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string array the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getStringArray(String, String[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public String[] getStringArray(String key) throws TableKeyNotDefinedException {
|
||||
return table.getStringArray(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string array the key maps to. If the key does not exist or is
|
||||
* of different type, it will return the default value.
|
||||
@@ -559,20 +473,6 @@ public class SmartDashboard {
|
||||
return table.setDefaultRaw(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw value (byte array) the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getRaw(String, byte[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public byte[] getRaw(String key) throws TableKeyNotDefinedException {
|
||||
return table.getRaw(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw value (byte array) the key maps to. If the key does not
|
||||
* exist or is of different type, it will return the default value.
|
||||
@@ -584,106 +484,4 @@ public class SmartDashboard {
|
||||
public static byte[] getRaw(String key, byte[] defaultValue) {
|
||||
return table.getRaw(key, defaultValue);
|
||||
}
|
||||
|
||||
/*
|
||||
* Deprecated Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
*
|
||||
* <p>The key can not be null. The value can be retrieved by calling the get method with a key
|
||||
* that is equal to the original key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @throws IllegalArgumentException if key is null
|
||||
* @deprecated Use {@link #putNumber(java.lang.String, double) putNumber method} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void putInt(String key, int value) {
|
||||
table.putNumber(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @return the value
|
||||
* @throws TableKeyNotDefinedException if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not an int
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* @deprecated Use {@link #getNumber(java.lang.String) getNumber} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getInt(String key) throws TableKeyNotDefinedException {
|
||||
return (int) table.getNumber(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param defaultValue the value returned if the key is undefined
|
||||
* @return the value
|
||||
* @throws TableKeyNotDefinedException if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not an int
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* @deprecated Use {@link #getNumber(java.lang.String, double) getNumber} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getInt(String key, int defaultValue) throws TableKeyNotDefinedException {
|
||||
try {
|
||||
return (int) table.getNumber(key);
|
||||
} catch (NoSuchElementException ex) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
*
|
||||
* <p>The key can not be null. The value can be retrieved by calling the get method with a key
|
||||
* that is equal to the original key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @throws IllegalArgumentException if key is null
|
||||
* @deprecated Use{@link #putNumber(java.lang.String, double) putNumber} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void putDouble(String key, double value) {
|
||||
table.putNumber(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @return the value
|
||||
* @throws TableKeyNotDefinedException if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a double
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* @deprecated Use {@link #getNumber(java.lang.String) getNumber} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static double getDouble(String key) throws TableKeyNotDefinedException {
|
||||
return table.getNumber(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param defaultValue the value returned if the key is undefined
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a double
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* @deprecated Use {@link #getNumber(java.lang.String, double) getNumber} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static double getDouble(String key, double defaultValue) {
|
||||
return table.getNumber(key, defaultValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public class PIDTest extends AbstractComsSetup {
|
||||
setupOutputRange();
|
||||
double setpoint = 2500.0;
|
||||
m_controller.setSetpoint(setpoint);
|
||||
assertFalse("PID did not begin disabled", m_controller.isEnable());
|
||||
assertFalse("PID did not begin disabled", m_controller.isEnabled());
|
||||
assertEquals("PID.getError() did not start at " + setpoint, setpoint,
|
||||
m_controller.getError(), 0);
|
||||
assertEquals(k_p, m_table.getNumber("p"), 0);
|
||||
@@ -149,11 +149,11 @@ public class PIDTest extends AbstractComsSetup {
|
||||
m_controller.enable();
|
||||
Timer.delay(.5);
|
||||
assertTrue(m_table.getBoolean("enabled"));
|
||||
assertTrue(m_controller.isEnable());
|
||||
assertTrue(m_controller.isEnabled());
|
||||
assertThat(0.0, is(not(me.getMotor().get())));
|
||||
m_controller.reset();
|
||||
assertFalse(m_table.getBoolean("enabled"));
|
||||
assertFalse(m_controller.isEnable());
|
||||
assertFalse(m_controller.isEnabled());
|
||||
assertEquals(0, me.getMotor().get(), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,6 @@ public class PreferencesTest extends AbstractComsSetup {
|
||||
assertEquals(m_pref.getFloat("checkedValueFloat", 0), 0, 0);
|
||||
assertFalse(m_pref.getBoolean("checkedValueBoolean", false));
|
||||
addCheckedValue();
|
||||
m_pref.save();
|
||||
assertEquals(m_check, m_pref.getLong("checkedValueLong", 0));
|
||||
assertEquals(m_pref.getDouble("checkedValueDouble", 0), 1, 0);
|
||||
assertEquals(m_pref.getString("checkedValueString", ""), "checked");
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.junit.Test;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.networktables.NetworkTable;
|
||||
import edu.wpi.first.wpilibj.networktables.NetworkTableKeyNotDefined;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -29,9 +28,9 @@ public class SmartDashboardTest extends AbstractComsSetup {
|
||||
return logger;
|
||||
}
|
||||
|
||||
@Test(expected = NetworkTableKeyNotDefined.class)
|
||||
@Test
|
||||
public void testGetBadValue() {
|
||||
SmartDashboard.getString("_404_STRING_KEY_SHOULD_NOT_BE_FOUND_");
|
||||
assertEquals("", SmartDashboard.getString("_404_STRING_KEY_SHOULD_NOT_BE_FOUND_", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -39,7 +38,7 @@ public class SmartDashboardTest extends AbstractComsSetup {
|
||||
String key = "testPutString";
|
||||
String value = "thisIsAValue";
|
||||
SmartDashboard.putString(key, value);
|
||||
assertEquals(value, SmartDashboard.getString(key));
|
||||
assertEquals(value, SmartDashboard.getString(key, ""));
|
||||
assertEquals(value, table.getString(key));
|
||||
}
|
||||
|
||||
@@ -48,7 +47,7 @@ public class SmartDashboardTest extends AbstractComsSetup {
|
||||
String key = "testPutNumber";
|
||||
int value = 2147483647;
|
||||
SmartDashboard.putNumber(key, value);
|
||||
assertEquals(value, SmartDashboard.getNumber(key), 0.01);
|
||||
assertEquals(value, SmartDashboard.getNumber(key, 0), 0.01);
|
||||
assertEquals(value, table.getNumber(key), 0.01);
|
||||
}
|
||||
|
||||
@@ -57,7 +56,7 @@ public class SmartDashboardTest extends AbstractComsSetup {
|
||||
String key = "testPutBoolean";
|
||||
boolean value = true;
|
||||
SmartDashboard.putBoolean(key, value);
|
||||
assertEquals(value, SmartDashboard.getBoolean(key));
|
||||
assertEquals(value, SmartDashboard.getBoolean(key, !value));
|
||||
assertEquals(value, table.getBoolean(key));
|
||||
}
|
||||
|
||||
@@ -66,12 +65,12 @@ public class SmartDashboardTest extends AbstractComsSetup {
|
||||
String key = "testReplaceString";
|
||||
String valueOld = "oldValue";
|
||||
SmartDashboard.putString(key, valueOld);
|
||||
assertEquals(valueOld, SmartDashboard.getString(key));
|
||||
assertEquals(valueOld, SmartDashboard.getString(key, ""));
|
||||
assertEquals(valueOld, table.getString(key));
|
||||
|
||||
String valueNew = "newValue";
|
||||
SmartDashboard.putString(key, valueNew);
|
||||
assertEquals(valueNew, SmartDashboard.getString(key));
|
||||
assertEquals(valueNew, SmartDashboard.getString(key, ""));
|
||||
assertEquals(valueNew, table.getString(key));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user