mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Made SensorBase a utility class and renamed it to SensorUtil (#813)
This commit is contained in:
committed by
Peter Johnson
parent
ba93f79d8b
commit
ecfe95383c
@@ -12,6 +12,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#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<int>::max();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "Counter.h"
|
||||
#include "Encoder.h"
|
||||
#include "SensorUtil.h"
|
||||
#include "Utility.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#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<int>::max();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <HAL/HAL.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#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<int>::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));
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <HAL/Ports.h>
|
||||
#include <HAL/Solenoid.h>
|
||||
|
||||
#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));
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <HAL/PWM.h>
|
||||
#include <HAL/Ports.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SensorUtil.h"
|
||||
|
||||
#include <HAL/AnalogInput.h>
|
||||
#include <HAL/AnalogOutput.h>
|
||||
@@ -17,24 +17,22 @@
|
||||
#include <HAL/Relay.h>
|
||||
#include <HAL/Solenoid.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <HAL/Ports.h>
|
||||
#include <HAL/Solenoid.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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 };
|
||||
|
||||
|
||||
@@ -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 };
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
#include <memory>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
|
||||
#include <HAL/Types.h>
|
||||
|
||||
#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;
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
#include <memory>
|
||||
|
||||
#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.
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
#include <HAL/Types.h>
|
||||
|
||||
#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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <HAL/Types.h>
|
||||
|
||||
#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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
#include <HAL/Interrupts.h>
|
||||
|
||||
#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,
|
||||
|
||||
@@ -49,11 +49,11 @@ class LiveWindow {
|
||||
void AddActuator(const wpi::Twine& subsystem, const wpi::Twine& name,
|
||||
std::shared_ptr<Sendable> 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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -7,28 +7,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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
|
||||
@@ -13,13 +13,14 @@
|
||||
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
|
||||
#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();
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
#include <vector>
|
||||
|
||||
#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 };
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -22,7 +22,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
* <p>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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -19,7 +19,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ import static java.util.Objects.requireNonNull;
|
||||
* <p>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.
|
||||
*/
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
* <p>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();
|
||||
|
||||
@@ -28,7 +28,7 @@ import static java.util.Objects.requireNonNull;
|
||||
* <p>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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,9 +57,6 @@ public class I2C implements AutoCloseable {
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
I2CJNI.i2CClose(m_port);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* <p>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() {
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -97,9 +97,6 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
public void free() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the resources for a RobotBase class.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
* <p>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;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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. </p>
|
||||
*/
|
||||
public abstract class PIDCommand extends Command implements Sendable {
|
||||
public abstract class PIDCommand extends Command {
|
||||
/**
|
||||
* The internal {@link PIDController}.
|
||||
*/
|
||||
|
||||
@@ -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}.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 <V> The type of the values to be stored
|
||||
*/
|
||||
public class SendableChooser<V> extends SendableBase implements Sendable {
|
||||
public class SendableChooser<V> extends SendableBase {
|
||||
/**
|
||||
* The key for the default value.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user