mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpilibc] Remove ErrorBase (#3306)
Replace with new exception-based error reporting, consistent with Java. This also builds stacktraces into the reporting/exceptions.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/I2C.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
@@ -23,8 +22,7 @@ class SendableBuilder;
|
||||
* an I2C bus. This class assumes the default (not alternate) sensor address of
|
||||
* 0x1D (7-bit address).
|
||||
*/
|
||||
class ADXL345_I2C : public ErrorBase,
|
||||
public Accelerometer,
|
||||
class ADXL345_I2C : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL345_I2C> {
|
||||
public:
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
@@ -20,8 +19,7 @@ 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 ErrorBase,
|
||||
public Accelerometer,
|
||||
class ADXL345_SPI : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL345_SPI> {
|
||||
public:
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
@@ -21,8 +20,7 @@ class SendableBuilder;
|
||||
*
|
||||
* This class allows access to an Analog Devices ADXL362 3-axis accelerometer.
|
||||
*/
|
||||
class ADXL362 : public ErrorBase,
|
||||
public Accelerometer,
|
||||
class ADXL362 : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXL362> {
|
||||
public:
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/SPI.h"
|
||||
#include "frc/interfaces/Gyro.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
@@ -30,7 +29,6 @@ namespace frc {
|
||||
* Only one instance of an ADXRS Gyro is supported.
|
||||
*/
|
||||
class ADXRS450_Gyro : public Gyro,
|
||||
public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<ADXRS450_Gyro> {
|
||||
public:
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <units/time.h>
|
||||
#include <wpi/ArrayRef.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "util/Color.h"
|
||||
#include "util/Color8Bit.h"
|
||||
|
||||
@@ -22,7 +21,7 @@ namespace frc {
|
||||
*
|
||||
* <p>Only 1 LED driver is currently supported by the roboRIO.
|
||||
*/
|
||||
class AddressableLED : public ErrorBase {
|
||||
class AddressableLED {
|
||||
public:
|
||||
class LEDData : public HAL_AddressableLEDData {
|
||||
public:
|
||||
@@ -86,7 +85,7 @@ class AddressableLED : public ErrorBase {
|
||||
*/
|
||||
explicit AddressableLED(int port);
|
||||
|
||||
~AddressableLED() override;
|
||||
~AddressableLED();
|
||||
|
||||
/**
|
||||
* Sets the length of the LED strip.
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -22,8 +21,7 @@ class SendableBuilder;
|
||||
* 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 ErrorBase,
|
||||
public Sendable,
|
||||
class AnalogAccelerometer : public Sendable,
|
||||
public SendableHelper<AnalogAccelerometer> {
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -22,9 +21,7 @@ class AnalogInput;
|
||||
/**
|
||||
* Class for supporting continuous analog encoders, such as the US Digital MA3.
|
||||
*/
|
||||
class AnalogEncoder : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogEncoder> {
|
||||
class AnalogEncoder : public Sendable, public SendableHelper<AnalogEncoder> {
|
||||
public:
|
||||
/**
|
||||
* Construct a new AnalogEncoder attached to a specific AnalogInput.
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/interfaces/Gyro.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
@@ -31,7 +30,6 @@ class AnalogInput;
|
||||
* This class is for gyro sensors that connect to an analog input.
|
||||
*/
|
||||
class AnalogGyro : public Gyro,
|
||||
public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogGyro> {
|
||||
public:
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -30,9 +29,7 @@ class DMASample;
|
||||
* are divided by the number of samples to retain the resolution, but get more
|
||||
* stable values.
|
||||
*/
|
||||
class AnalogInput : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogInput> {
|
||||
class AnalogInput : public Sendable, public SendableHelper<AnalogInput> {
|
||||
friend class AnalogTrigger;
|
||||
friend class AnalogGyro;
|
||||
friend class DMA;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -17,9 +16,7 @@ class SendableBuilder;
|
||||
/**
|
||||
* MXP analog output class.
|
||||
*/
|
||||
class AnalogOutput : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogOutput> {
|
||||
class AnalogOutput : public Sendable, public SendableHelper<AnalogOutput> {
|
||||
public:
|
||||
/**
|
||||
* Construct an analog output on the given channel.
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "frc/AnalogInput.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -21,8 +20,7 @@ class SendableBuilder;
|
||||
* units you choose, by way of the scaling and offset constants passed to the
|
||||
* constructor.
|
||||
*/
|
||||
class AnalogPotentiometer : public ErrorBase,
|
||||
public Sendable,
|
||||
class AnalogPotentiometer : public Sendable,
|
||||
public SendableHelper<AnalogPotentiometer> {
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/AnalogTriggerOutput.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -19,9 +18,7 @@ class AnalogInput;
|
||||
class DutyCycle;
|
||||
class SendableBuilder;
|
||||
|
||||
class AnalogTrigger : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<AnalogTrigger> {
|
||||
class AnalogTrigger : public Sendable, public SendableHelper<AnalogTrigger> {
|
||||
friend class AnalogTriggerOutput;
|
||||
|
||||
public:
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/interfaces/Accelerometer.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
@@ -18,8 +17,7 @@ class SendableBuilder;
|
||||
*
|
||||
* This class allows access to the roboRIO's internal accelerometer.
|
||||
*/
|
||||
class BuiltInAccelerometer : public ErrorBase,
|
||||
public Accelerometer,
|
||||
class BuiltInAccelerometer : public Accelerometer,
|
||||
public Sendable,
|
||||
public SendableHelper<BuiltInAccelerometer> {
|
||||
public:
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
#include <hal/CANAPITypes.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
struct CANData {
|
||||
uint8_t data[8];
|
||||
@@ -27,7 +25,7 @@ struct CANData {
|
||||
* All methods are thread save, however the buffer objects passed in
|
||||
* by the user need to not be modified for the duration of their calls.
|
||||
*/
|
||||
class CAN : public ErrorBase {
|
||||
class CAN {
|
||||
public:
|
||||
/**
|
||||
* Create a new CAN communication interface with the specific device ID.
|
||||
@@ -52,7 +50,7 @@ class CAN : public ErrorBase {
|
||||
/**
|
||||
* Closes the CAN communication.
|
||||
*/
|
||||
~CAN() override;
|
||||
~CAN();
|
||||
|
||||
CAN(CAN&&) = default;
|
||||
CAN& operator=(CAN&&) = default;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
@@ -30,9 +29,7 @@ class SendableBuilder;
|
||||
* loop control. You can only turn off closed loop control, thereby stopping
|
||||
* the compressor from operating.
|
||||
*/
|
||||
class Compressor : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Compressor> {
|
||||
class Compressor : public Sendable, public SendableHelper<Compressor> {
|
||||
public:
|
||||
/**
|
||||
* Constructor. The default PCM ID is 0.
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
#include "frc/CounterBase.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -31,8 +30,7 @@ class DMASample;
|
||||
* All counters will immediately start counting - Reset() them if you need them
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Counter : public ErrorBase,
|
||||
public CounterBase,
|
||||
class Counter : public CounterBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Counter> {
|
||||
friend class DMA;
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
class Encoder;
|
||||
class Counter;
|
||||
@@ -16,12 +14,12 @@ class DutyCycle;
|
||||
class AnalogInput;
|
||||
class DMASample;
|
||||
|
||||
class DMA : public ErrorBase {
|
||||
class DMA {
|
||||
friend class DMASample;
|
||||
|
||||
public:
|
||||
DMA();
|
||||
~DMA() override;
|
||||
~DMA();
|
||||
|
||||
DMA& operator=(DMA&& other) = default;
|
||||
DMA(DMA&& other) = default;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/DigitalSource.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -27,8 +26,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 ErrorBase,
|
||||
public Sendable,
|
||||
class DigitalGlitchFilter : public Sendable,
|
||||
public SendableHelper<DigitalGlitchFilter> {
|
||||
public:
|
||||
DigitalGlitchFilter();
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class MatchDataSender;
|
||||
@@ -25,12 +23,12 @@ class MatchDataSender;
|
||||
* Provide access to the network communication data to / from the Driver
|
||||
* Station.
|
||||
*/
|
||||
class DriverStation : public ErrorBase {
|
||||
class DriverStation {
|
||||
public:
|
||||
enum Alliance { kRed, kBlue, kInvalid };
|
||||
enum MatchType { kNone, kPractice, kQualification, kElimination };
|
||||
|
||||
~DriverStation() override;
|
||||
~DriverStation();
|
||||
|
||||
DriverStation(const DriverStation&) = delete;
|
||||
DriverStation& operator=(const DriverStation&) = delete;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -29,9 +28,7 @@ class DMASample;
|
||||
* order to implement rollover checking.
|
||||
*
|
||||
*/
|
||||
class DutyCycle : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<DutyCycle> {
|
||||
class DutyCycle : public Sendable, public SendableHelper<DutyCycle> {
|
||||
friend class AnalogTrigger;
|
||||
friend class DMA;
|
||||
friend class DMASample;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -25,8 +24,7 @@ class DigitalSource;
|
||||
* PWM Output, the CTRE Mag Encoder, the Rev Hex Encoder, and the AM Mag
|
||||
* Encoder.
|
||||
*/
|
||||
class DutyCycleEncoder : public ErrorBase,
|
||||
public Sendable,
|
||||
class DutyCycleEncoder : public Sendable,
|
||||
public SendableHelper<DutyCycleEncoder> {
|
||||
public:
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/CounterBase.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -37,8 +36,7 @@ class DMASample;
|
||||
* All encoders will immediately start counting - Reset() them if you need them
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Encoder : public ErrorBase,
|
||||
public CounterBase,
|
||||
class Encoder : public CounterBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Encoder> {
|
||||
friend class DMA;
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma push_macro("GetMessage")
|
||||
#undef GetMessage
|
||||
#endif
|
||||
|
||||
namespace frc {
|
||||
|
||||
class ErrorBase;
|
||||
|
||||
/**
|
||||
* Error object represents a library error.
|
||||
*/
|
||||
class Error {
|
||||
public:
|
||||
using Code = int;
|
||||
|
||||
Error() = default;
|
||||
Error(Code code, const wpi::Twine& contextMessage, wpi::StringRef filename,
|
||||
wpi::StringRef function, int lineNumber,
|
||||
const ErrorBase* originatingObject);
|
||||
|
||||
bool operator<(const Error& rhs) const;
|
||||
|
||||
Code GetCode() const;
|
||||
std::string GetMessage() const;
|
||||
std::string GetFilename() const;
|
||||
std::string GetFunction() const;
|
||||
int GetLineNumber() const;
|
||||
const ErrorBase* GetOriginatingObject() const;
|
||||
double GetTimestamp() const;
|
||||
void Clear();
|
||||
void Set(Code code, const wpi::Twine& contextMessage, wpi::StringRef filename,
|
||||
wpi::StringRef function, int lineNumber,
|
||||
const ErrorBase* originatingObject);
|
||||
|
||||
private:
|
||||
void Report();
|
||||
|
||||
Code m_code = 0;
|
||||
std::string m_message;
|
||||
std::string m_filename;
|
||||
std::string m_function;
|
||||
int m_lineNumber = 0;
|
||||
const ErrorBase* m_originatingObject = nullptr;
|
||||
double m_timestamp = 0.0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma pop_macro("GetMessage")
|
||||
#endif
|
||||
@@ -1,239 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#include "frc/Error.h"
|
||||
|
||||
// Forward declared manually to avoid needing to pull in entire HAL header.
|
||||
extern "C" const char* HAL_GetErrorMessage(int32_t code);
|
||||
|
||||
#define wpi_setErrnoErrorWithContext(context) \
|
||||
this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__)
|
||||
#define wpi_setErrnoError() wpi_setErrnoErrorWithContext("")
|
||||
#define wpi_setImaqErrorWithContext(code, context) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
this->SetImaqError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
|
||||
} while (0)
|
||||
#define wpi_setErrorWithContext(code, context) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
this->SetError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
|
||||
} while (0)
|
||||
#define wpi_setErrorWithContextRange(code, min, max, req, context) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
this->SetErrorRange((code), (min), (max), (req), (context), __FILE__, \
|
||||
__FUNCTION__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define wpi_setHALError(code) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
this->SetError((code), HAL_GetErrorMessage(code), __FILE__, \
|
||||
__FUNCTION__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define wpi_setHALErrorWithRange(code, min, max, req) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
this->SetErrorRange((code), (min), (max), (req), \
|
||||
HAL_GetErrorMessage(code), __FILE__, __FUNCTION__, \
|
||||
__LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define wpi_setError(code) wpi_setErrorWithContext(code, "")
|
||||
#define wpi_setStaticErrorWithContext(object, code, context) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
object->SetError((code), (context), __FILE__, __FUNCTION__, __LINE__); \
|
||||
} while (0)
|
||||
#define wpi_setStaticError(object, code) \
|
||||
wpi_setStaticErrorWithContext(object, code, "")
|
||||
|
||||
#define wpi_setGlobalErrorWithContext(code, context) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
::frc::ErrorBase::SetGlobalError((code), (context), __FILE__, \
|
||||
__FUNCTION__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define wpi_setGlobalHALError(code) \
|
||||
do { \
|
||||
if ((code) != 0) \
|
||||
::frc::ErrorBase::SetGlobalError((code), HAL_GetErrorMessage(code), \
|
||||
__FILE__, __FUNCTION__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define wpi_setGlobalError(code) wpi_setGlobalErrorWithContext(code, "")
|
||||
#define wpi_setWPIErrorWithContext(error, context) \
|
||||
this->SetWPIError(wpi_error_s_##error(), wpi_error_value_##error(), \
|
||||
(context), __FILE__, __FUNCTION__, __LINE__)
|
||||
#define wpi_setWPIError(error) (wpi_setWPIErrorWithContext(error, ""))
|
||||
#define wpi_setStaticWPIErrorWithContext(object, error, context) \
|
||||
object->SetWPIError(wpi_error_s_##error(), (context), __FILE__, \
|
||||
__FUNCTION__, __LINE__)
|
||||
#define wpi_setStaticWPIError(object, error) \
|
||||
wpi_setStaticWPIErrorWithContext(object, error, "")
|
||||
#define wpi_setGlobalWPIErrorWithContext(error, context) \
|
||||
::frc::ErrorBase::SetGlobalWPIError(wpi_error_s_##error(), (context), \
|
||||
__FILE__, __FUNCTION__, __LINE__)
|
||||
#define wpi_setGlobalWPIError(error) wpi_setGlobalWPIErrorWithContext(error, "")
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Base class for most objects.
|
||||
*
|
||||
* ErrorBase is the base class for most objects since it holds the generated
|
||||
* error for that object. In addition, there is a single instance of a global
|
||||
* error object.
|
||||
*/
|
||||
class ErrorBase {
|
||||
// TODO: Consider initializing instance variables and cleanup in destructor
|
||||
public:
|
||||
ErrorBase();
|
||||
virtual ~ErrorBase() = default;
|
||||
|
||||
ErrorBase(const ErrorBase&) = default;
|
||||
ErrorBase& operator=(const ErrorBase&) = default;
|
||||
ErrorBase(ErrorBase&&) = default;
|
||||
ErrorBase& operator=(ErrorBase&&) = default;
|
||||
|
||||
/**
|
||||
* @brief Retrieve the current error.
|
||||
*
|
||||
* Get the current error information associated with this sensor.
|
||||
*/
|
||||
virtual Error& GetError();
|
||||
|
||||
/**
|
||||
* @brief Retrieve the current error.
|
||||
*
|
||||
* Get the current error information associated with this sensor.
|
||||
*/
|
||||
virtual const Error& GetError() const;
|
||||
|
||||
/**
|
||||
* @brief Clear the current error information associated with this sensor.
|
||||
*/
|
||||
virtual void ClearError() const;
|
||||
|
||||
/**
|
||||
* @brief Set error information associated with a C library call that set an
|
||||
* error to the "errno" global variable.
|
||||
*
|
||||
* @param contextMessage A custom message from the code that set the error.
|
||||
* @param filename Filename of the error source
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
virtual void SetErrnoError(const wpi::Twine& contextMessage,
|
||||
wpi::StringRef filename, wpi::StringRef function,
|
||||
int lineNumber) const;
|
||||
|
||||
/**
|
||||
* @brief Set the current error information associated from the nivision Imaq
|
||||
* API.
|
||||
*
|
||||
* @param success The return from the function
|
||||
* @param contextMessage A custom message from the code that set the error.
|
||||
* @param filename Filename of the error source
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
virtual void SetImaqError(int success, const wpi::Twine& contextMessage,
|
||||
wpi::StringRef filename, wpi::StringRef function,
|
||||
int lineNumber) const;
|
||||
|
||||
/**
|
||||
* @brief Set the current error information associated with this sensor.
|
||||
*
|
||||
* @param code The error code
|
||||
* @param contextMessage A custom message from the code that set the error.
|
||||
* @param filename Filename of the error source
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
virtual void SetError(Error::Code code, const wpi::Twine& contextMessage,
|
||||
wpi::StringRef filename, wpi::StringRef function,
|
||||
int lineNumber) const;
|
||||
|
||||
/**
|
||||
* @brief Set the current error information associated with this sensor.
|
||||
* Range versions use for initialization code.
|
||||
*
|
||||
* @param code The error code
|
||||
* @param minRange The minimum allowed allocation range
|
||||
* @param maxRange The maximum allowed allocation range
|
||||
* @param requestedValue The requested value to allocate
|
||||
* @param contextMessage A custom message from the code that set the error.
|
||||
* @param filename Filename of the error source
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
virtual void SetErrorRange(Error::Code code, int32_t minRange,
|
||||
int32_t maxRange, int32_t requestedValue,
|
||||
const wpi::Twine& contextMessage,
|
||||
wpi::StringRef filename, wpi::StringRef function,
|
||||
int lineNumber) const;
|
||||
|
||||
/**
|
||||
* @brief Set the current error information associated with this sensor.
|
||||
*
|
||||
* @param errorMessage The error message from WPIErrors.h
|
||||
* @param contextMessage A custom message from the code that set the error.
|
||||
* @param filename Filename of the error source
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
virtual void SetWPIError(const wpi::Twine& errorMessage, Error::Code code,
|
||||
const wpi::Twine& contextMessage,
|
||||
wpi::StringRef filename, wpi::StringRef function,
|
||||
int lineNumber) const;
|
||||
|
||||
virtual void CloneError(const ErrorBase& rhs) const;
|
||||
|
||||
/**
|
||||
* @brief Check if the current error code represents a fatal error.
|
||||
*
|
||||
* @return true if the current error is fatal.
|
||||
*/
|
||||
virtual bool StatusIsFatal() const;
|
||||
|
||||
static void SetGlobalError(Error::Code code, const wpi::Twine& contextMessage,
|
||||
wpi::StringRef filename, wpi::StringRef function,
|
||||
int lineNumber);
|
||||
|
||||
static void SetGlobalWPIError(const wpi::Twine& errorMessage,
|
||||
const wpi::Twine& contextMessage,
|
||||
wpi::StringRef filename,
|
||||
wpi::StringRef function, int lineNumber);
|
||||
|
||||
/**
|
||||
* Retrieve the last global error.
|
||||
*/
|
||||
static Error GetGlobalError();
|
||||
|
||||
/**
|
||||
* Retrieve all global errors.
|
||||
*/
|
||||
static std::vector<Error> GetGlobalErrors();
|
||||
|
||||
/**
|
||||
* Clear global errors.
|
||||
*/
|
||||
void ClearGlobalErrors();
|
||||
|
||||
protected:
|
||||
mutable Error m_error;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
139
wpilibc/src/main/native/include/frc/Errors.h
Normal file
139
wpilibc/src/main/native/include/frc/Errors.h
Normal file
@@ -0,0 +1,139 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Runtime error exception.
|
||||
*/
|
||||
class RuntimeError : public std::runtime_error {
|
||||
public:
|
||||
RuntimeError(int32_t code, const wpi::Twine& message, const wpi::Twine& loc,
|
||||
wpi::StringRef stack);
|
||||
RuntimeError(int32_t code, const wpi::Twine& message, const char* fileName,
|
||||
int lineNumber, const char* funcName, wpi::StringRef stack);
|
||||
|
||||
int32_t code() const noexcept { return m_data->code; }
|
||||
const char* loc() const noexcept { return m_data->loc.c_str(); }
|
||||
const char* stack() const noexcept { return m_data->stack.c_str(); }
|
||||
|
||||
/**
|
||||
* Reports error to Driver Station (using HAL_SendError).
|
||||
*/
|
||||
void Report() const;
|
||||
|
||||
private:
|
||||
struct Data {
|
||||
int32_t code;
|
||||
std::string loc;
|
||||
std::string stack;
|
||||
};
|
||||
std::shared_ptr<Data> m_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets error message string for an error code.
|
||||
*/
|
||||
const char* GetErrorMessage(int32_t code);
|
||||
|
||||
/**
|
||||
* Reports an error to the driver station (using HAL_SendError).
|
||||
* Generally the FRC_ReportError wrapper macro should be used instead.
|
||||
*
|
||||
* @param status error code
|
||||
* @param message error message details
|
||||
* @param fileName source file name
|
||||
* @param lineNumber source line number
|
||||
* @param funcName source function name
|
||||
*/
|
||||
void ReportError(int32_t status, const wpi::Twine& message,
|
||||
const char* fileName, int lineNumber, const char* funcName);
|
||||
|
||||
/**
|
||||
* Makes a runtime error exception object. This object should be thrown
|
||||
* by the caller. Generally the FRC_MakeError wrapper macro should be used
|
||||
* instead.
|
||||
*
|
||||
* @param status error code
|
||||
* @param message error message details
|
||||
* @param fileName source file name
|
||||
* @param lineNumber source line number
|
||||
* @param funcName source function name
|
||||
* @return runtime error object
|
||||
*/
|
||||
[[nodiscard]] RuntimeError MakeError(int32_t status, const wpi::Twine& message,
|
||||
const char* fileName, int lineNumber,
|
||||
const char* funcName);
|
||||
|
||||
namespace err {
|
||||
#define S(label, offset, message) inline constexpr int label = offset;
|
||||
#include "frc/WPIErrors.mac"
|
||||
#undef S
|
||||
} // namespace err
|
||||
|
||||
namespace warn {
|
||||
#define S(label, offset, message) inline constexpr int label = offset;
|
||||
#include "frc/WPIWarnings.mac"
|
||||
#undef S
|
||||
} // namespace warn
|
||||
} // namespace frc
|
||||
|
||||
/**
|
||||
* Reports an error to the driver station (using HAL_SendError).
|
||||
*
|
||||
* @param status error code
|
||||
* @param message error message details
|
||||
*/
|
||||
#define FRC_ReportError(status, message) \
|
||||
do { \
|
||||
if ((status) != 0) { \
|
||||
::frc::ReportError(status, message, __FILE__, __LINE__, __FUNCTION__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Makes a runtime error exception object. This object should be thrown
|
||||
* by the caller.
|
||||
*
|
||||
* @param status error code
|
||||
* @param message error message details
|
||||
* @return runtime error object
|
||||
*/
|
||||
#define FRC_MakeError(status, message) \
|
||||
::frc::MakeError(status, message, __FILE__, __LINE__, __FUNCTION__)
|
||||
|
||||
/**
|
||||
* Checks a status code and depending on its value, either throws a
|
||||
* RuntimeError exception, calls ReportError, or does nothing (if no error).
|
||||
*
|
||||
* @param status error code
|
||||
* @param message error message details
|
||||
*/
|
||||
#define FRC_CheckErrorStatus(status, message) \
|
||||
do { \
|
||||
if ((status) < 0) { \
|
||||
throw FRC_MakeError(status, message); \
|
||||
} else if ((status) > 0) { \
|
||||
FRC_ReportError(status, message); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FRC_AssertMessage(condition, message) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
throw FRC_MakeError(err::AssertionFailure, message); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define FRC_Assert(condition) FRC_AssertMessage(condition, #condition)
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DriverStation;
|
||||
@@ -17,7 +15,7 @@ class DriverStation;
|
||||
/**
|
||||
* GenericHID Interface.
|
||||
*/
|
||||
class GenericHID : public ErrorBase {
|
||||
class GenericHID {
|
||||
public:
|
||||
enum RumbleType { kLeftRumble, kRightRumble };
|
||||
|
||||
@@ -44,7 +42,7 @@ class GenericHID : public ErrorBase {
|
||||
enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
|
||||
|
||||
explicit GenericHID(int port);
|
||||
~GenericHID() override = default;
|
||||
virtual ~GenericHID() = default;
|
||||
|
||||
GenericHID(GenericHID&&) = default;
|
||||
GenericHID& operator=(GenericHID&&) = default;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
#include <hal/I2CTypes.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
@@ -18,7 +16,7 @@ namespace frc {
|
||||
* This class is intended to be used by sensor (and other I2C device) drivers.
|
||||
* It probably should not be used directly.
|
||||
*/
|
||||
class I2C : public ErrorBase {
|
||||
class I2C {
|
||||
public:
|
||||
enum Port { kOnboard = 0, kMXP };
|
||||
|
||||
@@ -30,7 +28,7 @@ class I2C : public ErrorBase {
|
||||
*/
|
||||
I2C(Port port, int deviceAddress);
|
||||
|
||||
~I2C() override;
|
||||
~I2C();
|
||||
|
||||
I2C(I2C&&) = default;
|
||||
I2C& operator=(I2C&&) = default;
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
#include <hal/Interrupts.h>
|
||||
|
||||
#include "frc/AnalogTriggerType.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class InterruptableSensorBase : public ErrorBase {
|
||||
class InterruptableSensorBase {
|
||||
public:
|
||||
enum WaitResult {
|
||||
kTimeout = 0x0,
|
||||
@@ -35,7 +34,7 @@ class InterruptableSensorBase : public ErrorBase {
|
||||
/**
|
||||
* Free the resources for an interrupt event.
|
||||
*/
|
||||
~InterruptableSensorBase() override;
|
||||
virtual ~InterruptableSensorBase();
|
||||
|
||||
InterruptableSensorBase(InterruptableSensorBase&&) = default;
|
||||
InterruptableSensorBase& operator=(InterruptableSensorBase&&) = default;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/Timer.h"
|
||||
|
||||
namespace wpi {
|
||||
@@ -21,10 +20,10 @@ namespace frc {
|
||||
*
|
||||
* The subclass should call Feed() whenever the motor value is updated.
|
||||
*/
|
||||
class MotorSafety : public ErrorBase {
|
||||
class MotorSafety {
|
||||
public:
|
||||
MotorSafety();
|
||||
~MotorSafety() override;
|
||||
virtual ~MotorSafety();
|
||||
|
||||
MotorSafety(MotorSafety&& rhs);
|
||||
MotorSafety& operator=(MotorSafety&& rhs);
|
||||
|
||||
@@ -18,11 +18,9 @@
|
||||
#include <wpi/deprecated.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Notifier : public ErrorBase {
|
||||
class Notifier {
|
||||
public:
|
||||
/**
|
||||
* Create a Notifier for timer event notification.
|
||||
@@ -63,7 +61,7 @@ class Notifier : public ErrorBase {
|
||||
/**
|
||||
* Free the resources for a timer event.
|
||||
*/
|
||||
~Notifier() override;
|
||||
~Notifier();
|
||||
|
||||
Notifier(Notifier&& rhs);
|
||||
Notifier& operator=(Notifier&& rhs);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -33,7 +32,7 @@ class SendableBuilder;
|
||||
* - 1 = minimum pulse width (currently 0.5ms)
|
||||
* - 0 = disabled (i.e. PWM output is held low)
|
||||
*/
|
||||
class PWM : public ErrorBase, public Sendable, public SendableHelper<PWM> {
|
||||
class PWM : public Sendable, public SendableHelper<PWM> {
|
||||
public:
|
||||
friend class AddressableLED;
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <hal/Types.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -18,8 +17,7 @@ class SendableBuilder;
|
||||
* Class for getting voltage, current, temperature, power and energy from the
|
||||
* CAN PDP.
|
||||
*/
|
||||
class PowerDistributionPanel : public ErrorBase,
|
||||
public Sendable,
|
||||
class PowerDistributionPanel : public Sendable,
|
||||
public SendableHelper<PowerDistributionPanel> {
|
||||
public:
|
||||
PowerDistributionPanel();
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
#include <networktables/NetworkTable.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
@@ -30,7 +28,7 @@ namespace frc {
|
||||
* This will also interact with {@link NetworkTable} by creating a table called
|
||||
* "Preferences" with all the key-value pairs.
|
||||
*/
|
||||
class Preferences : public ErrorBase {
|
||||
class Preferences {
|
||||
public:
|
||||
/**
|
||||
* Get the one and only {@link Preferences} object.
|
||||
@@ -226,7 +224,7 @@ class Preferences : public ErrorBase {
|
||||
|
||||
protected:
|
||||
Preferences();
|
||||
~Preferences() override;
|
||||
~Preferences();
|
||||
|
||||
Preferences(Preferences&&) = default;
|
||||
Preferences& operator=(Preferences&&) = default;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <hal/Types.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
@@ -26,9 +24,9 @@ namespace frc {
|
||||
* resources; it just tracks which indices were marked in use by Allocate and
|
||||
* not yet freed by Free.
|
||||
*/
|
||||
class Resource : public ErrorBase {
|
||||
class Resource {
|
||||
public:
|
||||
~Resource() override = default;
|
||||
virtual ~Resource() = default;
|
||||
|
||||
/**
|
||||
* Factory method to create a Resource allocation-tracker *if* needed.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/Base.h"
|
||||
#include "frc/Errors.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -25,12 +26,17 @@ namespace impl {
|
||||
|
||||
template <class Robot>
|
||||
void RunRobot(wpi::mutex& m, Robot** robot) {
|
||||
static Robot theRobot;
|
||||
{
|
||||
std::scoped_lock lock{m};
|
||||
*robot = &theRobot;
|
||||
try {
|
||||
static Robot theRobot;
|
||||
{
|
||||
std::scoped_lock lock{m};
|
||||
*robot = &theRobot;
|
||||
}
|
||||
theRobot.StartCompetition();
|
||||
} catch (const frc::RuntimeError& e) {
|
||||
e.Report();
|
||||
throw;
|
||||
}
|
||||
theRobot.StartCompetition();
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DigitalSource;
|
||||
@@ -26,7 +24,7 @@ class DigitalSource;
|
||||
* It probably should not be used directly.
|
||||
*
|
||||
*/
|
||||
class SPI : public ErrorBase {
|
||||
class SPI {
|
||||
public:
|
||||
enum Port { kOnboardCS0 = 0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
|
||||
|
||||
@@ -37,7 +35,7 @@ class SPI : public ErrorBase {
|
||||
*/
|
||||
explicit SPI(Port port);
|
||||
|
||||
~SPI() override;
|
||||
~SPI();
|
||||
|
||||
SPI(SPI&&) = default;
|
||||
SPI& operator=(SPI&&) = default;
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#include <wpi/Twine.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
@@ -27,7 +25,7 @@ namespace frc {
|
||||
* and the NI-VISA Programmer's Reference Manual here:
|
||||
* http://www.ni.com/pdf/manuals/370132c.pdf
|
||||
*/
|
||||
class SerialPort : public ErrorBase {
|
||||
class SerialPort {
|
||||
public:
|
||||
enum Parity {
|
||||
kParity_None = 0,
|
||||
@@ -88,7 +86,7 @@ class SerialPort : public ErrorBase {
|
||||
int dataBits = 8, Parity parity = kParity_None,
|
||||
StopBits stopBits = kStopBits_One);
|
||||
|
||||
~SerialPort() override;
|
||||
~SerialPort();
|
||||
|
||||
SerialPort(SerialPort&& rhs) = default;
|
||||
SerialPort& operator=(SerialPort&& rhs) = default;
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* SolenoidBase class is the common base class for the Solenoid and
|
||||
* DoubleSolenoid classes.
|
||||
*/
|
||||
class SolenoidBase : public ErrorBase {
|
||||
class SolenoidBase {
|
||||
public:
|
||||
virtual ~SolenoidBase() = default;
|
||||
|
||||
/**
|
||||
* Get the CAN ID of the module this solenoid is connected to.
|
||||
*
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <wpi/deprecated.h>
|
||||
#include <wpi/priority_queue.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/IterativeRobotBase.h"
|
||||
#include "frc2/Timer.h"
|
||||
|
||||
@@ -29,7 +28,7 @@ namespace frc {
|
||||
* Periodic() functions from the base class are called on an interval by a
|
||||
* Notifier instance.
|
||||
*/
|
||||
class TimedRobot : public IterativeRobotBase, public ErrorBase {
|
||||
class TimedRobot : public IterativeRobotBase {
|
||||
public:
|
||||
static constexpr units::second_t kDefaultPeriod = 20_ms;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <hal/SimDevice.h>
|
||||
|
||||
#include "frc/Counter.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
@@ -33,9 +32,7 @@ class DigitalOutput;
|
||||
* received. The time that the line is high determines the round trip distance
|
||||
* (time of flight).
|
||||
*/
|
||||
class Ultrasonic : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<Ultrasonic> {
|
||||
class Ultrasonic : public Sendable, public SendableHelper<Ultrasonic> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of the Ultrasonic Sensor.
|
||||
|
||||
@@ -2,18 +2,9 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define S(label, offset, message) \
|
||||
constexpr inline const char* wpi_error_s_##label() { return message; } \
|
||||
constexpr inline int wpi_error_value_##label() { return offset; }
|
||||
|
||||
// Fatal errors
|
||||
S(ModuleIndexOutOfRange, -1,
|
||||
"Allocating module that is out of range or not found")
|
||||
S(ChannelIndexOutOfRange, -1, "Allocating channel that is out of range")
|
||||
S(ChannelIndexOutOfRange, -45, "Allocating channel that is out of range")
|
||||
S(NotAllocated, -2, "Attempting to free unallocated resource")
|
||||
S(ResourceAlreadyAllocated, -3, "Attempted to reuse an allocated resource")
|
||||
S(NoAvailableResources, -4, "No available resources to allocate")
|
||||
@@ -26,13 +17,13 @@ S(IncompatibleMode, -9, "The object is in an incompatible mode")
|
||||
S(AnalogTriggerLimitOrderError, -10,
|
||||
"AnalogTrigger limits error. Lower limit > Upper Limit")
|
||||
S(AnalogTriggerPulseOutputError, -11,
|
||||
"Attempted to read AnalogTrigger pulse output.")
|
||||
"Attempted to read AnalogTrigger pulse output")
|
||||
S(TaskError, -12, "Task can't be started")
|
||||
S(TaskIDError, -13, "Task error: Invalid ID.")
|
||||
S(TaskDeletedError, -14, "Task error: Task already deleted.")
|
||||
S(TaskOptionsError, -15, "Task error: Invalid options.")
|
||||
S(TaskMemoryError, -16, "Task can't be started due to insufficient memory.")
|
||||
S(TaskPriorityError, -17, "Task error: Invalid priority [1-255].")
|
||||
S(TaskIDError, -13, "Task error: Invalid ID")
|
||||
S(TaskDeletedError, -14, "Task error: Task already deleted")
|
||||
S(TaskOptionsError, -15, "Task error: Invalid options")
|
||||
S(TaskMemoryError, -16, "Task can't be started due to insufficient memory")
|
||||
S(TaskPriorityError, -17, "Task error: Invalid priority [1-255]")
|
||||
S(DriveUninitialized, -18, "RobotDrive not initialized for the C interface")
|
||||
S(CompressorNonMatching, -19,
|
||||
"Compressor slot/channel doesn't match previous instance")
|
||||
@@ -41,19 +32,19 @@ S(CompressorUndefined, -21,
|
||||
"Using compressor functions without defining compressor")
|
||||
S(InconsistentArrayValueAdded, -22,
|
||||
"When packing data into an array to the dashboard, not all values added were "
|
||||
"of the same type.")
|
||||
"of the same type")
|
||||
S(MismatchedComplexTypeClose, -23,
|
||||
"When packing data to the dashboard, a Close for a complex type was called "
|
||||
"without a matching Open.")
|
||||
"without a matching Open")
|
||||
S(DashboardDataOverflow, -24,
|
||||
"When packing data to the dashboard, too much data was packed and the buffer "
|
||||
"overflowed.")
|
||||
"overflowed")
|
||||
S(DashboardDataCollision, -25,
|
||||
"The same buffer was used for packing data and for printing.")
|
||||
S(EnhancedIOMissing, -26, "IO is not attached or Enhanced IO is not enabled.")
|
||||
"The same buffer was used for packing data and for printing")
|
||||
S(EnhancedIOMissing, -26, "IO is not attached or Enhanced IO is not enabled")
|
||||
S(LineNotOutput, -27,
|
||||
"Cannot SetDigitalOutput for a line not configured for output.")
|
||||
S(ParameterOutOfRange, -28, "A parameter is out of range.")
|
||||
"Cannot SetDigitalOutput for a line not configured for output")
|
||||
S(ParameterOutOfRange, -28, "A parameter is out of range")
|
||||
S(SPIClockRateTooLow, -29, "SPI clock rate was below the minimum supported")
|
||||
S(JaguarVersionError, -30, "Jaguar firmware version error")
|
||||
S(JaguarMessageNotFound, -31, "Jaguar message not found")
|
||||
@@ -62,31 +53,9 @@ S(NetworkTablesBufferFull, -41, "Buffer full writing to NetworkTables socket")
|
||||
S(NetworkTablesWrongType, -42,
|
||||
"The wrong type was read from the NetworkTables entry")
|
||||
S(NetworkTablesCorrupt, -43, "NetworkTables data stream is corrupt")
|
||||
S(SmartDashboardMissingKey, -43, "SmartDashboard data does not exist")
|
||||
S(SmartDashboardMissingKey, -44, "SmartDashboard data does not exist")
|
||||
S(CommandIllegalUse, -50, "Illegal use of Command")
|
||||
S(UnsupportedInSimulation, -80, "Unsupported in simulation")
|
||||
S(CameraServerError, -90, "CameraServer error")
|
||||
S(InvalidParameter, -100, "Invalid parameter value")
|
||||
|
||||
// Warnings
|
||||
S(SampleRateTooHigh, 1, "Analog module sample rate is too high")
|
||||
S(VoltageOutOfRange, 2,
|
||||
"Voltage to convert to raw value is out of range [-10; 10]")
|
||||
S(CompressorTaskError, 3, "Compressor task won't start")
|
||||
S(LoopTimingError, 4, "Digital module loop timing is not the expected value")
|
||||
S(NonBinaryDigitalValue, 5, "Digital output value is not 0 or 1")
|
||||
S(IncorrectBatteryChannel, 6,
|
||||
"Battery measurement channel is not correct value")
|
||||
S(BadJoystickIndex, 7, "Joystick index is out of range, should be 0-3")
|
||||
S(BadJoystickAxis, 8, "Joystick axis or POV is out of range")
|
||||
S(InvalidMotorIndex, 9, "Motor index is out of range, should be 0-3")
|
||||
S(DriverStationTaskError, 10, "Driver Station task won't start")
|
||||
S(EnhancedIOPWMPeriodOutOfRange, 11,
|
||||
"Driver Station Enhanced IO PWM Output period out of range.")
|
||||
S(SPIWriteNoMOSI, 12, "Cannot write to SPI port with no MOSI output")
|
||||
S(SPIReadNoMISO, 13, "Cannot read from SPI port with no MISO input")
|
||||
S(SPIReadNoData, 14, "No data available to read from SPI")
|
||||
S(IncompatibleState, 15,
|
||||
"Incompatible State: The operation cannot be completed")
|
||||
|
||||
#undef S
|
||||
S(AssertionFailure, -110, "Assertion failed")
|
||||
23
wpilibc/src/main/native/include/frc/WPIWarnings.mac
Normal file
23
wpilibc/src/main/native/include/frc/WPIWarnings.mac
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
S(SampleRateTooHigh, 1, "Analog module sample rate is too high")
|
||||
S(VoltageOutOfRange, 2,
|
||||
"Voltage to convert to raw value is out of range [-10; 10]")
|
||||
S(CompressorTaskError, 3, "Compressor task won't start")
|
||||
S(LoopTimingError, 4, "Digital module loop timing is not the expected value")
|
||||
S(NonBinaryDigitalValue, 5, "Digital output value is not 0 or 1")
|
||||
S(IncorrectBatteryChannel, 6,
|
||||
"Battery measurement channel is not correct value")
|
||||
S(BadJoystickIndex, 7, "Joystick index is out of range, should be 0-3")
|
||||
S(BadJoystickAxis, 8, "Joystick axis or POV is out of range")
|
||||
S(InvalidMotorIndex, 9, "Motor index is out of range, should be 0-3")
|
||||
S(DriverStationTaskError, 10, "Driver Station task won't start")
|
||||
S(EnhancedIOPWMPeriodOutOfRange, 11,
|
||||
"Driver Station Enhanced IO PWM Output period out of range")
|
||||
S(SPIWriteNoMOSI, 12, "Cannot write to SPI port with no MOSI output")
|
||||
S(SPIReadNoMISO, 13, "Cannot read from SPI port with no MISO input")
|
||||
S(SPIReadNoData, 14, "No data available to read from SPI")
|
||||
S(IncompatibleState, 15,
|
||||
"Incompatible State: The operation cannot be completed")
|
||||
@@ -5,7 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "frc/DigitalOutput.h"
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/MotorSafety.h"
|
||||
#include "frc/PWM.h"
|
||||
#include "frc/motorcontrol/MotorController.h"
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <hal/SimDevice.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/interfaces/Gyro.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
@@ -19,10 +18,7 @@ namespace frc {
|
||||
* This class is for the Romi onboard gyro, and will only work in
|
||||
* simulation/Romi mode. Only one instance of a RomiGyro is supported.
|
||||
*/
|
||||
class RomiGyro : public Gyro,
|
||||
public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<RomiGyro> {
|
||||
class RomiGyro : public Gyro, public Sendable, public SendableHelper<RomiGyro> {
|
||||
public:
|
||||
RomiGyro();
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/shuffleboard/BuiltInLayouts.h"
|
||||
#include "frc/shuffleboard/LayoutType.h"
|
||||
#include "frc/shuffleboard/ShuffleboardComponentBase.h"
|
||||
@@ -38,8 +36,7 @@ class SimpleWidget;
|
||||
/**
|
||||
* Common interface for objects that can contain shuffleboard components.
|
||||
*/
|
||||
class ShuffleboardContainer : public virtual ShuffleboardValue,
|
||||
public ErrorBase {
|
||||
class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
public:
|
||||
explicit ShuffleboardContainer(const wpi::Twine& title);
|
||||
|
||||
|
||||
@@ -11,16 +11,13 @@
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
|
||||
#include "frc/ErrorBase.h"
|
||||
#include "frc/smartdashboard/ListenerExecutor.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class SmartDashboard : public ErrorBase,
|
||||
public Sendable,
|
||||
public SendableHelper<SmartDashboard> {
|
||||
class SmartDashboard : public Sendable, public SendableHelper<SmartDashboard> {
|
||||
public:
|
||||
static void init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user