24#ifndef TAPROOT_SEQUENTIAL_COMMAND_HPP_
25#define TAPROOT_SEQUENTIAL_COMMAND_HPP_
29#include "modm/architecture/interface/assert.hpp"
44template <
size_t COMMANDS>
53 for (
Command* command : commands)
57 "SequentialCommand::SequentialCommand",
58 "Null pointer command passed into sequential command.");
65 return this->currentCommand == COMMANDS ?
""
66 : this->commands[this->currentCommand]->getName();
69 bool isReady()
override {
return this->commands[0]->isReady(); }
73 this->currentCommand = 0;
74 this->commandInitialized =
false;
79 if (!this->commandInitialized)
81 if (this->commands[this->currentCommand]->
isReady())
83 this->commands[this->currentCommand]->initialize();
84 this->commandInitialized =
true;
88 if (this->commandInitialized)
90 this->commands[this->currentCommand]->execute();
92 if (this->commands[this->currentCommand]->
isFinished())
94 this->commands[this->currentCommand]->end(
false);
95 this->commandInitialized =
false;
96 this->currentCommand++;
101 void end(
bool interrupted)
override
103 if (this->currentCommand != COMMANDS)
105 this->commands[this->currentCommand]->end(interrupted);
109 bool isFinished()
const override {
return this->currentCommand == COMMANDS; }
112 std::array<Command*, COMMANDS> commands;
113 size_t currentCommand;
114 bool commandInitialized;
Definition command.hpp:44
command_scheduler_bitmap_t commandRequirementsBitwise
Definition command.hpp:139
Definition sequential_command.hpp:46
const char * getName() const override
Definition sequential_command.hpp:63
bool isFinished() const override
Definition sequential_command.hpp:109
void initialize() override
Definition sequential_command.hpp:71
void execute() override
Definition sequential_command.hpp:77
bool isReady() override
Definition sequential_command.hpp:69
SequentialCommand(std::array< Command *, COMMANDS > commands)
Definition sequential_command.hpp:48
void end(bool interrupted) override
Definition sequential_command.hpp:101
Definition ballistics.cpp:29