mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Use units for new NotifierCommand (#1869)
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
NotifierCommand::NotifierCommand(std::function<void()> toRun, double period,
|
||||
NotifierCommand::NotifierCommand(std::function<void()> toRun,
|
||||
units::second_t period,
|
||||
std::initializer_list<Subsystem*> requirements)
|
||||
: m_toRun(toRun), m_notifier{std::move(toRun)}, m_period{period} {
|
||||
AddRequirements(requirements);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <frc/Notifier.h>
|
||||
|
||||
#include <units/units.h>
|
||||
|
||||
#include "CommandBase.h"
|
||||
#include "CommandHelper.h"
|
||||
|
||||
@@ -29,10 +31,10 @@ class NotifierCommand : public CommandHelper<CommandBase, NotifierCommand> {
|
||||
* Creates a new NotifierCommand.
|
||||
*
|
||||
* @param toRun the runnable for the notifier to run
|
||||
* @param period the period at which the notifier should run, in seconds
|
||||
* @param period the period at which the notifier should run
|
||||
* @param requirements the subsystems required by this command
|
||||
*/
|
||||
NotifierCommand(std::function<void()> toRun, double period,
|
||||
NotifierCommand(std::function<void()> toRun, units::second_t period,
|
||||
std::initializer_list<Subsystem*> requirements);
|
||||
|
||||
NotifierCommand(NotifierCommand&& other);
|
||||
@@ -46,6 +48,6 @@ class NotifierCommand : public CommandHelper<CommandBase, NotifierCommand> {
|
||||
private:
|
||||
std::function<void()> m_toRun;
|
||||
frc::Notifier m_notifier;
|
||||
double m_period;
|
||||
units::second_t m_period;
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
@@ -20,7 +20,7 @@ TEST_F(NotifierCommandTest, NotifierCommandScheduleTest) {
|
||||
|
||||
int counter = 0;
|
||||
|
||||
NotifierCommand command([&counter] { counter++; }, 0.01, {});
|
||||
NotifierCommand command([&counter] { counter++; }, 0.01_s, {});
|
||||
|
||||
scheduler.Schedule(&command);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
||||
|
||||
Reference in New Issue
Block a user