WPILibC++  2020.3.2
NotifierCommand.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <functional>
11 #include <initializer_list>
12 
13 #include <frc/Notifier.h>
14 #include <units/units.h>
15 #include <wpi/ArrayRef.h>
16 
17 #include "frc2/command/CommandBase.h"
18 #include "frc2/command/CommandHelper.h"
19 
20 namespace frc2 {
31 class NotifierCommand : public CommandHelper<CommandBase, NotifierCommand> {
32  public:
40  NotifierCommand(std::function<void()> toRun, units::second_t period,
41  std::initializer_list<Subsystem*> requirements);
42 
50  NotifierCommand(std::function<void()> toRun, units::second_t period,
51  wpi::ArrayRef<Subsystem*> requirements = {});
52 
54 
55  NotifierCommand(const NotifierCommand& other);
56 
57  void Initialize() override;
58 
59  void End(bool interrupted) override;
60 
61  private:
62  std::function<void()> m_toRun;
63  frc::Notifier m_notifier;
64  units::second_t m_period;
65 };
66 } // namespace frc2
frc2::NotifierCommand::End
void End(bool interrupted) override
The action to take when the command ends.
wpi::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:42
frc2::NotifierCommand
A command that starts a notifier to run the given runnable periodically in a separate thread.
Definition: NotifierCommand.h:31
frc2::CommandHelper
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
frc2::NotifierCommand::Initialize
void Initialize() override
The initial subroutine of a command.
frc2::NotifierCommand::NotifierCommand
NotifierCommand(std::function< void()> toRun, units::second_t period, std::initializer_list< Subsystem * > requirements)
Creates a new NotifierCommand.
frc::Notifier
Definition: Notifier.h:27