RIT VEXU Core API
Loading...
Searching...
No Matches
command_controller.h
1
10#pragma once
11#include "../core/include/utils/command_structure/auto_command.h"
12#include <queue>
13#include <vector>
14
16public:
19 [[deprecated("Empty constructor is bad. Use list constructor "
20 "instead.")]] CommandController()
21 : command_queue({}) {}
22
26 CommandController(std::initializer_list<AutoCommand *> cmds) : command_queue(cmds) {}
33 [[deprecated("Use list constructor instead. If you need to make a decision before adding new commands, use Branch "
34 "(https://github.com/RIT-VEX-U/Core/wiki/3-%7C-Utilites#commandcontroller)")]] void
35 add(std::vector<AutoCommand *> cmds);
36 void add(AutoCommand *cmd, double timeout_seconds = 10.0);
37
49 [[deprecated("Use list constructor instead. If you need to make a decision before adding new commands, use Branch "
50 "(https://github.com/RIT-VEX-U/Core/wiki/3-%7C-Utilites#commandcontroller)")]] void
51 add(std::vector<AutoCommand *> cmds, double timeout_sec);
58 void add_delay(int ms);
59
64 void add_cancel_func(std::function<bool(void)> true_if_cancel);
65
70 void run();
71
80
81private:
82 std::queue<AutoCommand *> command_queue;
83 bool command_timed_out = false;
84 std::function<bool()> should_cancel = []() { return false; };
85};
Definition command_controller.h:15
void add(std::vector< AutoCommand * > cmds)
Definition command_controller.cpp:28
void run()
Definition command_controller.cpp:66
bool last_command_timed_out()
Definition command_controller.cpp:120
CommandController(std::initializer_list< AutoCommand * > cmds)
Create a CommandController with commands pre added. More can be added with CommandController::add()
Definition command_controller.h:26
void add_cancel_func(std::function< bool(void)> true_if_cancel)
add_cancel_func specifies that when this func evaluates to true, to cancel the command controller
Definition command_controller.cpp:60
void add_delay(int ms)
Definition command_controller.cpp:55
CommandController()
Create an empty CommandController. Add Command with CommandController::add()
Definition command_controller.h:20