Merge changes I3d35139f,I05bb06f6,I4a3db0f1,I452b4794,If281e46a

* changes:
  artf4107: Removed most "Init" functions from classes
  artf4107: Replaced throw() with noexcept
  artf4107: GetInstance() calls are now atomic
  artf4107: Uniform initialization syntax introduced
  artf4107: clang-modernize was run on WPILib
This commit is contained in:
Brad Miller (WPI)
2015-07-07 16:34:39 -07:00
committed by Gerrit Code Review
229 changed files with 1159 additions and 1921 deletions

View File

@@ -15,7 +15,7 @@ class BadMessageException : public std::exception
{
public:
BadMessageException(const char* message);
~BadMessageException() throw ();
~BadMessageException() noexcept;
const char* what() const noexcept;
private:
std::string message;

View File

@@ -13,7 +13,7 @@ BadMessageException::BadMessageException(const char* msg)
}
BadMessageException::~BadMessageException() throw ()
BadMessageException::~BadMessageException() noexcept
{
}

View File

@@ -14,7 +14,7 @@ class Command;
class ButtonScheduler {
public:
ButtonScheduler(bool last, Trigger *button, Command *orders);
virtual ~ButtonScheduler() {}
virtual ~ButtonScheduler() = default;
virtual void Execute() = 0;
void Start();

View File

@@ -16,7 +16,7 @@ class Command;
class CancelButtonScheduler : public ButtonScheduler {
public:
CancelButtonScheduler(bool last, Trigger *button, Command *orders);
virtual ~CancelButtonScheduler() {}
virtual ~CancelButtonScheduler() = default;
virtual void Execute();
private:

View File

@@ -16,7 +16,7 @@ class Command;
class HeldButtonScheduler : public ButtonScheduler {
public:
HeldButtonScheduler(bool last, Trigger *button, Command *orders);
virtual ~HeldButtonScheduler() {}
virtual ~HeldButtonScheduler() = default;
virtual void Execute();
};

View File

@@ -12,9 +12,9 @@
class InternalButton : public Button {
public:
InternalButton();
InternalButton() = default;
InternalButton(bool inverted);
virtual ~InternalButton() {}
virtual ~InternalButton() = default;
void SetInverted(bool inverted);
void SetPressed(bool pressed);
@@ -22,8 +22,8 @@ class InternalButton : public Button {
virtual bool Get();
private:
bool m_pressed;
bool m_inverted;
bool m_pressed = false;
bool m_inverted = false;
};
#endif

View File

@@ -14,7 +14,7 @@
class JoystickButton : public Button {
public:
JoystickButton(GenericHID *joystick, int buttonNumber);
virtual ~JoystickButton() {}
virtual ~JoystickButton() = default;
virtual bool Get();

View File

@@ -15,7 +15,7 @@ class NetworkButton : public Button {
public:
NetworkButton(const char *tableName, const char *field);
NetworkButton(ITable *table, const char *field);
virtual ~NetworkButton() {}
virtual ~NetworkButton() = default;
virtual bool Get();

View File

@@ -16,7 +16,7 @@ class Command;
class PressedButtonScheduler : public ButtonScheduler {
public:
PressedButtonScheduler(bool last, Trigger *button, Command *orders);
virtual ~PressedButtonScheduler() {}
virtual ~PressedButtonScheduler() = default;
virtual void Execute();
};

View File

@@ -16,7 +16,7 @@ class Command;
class ReleasedButtonScheduler : public ButtonScheduler {
public:
ReleasedButtonScheduler(bool last, Trigger *button, Command *orders);
virtual ~ReleasedButtonScheduler() {}
virtual ~ReleasedButtonScheduler() = default;
virtual void Execute();
};

View File

@@ -16,7 +16,7 @@ class Command;
class ToggleButtonScheduler : public ButtonScheduler {
public:
ToggleButtonScheduler(bool last, Trigger *button, Command *orders);
virtual ~ToggleButtonScheduler() {}
virtual ~ToggleButtonScheduler() = default;
virtual void Execute();
private:

View File

@@ -31,8 +31,8 @@ class Command;
*/
class Trigger : public Sendable {
public:
Trigger();
virtual ~Trigger() {}
Trigger() = default;
virtual ~Trigger() = default;
bool Grab();
virtual bool Get() = 0;
void WhenActive(Command *command);
@@ -46,7 +46,7 @@ class Trigger : public Sendable {
virtual std::string GetSmartDashboardType() const;
protected:
ITable *m_table;
ITable *m_table = nullptr;
};
#endif

View File

@@ -131,7 +131,6 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
virtual void _Cancel();
private:
void InitCommand(const char *name, double timeout);
void LockChanges();
/*synchronized*/ void Removed();
void StartRunning();
@@ -139,28 +138,39 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
/** The name of this command */
std::string m_name;
/** The time since this command was initialized */
double m_startTime;
double m_startTime = -1;
/** The time (in seconds) before this command "times out" (or -1 if no
* timeout) */
double m_timeout;
/** Whether or not this command has been initialized */
bool m_initialized;
bool m_initialized = false;
/** The requirements (or null if no requirements) */
SubsystemSet m_requirements;
/** Whether or not it is running */
bool m_running;
bool m_running = false;
/** Whether or not it is interruptible*/
bool m_interruptible;
bool m_interruptible = true;
/** Whether or not it has been canceled */
bool m_canceled;
bool m_canceled = false;
/** Whether or not it has been locked */
bool m_locked;
bool m_locked = false;
/** Whether this command should run when the robot is disabled */
bool m_runWhenDisabled;
bool m_runWhenDisabled = false;
/** The {@link CommandGroup} this is in */
CommandGroup *m_parent;
int m_commandID;
CommandGroup *m_parent = nullptr;
int m_commandID = m_commandCounter++;
static int m_commandCounter;
public:
@@ -172,7 +182,7 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
EntryValue value, bool isNew);
protected:
ITable *m_table;
ITable *m_table = nullptr;
};
#endif

View File

@@ -36,9 +36,9 @@
*/
class CommandGroup : public Command {
public:
CommandGroup();
CommandGroup() = default;
CommandGroup(const char *name);
virtual ~CommandGroup();
virtual ~CommandGroup() = default;
void AddSequential(Command *command);
void AddSequential(Command *command, double timeout);
@@ -61,14 +61,14 @@ class CommandGroup : public Command {
private:
void CancelConflicts(Command *command);
typedef std::vector<CommandGroupEntry> CommandVector;
/** The commands in this group (stored in entries) */
CommandVector m_commands;
typedef std::list<CommandGroupEntry> CommandList;
std::vector<CommandGroupEntry> m_commands;
/** The active children in this group (stored in entries) */
CommandList m_children;
std::list<CommandGroupEntry> m_children;
/** The current command, -1 signifies that none have been run */
int m_currentCommandIndex;
int m_currentCommandIndex = -1;
};
#endif

View File

@@ -18,14 +18,13 @@ class CommandGroupEntry {
kSequence_BranchChild
} Sequence;
CommandGroupEntry();
CommandGroupEntry(Command *command, Sequence state);
CommandGroupEntry(Command *command, Sequence state, double timeout);
CommandGroupEntry() = default;
CommandGroupEntry(Command *command, Sequence state, double timeout = -1.0);
bool IsTimedOut() const;
double m_timeout;
Command *m_command;
Sequence m_state;
Command *m_command = nullptr;
Sequence m_state = kSequence_InSequence;
};
#endif

View File

@@ -14,7 +14,7 @@
class PrintCommand : public Command {
public:
PrintCommand(const char *message);
virtual ~PrintCommand() {}
virtual ~PrintCommand() = default;
protected:
virtual void Initialize();

View File

@@ -50,22 +50,21 @@ class Scheduler : public ErrorBase, public NamedSendable {
void ProcessCommandAddition(Command *command);
static Scheduler *_instance;
Command::SubsystemSet m_subsystems;
MUTEX_ID m_buttonsLock;
MUTEX_ID m_buttonsLock = nullptr;
typedef std::vector<ButtonScheduler *> ButtonVector;
ButtonVector m_buttons;
typedef std::vector<Command *> CommandVector;
MUTEX_ID m_additionsLock;
MUTEX_ID m_additionsLock = nullptr;
CommandVector m_additions;
typedef std::set<Command *> CommandSet;
CommandSet m_commands;
bool m_adding;
bool m_enabled;
StringArray *commands;
NumberArray *ids;
NumberArray *toCancel;
ITable *m_table;
bool m_runningCommandsChanged;
bool m_adding = false;
bool m_enabled = true;
StringArray *commands = nullptr;
NumberArray *ids = nullptr;
NumberArray *toCancel = nullptr;
ITable *m_table = nullptr;
bool m_runningCommandsChanged = false;
};
#endif

View File

@@ -13,7 +13,7 @@
class StartCommand : public Command {
public:
StartCommand(Command *commandToStart);
virtual ~StartCommand() {}
virtual ~StartCommand() = default;
protected:
virtual void Initialize();

View File

@@ -19,7 +19,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
public:
Subsystem(const char *name);
virtual ~Subsystem() {}
virtual ~Subsystem() = default;
void SetDefaultCommand(Command *command);
Command *GetDefaultCommand();
@@ -30,11 +30,11 @@ class Subsystem : public ErrorBase, public NamedSendable {
private:
void ConfirmCommand();
Command *m_currentCommand;
bool m_currentCommandChanged;
Command *m_defaultCommand;
Command *m_currentCommand = nullptr;
bool m_currentCommandChanged = true;
Command *m_defaultCommand = nullptr;
std::string m_name;
bool m_initializedDefaultCommand;
bool m_initializedDefaultCommand = false;
public:
virtual std::string GetName();
@@ -43,7 +43,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
virtual std::string GetSmartDashboardType() const;
protected:
ITable *m_table;
ITable *m_table = nullptr;
};
#endif

View File

@@ -14,7 +14,7 @@ class WaitCommand : public Command {
public:
WaitCommand(double timeout);
WaitCommand(const char *name, double timeout);
virtual ~WaitCommand() {}
virtual ~WaitCommand() = default;
protected:
virtual void Initialize();

View File

@@ -14,7 +14,7 @@ class WaitForChildren : public Command {
public:
WaitForChildren(double timeout);
WaitForChildren(const char *name, double timeout);
virtual ~WaitForChildren() {}
virtual ~WaitForChildren() = default;
protected:
virtual void Initialize();

View File

@@ -14,7 +14,7 @@ class WaitUntilCommand : public Command {
public:
WaitUntilCommand(double time);
WaitUntilCommand(const char *name, double time);
virtual ~WaitUntilCommand() {}
virtual ~WaitUntilCommand() = default;
protected:
virtual void Initialize();

View File

@@ -20,7 +20,7 @@
*/
class Controller {
public:
virtual ~Controller(){};
virtual ~Controller() = default;
/**
* Allows the control loop to run

View File

@@ -21,7 +21,6 @@ class Error {
typedef int32_t Code;
Error();
~Error();
void Clone(Error& error);
Code GetCode() const;
const char* GetMessage() const;
@@ -41,13 +40,13 @@ class Error {
private:
void Report();
Code m_code;
Code m_code = 0;
std::string m_message;
std::string m_filename;
std::string m_function;
uint32_t m_lineNumber;
const ErrorBase* m_originatingObject;
double m_timestamp;
uint32_t m_lineNumber = 0;
const ErrorBase* m_originatingObject = nullptr;
double m_timestamp = 0.0;
static bool m_suspendOnErrorEnabled;
DISALLOW_COPY_AND_ASSIGN(Error);

View File

@@ -51,7 +51,8 @@
class ErrorBase {
// TODO: Consider initializing instance variables and cleanup in destructor
public:
virtual ~ErrorBase();
ErrorBase();
virtual ~ErrorBase() = default;
virtual Error& GetError();
virtual const Error& GetError() const;
virtual void SetErrnoError(const char* contextMessage, const char* filename,
@@ -82,7 +83,6 @@ class ErrorBase {
// TODO: Replace globalError with a global list of all errors.
static MUTEX_ID _globalErrorMutex;
static Error _globalError;
ErrorBase();
private:
DISALLOW_COPY_AND_ASSIGN(ErrorBase);

View File

@@ -14,7 +14,7 @@ class GenericHID {
public:
enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
virtual ~GenericHID() {}
virtual ~GenericHID() = default;
virtual float GetX(JoystickHand hand = kRightHand) const = 0;
virtual float GetY(JoystickHand hand = kRightHand) const = 0;

View File

@@ -7,7 +7,7 @@
class HLUsageReportingInterface {
public:
virtual ~HLUsageReportingInterface(){};
virtual ~HLUsageReportingInterface() = default;
virtual void ReportScheduler() = 0;
virtual void ReportSmartDashboard() = 0;
};

View File

@@ -12,7 +12,7 @@ struct LiveWindowComponent {
std::string name;
bool isSensor;
LiveWindowComponent() {}
LiveWindowComponent() = default;
LiveWindowComponent(std::string subsystem, std::string name, bool isSensor) {
this->subsystem = subsystem;
this->name = name;
@@ -46,7 +46,7 @@ class LiveWindow {
protected:
LiveWindow();
virtual ~LiveWindow();
virtual ~LiveWindow() = default;
private:
void UpdateValues();
@@ -61,8 +61,8 @@ class LiveWindow {
Scheduler *m_scheduler;
bool m_enabled;
bool m_firstTime;
bool m_enabled = false;
bool m_firstTime = true;
};
#endif

View File

@@ -14,7 +14,7 @@ typedef void (*TimerEventHandler)(void *param);
class Notifier : public ErrorBase {
public:
Notifier(TimerEventHandler handler, void *param = NULL);
Notifier(TimerEventHandler handler, void *param = nullptr);
virtual ~Notifier();
void StartSingle(double delay);
void StartPeriodic(double period);
@@ -35,11 +35,11 @@ class Notifier : public ErrorBase {
void DeleteFromQueue(); // delete this Notifier from the timer queue
TimerEventHandler m_handler; // address of the handler
void *m_param; // a parameter to pass to the handler
double m_period; // the relative time (either periodic or single)
double m_expirationTime; // absolute expiration time for the current event
Notifier *m_nextEvent; // next Nofifier event
bool m_periodic; // true if this is a periodic event
bool m_queued; // indicates if this entry is queued
double m_period = 0; // the relative time (either periodic or single)
double m_expirationTime = 0; // absolute expiration time for the current event
Notifier *m_nextEvent = nullptr; // next Nofifier event
bool m_periodic = false; // true if this is a periodic event
bool m_queued = false; // indicates if this entry is queued
SEMAPHORE_ID m_handlerSemaphore; // held by interrupt manager task while
// handler call is in progress

View File

@@ -59,31 +59,35 @@ class PIDController : public LiveWindowSendable,
virtual void Reset() override;
virtual void InitTable(ITable *table);
virtual void InitTable(ITable *table) override;
private:
float m_P; // factor for "proportional" control
float m_I; // factor for "integral" control
float m_D; // factor for "derivative" control
float m_F; // factor for "feed forward" control
float m_maximumOutput; // |maximum output|
float m_minimumOutput; // |minimum output|
float m_maximumInput; // maximum input - limit setpoint to this
float m_minimumInput; // minimum input - limit setpoint to this
bool m_continuous; // do the endpoints wrap around? eg. Absolute encoder
bool m_enabled; // is the pid controller enabled
float m_maximumOutput = 1.0; // |maximum output|
float m_minimumOutput = -1.0; // |minimum output|
float m_maximumInput = 0; // maximum input - limit setpoint to this
float m_minimumInput = 0; // minimum input - limit setpoint to this
bool m_continuous = false; // do the endpoints wrap around? eg. Absolute encoder
bool m_enabled = false; // is the pid controller enabled
bool m_destruct; // should the calculate thread stop running
float m_prevError; // the prior sensor input (used to compute velocity)
double m_totalError; // the sum of the errors for use in the integral calc
enum { kAbsoluteTolerance, kPercentTolerance, kNoTolerance } m_toleranceType;
float m_tolerance; // the percetage or absolute error that is considered on
float m_prevError = 0; // the prior sensor input (used to compute velocity)
double m_totalError = 0; // the sum of the errors for use in the integral calc
enum {
kAbsoluteTolerance,
kPercentTolerance,
kNoTolerance
} m_toleranceType = kNoTolerance;
float m_tolerance = 0.05; // the percetage or absolute error that is considered on
// target
float m_setpoint;
float m_setpoint = 0;
float m_error;
float m_result;
float m_result = 0;
float m_period;
MUTEX_ID m_semaphore;
MUTEX_ID m_semaphore = 0;
PIDSource *m_pidInput;
PIDOutput *m_pidOutput;
@@ -94,16 +98,16 @@ class PIDController : public LiveWindowSendable,
PIDOutput *output, float period = 0.05);
static void CallCalculate(void *controller);
virtual ITable *GetTable() const;
virtual std::string GetSmartDashboardType() const;
virtual ITable *GetTable() const override;
virtual std::string GetSmartDashboardType() const override;
virtual void ValueChanged(ITable *source, const std::string &key,
EntryValue value, bool isNew);
virtual void UpdateTable();
virtual void StartLiveWindowMode();
virtual void StopLiveWindowMode();
EntryValue value, bool isNew) override;
virtual void UpdateTable() override;
virtual void StartLiveWindowMode() override;
virtual void StopLiveWindowMode() override;
protected:
ITable *m_table;
ITable *m_table = nullptr;
virtual void Calculate();
DISALLOW_COPY_AND_ASSIGN(PIDController);

View File

@@ -7,7 +7,7 @@
class RobotStateInterface {
public:
virtual ~RobotStateInterface(){};
virtual ~RobotStateInterface() = default;
virtual bool IsDisabled() const = 0;
virtual bool IsEnabled() const = 0;
virtual bool IsOperatorControl() const = 0;

View File

@@ -19,7 +19,7 @@
class SensorBase : public ErrorBase {
public:
SensorBase();
virtual ~SensorBase();
virtual ~SensorBase() = default;
static void DeleteSingletons();
static uint32_t GetDefaultSolenoidModule() { return 0; }

View File

@@ -32,8 +32,7 @@
*/
class SendableChooser : public Sendable {
public:
SendableChooser();
virtual ~SendableChooser(){};
virtual ~SendableChooser() = default;
void AddObject(const char *name, void *object);
void AddDefault(const char *name, void *object);

View File

@@ -40,9 +40,7 @@ class SmartDashboard : public SensorBase {
static void RetrieveValue(std::string keyName, ComplexData &value);
private:
SmartDashboard();
virtual ~SmartDashboard();
DISALLOW_COPY_AND_ASSIGN(SmartDashboard);
virtual ~SmartDashboard() = default;
/** The {@link NetworkTable} used by {@link SmartDashboard} */
static ITable *m_table;

View File

@@ -44,7 +44,7 @@ class Task : public ErrorBase {
private:
FUNCPTR m_function;
char* m_taskName;
TASK m_taskID;
TASK m_taskID = NULL_TASK;
uint32_t m_stackSize;
int m_priority;
bool HandleError(STATUS results);

View File

@@ -43,9 +43,9 @@ class Timer {
static constexpr double kRolloverTime = (1ll << 32) / 1e6;
private:
double m_startTime;
double m_accumulatedTime;
bool m_running;
MUTEX_ID m_semaphore;
double m_startTime = 0.0;
double m_accumulatedTime = 0.0;
bool m_running = false;
MUTEX_ID m_semaphore = nullptr;
DISALLOW_COPY_AND_ASSIGN(Timer);
};

View File

@@ -14,18 +14,18 @@
#include <string>
#define wpi_assert(condition) \
wpi_assert_impl(condition, #condition, NULL, __FILE__, __LINE__, __FUNCTION__)
wpi_assert_impl(condition, #condition, nullptr, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertWithMessage(condition, message) \
wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
__FUNCTION__)
#define wpi_assertEqual(a, b) \
wpi_assertEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__)
wpi_assertEqual_impl(a, b, #a, #b, nullptr, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertEqualWithMessage(a, b, message) \
wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqual(a, b) \
wpi_assertNotEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__)
wpi_assertNotEqual_impl(a, b, #a, #b, nullptr, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqualWithMessage(a, b, message) \
wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
__FUNCTION__)

View File

@@ -27,7 +27,7 @@ S(ChannelIndexOutOfRange, -1, "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");
S(NullParameter, -5, "A pointer parameter to a method is NULL");
S(NullParameter, -5, "A pointer parameter to a method is nullptr");
S(Timeout, -6, "A timeout has been exceeded");
S(CompassManufacturerError, -7, "Compass manufacturer doesn't match HiTechnic");
S(CompassTypeError, -8,

View File

@@ -10,7 +10,7 @@
*/
class Accelerometer {
public:
virtual ~Accelerometer(){};
virtual ~Accelerometer() = default;
enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 };

View File

@@ -15,7 +15,7 @@
*/
class Potentiometer : public PIDSource {
public:
virtual ~Potentiometer(){};
virtual ~Potentiometer() = default;
/**
* Common interface for getting the current value of a potentiometer.
*

View File

@@ -7,8 +7,6 @@
#include "Buttons/InternalButton.h"
InternalButton::InternalButton() : m_pressed(false), m_inverted(false) {}
InternalButton::InternalButton(bool inverted)
: m_pressed(inverted), m_inverted(inverted) {}

View File

@@ -13,12 +13,10 @@
#include "Buttons/ToggleButtonScheduler.h"
#include "Buttons/CancelButtonScheduler.h"
Trigger::Trigger() { m_table = NULL; }
bool Trigger::Grab() {
if (Get())
return true;
else if (m_table != NULL) {
else if (m_table != nullptr) {
// if (m_table->isConnected())//TODO is connected on button?
return m_table->GetBoolean("pressed");
/*else
@@ -28,29 +26,27 @@ bool Trigger::Grab() {
}
void Trigger::WhenActive(Command *command) {
PressedButtonScheduler *pbs =
new PressedButtonScheduler(Grab(), this, command);
auto pbs = new PressedButtonScheduler(Grab(), this, command);
pbs->Start();
}
void Trigger::WhileActive(Command *command) {
HeldButtonScheduler *hbs = new HeldButtonScheduler(Grab(), this, command);
auto hbs = new HeldButtonScheduler(Grab(), this, command);
hbs->Start();
}
void Trigger::WhenInactive(Command *command) {
ReleasedButtonScheduler *rbs =
new ReleasedButtonScheduler(Grab(), this, command);
auto rbs = new ReleasedButtonScheduler(Grab(), this, command);
rbs->Start();
}
void Trigger::CancelWhenActive(Command *command) {
CancelButtonScheduler *cbs = new CancelButtonScheduler(Grab(), this, command);
auto cbs = new CancelButtonScheduler(Grab(), this, command);
cbs->Start();
}
void Trigger::ToggleWhenActive(Command *command) {
ToggleButtonScheduler *tbs = new ToggleButtonScheduler(Grab(), this, command);
auto tbs = new ToggleButtonScheduler(Grab(), this, command);
tbs->Start();
}
@@ -58,7 +54,7 @@ std::string Trigger::GetSmartDashboardType() const { return "Button"; }
void Trigger::InitTable(ITable *table) {
m_table = table;
if (m_table != NULL) {
if (m_table != nullptr) {
m_table->PutBoolean("pressed", Get());
}
}

View File

@@ -19,46 +19,24 @@ static const char *kIsParented = "isParented";
int Command::m_commandCounter = 0;
void Command::InitCommand(const char *name, double timeout) {
m_commandID = m_commandCounter++;
m_timeout = timeout;
m_locked = false;
m_startTime = -1;
m_initialized = false;
m_running = false;
m_interruptible = true;
m_canceled = false;
m_runWhenDisabled = false;
m_parent = NULL;
m_name = name == NULL ? std::string() : name;
m_table = NULL;
}
/**
* Creates a new command.
* The name of this command will be default.
*/
Command::Command() { InitCommand(NULL, -1.0); }
Command::Command() : Command(nullptr, -1.0) {}
/**
* Creates a new command with the given name and no timeout.
* @param name the name for this command
*/
Command::Command(const char *name) {
if (name == NULL) wpi_setWPIErrorWithContext(NullParameter, "name");
InitCommand(name, -1.0);
}
Command::Command(const char *name) : Command(name, -1.0) {}
/**
* Creates a new command with the given timeout and a default name.
* @param timeout the time (in seconds) before this command "times out"
* @see Command#isTimedOut() isTimedOut()
*/
Command::Command(double timeout) {
if (timeout < 0.0)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
InitCommand(NULL, timeout);
}
Command::Command(double timeout) : Command(nullptr, timeout) {}
/**
* Creates a new command with the given name and timeout.
@@ -67,14 +45,16 @@ Command::Command(double timeout) {
* @see Command#isTimedOut() isTimedOut()
*/
Command::Command(const char *name, double timeout) {
if (name == NULL) wpi_setWPIErrorWithContext(NullParameter, "name");
if (name == nullptr) wpi_setWPIErrorWithContext(NullParameter, "name");
if (timeout < 0.0)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
InitCommand(name, timeout);
m_timeout = timeout;
m_name = name == nullptr ? std::string() : name;
}
Command::~Command() { // TODO deal with cleaning up all listeners
/*if (m_table != NULL){
/*if (m_table != nullptr){
m_table->RemoveChangeListener(kRunning, this);
}*/
}
@@ -124,7 +104,7 @@ double Command::TimeSinceInitialized() const {
void Command::Requires(Subsystem *subsystem) {
if (!AssertUnlocked("Can not add new requirement to command")) return;
if (subsystem != NULL)
if (subsystem != nullptr)
m_requirements.insert(subsystem);
else
wpi_setWPIErrorWithContext(NullParameter, "subsystem");
@@ -148,7 +128,7 @@ void Command::Removed() {
m_initialized = false;
m_canceled = false;
m_running = false;
if (m_table != NULL) m_table->PutBoolean(kRunning, false);
if (m_table != nullptr) m_table->PutBoolean(kRunning, false);
}
/**
@@ -160,7 +140,7 @@ void Command::Removed() {
*/
void Command::Start() {
LockChanges();
if (m_parent != NULL)
if (m_parent != nullptr)
wpi_setWPIErrorWithContext(
CommandIllegalUse,
"Can not start a command that is part of a command group");
@@ -173,7 +153,7 @@ void Command::Start() {
* @return whether or not the command should stay within the {@link Scheduler}.
*/
bool Command::Run() {
if (!m_runWhenDisabled && m_parent == NULL && RobotState::IsDisabled())
if (!m_runWhenDisabled && m_parent == nullptr && RobotState::IsDisabled())
Cancel();
if (IsCanceled()) return false;
@@ -255,16 +235,16 @@ bool Command::AssertUnlocked(const char *message) {
* @param parent the parent
*/
void Command::SetParent(CommandGroup *parent) {
if (parent == NULL) {
if (parent == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "parent");
} else if (m_parent != NULL) {
} else if (m_parent != nullptr) {
wpi_setWPIErrorWithContext(CommandIllegalUse,
"Can not give command to a command group after "
"already being put in a command group");
} else {
LockChanges();
m_parent = parent;
if (m_table != NULL) {
if (m_table != nullptr) {
m_table->PutBoolean(kIsParented, true);
}
}
@@ -285,7 +265,7 @@ void Command::SetParent(CommandGroup *parent) {
void Command::StartRunning() {
m_running = true;
m_startTime = -1;
if (m_table != NULL) m_table->PutBoolean(kRunning, true);
if (m_table != nullptr) m_table->PutBoolean(kRunning, true);
}
/**
@@ -308,7 +288,7 @@ bool Command::IsRunning() const { return m_running; }
* instead.</p>
*/
void Command::Cancel() {
if (m_parent != NULL)
if (m_parent != nullptr)
wpi_setWPIErrorWithContext(
CommandIllegalUse,
"Can not cancel a command that is part of a command group");
@@ -348,7 +328,7 @@ void Command::SetInterruptible(bool interruptible) {
/**
* Checks if the command requires the given {@link Subsystem}.
* @param system the system
* @return whether or not the subsystem is required (false if given NULL)
* @return whether or not the subsystem is required (false if given nullptr)
*/
bool Command::DoesRequire(Subsystem *system) const {
return m_requirements.count(system) > 0;
@@ -390,12 +370,12 @@ std::string Command::GetName() {
std::string Command::GetSmartDashboardType() const { return "Command"; }
void Command::InitTable(ITable *table) {
if (m_table != NULL) m_table->RemoveTableListener(this);
if (m_table != nullptr) m_table->RemoveTableListener(this);
m_table = table;
if (m_table != NULL) {
if (m_table != nullptr) {
m_table->PutString(kName, GetName());
m_table->PutBoolean(kRunning, IsRunning());
m_table->PutBoolean(kIsParented, m_parent != NULL);
m_table->PutBoolean(kIsParented, m_parent != nullptr);
m_table->AddTableListener(kRunning, this, false);
}
}

View File

@@ -8,20 +8,11 @@
#include "Commands/CommandGroup.h"
#include "WPIErrors.h"
/**
* Creates a new {@link CommandGroup CommandGroup}.
*/
CommandGroup::CommandGroup() { m_currentCommandIndex = -1; }
/**
* Creates a new {@link CommandGroup CommandGroup} with the given name.
* @param name the name for this command group
*/
CommandGroup::CommandGroup(const char *name) : Command(name) {
m_currentCommandIndex = -1;
}
CommandGroup::~CommandGroup() {}
CommandGroup::CommandGroup(const char *name) : Command(name) {}
/**
* Adds a new {@link Command Command} to the group. The {@link Command Command}
@@ -39,7 +30,7 @@ CommandGroup::~CommandGroup() {}
* @param command The {@link Command Command} to be added
*/
void CommandGroup::AddSequential(Command *command) {
if (command == NULL) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -52,7 +43,7 @@ void CommandGroup::AddSequential(Command *command) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter = requirements.begin();
auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -79,7 +70,7 @@ void CommandGroup::AddSequential(Command *command) {
* @param timeout The timeout (in seconds)
*/
void CommandGroup::AddSequential(Command *command, double timeout) {
if (command == NULL) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -96,7 +87,7 @@ void CommandGroup::AddSequential(Command *command, double timeout) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter = requirements.begin();
auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -126,7 +117,7 @@ void CommandGroup::AddSequential(Command *command, double timeout) {
* @param command The command to be added
*/
void CommandGroup::AddParallel(Command *command) {
if (command == NULL) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -139,7 +130,7 @@ void CommandGroup::AddParallel(Command *command) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter = requirements.begin();
auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -177,7 +168,7 @@ void CommandGroup::AddParallel(Command *command) {
* @param timeout The timeout (in seconds)
*/
void CommandGroup::AddParallel(Command *command, double timeout) {
if (command == NULL) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -194,7 +185,7 @@ void CommandGroup::AddParallel(Command *command, double timeout) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter = requirements.begin();
auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -202,7 +193,7 @@ void CommandGroup::_Initialize() { m_currentCommandIndex = -1; }
void CommandGroup::_Execute() {
CommandGroupEntry entry;
Command *cmd = NULL;
Command *cmd = nullptr;
bool firstRun = false;
if (m_currentCommandIndex == -1) {
@@ -211,7 +202,7 @@ void CommandGroup::_Execute() {
}
while ((unsigned)m_currentCommandIndex < m_commands.size()) {
if (cmd != NULL) {
if (cmd != nullptr) {
if (entry.IsTimedOut()) cmd->_Cancel();
if (cmd->Run()) {
@@ -220,13 +211,13 @@ void CommandGroup::_Execute() {
cmd->Removed();
m_currentCommandIndex++;
firstRun = true;
cmd = NULL;
cmd = nullptr;
continue;
}
}
entry = m_commands[m_currentCommandIndex];
cmd = NULL;
cmd = nullptr;
switch (entry.m_state) {
case CommandGroupEntry::kSequence_InSequence:
@@ -253,7 +244,7 @@ void CommandGroup::_Execute() {
}
// Run Children
CommandList::iterator iter = m_children.begin();
auto iter = m_children.begin();
for (; iter != m_children.end();) {
entry = *iter;
Command *child = entry.m_command;
@@ -278,7 +269,7 @@ void CommandGroup::_End() {
cmd->Removed();
}
CommandList::iterator iter = m_children.begin();
auto iter = m_children.begin();
for (; iter != m_children.end(); iter++) {
Command *cmd = iter->m_command;
cmd->_Cancel();
@@ -315,7 +306,7 @@ bool CommandGroup::IsInterruptible() const {
if (!cmd->IsInterruptible()) return false;
}
CommandList::const_iterator iter = m_children.cbegin();
auto iter = m_children.cbegin();
for (; iter != m_children.cend(); iter++) {
if (!iter->m_command->IsInterruptible()) return false;
}
@@ -324,13 +315,13 @@ bool CommandGroup::IsInterruptible() const {
}
void CommandGroup::CancelConflicts(Command *command) {
CommandList::iterator childIter = m_children.begin();
auto childIter = m_children.begin();
for (; childIter != m_children.end();) {
Command *child = childIter->m_command;
bool erased = false;
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator requirementIter = requirements.begin();
auto requirementIter = requirements.begin();
for (; requirementIter != requirements.end(); requirementIter++) {
if (child->DoesRequire(*requirementIter)) {
child->_Cancel();

View File

@@ -9,12 +9,6 @@
#include "Commands/Command.h"
CommandGroupEntry::CommandGroupEntry()
: m_timeout(-1.0), m_command(NULL), m_state(kSequence_InSequence) {}
CommandGroupEntry::CommandGroupEntry(Command *command, Sequence state)
: m_timeout(-1.0), m_command(command), m_state(state) {}
CommandGroupEntry::CommandGroupEntry(Command *command, Sequence state,
double timeout)
: m_timeout(timeout), m_command(command), m_state(state) {}

View File

@@ -16,21 +16,11 @@
#include <set>
#include <algorithm>
Scheduler *Scheduler::_instance = NULL;
Scheduler::Scheduler()
: m_buttonsLock(NULL), m_additionsLock(NULL), m_adding(false) {
Scheduler::Scheduler() {
m_buttonsLock = initializeMutexNormal();
m_additionsLock = initializeMutexNormal();
HLUsageReporting::ReportScheduler();
m_table = NULL;
m_enabled = true;
m_runningCommandsChanged = false;
toCancel = NULL;
commands = NULL;
ids = NULL;
}
Scheduler::~Scheduler() {
@@ -46,8 +36,8 @@ Scheduler::~Scheduler() {
* @return the {@link Scheduler}
*/
Scheduler *Scheduler::GetInstance() {
if (_instance == NULL) _instance = new Scheduler();
return _instance;
static Scheduler instance;
return &instance;
}
void Scheduler::SetEnabled(bool enabled) { m_enabled = enabled; }
@@ -73,7 +63,7 @@ void Scheduler::AddButton(ButtonScheduler *button) {
}
void Scheduler::ProcessCommandAddition(Command *command) {
if (command == NULL) return;
if (command == nullptr) return;
// Check to make sure no adding during adding
if (m_adding) {
@@ -83,14 +73,14 @@ void Scheduler::ProcessCommandAddition(Command *command) {
}
// Only add if not already in
CommandSet::iterator found = m_commands.find(command);
auto found = m_commands.find(command);
if (found == m_commands.end()) {
// Check that the requirements can be had
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter;
for (iter = requirements.begin(); iter != requirements.end(); iter++) {
Subsystem *lock = *iter;
if (lock->GetCurrentCommand() != NULL &&
if (lock->GetCurrentCommand() != nullptr &&
!lock->GetCurrentCommand()->IsInterruptible())
return;
}
@@ -99,7 +89,7 @@ void Scheduler::ProcessCommandAddition(Command *command) {
m_adding = true;
for (iter = requirements.begin(); iter != requirements.end(); iter++) {
Subsystem *lock = *iter;
if (lock->GetCurrentCommand() != NULL) {
if (lock->GetCurrentCommand() != nullptr) {
lock->GetCurrentCommand()->Cancel();
Remove(lock->GetCurrentCommand());
}
@@ -133,7 +123,7 @@ void Scheduler::Run() {
if (!m_enabled) return;
Synchronized sync(m_buttonsLock);
ButtonVector::reverse_iterator rButtonIter = m_buttons.rbegin();
auto rButtonIter = m_buttons.rbegin();
for (; rButtonIter != m_buttons.rend(); rButtonIter++) {
(*rButtonIter)->Execute();
}
@@ -142,7 +132,7 @@ void Scheduler::Run() {
m_runningCommandsChanged = false;
// Loop through the commands
CommandSet::iterator commandIter = m_commands.begin();
auto commandIter = m_commands.begin();
for (; commandIter != m_commands.end();) {
Command *command = *commandIter;
// Increment before potentially removing to keep the iterator valid
@@ -156,7 +146,7 @@ void Scheduler::Run() {
// Add the new things
{
Synchronized sync(m_additionsLock);
CommandVector::iterator additionsIter = m_additions.begin();
auto additionsIter = m_additions.begin();
for (; additionsIter != m_additions.end(); additionsIter++) {
ProcessCommandAddition(*additionsIter);
}
@@ -164,10 +154,10 @@ void Scheduler::Run() {
}
// Add in the defaults
Command::SubsystemSet::iterator subsystemIter = m_subsystems.begin();
auto subsystemIter = m_subsystems.begin();
for (; subsystemIter != m_subsystems.end(); subsystemIter++) {
Subsystem *lock = *subsystemIter;
if (lock->GetCurrentCommand() == NULL) {
if (lock->GetCurrentCommand() == nullptr) {
ProcessCommandAddition(lock->GetDefaultCommand());
}
lock->ConfirmCommand();
@@ -184,7 +174,7 @@ void Scheduler::Run() {
* @param system the system
*/
void Scheduler::RegisterSubsystem(Subsystem *subsystem) {
if (subsystem == NULL) {
if (subsystem == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "subsystem");
return;
}
@@ -196,7 +186,7 @@ void Scheduler::RegisterSubsystem(Subsystem *subsystem) {
* @param command the command to remove
*/
void Scheduler::Remove(Command *command) {
if (command == NULL) {
if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -204,10 +194,10 @@ void Scheduler::Remove(Command *command) {
if (!m_commands.erase(command)) return;
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter = requirements.begin();
auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) {
Subsystem *lock = *iter;
lock->SetCurrentCommand(NULL);
lock->SetCurrentCommand(nullptr);
}
command->Removed();
@@ -228,7 +218,7 @@ void Scheduler::ResetAll() {
m_buttons.clear();
m_additions.clear();
m_commands.clear();
m_table = NULL;
m_table = nullptr;
}
/**
@@ -237,7 +227,7 @@ void Scheduler::ResetAll() {
*/
void Scheduler::UpdateTable() {
CommandSet::iterator commandIter;
if (m_table != NULL) {
if (m_table != nullptr) {
// Get the list of possible commands to cancel
m_table->RetrieveValue("Cancel", *toCancel);
// m_table->RetrieveValue("Ids", *ids);

View File

@@ -15,14 +15,9 @@
* Creates a subsystem with the given name
* @param name the name of the subsystem
*/
Subsystem::Subsystem(const char *name)
: m_currentCommand(NULL),
m_defaultCommand(NULL),
m_initializedDefaultCommand(false) {
Subsystem::Subsystem(const char *name) {
m_name = name;
Scheduler::GetInstance()->RegisterSubsystem(this);
m_table = NULL;
m_currentCommandChanged = true;
}
/**
* Initialize the default command for this subsystem
@@ -47,12 +42,12 @@ void Subsystem::InitDefaultCommand() {}
* @param command the default command (or null if there should be none)
*/
void Subsystem::SetDefaultCommand(Command *command) {
if (command == NULL) {
m_defaultCommand = NULL;
if (command == nullptr) {
m_defaultCommand = nullptr;
} else {
bool found = false;
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter = requirements.begin();
auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) {
if (*iter == this) {
found = true;
@@ -68,8 +63,8 @@ void Subsystem::SetDefaultCommand(Command *command) {
m_defaultCommand = command;
}
if (m_table != NULL) {
if (m_defaultCommand != NULL) {
if (m_table != nullptr) {
if (m_defaultCommand != nullptr) {
m_table->PutBoolean("hasDefault", true);
m_table->PutString("default", m_defaultCommand->GetName());
} else {
@@ -115,8 +110,8 @@ Command *Subsystem::GetCurrentCommand() const { return m_currentCommand; }
*/
void Subsystem::ConfirmCommand() {
if (m_currentCommandChanged) {
if (m_table != NULL) {
if (m_currentCommand != NULL) {
if (m_table != nullptr) {
if (m_currentCommand != nullptr) {
m_table->PutBoolean("hasCommand", true);
m_table->PutString("command", m_currentCommand->GetName());
} else {
@@ -133,14 +128,14 @@ std::string Subsystem::GetSmartDashboardType() const { return "Subsystem"; }
void Subsystem::InitTable(ITable *table) {
m_table = table;
if (m_table != NULL) {
if (m_defaultCommand != NULL) {
if (m_table != nullptr) {
if (m_defaultCommand != nullptr) {
m_table->PutBoolean("hasDefault", true);
m_table->PutString("default", m_defaultCommand->GetName());
} else {
m_table->PutBoolean("hasDefault", false);
}
if (m_currentCommand != NULL) {
if (m_currentCommand != nullptr) {
m_table->PutBoolean("hasCommand", true);
m_table->PutString("command", m_currentCommand->GetName());
} else {

View File

@@ -23,5 +23,5 @@ void WaitForChildren::End() {}
void WaitForChildren::Interrupted() {}
bool WaitForChildren::IsFinished() {
return GetGroup() == NULL || GetGroup()->GetSize() == 0;
return GetGroup() == nullptr || GetGroup()->GetSize() == 0;
}

View File

@@ -19,10 +19,7 @@
#include "Utility.h"
bool Error::m_suspendOnErrorEnabled = false;
Error::Error()
: m_code(0), m_lineNumber(0), m_originatingObject(NULL), m_timestamp(0.0) {}
Error::~Error() {}
Error::Error() {}
void Error::Clone(Error& error) {
m_code = error.m_code;
@@ -71,7 +68,7 @@ void Error::Set(Code code, const char* contextMessage, const char* filename,
Report();
}
if (m_suspendOnErrorEnabled) suspendTask(0);
if (m_suspendOnErrorEnabled) suspendTask(nullptr);
}
void Error::Report() {
@@ -93,6 +90,6 @@ void Error::Clear() {
m_filename = "";
m_function = "";
m_lineNumber = 0;
m_originatingObject = NULL;
m_originatingObject = nullptr;
m_timestamp = 0.0;
}

View File

@@ -21,8 +21,6 @@ Error ErrorBase::_globalError;
*/
ErrorBase::ErrorBase() {}
ErrorBase::~ErrorBase() {}
/**
* @brief Retrieve the current error.
* Get the current error information associated with this sensor.
@@ -165,7 +163,7 @@ void ErrorBase::SetGlobalError(Error::Code code, const char* contextMessage,
// Set the current error information for this object.
_globalError.Set(code, contextMessage, filename, function, lineNumber,
NULL);
nullptr);
}
}
@@ -180,7 +178,7 @@ void ErrorBase::SetGlobalWPIError(const char* errorMessage,
if (_globalError.GetCode() != 0) {
_globalError.Clear();
}
_globalError.Set(-1, err, filename, function, lineNumber, NULL);
_globalError.Set(-1, err, filename, function, lineNumber, nullptr);
}
/**

View File

@@ -1,20 +1,20 @@
#include "HLUsageReporting.h"
HLUsageReportingInterface* HLUsageReporting::impl = 0;
HLUsageReportingInterface* HLUsageReporting::impl = nullptr;
void HLUsageReporting::SetImplementation(HLUsageReportingInterface* i) {
impl = i;
}
void HLUsageReporting::ReportScheduler() {
if (impl != 0) {
if (impl != nullptr) {
impl->ReportScheduler();
}
}
void HLUsageReporting::ReportSmartDashboard() {
if (impl != 0) {
if (impl != nullptr) {
impl->ReportSmartDashboard();
}
}

View File

@@ -10,9 +10,8 @@
* how many times GetInstance is called.
*/
LiveWindow *LiveWindow::GetInstance() {
static LiveWindow *instance = new LiveWindow();
return instance;
static LiveWindow instance;
return &instance;
}
/**
@@ -20,7 +19,6 @@ LiveWindow *LiveWindow::GetInstance() {
* Allocate the necessary tables.
*/
LiveWindow::LiveWindow() {
m_enabled = false;
m_liveWindowTable = NetworkTable::GetTable("LiveWindow");
m_statusTable = m_liveWindowTable->GetSubTable("~STATUS~");
m_scheduler = Scheduler::GetInstance();
@@ -39,16 +37,12 @@ void LiveWindow::SetEnabled(bool enabled) {
}
m_scheduler->SetEnabled(false);
m_scheduler->RemoveAll();
for (std::map<LiveWindowSendable *, LiveWindowComponent>::iterator it =
m_components.begin();
it != m_components.end(); ++it) {
it->first->StartLiveWindowMode();
for (auto& elem : m_components) {
elem.first->StartLiveWindowMode();
}
} else {
for (std::map<LiveWindowSendable *, LiveWindowComponent>::iterator it =
m_components.begin();
it != m_components.end(); ++it) {
it->first->StopLiveWindowMode();
for (auto& elem : m_components) {
elem.first->StopLiveWindowMode();
}
m_scheduler->SetEnabled(true);
}
@@ -56,8 +50,6 @@ void LiveWindow::SetEnabled(bool enabled) {
m_statusTable->PutBoolean("LW Enabled", m_enabled);
}
LiveWindow::~LiveWindow() {}
/**
* Add a Sensor associated with the subsystem and with call it by the given
* name.
@@ -94,7 +86,7 @@ void LiveWindow::AddSensor(std::string type, int channel,
std::ostringstream oss;
oss << type << "[" << channel << "]";
std::string types(oss.str());
char *cc = new char[types.size() + 1];
auto cc = new char[types.size() + 1];
types.copy(cc, types.size());
cc[types.size()] = '\0';
AddSensor("Ungrouped", cc, component);
@@ -111,7 +103,7 @@ void LiveWindow::AddActuator(std::string type, int channel,
std::ostringstream oss;
oss << type << "[" << channel << "]";
std::string types(oss.str());
char *cc = new char[types.size() + 1];
auto cc = new char[types.size() + 1];
types.copy(cc, types.size());
cc[types.size()] = '\0';
AddActuator("Ungrouped", cc, component);
@@ -125,7 +117,7 @@ void LiveWindow::AddActuator(std::string type, int module, int channel,
std::ostringstream oss;
oss << type << "[" << module << "," << channel << "]";
std::string types(oss.str());
char *cc = new char[types.size() + 1];
auto cc = new char[types.size() + 1];
types.copy(cc, types.size());
cc[types.size()] = '\0';
AddActuator("Ungrouped", cc, component);
@@ -137,8 +129,8 @@ void LiveWindow::AddActuator(std::string type, int module, int channel,
* SmartDashboard widgets.
*/
void LiveWindow::UpdateValues() {
for (unsigned int i = 0; i < m_sensors.size(); i++) {
m_sensors[i]->UpdateTable();
for (auto& elem : m_sensors) {
elem->UpdateTable();
}
}
@@ -164,11 +156,9 @@ void LiveWindow::Run() {
* addActuator and addSensor.
*/
void LiveWindow::InitializeLiveWindowComponents() {
for (std::map<LiveWindowSendable *, LiveWindowComponent>::iterator it =
m_components.begin();
it != m_components.end(); ++it) {
LiveWindowSendable *component = it->first;
LiveWindowComponent c = it->second;
for (auto& elem : m_components) {
LiveWindowSendable *component = elem.first;
LiveWindowComponent c = elem.second;
std::string subsystem = c.subsystem;
std::string name = c.name;
m_liveWindowTable->GetSubTable(subsystem)

View File

@@ -30,8 +30,8 @@ Resource::Resource(uint32_t elements) {
/**
* Factory method to create a Resource allocation-tracker *if* needed.
*
* @param r -- address of the caller's Resource pointer. If *r == NULL, this
* will construct a Resource and make *r point to it. If *r != NULL, i.e.
* @param r -- address of the caller's Resource pointer. If *r == nullptr, this
* will construct a Resource and make *r point to it. If *r != nullptr, i.e.
* the caller already has a Resource instance, this won't do anything.
* @param elements -- the number of elements for this Resource allocator to
* track, that is, it will allocate resource numbers in the range
@@ -40,7 +40,7 @@ Resource::Resource(uint32_t elements) {
/*static*/ void Resource::CreateResourceObject(Resource **r,
uint32_t elements) {
Synchronized sync(m_createLock);
if (*r == NULL) {
if (*r == nullptr) {
*r = new Resource(elements);
}
}

View File

@@ -1,6 +1,6 @@
#include "RobotState.h"
RobotStateInterface* RobotState::impl = 0;
RobotStateInterface* RobotState::impl = nullptr;
void RobotState::SetImplementation(RobotStateInterface* i) { impl = i; }

View File

@@ -14,8 +14,6 @@ static const char *kDefault = "default";
static const char *kOptions = "options";
static const char *kSelected = "selected";
SendableChooser::SendableChooser() { m_defaultChoice = ""; }
/**
* Adds the given object to the list of options. On the {@link SmartDashboard}
* on the desktop,
@@ -44,13 +42,13 @@ void SendableChooser::AddDefault(const char *name, void *object) {
/**
* Returns the selected option. If there is none selected, it will return the
* default. If there is none selected
* and no default, then it will return {@code NULL}.
* and no default, then it will return {@code nullptr}.
* @return the option selected
*/
void *SendableChooser::GetSelected() {
std::string selected = m_table->GetString(kSelected, m_defaultChoice);
if (selected == "")
return NULL;
return nullptr;
else
return m_choices[selected];
}
@@ -58,7 +56,7 @@ void *SendableChooser::GetSelected() {
void SendableChooser::InitTable(ITable *subtable) {
StringArray keys;
m_table = subtable;
if (m_table != NULL) {
if (m_table != nullptr) {
std::map<std::string, void *>::iterator iter;
for (iter = m_choices.begin(); iter != m_choices.end(); iter++) {
keys.add(iter->first);

View File

@@ -13,7 +13,7 @@
#include "networktables/NetworkTable.h"
#include "HLUsageReporting.h"
ITable *SmartDashboard::m_table = NULL;
ITable *SmartDashboard::m_table = nullptr;
std::map<ITable *, Sendable *> SmartDashboard::m_tablesToData;
void SmartDashboard::init() {
@@ -24,14 +24,14 @@ void SmartDashboard::init() {
/**
* Maps the specified key to the specified value in this table.
* The key can not be NULL.
* The key can not be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key
* @param value the value
*/
void SmartDashboard::PutData(std::string key, Sendable *data) {
if (data == NULL) {
if (data == nullptr) {
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
return;
}
@@ -50,7 +50,7 @@ void SmartDashboard::PutData(std::string key, Sendable *data) {
* @param value the value
*/
void SmartDashboard::PutData(NamedSendable *value) {
if (value == NULL) {
if (value == nullptr) {
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
return;
}
@@ -65,9 +65,9 @@ void SmartDashboard::PutData(NamedSendable *value) {
Sendable *SmartDashboard::GetData(std::string key) {
ITable *subtable = m_table->GetSubTable(key);
Sendable *data = m_tablesToData[subtable];
if (data == NULL) {
if (data == nullptr) {
wpi_setGlobalWPIErrorWithContext(SmartDashboardMissingKey, key.c_str());
return NULL;
return nullptr;
}
return data;
}
@@ -75,7 +75,7 @@ Sendable *SmartDashboard::GetData(std::string key) {
/**
* Maps the specified key to the specified complex value (such as an array) in
* this table.
* The key can not be NULL.
* The key can not be nullptr.
* The value can be retrieved by calling the RetrieveValue method with a key
* that is equal to the original key.
* @param keyName the key
@@ -88,7 +88,7 @@ void SmartDashboard::PutValue(std::string keyName, ComplexData &value) {
/**
* Retrieves the complex value (such as an array) in this table into the complex
* data object
* The key can not be NULL.
* The key can not be nullptr.
* @param keyName the key
* @param value the object to retrieve the value into
*/
@@ -98,7 +98,7 @@ void SmartDashboard::RetrieveValue(std::string keyName, ComplexData &value) {
/**
* Maps the specified key to the specified value in this table.
* The key can not be NULL.
* The key can not be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key
@@ -130,7 +130,7 @@ bool SmartDashboard::GetBoolean(std::string keyName, bool defaultValue) {
/**
* Maps the specified key to the specified value in this table.
* The key can not be NULL.
* The key can not be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key
@@ -162,7 +162,7 @@ double SmartDashboard::GetNumber(std::string keyName, double defaultValue) {
/**
* Maps the specified key to the specified value in this table.
* Neither the key nor the value can be NULL.
* Neither the key nor the value can be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key

View File

@@ -51,7 +51,7 @@ class ADXL345_I2C : public Accelerometer,
public:
explicit ADXL345_I2C(Port port, Range range = kRange_2G);
virtual ~ADXL345_I2C();
virtual ~ADXL345_I2C() = default;
// Accelerometer interface
virtual void SetRange(Range range) override;
@@ -69,8 +69,6 @@ class ADXL345_I2C : public Accelerometer,
virtual void StartLiveWindowMode() override {}
virtual void StopLiveWindowMode() override {}
protected:
// I2C* m_i2c;
private:
ITable *m_table;
};

View File

@@ -43,9 +43,9 @@ class AnalogAccelerometer : public SensorBase,
void InitAccelerometer();
AnalogInput *m_AnalogInput;
float m_voltsPerG;
float m_zeroGVoltage;
float m_voltsPerG = 1.0;
float m_zeroGVoltage = 2.5;
bool m_allocatedChannel;
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -75,10 +75,9 @@ class AnalogInput : public SensorBase,
ITable *GetTable() const override;
private:
void InitAnalogInput(uint32_t channel);
uint32_t m_channel;
void *m_port;
int64_t m_accumulatorOffset;
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -30,9 +30,8 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable {
ITable *GetTable() const override;
protected:
void InitAnalogOutput(uint32_t channel);
uint32_t m_channel;
void *m_port;
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -30,8 +30,6 @@ class AnalogTrigger : public SensorBase {
AnalogTriggerOutput *CreateOutput(AnalogTriggerType type);
private:
void InitTrigger(uint32_t channel);
uint8_t m_index;
void *m_trigger;
};

View File

@@ -19,7 +19,7 @@ class BuiltInAccelerometer : public Accelerometer,
public LiveWindowSendable {
public:
BuiltInAccelerometer(Range range = kRange_8G);
virtual ~BuiltInAccelerometer();
virtual ~BuiltInAccelerometer() = default;
// Accelerometer interface
virtual void SetRange(Range range) override;
@@ -35,5 +35,5 @@ class BuiltInAccelerometer : public Accelerometer,
virtual void StopLiveWindowMode() override {}
private:
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -16,6 +16,7 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "tables/ITable.h"
#include "NetworkCommunication/CANSessionMux.h"
#include "CAN/can_proto.h"
#include <atomic>
#include <mutex>
@@ -170,64 +171,64 @@ class CANJaguar : public MotorSafety,
mutable std::recursive_mutex m_mutex;
uint8_t m_deviceNumber;
float m_value;
float m_value = 0.0f;
// Parameters/configuration
ControlMode m_controlMode;
uint8_t m_speedReference;
uint8_t m_positionReference;
double m_p;
double m_i;
double m_d;
NeutralMode m_neutralMode;
uint16_t m_encoderCodesPerRev;
uint16_t m_potentiometerTurns;
LimitMode m_limitMode;
double m_forwardLimit;
double m_reverseLimit;
double m_maxOutputVoltage;
double m_voltageRampRate;
float m_faultTime;
uint8_t m_speedReference = LM_REF_NONE;
uint8_t m_positionReference = LM_REF_NONE;
double m_p = 0.0;
double m_i = 0.0;
double m_d = 0.0;
NeutralMode m_neutralMode = kNeutralMode_Jumper;
uint16_t m_encoderCodesPerRev = 0;
uint16_t m_potentiometerTurns = 0;
LimitMode m_limitMode = kLimitMode_SwitchInputsOnly;
double m_forwardLimit = 0.0;
double m_reverseLimit = 0.0;
double m_maxOutputVoltage = 30.0;
double m_voltageRampRate = 0.0;
float m_faultTime = 0.0f;
// Which parameters have been verified since they were last set?
bool m_controlModeVerified;
bool m_speedRefVerified;
bool m_posRefVerified;
bool m_pVerified;
bool m_iVerified;
bool m_dVerified;
bool m_neutralModeVerified;
bool m_encoderCodesPerRevVerified;
bool m_potentiometerTurnsVerified;
bool m_forwardLimitVerified;
bool m_reverseLimitVerified;
bool m_limitModeVerified;
bool m_maxOutputVoltageVerified;
bool m_voltageRampRateVerified;
bool m_faultTimeVerified;
bool m_controlModeVerified = false; // Needs to be verified because it's set in the constructor
bool m_speedRefVerified = true;
bool m_posRefVerified = true;
bool m_pVerified = true;
bool m_iVerified = true;
bool m_dVerified = true;
bool m_neutralModeVerified = true;
bool m_encoderCodesPerRevVerified = true;
bool m_potentiometerTurnsVerified = true;
bool m_forwardLimitVerified = true;
bool m_reverseLimitVerified = true;
bool m_limitModeVerified = true;
bool m_maxOutputVoltageVerified = true;
bool m_voltageRampRateVerified = true;
bool m_faultTimeVerified = true;
// Status data
mutable float m_busVoltage;
mutable float m_outputVoltage;
mutable float m_outputCurrent;
mutable float m_temperature;
mutable double m_position;
mutable double m_speed;
mutable uint8_t m_limits;
mutable uint16_t m_faults;
uint32_t m_firmwareVersion;
uint8_t m_hardwareVersion;
mutable float m_busVoltage = 0.0f;
mutable float m_outputVoltage = 0.0f;
mutable float m_outputCurrent = 0.0f;
mutable float m_temperature = 0.0f;
mutable double m_position = 0.0;
mutable double m_speed = 0.0;
mutable uint8_t m_limits = 0x00;
mutable uint16_t m_faults = 0x0000;
uint32_t m_firmwareVersion = 0;
uint8_t m_hardwareVersion = 0;
// Which periodic status messages have we received at least once?
mutable std::atomic<bool> m_receivedStatusMessage0;
mutable std::atomic<bool> m_receivedStatusMessage1;
mutable std::atomic<bool> m_receivedStatusMessage2;
mutable std::atomic<bool> m_receivedStatusMessage0{false};
mutable std::atomic<bool> m_receivedStatusMessage1{false};
mutable std::atomic<bool> m_receivedStatusMessage2{false};
bool m_controlEnabled;
void verify();
MotorSafetyHelper *m_safetyHelper;
MotorSafetyHelper *m_safetyHelper = nullptr;
void ValueChanged(ITable *source, const std::string &key, EntryValue value,
bool isNew) override;
@@ -238,9 +239,9 @@ class CANJaguar : public MotorSafety,
void InitTable(ITable *subTable) override;
ITable *GetTable() const override;
ITable *m_table;
ITable *m_table = nullptr;
private:
void InitCANJaguar();
bool m_isInverted;
bool m_isInverted = false;
};

View File

@@ -66,7 +66,7 @@ class CANTalon : public MotorSafety,
virtual void SetSetpoint(float value) override;
virtual void Disable() override;
virtual void EnableControl();
virtual void Enable();
virtual void Enable() override;
virtual void SetP(double p) override;
virtual void SetI(double i) override;
virtual void SetD(double d) override;
@@ -183,14 +183,14 @@ class CANTalon : public MotorSafety,
int m_deviceNumber;
CanTalonSRX *m_impl;
MotorSafetyHelper *m_safetyHelper;
int m_profile; // Profile from CANTalon to use. Set to zero until we can
// actually test this.
int m_profile = 0; // Profile from CANTalon to use. Set to zero until we can
// actually test this.
bool m_controlEnabled;
ControlMode m_controlMode;
bool m_controlEnabled = true;
ControlMode m_controlMode = kPercentVbus;
TalonControlMode m_sendMode;
double m_setPoint;
double m_setPoint = 0;
static const unsigned int kDelayForSolicitedSignalsUs = 4000;
/**
* Fixup the sendMode so Set() serializes the correct demand value.

View File

@@ -55,8 +55,6 @@ class CameraServer : public ErrorBase {
uint32_t size;
};
static CameraServer* s_instance;
public:
static CameraServer* GetInstance();
void SetImage(Image const* image);

View File

@@ -19,9 +19,9 @@ class Compressor : public SensorBase,
public LiveWindowSendable,
public ITableListener {
public:
explicit Compressor(uint8_t pcmID);
Compressor();
virtual ~Compressor();
// Default PCM ID is 0
explicit Compressor(uint8_t pcmID = GetDefaultSolenoidModule());
virtual ~Compressor() = default;
void Start();
void Stop();
@@ -49,16 +49,15 @@ class Compressor : public SensorBase,
void InitTable(ITable *subTable) override;
ITable *GetTable() const override;
void ValueChanged(ITable *source, const std::string &key, EntryValue value,
bool isNew);
bool isNew) override;
protected:
void *m_pcm_pointer;
private:
void InitCompressor(uint8_t module);
void SetCompressor(bool on);
ITable *m_table;
ITable *m_table = nullptr;
};
#endif /* Compressor_H_ */

View File

@@ -27,7 +27,7 @@ class Counter : public SensorBase,
public CounterBase,
public LiveWindowSendable {
public:
Counter();
explicit Counter(Mode mode = kTwoPulse);
explicit Counter(int32_t channel);
explicit Counter(DigitalSource *source);
explicit Counter(DigitalSource &source);
@@ -83,15 +83,13 @@ class Counter : public SensorBase,
ITable *GetTable() const override;
protected:
DigitalSource *m_upSource; ///< What makes the counter count up.
DigitalSource *m_downSource; ///< What makes the counter count down.
void *m_counter; ///< The FPGA counter object.
DigitalSource *m_upSource = nullptr; ///< What makes the counter count up.
DigitalSource *m_downSource = nullptr; ///< What makes the counter count down.
void *m_counter = nullptr; ///< The FPGA counter object.
private:
void InitCounter(Mode mode = kTwoPulse);
bool m_allocatedUpSource = false; ///< Was the upSource allocated locally?
bool m_allocatedDownSource = false; ///< Was the downSource allocated locally?
uint32_t m_index = 0; ///< The index of this counter.
bool m_allocatedUpSource; ///< Was the upSource allocated locally?
bool m_allocatedDownSource; ///< Was the downSource allocated locally?
uint32_t m_index; ///< The index of this counter.
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -20,7 +20,7 @@ class CounterBase {
public:
enum EncodingType { k1X, k2X, k4X };
virtual ~CounterBase() {}
virtual ~CounterBase() = default;
virtual int32_t Get() const = 0;
virtual void Reset() = 0;
virtual double GetPeriod() const = 0;

View File

@@ -39,9 +39,8 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
ITable *GetTable() const;
private:
void InitDigitalInput(uint32_t channel);
uint32_t m_channel;
bool m_lastValue;
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -46,10 +46,8 @@ class DigitalOutput : public DigitalSource,
ITable *GetTable() const;
private:
void InitDigitalOutput(uint32_t channel);
uint32_t m_channel;
void *m_pwmGenerator;
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -20,7 +20,7 @@
*/
class DigitalSource : public InterruptableSensorBase {
public:
virtual ~DigitalSource();
virtual ~DigitalSource() = default;
virtual uint32_t GetChannelForRouting() const = 0;
virtual uint32_t GetModuleForRouting() const = 0;
virtual bool GetAnalogTriggerForRouting() const = 0;

View File

@@ -42,12 +42,10 @@ class DoubleSolenoid : public SolenoidBase,
ITable* GetTable() const;
private:
virtual void InitSolenoid();
uint32_t m_forwardChannel; ///< The forward channel on the module to control.
uint32_t m_reverseChannel; ///< The reverse channel on the module to control.
uint8_t m_forwardMask; ///< The mask for the forward channel.
uint8_t m_reverseMask; ///< The mask for the reverse channel.
ITable* m_table;
ITable* m_table = nullptr;
};

View File

@@ -97,15 +97,15 @@ class DriverStation : public SensorBase, public RobotStateInterface {
HALJoystickPOVs m_joystickPOVs[kJoystickPorts];
HALJoystickButtons m_joystickButtons[kJoystickPorts];
HALJoystickDescriptor m_joystickDescriptor[kJoystickPorts];
Task m_task;
SEMAPHORE_ID m_newControlData;
MULTIWAIT_ID m_packetDataAvailableMultiWait;
Task m_task{"DriverStation", (FUNCPTR)DriverStation::InitTask};
SEMAPHORE_ID m_newControlData = 0;
MULTIWAIT_ID m_packetDataAvailableMultiWait = 0;
MUTEX_ID m_packetDataAvailableMutex;
MULTIWAIT_ID m_waitForDataSem;
MULTIWAIT_ID m_waitForDataSem = 0;
MUTEX_ID m_waitForDataMutex;
bool m_userInDisabled;
bool m_userInAutonomous;
bool m_userInTeleop;
bool m_userInTest;
double m_nextMessageTime;
bool m_userInDisabled = false;
bool m_userInAutonomous = false;
bool m_userInTeleop = false;
bool m_userInTest = false;
double m_nextMessageTime = 0;
};

View File

@@ -96,14 +96,14 @@ class Encoder : public SensorBase,
DigitalSource *m_bSource; // the B phase of the quad encoder
bool m_allocatedASource; // was the A source allocated locally?
bool m_allocatedBSource; // was the B source allocated locally?
void *m_encoder;
int32_t m_index; // The encoder's FPGA index.
double m_distancePerPulse; // distance of travel for each encoder tick
Counter *m_counter; // Counter object for 1x and 2x encoding
EncodingType m_encodingType; // Encoding type
int32_t m_encodingScale; // 1x, 2x, or 4x, per the encodingType
void *m_encoder = nullptr;
int32_t m_index = 0; // The encoder's FPGA index.
double m_distancePerPulse = 1.0; // distance of travel for each encoder tick
Counter *m_counter = nullptr; // Counter object for 1x and 2x encoding
EncodingType m_encodingType; // Encoding type
int32_t m_encodingScale; // 1x, 2x, or 4x, per the encodingType
PIDSourceParameter
m_pidSource; // Encoder parameter that sources a PID controller
m_pidSource = kDistance; // Encoder parameter that sources a PID controller
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -23,7 +23,7 @@ class GearTooth : public Counter {
GearTooth(uint32_t channel, bool directionSensitive = false);
GearTooth(DigitalSource *source, bool directionSensitive = false);
GearTooth(DigitalSource &source, bool directionSensitive = false);
virtual ~GearTooth();
virtual ~GearTooth() = default;
void EnableDirectionSensing(bool directionSensitive);
virtual std::string GetSmartDashboardType() const override;

View File

@@ -68,5 +68,5 @@ class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable {
uint32_t m_center;
PIDSourceParameter m_pidSource;
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -20,7 +20,7 @@ class InterruptableSensorBase : public SensorBase {
};
InterruptableSensorBase();
virtual ~InterruptableSensorBase();
virtual ~InterruptableSensorBase() = default;
virtual uint32_t GetChannelForRouting() const = 0;
virtual uint32_t GetModuleForRouting() const = 0;
virtual bool GetAnalogTriggerForRouting() const = 0;
@@ -42,7 +42,7 @@ class InterruptableSensorBase : public SensorBase {
virtual void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
protected:
void *m_interrupt;
void *m_interrupt = nullptr;
uint32_t m_interruptIndex;
void AllocateInterrupts(bool watcher);

View File

@@ -72,12 +72,12 @@ class IterativeRobot : public RobotBase {
protected:
virtual void Prestart();
virtual ~IterativeRobot();
virtual ~IterativeRobot() = default;
IterativeRobot();
private:
bool m_disabledInitialized;
bool m_autonomousInitialized;
bool m_teleopInitialized;
bool m_testInitialized;
bool m_disabledInitialized = false;
bool m_autonomousInitialized = false;
bool m_teleopInitialized = false;
bool m_testInitialized = false;
};

View File

@@ -16,16 +16,15 @@
class Jaguar : public SafePWM, public SpeedController {
public:
explicit Jaguar(uint32_t channel);
virtual ~Jaguar();
virtual void Set(float value, uint8_t syncGroup = 0);
virtual float Get() const;
virtual void Disable();
virtual ~Jaguar() = default;
virtual void Set(float value, uint8_t syncGroup = 0) override;
virtual float Get() const override;
virtual void Disable() override;
virtual void PIDWrite(float output) override;
virtual void SetInverted(bool isInverted) override;
virtual bool GetInverted() const override;
private:
void InitJaguar();
bool m_isInverted;
bool m_isInverted = false;
};

View File

@@ -102,15 +102,14 @@ class Joystick : public GenericHID, public ErrorBase {
private:
DISALLOW_COPY_AND_ASSIGN(Joystick);
void InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes);
DriverStation *m_ds;
DriverStation *m_ds = nullptr;
uint32_t m_port;
uint32_t *m_axes;
uint32_t *m_buttons;
uint32_t m_outputs;
uint16_t m_leftRumble;
uint16_t m_rightRumble;
uint32_t *m_axes = nullptr;
uint32_t *m_buttons = nullptr;
uint32_t m_outputs = 0;
uint16_t m_leftRumble = 0;
uint16_t m_rightRumble = 0;
};
#endif

View File

@@ -31,7 +31,7 @@ class CANInterfacePlugin {
* @param messageID The 29-bit CAN message ID in the lsbs. The msb can
* indicate a remote frame.
* @param data A pointer to a buffer containing between 0 and 8 bytes to send
* with the message. May be NULL if dataSize is 0.
* with the message. May be nullptr if dataSize is 0.
* @param dataSize The number of bytes to send with the message.
* @return Return any error code. On success return 0.
*/
@@ -101,7 +101,7 @@ class CANInterfacePlugin {
*
* @param interface A pointer to an object that inherits from CANInterfacePlugin
* and implements
* the pure virtual interface. If NULL, unregister the current plugin.
* the pure virtual interface. If nullptr, unregister the current plugin.
*/
void FRC_NetworkCommunication_CANSessionMux_registerInterface(
CANInterfacePlugin *interface);

View File

@@ -128,7 +128,7 @@ typedef enum {
* change the feature string.
*/
uint32_t EXPORT_FUNC report(tResourceType resource, uint8_t instanceNumber,
uint8_t context = 0, const char *feature = NULL);
uint8_t context = 0, const char *feature = nullptr);
}
#ifdef __cplusplus

View File

@@ -106,10 +106,9 @@ class PWM : public SensorBase,
void InitTable(ITable* subTable) override;
ITable* GetTable() const override;
ITable* m_table;
ITable* m_table = nullptr;
private:
void InitPWM(uint32_t channel);
uint32_t m_channel;
int32_t GetMaxPositivePwm() const { return m_maxPwm; }
int32_t GetMinPositivePwm() const {

View File

@@ -40,7 +40,7 @@ class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
ITable *GetTable() const override;
private:
ITable *m_table;
ITable *m_table = nullptr;
uint8_t m_module;
};

View File

@@ -82,14 +82,12 @@ class Preferences : public ErrorBase, public ITableListener {
return 0;
}
static Preferences *_instance;
/** The semaphore for accessing the file */
MUTEX_ID m_fileLock;
MUTEX_ID m_fileLock = nullptr;
/** The semaphore for beginning reads and writes to the file */
SEMAPHORE_ID m_fileOpStarted;
SEMAPHORE_ID m_fileOpStarted = nullptr;
/** The semaphore for reading from the table */
MUTEX_ID m_tableLock;
MUTEX_ID m_tableLock = nullptr;
typedef std::map<std::string, std::string> StringMap;
/** The actual values (String->String) */
StringMap m_values;

View File

@@ -47,11 +47,9 @@ class Relay : public SensorBase,
void InitTable(ITable* subTable) override;
ITable* GetTable() const override;
ITable* m_table;
ITable* m_table = nullptr;
private:
void InitRelay();
uint32_t m_channel;
Direction m_direction;
};

View File

@@ -61,8 +61,8 @@ class RobotBase {
virtual void Prestart();
Task *m_task;
DriverStation *m_ds;
Task *m_task = nullptr;
DriverStation *m_ds = nullptr;
private:
static RobotBase *m_instance;

View File

@@ -97,15 +97,15 @@ class RobotDrive : public MotorSafety, public ErrorBase {
void RotateVector(double &x, double &y, double angle);
static const int32_t kMaxNumberOfMotors = 4;
float m_sensitivity;
double m_maxOutput;
float m_sensitivity = 0.5;
double m_maxOutput = 1.0;
bool m_deleteSpeedControllers;
SpeedController *m_frontLeftMotor;
SpeedController *m_frontRightMotor;
SpeedController *m_rearLeftMotor;
SpeedController *m_rearRightMotor;
MotorSafetyHelper *m_safetyHelper;
uint8_t m_syncGroup;
SpeedController *m_frontLeftMotor = nullptr;
SpeedController *m_frontRightMotor = nullptr;
SpeedController *m_rearLeftMotor = nullptr;
SpeedController *m_rearRightMotor = nullptr;
MotorSafetyHelper *m_safetyHelper = nullptr;
uint8_t m_syncGroup = 0;
private:
int32_t GetNumMotors() {

View File

@@ -36,6 +36,5 @@ class SafePWM : public PWM, public MotorSafety {
virtual void SetSpeed(float speed);
private:
void InitSafePWM();
MotorSafetyHelper *m_safetyHelper;
};

View File

@@ -11,7 +11,7 @@
class SampleRobot : public RobotBase {
public:
SampleRobot();
virtual ~SampleRobot() {}
virtual ~SampleRobot() = default;
virtual void RobotInit();
virtual void Disabled();
virtual void Autonomous();

View File

@@ -62,9 +62,9 @@ class SerialPort : public ErrorBase {
void Reset();
private:
uint32_t m_resourceManagerHandle;
uint32_t m_portHandle;
bool m_consoleModeEnabled;
uint32_t m_resourceManagerHandle = 0;
uint32_t m_portHandle = 0;
bool m_consoleModeEnabled = false;
uint8_t m_port;
DISALLOW_COPY_AND_ASSIGN(SerialPort);

View File

@@ -37,10 +37,9 @@ class Servo : public SafePWM {
void InitTable(ITable* subTable) override;
ITable* GetTable() const override;
ITable* m_table;
ITable* m_table = nullptr;
private:
void InitServo();
float GetServoAngleRange() const { return kMaxServoAngle - kMinServoAngle; }
static constexpr float kMaxServoAngle = 180.0;

View File

@@ -38,8 +38,6 @@ class Solenoid : public SolenoidBase,
ITable* GetTable() const;
private:
void InitSolenoid();
uint32_t m_channel; ///< The channel on the module to control.
ITable* m_table;
ITable* m_table = nullptr;
};

View File

@@ -18,7 +18,7 @@
*/
class SolenoidBase : public SensorBase {
public:
virtual ~SolenoidBase();
virtual ~SolenoidBase() = default;
uint8_t GetAll(int module = 0) const;
uint8_t GetPCMSolenoidBlackList(int module) const;
@@ -29,7 +29,6 @@ class SolenoidBase : public SensorBase {
protected:
explicit SolenoidBase(uint8_t pcmID);
void Set(uint8_t value, uint8_t mask, int module);
virtual void InitSolenoid() = 0;
const static int m_maxModules = 63;
const static int m_maxPorts = 8;
static void* m_ports[m_maxModules][m_maxPorts];

View File

@@ -14,7 +14,7 @@
*/
class SpeedController : public PIDOutput {
public:
virtual ~SpeedController() {}
virtual ~SpeedController() = default;
/**
* Common interface for setting the speed of a speed controller.
*

View File

@@ -16,16 +16,15 @@
class Talon : public SafePWM, public SpeedController {
public:
explicit Talon(uint32_t channel);
virtual ~Talon();
virtual void Set(float value, uint8_t syncGroup = 0);
virtual float Get() const;
virtual void Disable();
virtual ~Talon() = default;
virtual void Set(float value, uint8_t syncGroup = 0) override;
virtual float Get() const override;
virtual void Disable() override;
virtual void PIDWrite(float output) override;
virtual void SetInverted(bool isInverted) override;
virtual bool GetInverted() const override;
private:
void InitTalon();
bool m_isInverted;
bool m_isInverted = false;
};

View File

@@ -17,7 +17,7 @@
class TalonSRX : public SafePWM, public SpeedController {
public:
explicit TalonSRX(uint32_t channel);
virtual ~TalonSRX();
virtual ~TalonSRX() = default;
virtual void Set(float value, uint8_t syncGroup = 0) override;
virtual float Get() const override;
virtual void Disable() override;
@@ -27,6 +27,5 @@ class TalonSRX : public SafePWM, public SpeedController {
virtual bool GetInverted() const override;
private:
void InitTalonSRX();
bool m_isInverted;
bool m_isInverted = false;
};

View File

@@ -36,26 +36,30 @@ class USBCamera : public ErrorBase {
static constexpr char const *ATTR_BR_VALUE =
"CameraAttributes::Brightness::Value";
// Constants for the manual and auto types
static constexpr char const* AUTO = "Auto";
static constexpr char const* MANUAL = "Manual";
protected:
IMAQdxSession m_id;
IMAQdxSession m_id = 0;
std::string m_name;
bool m_useJpeg;
bool m_active;
bool m_open;
bool m_active = false;
bool m_open = false;
std::recursive_mutex m_mutex;
unsigned int m_width;
unsigned int m_height;
double m_fps;
std::string m_whiteBalance;
unsigned int m_whiteBalanceValue;
bool m_whiteBalanceValuePresent;
std::string m_exposure;
unsigned int m_exposureValue;
bool m_exposureValuePresent;
unsigned int m_brightness;
bool m_needSettingsUpdate;
unsigned int m_width = 320;
unsigned int m_height = 240;
double m_fps = 30;
std::string m_whiteBalance = AUTO;
unsigned int m_whiteBalanceValue = 0;
bool m_whiteBalanceValuePresent = false;
std::string m_exposure = MANUAL;
unsigned int m_exposureValue = 50;
bool m_exposureValuePresent = false;
unsigned int m_brightness = 80;
bool m_needSettingsUpdate = true;
unsigned int GetJpegSize(void *buffer, unsigned int buffSize);

View File

@@ -90,5 +90,5 @@ class Ultrasonic : public SensorBase,
Ultrasonic *m_nextSensor;
DistanceUnit m_units;
ITable *m_table;
ITable *m_table = nullptr;
};

View File

@@ -19,10 +19,10 @@
class Victor : public SafePWM, public SpeedController {
public:
explicit Victor(uint32_t channel);
virtual ~Victor();
virtual void Set(float value, uint8_t syncGroup = 0);
virtual float Get() const;
virtual void Disable();
virtual ~Victor() = default;
virtual void Set(float value, uint8_t syncGroup = 0) override;
virtual float Get() const override;
virtual void Disable() override;
virtual void PIDWrite(float output) override;
@@ -30,6 +30,5 @@ class Victor : public SafePWM, public SpeedController {
virtual bool GetInverted() const override;
private:
void InitVictor();
bool m_isInverted;
bool m_isInverted = false;
};

Some files were not shown because too many files have changed in this diff Show More