Introduced the TargetControllerConsole class to provide access to common functionality within the TargetController.

This commit is contained in:
Nav
2021-04-24 20:23:17 +01:00
parent 03a2bfab57
commit fa2a3f67db
10 changed files with 378 additions and 285 deletions

View File

@@ -46,7 +46,7 @@ void Insight::startup() {
std::bind(&Insight::onTargetControllerStateChangedEvent, this, std::placeholders::_1)
);
auto targetDescriptor = this->getTargetDescriptor();
auto targetDescriptor = this->targetControllerConsole.getTargetDescriptor();
std::string qtAppName = "Bloom";
char* appArguments[] = {qtAppName.data()};
@@ -91,24 +91,6 @@ void Insight::startup() {
connect(&(this->mainWindow), &InsightWindow::setTargetPinState, worker, &InsightWorker::requestPinStateUpdate);
}
Targets::TargetDescriptor Insight::getTargetDescriptor() {
auto extractEvent = std::make_shared<Events::ExtractTargetDescriptor>();
this->eventManager.triggerEvent(extractEvent);
auto responseEvent = this->eventListener->waitForEvent<
Events::TargetDescriptorExtracted,
Events::TargetControllerErrorOccurred
>(std::chrono::milliseconds(5000), extractEvent->id);
if (!responseEvent.has_value()
|| !std::holds_alternative<EventPointer<Events::TargetDescriptorExtracted>>(responseEvent.value())
) {
throw Exception("Unexpected response from TargetController");
}
auto descriptorExtracted = std::get<EventPointer<Events::TargetDescriptorExtracted>>(responseEvent.value());
return descriptorExtracted->targetDescriptor;
}
void Insight::shutdown() {
if (this->getState() == ThreadState::STOPPED) {
return;