RIT VEXU Core API
Loading...
Searching...
No Matches
command_controller.h
1
9
10#pragma once
11#include "core/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
42
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
72 /*
73 * returns the amount of commands in the controller
74 */
75 std::string toString();
76
85 bool printPathLogs = true;
86
87private:
88 std::queue<AutoCommand *> command_queue;
89 bool command_timed_out = false;
90 std::function<bool()> should_cancel = []() { return false; };
91};
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:128
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