24#ifndef TAPROOT_CONCURRENT_COMMAND_HPP_
25#define TAPROOT_CONCURRENT_COMMAND_HPP_
29#include "modm/architecture/interface/assert.hpp"
44template <
size_t COMMANDS,
bool RACE>
55 for (
Command* command : commands)
59 "ConcurrentCommand::ConcurrentCommand",
60 "Null pointer command passed into concurrent command.");
61 auto requirements = command->getRequirementsBitwise();
64 "ConcurrentCommand::ConcurrentCommand",
65 "Multiple commands to concurrent command have overlapping requirements.");
67 this->allCommands |= (1ull << command->getGlobalIdentifier());
71 const char*
getName()
const override {
return this->name; }
75 for (
Command* command : commands)
77 if (!command->isReady())
87 for (
Command* command : commands)
89 command->initialize();
95 for (
Command* command : commands)
97 if (!(this->finishedCommands & (1ull << command->getGlobalIdentifier())))
100 if (command->isFinished())
103 this->finishedCommands |= 1ull << command->getGlobalIdentifier();
109 void end(
bool interrupted)
override
111 for (
Command* command : commands)
113 if (!(this->finishedCommands & (1ull << command->getGlobalIdentifier())))
121 command->end(interrupted);
131 return this->finishedCommands != 0;
133 return this->finishedCommands == this->allCommands;
137 std::array<Command*, COMMANDS> commands;
146template <
size_t COMMANDS>
152template <
size_t COMMANDS>
Definition command.hpp:44
command_scheduler_bitmap_t commandRequirementsBitwise
Definition command.hpp:139
Definition concurrent_command.hpp:46
void execute() override
Definition concurrent_command.hpp:93
bool isFinished() const override
Definition concurrent_command.hpp:127
void initialize() override
Definition concurrent_command.hpp:85
ConcurrentTemplateCommand(std::array< Command *, COMMANDS > commands, const char *name)
Definition concurrent_command.hpp:48
bool isReady() override
Definition concurrent_command.hpp:73
const char * getName() const override
Definition concurrent_command.hpp:71
void end(bool interrupted) override
Definition concurrent_command.hpp:109
uint64_t command_scheduler_bitmap_t
Definition command_scheduler_types.hpp:31
Definition ballistics.cpp:29