This commit is contained in:
Nav
2021-05-31 00:03:57 +01:00
parent f7944ac6b4
commit 08914372b9
11 changed files with 93 additions and 77 deletions

View File

@@ -123,7 +123,7 @@ void TargetController::shutdown() {
try {
Logger::info("Shutting down TargetController");
this->eventManager.deregisterListener(this->eventListener->getId());
this->releaseResources();
this->releaseHardware();
} catch (const std::exception& exception) {
Logger::error("Failed to properly shutdown TargetController. Error: " + std::string(exception.what()));
@@ -140,7 +140,7 @@ void TargetController::suspend() {
Logger::debug("Suspending TargetController");
try {
this->releaseResources();
this->releaseHardware();
} catch (const std::exception& exception) {
Logger::error("Failed to release connected debug tool and target resources. Error: "
@@ -175,7 +175,7 @@ void TargetController::suspend() {
}
void TargetController::resume() {
this->acquireResources();
this->acquireHardware();
this->eventListener->registerCallbackForEventType<Events::DebugSessionFinished>(
std::bind(&TargetController::onDebugSessionFinishedEvent, this, std::placeholders::_1)
@@ -248,7 +248,7 @@ void TargetController::resume() {
}
}
void TargetController::acquireResources() {
void TargetController::acquireHardware() {
auto debugToolName = this->environmentConfig.debugToolConfig.name;
auto targetName = this->environmentConfig.targetConfig.name;
@@ -311,7 +311,7 @@ void TargetController::acquireResources() {
Logger::info("Target name: " + this->target->getName());
}
void TargetController::releaseResources() {
void TargetController::releaseHardware() {
auto target = this->getTarget();
auto debugTool = this->getDebugTool();
@@ -360,7 +360,7 @@ void TargetController::emitErrorEvent(int correlationId) {
this->eventManager.triggerEvent(errorEvent);
}
void TargetController::onShutdownTargetControllerEvent(EventPointer<Events::ShutdownTargetController> event) {
void TargetController::onShutdownTargetControllerEvent(EventPointer<Events::ShutdownTargetController>) {
this->shutdown();
}

View File

@@ -183,19 +183,33 @@ namespace Bloom
/**
* Exit point - must be called before the TargetController thread is terminated.
*
* Handles deactivating the target among other clean-up related things.
* Handles releasing the hardware among other clean-up related things.
*/
void shutdown();
/**
* Establishes a connection with the debug tool and target. Prepares the hardware for a debug session.
*/
void acquireHardware();
/**
* Attempts to gracefully disconnect from the debug tool and the target. All control of the debug tool and
* target will cease.
*/
void releaseHardware();
/**
* Puts the TargetController into the suspended state.
*
* In this state, the hardware is released and the TargetController will only handle a subset of events.
*/
void suspend();
/**
* Wakes the TargetController from the suspended state.
*/
void resume();
void acquireResources();
void releaseResources();
/**
* Should fire any events queued on the target.
*/

View File

@@ -19,7 +19,7 @@ TargetControllerState TargetControllerConsole::getTargetControllerState() {
if (!responseEvent.has_value()
|| !std::holds_alternative<EventPointer<Events::TargetControllerStateReported>>(responseEvent.value())
) {
) {
throw Exception("Unexpected response from TargetController");
}