diff --git a/wpilibc/src/main/native/cpp/AnalogInput.cpp b/wpilibc/src/main/native/cpp/AnalogInput.cpp index 7b1276fd22..0acfabdd24 100644 --- a/wpilibc/src/main/native/cpp/AnalogInput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogInput.cpp @@ -12,6 +12,7 @@ #include #include +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "Timer.h" #include "WPIErrors.h" @@ -25,7 +26,7 @@ using namespace frc; * on-board 4-7 are on the MXP port. */ AnalogInput::AnalogInput(int channel) { - if (!SensorBase::CheckAnalogInputChannel(channel)) { + if (!SensorUtil::CheckAnalogInputChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, "Analog Input " + wpi::Twine(channel)); return; diff --git a/wpilibc/src/main/native/cpp/AnalogOutput.cpp b/wpilibc/src/main/native/cpp/AnalogOutput.cpp index cf8e1fb0bf..65129df616 100644 --- a/wpilibc/src/main/native/cpp/AnalogOutput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogOutput.cpp @@ -12,7 +12,7 @@ #include #include -#include "SensorBase.h" +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -26,7 +26,7 @@ using namespace frc; * @param channel The channel number on the roboRIO to represent. */ AnalogOutput::AnalogOutput(int channel) { - if (!SensorBase::CheckAnalogOutputChannel(channel)) { + if (!SensorUtil::CheckAnalogOutputChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, "analog output " + wpi::Twine(channel)); m_channel = std::numeric_limits::max(); diff --git a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp index 7ab9790ea7..197a2b8d3c 100644 --- a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp +++ b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp @@ -16,6 +16,7 @@ #include "Counter.h" #include "Encoder.h" +#include "SensorUtil.h" #include "Utility.h" #include "WPIErrors.h" diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp index 826a72511b..7d53807606 100644 --- a/wpilibc/src/main/native/cpp/DigitalInput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp @@ -13,6 +13,7 @@ #include #include +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -26,7 +27,7 @@ using namespace frc; * @param channel The DIO channel 0-9 are on-board, 10-25 are on the MXP port */ DigitalInput::DigitalInput(int channel) { - if (!CheckDigitalChannel(channel)) { + if (!SensorUtil::CheckDigitalChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, "Digital Channel " + wpi::Twine(channel)); m_channel = std::numeric_limits::max(); diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index df6fbeb14e..9837ee1df5 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -13,7 +13,7 @@ #include #include -#include "SensorBase.h" +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -29,7 +29,7 @@ using namespace frc; */ DigitalOutput::DigitalOutput(int channel) { m_pwmGenerator = HAL_kInvalidHandle; - if (!SensorBase::CheckDigitalChannel(channel)) { + if (!SensorUtil::CheckDigitalChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, "Digital Channel " + wpi::Twine(channel)); m_channel = std::numeric_limits::max(); @@ -187,7 +187,7 @@ void DigitalOutput::DisablePWM() { int32_t status = 0; // Disable the output by routing to a dead bit. - HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, SensorBase::kDigitalChannels, + HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, SensorUtil::kDigitalChannels, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); diff --git a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp index e7ece40103..87e548cad1 100644 --- a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp +++ b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp @@ -11,7 +11,7 @@ #include #include -#include "SensorBase.h" +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -26,7 +26,7 @@ using namespace frc; * @param reverseChannel The reverse channel number on the PCM (0..7). */ DoubleSolenoid::DoubleSolenoid(int forwardChannel, int reverseChannel) - : DoubleSolenoid(SensorBase::GetDefaultSolenoidModule(), forwardChannel, + : DoubleSolenoid(SensorUtil::GetDefaultSolenoidModule(), forwardChannel, reverseChannel) {} /** @@ -41,18 +41,18 @@ DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel, : SolenoidBase(moduleNumber), m_forwardChannel(forwardChannel), m_reverseChannel(reverseChannel) { - if (!SensorBase::CheckSolenoidModule(m_moduleNumber)) { + if (!SensorUtil::CheckSolenoidModule(m_moduleNumber)) { wpi_setWPIErrorWithContext(ModuleIndexOutOfRange, "Solenoid Module " + wpi::Twine(m_moduleNumber)); return; } - if (!SensorBase::CheckSolenoidChannel(m_forwardChannel)) { + if (!SensorUtil::CheckSolenoidChannel(m_forwardChannel)) { wpi_setWPIErrorWithContext( ChannelIndexOutOfRange, "Solenoid Channel " + wpi::Twine(m_forwardChannel)); return; } - if (!SensorBase::CheckSolenoidChannel(m_reverseChannel)) { + if (!SensorUtil::CheckSolenoidChannel(m_reverseChannel)) { wpi_setWPIErrorWithContext( ChannelIndexOutOfRange, "Solenoid Channel " + wpi::Twine(m_reverseChannel)); diff --git a/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp b/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp index 635f2302ef..cac41a10b5 100644 --- a/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp +++ b/wpilibc/src/main/native/cpp/LiveWindow/LiveWindow.cpp @@ -186,7 +186,7 @@ void LiveWindow::AddActuator(const wpi::Twine& subsystem, /** * Meant for internal use in other WPILib classes. - * @deprecated Use SensorBase::SetName() instead. + * @deprecated Use SendableBase::SetName() instead. */ void LiveWindow::AddSensor(const wpi::Twine& type, int channel, Sendable* component) { @@ -197,7 +197,7 @@ void LiveWindow::AddSensor(const wpi::Twine& type, int channel, /** * Meant for internal use in other WPILib classes. - * @deprecated Use SensorBase::SetName() instead. + * @deprecated Use SendableBase::SetName() instead. */ void LiveWindow::AddActuator(const wpi::Twine& type, int channel, Sendable* component) { @@ -208,7 +208,7 @@ void LiveWindow::AddActuator(const wpi::Twine& type, int channel, /** * Meant for internal use in other WPILib classes. - * @deprecated Use SensorBase::SetName() instead. + * @deprecated Use SendableBase::SetName() instead. */ void LiveWindow::AddActuator(const wpi::Twine& type, int module, int channel, Sendable* component) { diff --git a/wpilibc/src/main/native/cpp/PWM.cpp b/wpilibc/src/main/native/cpp/PWM.cpp index 42627339f1..e6ca213cb4 100644 --- a/wpilibc/src/main/native/cpp/PWM.cpp +++ b/wpilibc/src/main/native/cpp/PWM.cpp @@ -11,7 +11,7 @@ #include #include -#include "SensorBase.h" +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "Utility.h" #include "WPIErrors.h" @@ -29,7 +29,7 @@ using namespace frc; * MXP port */ PWM::PWM(int channel) { - if (!SensorBase::CheckPWMChannel(channel)) { + if (!SensorUtil::CheckPWMChannel(channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, "PWM Channel " + wpi::Twine(channel)); return; diff --git a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp index d99ac506f9..7d3b5de24a 100644 --- a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp +++ b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp @@ -13,6 +13,7 @@ #include #include +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -77,7 +78,7 @@ double PowerDistributionPanel::GetTemperature() const { double PowerDistributionPanel::GetCurrent(int channel) const { int32_t status = 0; - if (!CheckPDPChannel(channel)) { + if (!SensorUtil::CheckPDPChannel(channel)) { wpi::SmallString<32> str; wpi::raw_svector_ostream buf(str); buf << "PDP Channel " << channel; @@ -174,7 +175,7 @@ void PowerDistributionPanel::ClearStickyFaults() { void PowerDistributionPanel::InitSendable(SendableBuilder& builder) { builder.SetSmartDashboardType("PowerDistributionPanel"); - for (int i = 0; i < kPDPChannels; ++i) { + for (int i = 0; i < SensorUtil::kPDPChannels; ++i) { builder.AddDoubleProperty("Chan" + wpi::Twine(i), [=]() { return GetCurrent(i); }, nullptr); } diff --git a/wpilibc/src/main/native/cpp/Relay.cpp b/wpilibc/src/main/native/cpp/Relay.cpp index 9cd2c31d8d..e57e148a6f 100644 --- a/wpilibc/src/main/native/cpp/Relay.cpp +++ b/wpilibc/src/main/native/cpp/Relay.cpp @@ -13,7 +13,7 @@ #include #include "MotorSafetyHelper.h" -#include "SensorBase.h" +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -30,7 +30,7 @@ using namespace frc; */ Relay::Relay(int channel, Relay::Direction direction) : m_channel(channel), m_direction(direction) { - if (!SensorBase::CheckRelayChannel(m_channel)) { + if (!SensorUtil::CheckRelayChannel(m_channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, "Relay Channel " + wpi::Twine(m_channel)); return; diff --git a/wpilibc/src/main/native/cpp/SensorBase.cpp b/wpilibc/src/main/native/cpp/SensorUtil.cpp similarity index 72% rename from wpilibc/src/main/native/cpp/SensorBase.cpp rename to wpilibc/src/main/native/cpp/SensorUtil.cpp index ca87fa3351..bcf9109aed 100644 --- a/wpilibc/src/main/native/cpp/SensorBase.cpp +++ b/wpilibc/src/main/native/cpp/SensorUtil.cpp @@ -5,7 +5,7 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "SensorBase.h" +#include "SensorUtil.h" #include #include @@ -17,24 +17,22 @@ #include #include -#include "WPIErrors.h" - using namespace frc; -const int SensorBase::kDigitalChannels = HAL_GetNumDigitalChannels(); -const int SensorBase::kAnalogInputs = HAL_GetNumAnalogInputs(); -const int SensorBase::kSolenoidChannels = HAL_GetNumSolenoidChannels(); -const int SensorBase::kSolenoidModules = HAL_GetNumPCMModules(); -const int SensorBase::kPwmChannels = HAL_GetNumPWMChannels(); -const int SensorBase::kRelayChannels = HAL_GetNumRelayHeaders(); -const int SensorBase::kPDPChannels = HAL_GetNumPDPChannels(); +const int SensorUtil::kDigitalChannels = HAL_GetNumDigitalChannels(); +const int SensorUtil::kAnalogInputs = HAL_GetNumAnalogInputs(); +const int SensorUtil::kSolenoidChannels = HAL_GetNumSolenoidChannels(); +const int SensorUtil::kSolenoidModules = HAL_GetNumPCMModules(); +const int SensorUtil::kPwmChannels = HAL_GetNumPWMChannels(); +const int SensorUtil::kRelayChannels = HAL_GetNumRelayHeaders(); +const int SensorUtil::kPDPChannels = HAL_GetNumPDPChannels(); /** * Check that the solenoid module number is valid. * * @return Solenoid module is valid and present */ -bool SensorBase::CheckSolenoidModule(int moduleNumber) { +bool SensorUtil::CheckSolenoidModule(int moduleNumber) { return HAL_CheckSolenoidModule(moduleNumber); } @@ -46,7 +44,7 @@ bool SensorBase::CheckSolenoidModule(int moduleNumber) { * * @return Digital channel is valid */ -bool SensorBase::CheckDigitalChannel(int channel) { +bool SensorUtil::CheckDigitalChannel(int channel) { return HAL_CheckDIOChannel(channel); } @@ -58,7 +56,7 @@ bool SensorBase::CheckDigitalChannel(int channel) { * * @return Relay channel is valid */ -bool SensorBase::CheckRelayChannel(int channel) { +bool SensorUtil::CheckRelayChannel(int channel) { return HAL_CheckRelayChannel(channel); } @@ -70,7 +68,7 @@ bool SensorBase::CheckRelayChannel(int channel) { * * @return PWM channel is valid */ -bool SensorBase::CheckPWMChannel(int channel) { +bool SensorUtil::CheckPWMChannel(int channel) { return HAL_CheckPWMChannel(channel); } @@ -82,7 +80,7 @@ bool SensorBase::CheckPWMChannel(int channel) { * * @return Analog channel is valid */ -bool SensorBase::CheckAnalogInputChannel(int channel) { +bool SensorUtil::CheckAnalogInputChannel(int channel) { return HAL_CheckAnalogInputChannel(channel); } @@ -94,7 +92,7 @@ bool SensorBase::CheckAnalogInputChannel(int channel) { * * @return Analog channel is valid */ -bool SensorBase::CheckAnalogOutputChannel(int channel) { +bool SensorUtil::CheckAnalogOutputChannel(int channel) { return HAL_CheckAnalogOutputChannel(channel); } @@ -103,7 +101,7 @@ bool SensorBase::CheckAnalogOutputChannel(int channel) { * * @return Solenoid channel is valid */ -bool SensorBase::CheckSolenoidChannel(int channel) { +bool SensorUtil::CheckSolenoidChannel(int channel) { return HAL_CheckSolenoidChannel(channel); } @@ -112,6 +110,6 @@ bool SensorBase::CheckSolenoidChannel(int channel) { * * @return PDP channel is valid */ -bool SensorBase::CheckPDPChannel(int channel) { +bool SensorUtil::CheckPDPChannel(int channel) { return HAL_CheckPDPModule(channel); } diff --git a/wpilibc/src/main/native/cpp/Solenoid.cpp b/wpilibc/src/main/native/cpp/Solenoid.cpp index 31c9430847..c648f81d5c 100644 --- a/wpilibc/src/main/native/cpp/Solenoid.cpp +++ b/wpilibc/src/main/native/cpp/Solenoid.cpp @@ -11,7 +11,7 @@ #include #include -#include "SensorBase.h" +#include "SensorUtil.h" #include "SmartDashboard/SendableBuilder.h" #include "WPIErrors.h" @@ -23,7 +23,7 @@ using namespace frc; * @param channel The channel on the PCM to control (0..7). */ Solenoid::Solenoid(int channel) - : Solenoid(SensorBase::GetDefaultSolenoidModule(), channel) {} + : Solenoid(SensorUtil::GetDefaultSolenoidModule(), channel) {} /** * Constructor. @@ -33,12 +33,12 @@ Solenoid::Solenoid(int channel) */ Solenoid::Solenoid(int moduleNumber, int channel) : SolenoidBase(moduleNumber), m_channel(channel) { - if (!SensorBase::CheckSolenoidModule(m_moduleNumber)) { + if (!SensorUtil::CheckSolenoidModule(m_moduleNumber)) { wpi_setWPIErrorWithContext(ModuleIndexOutOfRange, "Solenoid Module " + wpi::Twine(m_moduleNumber)); return; } - if (!SensorBase::CheckSolenoidChannel(m_channel)) { + if (!SensorUtil::CheckSolenoidChannel(m_channel)) { wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, "Solenoid Channel " + wpi::Twine(m_channel)); return; diff --git a/wpilibc/src/main/native/include/ADXL345_I2C.h b/wpilibc/src/main/native/include/ADXL345_I2C.h index e03a16e724..a618a2a3f5 100644 --- a/wpilibc/src/main/native/include/ADXL345_I2C.h +++ b/wpilibc/src/main/native/include/ADXL345_I2C.h @@ -7,8 +7,9 @@ #pragma once +#include "ErrorBase.h" #include "I2C.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" #include "interfaces/Accelerometer.h" namespace frc { @@ -20,7 +21,9 @@ namespace frc { * an I2C bus. This class assumes the default (not alternate) sensor address of * 0x1D (7-bit address). */ -class ADXL345_I2C : public SensorBase, public Accelerometer { +class ADXL345_I2C : public ErrorBase, + public SendableBase, + public Accelerometer { public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; diff --git a/wpilibc/src/main/native/include/ADXL345_SPI.h b/wpilibc/src/main/native/include/ADXL345_SPI.h index ac6e4f43c0..bc73e87c88 100644 --- a/wpilibc/src/main/native/include/ADXL345_SPI.h +++ b/wpilibc/src/main/native/include/ADXL345_SPI.h @@ -7,8 +7,9 @@ #pragma once +#include "ErrorBase.h" #include "SPI.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" #include "interfaces/Accelerometer.h" namespace frc { @@ -19,7 +20,9 @@ namespace frc { * This class allows access to an Analog Devices ADXL345 3-axis accelerometer * via SPI. This class assumes the sensor is wired in 4-wire SPI mode. */ -class ADXL345_SPI : public SensorBase, public Accelerometer { +class ADXL345_SPI : public ErrorBase, + public SendableBase, + public Accelerometer { public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; diff --git a/wpilibc/src/main/native/include/ADXL362.h b/wpilibc/src/main/native/include/ADXL362.h index 8083df107d..80a438e6ab 100644 --- a/wpilibc/src/main/native/include/ADXL362.h +++ b/wpilibc/src/main/native/include/ADXL362.h @@ -7,8 +7,9 @@ #pragma once +#include "ErrorBase.h" #include "SPI.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" #include "interfaces/Accelerometer.h" namespace frc { @@ -18,7 +19,7 @@ namespace frc { * * This class allows access to an Analog Devices ADXL362 3-axis accelerometer. */ -class ADXL362 : public SensorBase, public Accelerometer { +class ADXL362 : public ErrorBase, public SendableBase, public Accelerometer { public: enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 }; struct AllAxes { diff --git a/wpilibc/src/main/native/include/AnalogAccelerometer.h b/wpilibc/src/main/native/include/AnalogAccelerometer.h index ec9b4ddbf1..0cc9695dea 100644 --- a/wpilibc/src/main/native/include/AnalogAccelerometer.h +++ b/wpilibc/src/main/native/include/AnalogAccelerometer.h @@ -10,8 +10,9 @@ #include #include "AnalogInput.h" +#include "ErrorBase.h" #include "PIDSource.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { @@ -22,7 +23,9 @@ namespace frc { * sensors have multiple axis and can be treated as multiple devices. Each is * calibrated by finding the center value over a period of time. */ -class AnalogAccelerometer : public SensorBase, public PIDSource { +class AnalogAccelerometer : public ErrorBase, + public SendableBase, + public PIDSource { public: explicit AnalogAccelerometer(int channel); explicit AnalogAccelerometer(AnalogInput* channel); diff --git a/wpilibc/src/main/native/include/AnalogInput.h b/wpilibc/src/main/native/include/AnalogInput.h index 040079838a..c51ec2a856 100644 --- a/wpilibc/src/main/native/include/AnalogInput.h +++ b/wpilibc/src/main/native/include/AnalogInput.h @@ -11,8 +11,9 @@ #include +#include "ErrorBase.h" #include "PIDSource.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { @@ -28,7 +29,7 @@ namespace frc { * are divided by the number of samples to retain the resolution, but get more * stable values. */ -class AnalogInput : public SensorBase, public PIDSource { +class AnalogInput : public ErrorBase, public SendableBase, public PIDSource { friend class AnalogTrigger; friend class AnalogGyro; diff --git a/wpilibc/src/main/native/include/AnalogPotentiometer.h b/wpilibc/src/main/native/include/AnalogPotentiometer.h index e41a8a373e..72c43af13c 100644 --- a/wpilibc/src/main/native/include/AnalogPotentiometer.h +++ b/wpilibc/src/main/native/include/AnalogPotentiometer.h @@ -10,7 +10,8 @@ #include #include "AnalogInput.h" -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" #include "interfaces/Potentiometer.h" namespace frc { @@ -21,7 +22,9 @@ namespace frc { * units you choose, by way of the scaling and offset constants passed to the * constructor. */ -class AnalogPotentiometer : public SensorBase, public Potentiometer { +class AnalogPotentiometer : public ErrorBase, + public SendableBase, + public Potentiometer { public: /** * AnalogPotentiometer constructor. diff --git a/wpilibc/src/main/native/include/AnalogTrigger.h b/wpilibc/src/main/native/include/AnalogTrigger.h index 21a1b2f816..f1a66eb83c 100644 --- a/wpilibc/src/main/native/include/AnalogTrigger.h +++ b/wpilibc/src/main/native/include/AnalogTrigger.h @@ -12,13 +12,14 @@ #include #include "AnalogTriggerOutput.h" -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { class AnalogInput; -class AnalogTrigger : public SensorBase { +class AnalogTrigger : public ErrorBase, public SendableBase { friend class AnalogTriggerOutput; public: diff --git a/wpilibc/src/main/native/include/BuiltInAccelerometer.h b/wpilibc/src/main/native/include/BuiltInAccelerometer.h index 90ad556b50..a8e6683a41 100644 --- a/wpilibc/src/main/native/include/BuiltInAccelerometer.h +++ b/wpilibc/src/main/native/include/BuiltInAccelerometer.h @@ -7,7 +7,8 @@ #pragma once -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" #include "interfaces/Accelerometer.h" namespace frc { @@ -17,7 +18,9 @@ namespace frc { * * This class allows access to the roboRIO's internal accelerometer. */ -class BuiltInAccelerometer : public SensorBase, public Accelerometer { +class BuiltInAccelerometer : public ErrorBase, + public SendableBase, + public Accelerometer { public: explicit BuiltInAccelerometer(Range range = kRange_8G); diff --git a/wpilibc/src/main/native/include/Compressor.h b/wpilibc/src/main/native/include/Compressor.h index 763d493f17..fe05de8b75 100644 --- a/wpilibc/src/main/native/include/Compressor.h +++ b/wpilibc/src/main/native/include/Compressor.h @@ -10,7 +10,7 @@ #include #include "ErrorBase.h" -#include "SensorBase.h" +#include "SensorUtil.h" #include "SmartDashboard/SendableBase.h" namespace frc { @@ -33,7 +33,7 @@ namespace frc { class Compressor : public ErrorBase, public SendableBase { public: // Default PCM ID is 0 - explicit Compressor(int pcmID = SensorBase::GetDefaultSolenoidModule()); + explicit Compressor(int pcmID = SensorUtil::GetDefaultSolenoidModule()); ~Compressor() override = default; void Start(); diff --git a/wpilibc/src/main/native/include/Counter.h b/wpilibc/src/main/native/include/Counter.h index 9c0d0e5bb3..bdc572eac4 100644 --- a/wpilibc/src/main/native/include/Counter.h +++ b/wpilibc/src/main/native/include/Counter.h @@ -14,7 +14,8 @@ #include "AnalogTrigger.h" #include "CounterBase.h" -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { @@ -30,7 +31,7 @@ class DigitalGlitchFilter; * All counters will immediately start counting - Reset() them if you need them * to be zeroed before use. */ -class Counter : public SensorBase, public CounterBase { +class Counter : public ErrorBase, public SendableBase, public CounterBase { public: enum Mode { kTwoPulse = 0, diff --git a/wpilibc/src/main/native/include/DigitalGlitchFilter.h b/wpilibc/src/main/native/include/DigitalGlitchFilter.h index 84a86f55c0..3b81285de5 100644 --- a/wpilibc/src/main/native/include/DigitalGlitchFilter.h +++ b/wpilibc/src/main/native/include/DigitalGlitchFilter.h @@ -14,7 +14,8 @@ #include #include "DigitalSource.h" -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { @@ -28,7 +29,7 @@ class Counter; * filter. The filter lets the user configure the time that an input must remain * high or low before it is classified as high or low. */ -class DigitalGlitchFilter : public SensorBase { +class DigitalGlitchFilter : public ErrorBase, public SendableBase { public: DigitalGlitchFilter(); ~DigitalGlitchFilter() override; diff --git a/wpilibc/src/main/native/include/Encoder.h b/wpilibc/src/main/native/include/Encoder.h index 79ade49b3f..429ebf8e45 100644 --- a/wpilibc/src/main/native/include/Encoder.h +++ b/wpilibc/src/main/native/include/Encoder.h @@ -13,8 +13,9 @@ #include "Counter.h" #include "CounterBase.h" +#include "ErrorBase.h" #include "PIDSource.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { @@ -36,7 +37,10 @@ class DigitalGlitchFilter; * All encoders will immediately start counting - Reset() them if you need them * to be zeroed before use. */ -class Encoder : public SensorBase, public CounterBase, public PIDSource { +class Encoder : public ErrorBase, + public SendableBase, + public CounterBase, + public PIDSource { public: enum IndexingType { kResetWhileHigh, diff --git a/wpilibc/src/main/native/include/GyroBase.h b/wpilibc/src/main/native/include/GyroBase.h index ddd561fc88..dcddd86d06 100644 --- a/wpilibc/src/main/native/include/GyroBase.h +++ b/wpilibc/src/main/native/include/GyroBase.h @@ -7,8 +7,9 @@ #pragma once +#include "ErrorBase.h" #include "PIDSource.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" #include "interfaces/Gyro.h" namespace frc { @@ -17,7 +18,10 @@ namespace frc { * GyroBase is the common base class for Gyro implementations such as * AnalogGyro. */ -class GyroBase : public Gyro, public SensorBase, public PIDSource { +class GyroBase : public Gyro, + public ErrorBase, + public SendableBase, + public PIDSource { public: // PIDSource interface double PIDGet() override; diff --git a/wpilibc/src/main/native/include/InterruptableSensorBase.h b/wpilibc/src/main/native/include/InterruptableSensorBase.h index 267353a76f..84430cf8d0 100644 --- a/wpilibc/src/main/native/include/InterruptableSensorBase.h +++ b/wpilibc/src/main/native/include/InterruptableSensorBase.h @@ -10,11 +10,12 @@ #include #include "AnalogTriggerType.h" -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { -class InterruptableSensorBase : public SensorBase { +class InterruptableSensorBase : public ErrorBase, public SendableBase { public: enum WaitResult { kTimeout = 0x0, diff --git a/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h b/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h index fffc2b8b6a..28235550fd 100644 --- a/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h +++ b/wpilibc/src/main/native/include/LiveWindow/LiveWindow.h @@ -49,11 +49,11 @@ class LiveWindow { void AddActuator(const wpi::Twine& subsystem, const wpi::Twine& name, std::shared_ptr component); - WPI_DEPRECATED("use SensorBase::SetName() instead") + WPI_DEPRECATED("use SensorUtil::SetName() instead") void AddSensor(const wpi::Twine& type, int channel, Sendable* component); - WPI_DEPRECATED("use SensorBase::SetName() instead") + WPI_DEPRECATED("use SensorUtil::SetName() instead") void AddActuator(const wpi::Twine& type, int channel, Sendable* component); - WPI_DEPRECATED("use SensorBase::SetName() instead") + WPI_DEPRECATED("use SensorUtil::SetName() instead") void AddActuator(const wpi::Twine& type, int module, int channel, Sendable* component); diff --git a/wpilibc/src/main/native/include/PowerDistributionPanel.h b/wpilibc/src/main/native/include/PowerDistributionPanel.h index b2576b22bb..1e04650472 100644 --- a/wpilibc/src/main/native/include/PowerDistributionPanel.h +++ b/wpilibc/src/main/native/include/PowerDistributionPanel.h @@ -7,7 +7,8 @@ #pragma once -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { @@ -15,7 +16,7 @@ namespace frc { * Class for getting voltage, current, temperature, power and energy from the * CAN PDP. */ -class PowerDistributionPanel : public SensorBase { +class PowerDistributionPanel : public ErrorBase, public SendableBase { public: PowerDistributionPanel(); explicit PowerDistributionPanel(int module); diff --git a/wpilibc/src/main/native/include/SensorBase.h b/wpilibc/src/main/native/include/SensorUtil.h similarity index 79% rename from wpilibc/src/main/native/include/SensorBase.h rename to wpilibc/src/main/native/include/SensorUtil.h index 27405c3608..d94b7e6434 100644 --- a/wpilibc/src/main/native/include/SensorBase.h +++ b/wpilibc/src/main/native/include/SensorUtil.h @@ -7,28 +7,14 @@ #pragma once -#include - -#include "Base.h" -#include "ErrorBase.h" -#include "SmartDashboard/Sendable.h" -#include "SmartDashboard/SendableBase.h" - namespace frc { /** - * Base class for all sensors. - * * Stores most recent status information as well as containing utility functions * for checking channels and error processing. */ -class SensorBase : public ErrorBase, public SendableBase { +class SensorUtil final { public: - SensorBase() = default; - - SensorBase(const SensorBase&) = delete; - SensorBase& operator=(const SensorBase&) = delete; - static int GetDefaultSolenoidModule() { return 0; } static bool CheckSolenoidModule(int moduleNumber); @@ -48,6 +34,9 @@ class SensorBase : public ErrorBase, public SendableBase { static const int kPwmChannels; static const int kRelayChannels; static const int kPDPChannels; + + private: + SensorUtil() = default; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h b/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h index d0f06665ea..75ed58d7d4 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SmartDashboard.h @@ -13,13 +13,14 @@ #include -#include "SensorBase.h" +#include "ErrorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { class Sendable; -class SmartDashboard : public SensorBase { +class SmartDashboard : public ErrorBase, public SendableBase { public: static void init(); diff --git a/wpilibc/src/main/native/include/Ultrasonic.h b/wpilibc/src/main/native/include/Ultrasonic.h index 51f3b4b2a8..1ef25d2466 100644 --- a/wpilibc/src/main/native/include/Ultrasonic.h +++ b/wpilibc/src/main/native/include/Ultrasonic.h @@ -13,8 +13,9 @@ #include #include "Counter.h" +#include "ErrorBase.h" #include "PIDSource.h" -#include "SensorBase.h" +#include "SmartDashboard/SendableBase.h" namespace frc { @@ -33,7 +34,7 @@ class DigitalOutput; * received. The time that the line is high determines the round trip distance * (time of flight). */ -class Ultrasonic : public SensorBase, public PIDSource { +class Ultrasonic : public ErrorBase, public SendableBase, public PIDSource { public: enum DistanceUnit { kInches = 0, kMilliMeters = 1 }; diff --git a/wpilibc/src/main/native/include/WPILib.h b/wpilibc/src/main/native/include/WPILib.h index b166354179..ce1743923a 100644 --- a/wpilibc/src/main/native/include/WPILib.h +++ b/wpilibc/src/main/native/include/WPILib.h @@ -74,7 +74,7 @@ #include "SD540.h" #include "SPI.h" #include "SampleRobot.h" -#include "SensorBase.h" +#include "SensorUtil.h" #include "SerialPort.h" #include "Servo.h" #include "SmartDashboard/SendableChooser.h" diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java index d7994550d8..c084e9a5c0 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_I2C.java @@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * ADXL345 I2C Accelerometer. */ @SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"}) -public class ADXL345_I2C extends SensorBase implements Accelerometer, Sendable { +public class ADXL345_I2C extends SendableBase implements Accelerometer { private static final byte kAddress = 0x1D; private static final byte kPowerCtlRegister = 0x2D; private static final byte kDataFormatRegister = 0x31; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java index 429a017777..8dbfa3ad15 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL345_SPI.java @@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * ADXL345 SPI Accelerometer. */ @SuppressWarnings({"TypeName", "PMD.UnusedPrivateField"}) -public class ADXL345_SPI extends SensorBase implements Accelerometer, Sendable { +public class ADXL345_SPI extends SendableBase implements Accelerometer { private static final int kPowerCtlRegister = 0x2D; private static final int kDataFormatRegister = 0x31; private static final int kDataRegister = 0x32; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java index aebdd66f79..2f8fa00070 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java @@ -22,7 +22,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; *

This class allows access to an Analog Devices ADXL362 3-axis accelerometer. */ @SuppressWarnings("PMD.UnusedPrivateField") -public class ADXL362 extends SensorBase implements Accelerometer, Sendable { +public class ADXL362 extends SendableBase implements Accelerometer { private static final byte kRegWrite = 0x0A; private static final byte kRegRead = 0x0B; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java index f5fc17e648..0854091da6 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogAccelerometer.java @@ -18,7 +18,7 @@ import static java.util.Objects.requireNonNull; * through the sensor. Many sensors have multiple axis and can be treated as multiple devices. Each * is calibrated by finding the center value over a period of time. */ -public class AnalogAccelerometer extends SensorBase implements PIDSource, Sendable { +public class AnalogAccelerometer extends SendableBase implements PIDSource { private AnalogInput m_analogChannel; private double m_voltsPerG = 1.0; private double m_zeroGVoltage = 2.5; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java index cb902e5e73..072b680b7b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java @@ -26,7 +26,7 @@ import edu.wpi.first.wpilibj.util.AllocationException; * accumulated effectively increasing the resolution, while the averaged samples are divided by the * number of samples to retain the resolution, but get more stable values. */ -public class AnalogInput extends SensorBase implements PIDSource, Sendable { +public class AnalogInput extends SendableBase implements PIDSource { private static final int kAccumulatorSlot = 1; int m_port; // explicit no modifier, private and package accessible. private int m_channel; @@ -40,7 +40,7 @@ public class AnalogInput extends SensorBase implements PIDSource, Sendable { * @param channel The channel number to represent. 0-3 are on-board 4-7 are on the MXP port. */ public AnalogInput(final int channel) { - checkAnalogInputChannel(channel); + AnalogJNI.checkAnalogInputChannel(channel); m_channel = channel; final int portHandle = HAL.getPort((byte) channel); @@ -50,9 +50,6 @@ public class AnalogInput extends SensorBase implements PIDSource, Sendable { setName("AnalogInput", channel); } - /** - * Channel destructor. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java index 4d0783a805..1af1c87cd5 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java @@ -16,7 +16,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** * Analog output class. */ -public class AnalogOutput extends SendableBase implements Sendable { +public class AnalogOutput extends SendableBase { private int m_port; private int m_channel; @@ -26,7 +26,7 @@ public class AnalogOutput extends SendableBase implements Sendable { * @param channel The channel number to represent. */ public AnalogOutput(final int channel) { - SensorBase.checkAnalogOutputChannel(channel); + SensorUtil.checkAnalogOutputChannel(channel); m_channel = channel; final int portHandle = HAL.getPort((byte) channel); @@ -36,9 +36,6 @@ public class AnalogOutput extends SendableBase implements Sendable { setName("AnalogOutput", channel); } - /** - * Channel destructor. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java index 4c2e136681..d1a9018a2c 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometer.java @@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * corresponds to a position. The position is in whichever units you choose, by way of the scaling * and offset constants passed to the constructor. */ -public class AnalogPotentiometer extends SensorBase implements Potentiometer, Sendable { +public class AnalogPotentiometer extends SendableBase implements Potentiometer { private AnalogInput m_analogInput; private boolean m_initAnalogInput; private double m_fullRange; @@ -154,9 +154,6 @@ public class AnalogPotentiometer extends SensorBase implements Potentiometer, Se } } - /** - * Frees this resource. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java index 090c24d297..81f3e6d25e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogTrigger.java @@ -20,7 +20,7 @@ import edu.wpi.first.wpilibj.util.BoundaryException; /** * Class for creating and configuring Analog Triggers. */ -public class AnalogTrigger extends SensorBase implements Sendable { +public class AnalogTrigger extends SendableBase { /** * Exceptions dealing with improper operation of the Analog trigger. */ @@ -74,9 +74,6 @@ public class AnalogTrigger extends SensorBase implements Sendable { setName("AnalogTrigger", channel.getChannel()); } - /** - * Release the resources used by this object. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java index 5f6ddfe8d2..8b0d8ccf74 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometer.java @@ -19,7 +19,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * *

This class allows access to the roboRIO's internal accelerometer. */ -public class BuiltInAccelerometer extends SensorBase implements Accelerometer, Sendable { +public class BuiltInAccelerometer extends SendableBase implements Accelerometer { /** * Constructor. * diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java index e0f8c2dc4d..aa9943b687 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java @@ -23,7 +23,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * the safety provided by using the pressure switch and closed loop control. You can only turn off * closed loop control, thereby stopping the compressor from operating. */ -public class Compressor extends SendableBase implements Sendable { +public class Compressor extends SendableBase { private int m_compressorHandle; private byte m_module; @@ -49,7 +49,7 @@ public class Compressor extends SendableBase implements Sendable { * specifying the CAN ID.} */ public Compressor() { - this(SensorBase.getDefaultSolenoidModule()); + this(SensorUtil.getDefaultSolenoidModule()); } /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java index c059190b15..efcee2f51c 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java @@ -28,7 +28,7 @@ import static java.util.Objects.requireNonNull; *

All counters will immediately start counting - reset() them if you need them to be zeroed * before use. */ -public class Counter extends SensorBase implements CounterBase, Sendable, PIDSource { +public class Counter extends SendableBase implements CounterBase, PIDSource { /** * Mode determines how and what the counter counts. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java index ad4a6173ba..04ce144be2 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java @@ -20,7 +20,7 @@ import edu.wpi.first.wpilibj.hal.HAL; * removing digital inputs from a FPGA glitch filter. The filter lets the user configure the time * that an input must remain high or low before it is classified as high or low. */ -public class DigitalGlitchFilter extends SensorBase { +public class DigitalGlitchFilter extends SendableBase { /** * Configures the Digital Glitch Filter to its default settings. */ @@ -40,9 +40,7 @@ public class DigitalGlitchFilter extends SensorBase { } } - /** - * Free the resources used by this object. - */ + @Override public void close() { super.close(); if (m_channelIndex >= 0) { @@ -144,7 +142,7 @@ public class DigitalGlitchFilter extends SensorBase { * @param nanoseconds The number of nanoseconds. */ public void setPeriodNanoSeconds(long nanoseconds) { - int fpgaCycles = (int) (nanoseconds * kSystemClockTicksPerMicrosecond / 4 + int fpgaCycles = (int) (nanoseconds * SensorUtil.kSystemClockTicksPerMicrosecond / 4 / 1000); setPeriodCycles(fpgaCycles); } @@ -169,7 +167,7 @@ public class DigitalGlitchFilter extends SensorBase { int fpgaCycles = getPeriodCycles(); return (long) fpgaCycles * 1000L - / (long) (kSystemClockTicksPerMicrosecond / 4); + / (long) (SensorUtil.kSystemClockTicksPerMicrosecond / 4); } @SuppressWarnings("PMD.UnusedFormalParameter") diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java index b4da7ef667..de4b78b2da 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalInput.java @@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * elsewhere will automatically allocate digital inputs and outputs as required. This class is only * for devices like switches etc. that aren't implemented anywhere else. */ -public class DigitalInput extends DigitalSource implements Sendable { +public class DigitalInput extends DigitalSource { private int m_channel = 0; private int m_handle = 0; @@ -28,7 +28,7 @@ public class DigitalInput extends DigitalSource implements Sendable { * @param channel the DIO channel for the digital input 0-9 are on-board, 10-25 are on the MXP */ public DigitalInput(int channel) { - checkDigitalChannel(channel); + SensorUtil.checkDigitalChannel(channel); m_channel = channel; m_handle = DIOJNI.initializeDIOPort(HAL.getPort((byte) channel), true); @@ -37,9 +37,7 @@ public class DigitalInput extends DigitalSource implements Sendable { setName("DigitalInput", channel); } - /** - * Frees the resources for this output. - */ + @Override public void close() { super.close(); if (m_interrupt != 0) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java index b2cdccfe76..ac64b6970f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalOutput.java @@ -16,7 +16,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * Class to write digital outputs. This class will write digital outputs. Other devices that are * implemented elsewhere will automatically allocate digital inputs and outputs as required. */ -public class DigitalOutput extends SendableBase implements Sendable { +public class DigitalOutput extends SendableBase { private static final int invalidPwmGenerator = 0; private int m_pwmGenerator = invalidPwmGenerator; @@ -31,7 +31,7 @@ public class DigitalOutput extends SendableBase implements Sendable { * the MXP */ public DigitalOutput(int channel) { - SensorBase.checkDigitalChannel(channel); + SensorUtil.checkDigitalChannel(channel); m_channel = channel; m_handle = DIOJNI.initializeDIOPort(HAL.getPort((byte) channel), false); @@ -40,13 +40,10 @@ public class DigitalOutput extends SendableBase implements Sendable { setName("DigitalOutput", channel); } - /** - * Free the resources associated with a digital output. - */ @Override public void close() { super.close(); - // disable the pwm only if we have allocated it + // Disable the pwm only if we have allocated it if (m_pwmGenerator != invalidPwmGenerator) { disablePWM(); } @@ -143,7 +140,7 @@ public class DigitalOutput extends SendableBase implements Sendable { return; } // Disable the output by routing to a dead bit. - DIOJNI.setDigitalPWMOutputChannel(m_pwmGenerator, SensorBase.kDigitalChannels); + DIOJNI.setDigitalPWMOutputChannel(m_pwmGenerator, SensorUtil.kDigitalChannels); DIOJNI.freeDigitalPWM(m_pwmGenerator); m_pwmGenerator = invalidPwmGenerator; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java index 521d3af350..8f8bcd5014 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java @@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; *

The DoubleSolenoid class is typically used for pneumatics solenoids that have two positions * controlled by two separate channels. */ -public class DoubleSolenoid extends SolenoidBase implements Sendable { +public class DoubleSolenoid extends SolenoidBase { /** * Possible values for a DoubleSolenoid. */ @@ -40,7 +40,7 @@ public class DoubleSolenoid extends SolenoidBase implements Sendable { * @param reverseChannel The reverse channel number on the PCM (0..7). */ public DoubleSolenoid(final int forwardChannel, final int reverseChannel) { - this(SensorBase.getDefaultSolenoidModule(), forwardChannel, reverseChannel); + this(SensorUtil.getDefaultSolenoidModule(), forwardChannel, reverseChannel); } /** @@ -54,9 +54,9 @@ public class DoubleSolenoid extends SolenoidBase implements Sendable { final int reverseChannel) { super(moduleNumber); - SensorBase.checkSolenoidModule(m_moduleNumber); - SensorBase.checkSolenoidChannel(forwardChannel); - SensorBase.checkSolenoidChannel(reverseChannel); + SensorUtil.checkSolenoidModule(m_moduleNumber); + SensorUtil.checkSolenoidChannel(forwardChannel); + SensorUtil.checkSolenoidChannel(reverseChannel); int portHandle = HAL.getPortWithModule((byte) m_moduleNumber, (byte) forwardChannel); m_forwardHandle = SolenoidJNI.initializeSolenoidPort(portHandle); @@ -82,9 +82,6 @@ public class DoubleSolenoid extends SolenoidBase implements Sendable { setName("DoubleSolenoid", m_moduleNumber, forwardChannel); } - /** - * Destructor. - */ @Override public synchronized void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java index 93a862834f..5feeae8ba2 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java @@ -28,7 +28,7 @@ import static java.util.Objects.requireNonNull; *

All encoders will immediately start counting - reset() them if you need them to be zeroed * before use. */ -public class Encoder extends SensorBase implements CounterBase, PIDSource, Sendable { +public class Encoder extends SendableBase implements CounterBase, PIDSource { public enum IndexingType { kResetWhileHigh(0), kResetWhileLow(1), kResetOnFallingEdge(2), kResetOnRisingEdge(3); @@ -290,9 +290,6 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, Senda return EncoderJNI.getEncoderEncodingScale(m_encoder); } - /** - * Free the resources used by this object. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GyroBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/GyroBase.java index 9647df718b..4bd47e82f0 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GyroBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/GyroBase.java @@ -13,7 +13,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** * GyroBase is the common base class for Gyro implementations such as AnalogGyro. */ -public abstract class GyroBase extends SensorBase implements Gyro, PIDSource, Sendable { +public abstract class GyroBase extends SendableBase implements Gyro, PIDSource { private PIDSourceType m_pidSource = PIDSourceType.kDisplacement; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java index 37f442571a..ee1d226e66 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java @@ -57,9 +57,6 @@ public class I2C implements AutoCloseable { close(); } - /** - * Destructor. - */ @Override public void close() { I2CJNI.i2CClose(m_port); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java index 29008f731b..d6627c610f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java @@ -14,7 +14,7 @@ import edu.wpi.first.wpilibj.util.AllocationException; /** * Base for sensors to be used with interrupts. */ -public abstract class InterruptableSensorBase extends SensorBase { +public abstract class InterruptableSensorBase extends SendableBase { @SuppressWarnings("JavadocMethod") public enum WaitResult { kTimeout(0x0), kRisingEdge(0x1), kFallingEdge(0x100), kBoth(0x101); @@ -44,9 +44,6 @@ public abstract class InterruptableSensorBase extends SensorBase { m_interrupt = 0; } - /** - * Frees the resources for this output. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/NidecBrushless.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/NidecBrushless.java index 198e64e42e..0fa0422935 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/NidecBrushless.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/NidecBrushless.java @@ -49,9 +49,6 @@ public class NidecBrushless extends SendableBase implements SpeedController, Mot setName("Nidec Brushless", pwmChannel); } - /** - * Free the resources used by this object. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PIDController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PIDController.java index f6c768cbb5..393b5b417b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PIDController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PIDController.java @@ -88,9 +88,6 @@ public class PIDController extends PIDBase implements Controller { this(Kp, Ki, Kd, Kf, source, output, kDefaultPeriod); } - /** - * Free the PID object. - */ @Override public void close() { super.close(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java index d8d09a45c2..668dcdae16 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java @@ -24,7 +24,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * center value - 999 to 2 = linear scaling from "center" to "full reverse" - 1 = minimum pulse * width (currently .5ms) - 0 = disabled (i.e. PWM output is held low) */ -public class PWM extends SendableBase implements Sendable { +public class PWM extends SendableBase { /** * Represents the amount to multiply the minimum servo-pulse pwm period by. */ @@ -52,7 +52,7 @@ public class PWM extends SendableBase implements Sendable { * @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port */ public PWM(final int channel) { - SensorBase.checkPWMChannel(channel); + SensorUtil.checkPWMChannel(channel); m_channel = channel; m_handle = PWMJNI.initializePWMPort(HAL.getPort((byte) channel)); @@ -66,9 +66,7 @@ public class PWM extends SendableBase implements Sendable { } /** - * Free the PWM channel. - * - *

Free the resource associated with the PWM channel and set the value to 0. + * Free the resource associated with the PWM channel and set the value to 0. */ @Override public void close() { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMSpeedController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMSpeedController.java index bf499b9ed9..01466dfb13 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMSpeedController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMSpeedController.java @@ -25,6 +25,11 @@ public abstract class PWMSpeedController extends SafePWM implements SpeedControl super(channel); } + @Override + public String getDescription() { + return "PWM " + getChannel(); + } + /** * Set the PWM value. * diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java index 958d2e07a9..718d455544 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java @@ -14,7 +14,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * Class for getting voltage, current, temperature, power and energy from the Power Distribution * Panel over CAN. */ -public class PowerDistributionPanel extends SensorBase implements Sendable { +public class PowerDistributionPanel extends SendableBase { private final int m_module; /** @@ -24,7 +24,7 @@ public class PowerDistributionPanel extends SensorBase implements Sendable { */ public PowerDistributionPanel(int module) { m_module = module; - checkPDPModule(module); + SensorUtil.checkPDPModule(module); PDPJNI.initializePDP(module); setName("PowerDistributionPanel", module); } @@ -62,7 +62,7 @@ public class PowerDistributionPanel extends SensorBase implements Sendable { public double getCurrent(int channel) { double current = PDPJNI.getPDPChannelCurrent((byte) channel, m_module); - checkPDPChannel(channel); + SensorUtil.checkPDPChannel(channel); return current; } @@ -111,7 +111,7 @@ public class PowerDistributionPanel extends SensorBase implements Sendable { @Override public void initSendable(SendableBuilder builder) { builder.setSmartDashboardType("PowerDistributionPanel"); - for (int i = 0; i < kPDPChannels; ++i) { + for (int i = 0; i < SensorUtil.kPDPChannels; ++i) { final int chan = i; builder.addDoubleProperty("Chan" + i, () -> getCurrent(chan), null); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java index af5e6ee605..12aa795343 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java @@ -26,7 +26,7 @@ import static java.util.Objects.requireNonNull; * channels (forward and reverse) to be used independently for something that does not care about * voltage polarity (like a solenoid). */ -public class Relay extends SendableBase implements MotorSafety, Sendable { +public class Relay extends SendableBase implements MotorSafety { private MotorSafetyHelper m_safetyHelper; /** @@ -100,7 +100,7 @@ public class Relay extends SendableBase implements MotorSafety, Sendable { * set to both lines at 0v. */ private void initRelay() { - SensorBase.checkRelayChannel(m_channel); + SensorUtil.checkRelayChannel(m_channel); int portHandle = HAL.getPort((byte) m_channel); if (m_direction == Direction.kBoth || m_direction == Direction.kForward) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java index b80d48f36a..55ddea32d6 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java @@ -97,9 +97,6 @@ public abstract class RobotBase implements AutoCloseable { public void free() { } - /** - * Free the resources for a RobotBase class. - */ @Override public void close() { } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java index b882f9be92..a0069beadc 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java @@ -55,9 +55,6 @@ public class SPI implements AutoCloseable { close(); } - /** - * Free the resources used by this object. - */ @Override public void close() { if (m_accum != null) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SendableBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SendableBase.java index 8937c408c2..b663ed52d3 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SendableBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SendableBase.java @@ -40,9 +40,6 @@ public abstract class SendableBase implements Sendable, AutoCloseable { close(); } - /** - * Free the resources used by this object. - */ @Override public void close() { LiveWindow.remove(this); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java similarity index 91% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorBase.java rename to wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java index 6e33a79169..265719b8f5 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java @@ -17,64 +17,61 @@ import edu.wpi.first.wpilibj.hal.RelayJNI; import edu.wpi.first.wpilibj.hal.SolenoidJNI; /** - * Base class for all sensors. Stores most recent status information as well as containing utility - * functions for checking channels and error processing. + * Stores most recent status information as well as containing utility functions for checking + * channels and error processing. */ -public abstract class SensorBase extends SendableBase { +public final class SensorUtil { /** * Ticks per microsecond. */ - public static final int kSystemClockTicksPerMicrosecond = - ConstantsJNI.getSystemClockTicksPerMicrosecond(); + public static final int kSystemClockTicksPerMicrosecond + = ConstantsJNI.getSystemClockTicksPerMicrosecond(); + /** * Number of digital channels per roboRIO. */ public static final int kDigitalChannels = PortsJNI.getNumDigitalChannels(); + /** * Number of analog input channels per roboRIO. */ public static final int kAnalogInputChannels = PortsJNI.getNumAnalogInputs(); + /** * Number of analog output channels per roboRIO. */ public static final int kAnalogOutputChannels = PortsJNI.getNumAnalogOutputs(); + /** * Number of solenoid channels per module. */ public static final int kSolenoidChannels = PortsJNI.getNumSolenoidChannels(); + /** * Number of PWM channels per roboRIO. */ public static final int kPwmChannels = PortsJNI.getNumPWMChannels(); + /** * Number of relay channels per roboRIO. */ public static final int kRelayChannels = PortsJNI.getNumRelayHeaders(); + /** * Number of power distribution channels per PDP. */ public static final int kPDPChannels = PortsJNI.getNumPDPChannels(); + /** * Number of power distribution modules per PDP. */ public static final int kPDPModules = PortsJNI.getNumPDPModules(); + /** * Number of PCM Modules. */ public static final int kPCMModules = PortsJNI.getNumPCMModules(); - private static int m_defaultSolenoidModule = 0; - - /** - * Set the default location for the Solenoid module. - * - * @param moduleNumber The number of the solenoid module to use. - */ - public static void setDefaultSolenoidModule(final int moduleNumber) { - checkSolenoidModule(moduleNumber); - SensorBase.m_defaultSolenoidModule = moduleNumber; - } - /** * Verify that the solenoid module is correct. * @@ -231,6 +228,9 @@ public abstract class SensorBase extends SendableBase { * @return The number of the default solenoid module. */ public static int getDefaultSolenoidModule() { - return SensorBase.m_defaultSolenoidModule; + return 0; + } + + private SensorUtil() { } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java index c2bbaf53a2..0999360e3b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java @@ -24,7 +24,7 @@ import edu.wpi.first.wpilibj.hal.SerialPortJNI; * .com/pdf/manuals/370423a.pdf and the NI-VISA Programmer's Reference Manual here: * http://www.ni.com/pdf/manuals/370132c.pdf */ -public class SerialPort { +public class SerialPort implements AutoCloseable { private byte m_port; public enum Port { @@ -194,9 +194,7 @@ public class SerialPort { this(baudRate, port, 8, Parity.kNone, StopBits.kOne); } - /** - * Destructor. - */ + @Override public void close() { SerialPortJNI.serialClose(m_port); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java index c61e140ebb..bacd3a25c6 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Solenoid.java @@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; *

The Solenoid class is typically used for pneumatic solenoids, but could be used for any * device within the current spec of the PCM. */ -public class Solenoid extends SolenoidBase implements Sendable { +public class Solenoid extends SolenoidBase { private final int m_channel; // The channel to control. private int m_solenoidHandle; @@ -28,7 +28,7 @@ public class Solenoid extends SolenoidBase implements Sendable { * @param channel The channel on the PCM to control (0..7). */ public Solenoid(final int channel) { - this(SensorBase.getDefaultSolenoidModule(), channel); + this(SensorUtil.getDefaultSolenoidModule(), channel); } /** @@ -41,8 +41,8 @@ public class Solenoid extends SolenoidBase implements Sendable { super(moduleNumber); m_channel = channel; - SensorBase.checkSolenoidModule(m_moduleNumber); - SensorBase.checkSolenoidChannel(m_channel); + SensorUtil.checkSolenoidModule(m_moduleNumber); + SensorUtil.checkSolenoidChannel(m_channel); int portHandle = HAL.getPortWithModule((byte) m_moduleNumber, (byte) m_channel); m_solenoidHandle = SolenoidJNI.initializeSolenoidPort(portHandle); @@ -51,11 +51,8 @@ public class Solenoid extends SolenoidBase implements Sendable { setName("Solenoid", m_moduleNumber, m_channel); } - /** - * Destructor. - */ @Override - public synchronized void close() { + public void close() { super.close(); SolenoidJNI.freeSolenoidPort(m_solenoidHandle); m_solenoidHandle = 0; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java index 3ebb8a0b27..4b30a36800 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java @@ -22,7 +22,7 @@ import static java.util.Objects.requireNonNull; * echo is received. The time that the line is high determines the round trip distance (time of * flight). */ -public class Ultrasonic extends SensorBase implements PIDSource, Sendable { +public class Ultrasonic extends SendableBase implements PIDSource { /** * The units to return when PIDGet is called. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java index abb28139f8..027d3c8d3c 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java @@ -10,7 +10,6 @@ package edu.wpi.first.wpilibj.command; import java.util.Enumeration; import edu.wpi.first.wpilibj.RobotState; -import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.SendableBase; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; @@ -40,7 +39,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * @see CommandGroup * @see IllegalUseOfCommandException */ -public abstract class Command extends SendableBase implements Sendable { +public abstract class Command extends SendableBase { /** * The time since this command was initialized. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java index 0569fa6e9f..b6a89dd0b4 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDCommand.java @@ -11,7 +11,6 @@ import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.PIDOutput; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.PIDSourceType; -import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** @@ -21,7 +20,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * start and stop said {@link PIDController} when the {@link PIDCommand} is first initialized and * ended/interrupted.

*/ -public abstract class PIDCommand extends Command implements Sendable { +public abstract class PIDCommand extends Command { /** * The internal {@link PIDController}. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDSubsystem.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDSubsystem.java index e2edfb956b..754e233347 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDSubsystem.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/PIDSubsystem.java @@ -11,7 +11,6 @@ import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.PIDOutput; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.PIDSourceType; -import edu.wpi.first.wpilibj.Sendable; /** * This class is designed to handle the case where there is a {@link Subsystem} which uses a single @@ -22,7 +21,7 @@ import edu.wpi.first.wpilibj.Sendable; * allows access to the internal {@link PIDController} in order to give total control to the * programmer. */ -public abstract class PIDSubsystem extends Subsystem implements Sendable { +public abstract class PIDSubsystem extends Subsystem { /** * The internal {@link PIDController}. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java index f1ee2e4ef6..a213f95d00 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Scheduler.java @@ -13,7 +13,6 @@ import java.util.Vector; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.wpilibj.HLUsageReporting; -import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.SendableBase; import edu.wpi.first.wpilibj.buttons.Trigger.ButtonScheduler; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; @@ -30,7 +29,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * * @see Command */ -public class Scheduler extends SendableBase implements Sendable { +public class Scheduler extends SendableBase { /** * The Singleton Instance. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java index 0af2ca76ce..046ac3e1ad 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Subsystem.java @@ -28,7 +28,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; * * @see Command */ -public abstract class Subsystem extends SendableBase implements Sendable { +public abstract class Subsystem extends SendableBase { /** * Whether or not getDefaultCommand() was called. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java index 8a6410e1aa..689c1586dd 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java @@ -107,7 +107,7 @@ public class LiveWindow { * @param moduleType A string indicating the type of the module used in the naming (above) * @param channel The channel number the device is connected to * @param component A reference to the object being added - * @deprecated Use {@link edu.wpi.first.wpilibj.SensorBase#setName(String, int)} instead. + * @deprecated Use {@link edu.wpi.first.wpilibj.SendableBase#setName(String, int)} instead. */ @Deprecated public static void addSensor(String moduleType, int channel, Sendable component) { @@ -136,7 +136,7 @@ public class LiveWindow { * @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 (usually PWM) * @param component The reference to the object being added - * @deprecated Use {@link edu.wpi.first.wpilibj.SensorBase#setName(String, int)} instead. + * @deprecated Use {@link edu.wpi.first.wpilibj.SendableBase#setName(String, int)} instead. */ @Deprecated public static void addActuator(String moduleType, int channel, Sendable component) { @@ -152,7 +152,7 @@ public class LiveWindow { * @param moduleNumber The number of the particular module type * @param channel The channel number the device is plugged into (usually PWM) * @param component The reference to the object being added - * @deprecated Use {@link edu.wpi.first.wpilibj.SensorBase#setName(String, int, int)} instead. + * @deprecated Use {@link edu.wpi.first.wpilibj.SendableBase#setName(String, int, int)} instead. */ @Deprecated public static void addActuator(String moduleType, int moduleNumber, int channel, diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java index c79521de39..4a4329b823 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java @@ -10,7 +10,6 @@ package edu.wpi.first.wpilibj.smartdashboard; import java.util.LinkedHashMap; import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.SendableBase; import edu.wpi.first.wpilibj.command.Command; @@ -28,7 +27,7 @@ import static java.util.Objects.requireNonNull; * * @param The type of the values to be stored */ -public class SendableChooser extends SendableBase implements Sendable { +public class SendableChooser extends SendableBase { /** * The key for the default value. */ diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java index c181e8d081..93fb6ef470 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java @@ -30,7 +30,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testDigitalChannels() { - assertEquals(31, SensorBase.kDigitalChannels); + assertEquals(31, SensorUtil.kDigitalChannels); } /** @@ -38,7 +38,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testAnalogInputChannels() { - assertEquals(8, SensorBase.kAnalogInputChannels); + assertEquals(8, SensorUtil.kAnalogInputChannels); } /** @@ -46,7 +46,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testAnalogOutputChannels() { - assertEquals(2, SensorBase.kAnalogOutputChannels); + assertEquals(2, SensorUtil.kAnalogOutputChannels); } /** @@ -54,7 +54,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testSolenoidChannels() { - assertEquals(8, SensorBase.kSolenoidChannels); + assertEquals(8, SensorUtil.kSolenoidChannels); } /** @@ -62,7 +62,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testPwmChannels() { - assertEquals(20, SensorBase.kPwmChannels); + assertEquals(20, SensorUtil.kPwmChannels); } /** @@ -70,7 +70,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testRelayChannels() { - assertEquals(4, SensorBase.kRelayChannels); + assertEquals(4, SensorUtil.kRelayChannels); } /** @@ -78,7 +78,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testPDPChannels() { - assertEquals(16, SensorBase.kPDPChannels); + assertEquals(16, SensorUtil.kPDPChannels); } /** @@ -86,7 +86,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testPDPModules() { - assertEquals(63, SensorBase.kPDPModules); + assertEquals(63, SensorUtil.kPDPModules); } /** @@ -94,6 +94,6 @@ public class ConstantsPortsTest extends AbstractComsSetup { */ @Test public void testPCMModules() { - assertEquals(63, SensorBase.kPCMModules); + assertEquals(63, SensorUtil.kPCMModules); } }