New resume & suspend TargetController commands

This commit is contained in:
Nav
2022-09-14 22:05:50 +01:00
parent beae66e477
commit 98963ef4a8
8 changed files with 111 additions and 15 deletions

View File

@@ -24,6 +24,8 @@ namespace Bloom::TargetController
using Commands::Command;
using Commands::GetState;
using Commands::Resume;
using Commands::Suspend;
using Commands::GetTargetDescriptor;
using Commands::GetTargetState;
using Commands::StopTargetExecution;
@@ -172,6 +174,14 @@ namespace Bloom::TargetController
std::bind(&TargetControllerComponent::handleGetState, this, std::placeholders::_1)
);
this->registerCommandHandler<Resume>(
std::bind(&TargetControllerComponent::handleResume, this, std::placeholders::_1)
);
this->registerCommandHandler<Suspend>(
std::bind(&TargetControllerComponent::handleSuspend, this, std::placeholders::_1)
);
this->registerCommandHandler<GetTargetDescriptor>(
std::bind(&TargetControllerComponent::handleGetTargetDescriptor, this, std::placeholders::_1)
);
@@ -765,6 +775,22 @@ namespace Bloom::TargetController
return std::make_unique<Responses::State>(this->state);
}
std::unique_ptr<Responses::Response> TargetControllerComponent::handleResume(Resume& command) {
if (this->state != TargetControllerState::ACTIVE) {
this->resume();
}
return std::make_unique<Response>();
}
std::unique_ptr<Responses::Response> TargetControllerComponent::handleSuspend(Suspend& command) {
if (this->state != TargetControllerState::SUSPENDED) {
this->suspend();
}
return std::make_unique<Response>();
}
std::unique_ptr<Responses::TargetDescriptor> TargetControllerComponent::handleGetTargetDescriptor(
GetTargetDescriptor& command
) {