Moved TargetController components into new 'TargetController' namespace.

This commit is contained in:
Nav
2022-04-09 15:57:24 +01:00
parent 0a537dcf90
commit 8be1446e72
55 changed files with 134 additions and 39 deletions

View File

@@ -351,13 +351,13 @@ namespace Bloom
}
void Application::startTargetController() {
this->targetController = std::make_unique<TargetControllerComponent>(
this->targetController = std::make_unique<TargetController::TargetControllerComponent>(
this->projectConfig.value(),
this->environmentConfig.value()
);
this->targetControllerThread = std::thread(
&TargetControllerComponent::run,
&TargetController::TargetControllerComponent::run,
this->targetController.get()
);

View File

@@ -76,7 +76,7 @@ namespace Bloom
* std::unique_ptr for the debug server (for polymorphism), I thought I'd keep it consistent and just use
* std::unique_ptr for lazy loading.
*/
std::unique_ptr<TargetControllerComponent> targetController = nullptr;
std::unique_ptr<TargetController::TargetControllerComponent> targetController = nullptr;
std::thread targetControllerThread;
/**

View File

@@ -8,6 +8,8 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::ResponsePacket;

View File

@@ -31,6 +31,9 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
explicit ReadMemory(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -8,6 +8,8 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::OkResponsePacket;

View File

@@ -31,6 +31,9 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
explicit WriteMemory(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -13,6 +13,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::ResponsePacket;
using ResponsePackets::OkResponsePacket;
using ResponsePackets::TargetStopped;

View File

@@ -46,6 +46,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
*
* @param targetControllerConsole
*/
virtual void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole);
virtual void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
);
};
}

View File

@@ -7,6 +7,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::ErrorResponsePacket;
using Exceptions::Exception;

View File

@@ -26,6 +26,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
explicit ContinueExecution(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -9,6 +9,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::TargetStopped;
using ResponsePackets::ErrorResponsePacket;
using Exceptions::Exception;

View File

@@ -17,6 +17,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
public:
explicit InterruptExecution(const RawPacketType& rawPacket): CommandPacket(rawPacket) {}
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -6,6 +6,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::EmptyResponsePacket;
Monitor::Monitor(const RawPacketType& rawPacket)

View File

@@ -19,6 +19,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
explicit Monitor(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -9,6 +9,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using Targets::TargetRegister;
using Targets::TargetRegisterDescriptors;

View File

@@ -27,6 +27,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
explicit ReadRegisters(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -12,6 +12,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using Targets::TargetBreakpoint;
using ResponsePackets::OkResponsePacket;

View File

@@ -28,6 +28,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
explicit RemoveBreakpoint(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -8,6 +8,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::ResponsePacket;

View File

@@ -17,6 +17,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
public:
explicit ResetTarget(Monitor&& monitorPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -12,6 +12,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using Targets::TargetBreakpoint;
using ResponsePackets::OkResponsePacket;

View File

@@ -28,6 +28,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
explicit SetBreakpoint(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -7,6 +7,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::ErrorResponsePacket;
using Exceptions::Exception;

View File

@@ -21,6 +21,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
explicit StepExecution(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -13,6 +13,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::SupportedFeaturesResponse;
using ResponsePackets::ErrorResponsePacket;

View File

@@ -32,7 +32,10 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
return this->supportedFeatures;
}
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
private:
std::set<Feature> supportedFeatures;

View File

@@ -11,6 +11,8 @@
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using Targets::TargetRegister;
using Targets::TargetRegisterDescriptors;

View File

@@ -19,6 +19,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
explicit WriteRegister(const RawPacketType& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
};
}

View File

@@ -295,7 +295,10 @@ namespace Bloom::DebugServer::Gdb
}
void GdbRspDebugServer::onTargetControllerStateReported(const Events::TargetControllerStateReported& event) {
if (event.state == TargetControllerState::SUSPENDED && this->activeDebugSession.has_value()) {
if (
event.state == TargetController::TargetControllerState::SUSPENDED
&& this->activeDebugSession.has_value()
) {
Logger::warning("Terminating debug session - TargetController suspended unexpectedly");
this->terminateActiveDebugSession();
}

View File

@@ -112,7 +112,9 @@ namespace Bloom::DebugServer::Gdb
*
* See documentation in src/DebugServer/Gdb/README.md for more on how GDB commands are processed.
*/
TargetControllerConsole targetControllerConsole = TargetControllerConsole(this->eventListener);
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(
this->eventListener
);
/**
* Listening socket address

View File

@@ -13,8 +13,8 @@ namespace Bloom::Events
static constexpr EventType type = EventType::TARGET_CONTROLLER_STATE_REPORTED;
static inline const std::string name = "TargetControllerStateReported";
TargetControllerState state;
explicit TargetControllerStateReported(TargetControllerState state): state(state) {};
TargetController::TargetControllerState state;
explicit TargetControllerStateReported(TargetController::TargetControllerState state): state(state) {};
[[nodiscard]] EventType getType() const override {
return TargetControllerStateReported::type;

View File

@@ -78,7 +78,9 @@ namespace Bloom
this->insightProjectSettings
);
TargetControllerConsole targetControllerConsole = TargetControllerConsole(this->eventListener);
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(
this->eventListener
);
/**
* Insight consists of two threads - the main thread where the main Qt event loop runs (for the GUI), and

View File

@@ -119,12 +119,16 @@ namespace Bloom
}
void InsightWorker::onTargetControllerStateReportedEvent(const Events::TargetControllerStateReported& event) {
if (this->lastTargetControllerState == TargetControllerState::ACTIVE
using TargetController::TargetControllerState;
if (
this->lastTargetControllerState == TargetControllerState::ACTIVE
&& event.state == TargetControllerState::SUSPENDED
) {
emit this->targetControllerSuspended();
} else if (this->lastTargetControllerState == TargetControllerState::SUSPENDED
} else if (
this->lastTargetControllerState == TargetControllerState::SUSPENDED
&& event.state == TargetControllerState::ACTIVE
) {
try {

View File

@@ -49,8 +49,11 @@ namespace Bloom
private:
EventListenerPointer eventListener = std::make_shared<EventListener>("InsightWorkerEventListener");
TargetControllerConsole targetControllerConsole = TargetControllerConsole(*(this->eventListener));
TargetControllerState lastTargetControllerState = TargetControllerState::ACTIVE;
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(
*(this->eventListener)
);
TargetController::TargetControllerState lastTargetControllerState =
TargetController::TargetControllerState::ACTIVE;
QTimer* eventDispatchTimer = nullptr;

View File

@@ -4,6 +4,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void InsightWorkerTask::execute(TargetControllerConsole& targetControllerConsole) {
try {
this->state = InsightWorkerTaskState::STARTED;

View File

@@ -24,7 +24,7 @@ namespace Bloom
InsightWorkerTask(): QObject(nullptr) {};
void execute(TargetControllerConsole& targetControllerConsole);
void execute(TargetController::TargetControllerConsole& targetControllerConsole);
signals:
void started();
@@ -32,6 +32,6 @@ namespace Bloom
void completed();
protected:
virtual void run(TargetControllerConsole& targetControllerConsole) = 0;
virtual void run(TargetController::TargetControllerConsole& targetControllerConsole) = 0;
};
}

View File

@@ -11,6 +11,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void QueryLatestVersionNumber::run(TargetControllerConsole& targetControllerConsole) {
auto* networkAccessManager = new QNetworkAccessManager(this);
auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Paths::homeDomainName() + "/latest-version"));

View File

@@ -18,7 +18,7 @@ namespace Bloom
void latestVersionNumberRetrieved(const VersionNumber& latestVersionNumber);
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
private:
VersionNumber currentVersionNumber;

View File

@@ -2,6 +2,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void ReadStackPointer::run(TargetControllerConsole& targetControllerConsole) {
emit this->stackPointerRead(targetControllerConsole.getStackPointer());
}

View File

@@ -15,6 +15,6 @@ namespace Bloom
void stackPointerRead(std::uint32_t stackPointer);
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
};
}

View File

@@ -2,6 +2,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void ReadTargetMemory::run(TargetControllerConsole& targetControllerConsole) {
emit this->targetMemoryRead(
targetControllerConsole.readMemory(

View File

@@ -28,7 +28,7 @@ namespace Bloom
void targetMemoryRead(Targets::TargetMemoryBuffer buffer);
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
private:
Targets::TargetMemoryType memoryType;

View File

@@ -2,6 +2,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void ReadTargetRegisters::run(TargetControllerConsole& targetControllerConsole) {
emit this->targetRegistersRead(targetControllerConsole.readRegisters(this->descriptors));
}

View File

@@ -16,7 +16,7 @@ namespace Bloom
void targetRegistersRead(Targets::TargetRegisters registers);
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
private:
Targets::TargetRegisterDescriptors descriptors;

View File

@@ -2,6 +2,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void RefreshTargetPinStates::run(TargetControllerConsole& targetControllerConsole) {
emit this->targetPinStatesRetrieved(targetControllerConsole.getPinStates(this->variantId));
}

View File

@@ -17,7 +17,7 @@ namespace Bloom
void targetPinStatesRetrieved(Bloom::Targets::TargetPinStateMappingType pinStatesByNumber);
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
private:
int variantId;

View File

@@ -2,6 +2,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void SetTargetPinState::run(TargetControllerConsole& targetControllerConsole) {
targetControllerConsole.setPinState(this->pinDescriptor, this->pinState);
}

View File

@@ -14,7 +14,7 @@ namespace Bloom
pinDescriptor(pinDescriptor), pinState(pinState) {}
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
private:
Targets::TargetPinDescriptor pinDescriptor;

View File

@@ -2,6 +2,8 @@
namespace Bloom
{
using TargetController::TargetControllerConsole;
void WriteTargetRegister::run(TargetControllerConsole& targetControllerConsole) {
targetControllerConsole.writeRegisters({this->targetRegister});
}

View File

@@ -13,7 +13,7 @@ namespace Bloom
explicit WriteTargetRegister(const Targets::TargetRegister& targetRegister): targetRegister(targetRegister) {}
protected:
void run(TargetControllerConsole& targetControllerConsole) override;
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
private:
Targets::TargetRegister targetRegister;

View File

@@ -14,7 +14,7 @@
#include "src/Exceptions/TargetControllerStartupFailure.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
namespace Bloom
namespace Bloom::TargetController
{
using namespace Bloom::Targets;
using namespace Bloom::Events;

View File

@@ -20,7 +20,7 @@
#include "src/EventManager/EventListener.hpp"
#include "src/EventManager/Events/Events.hpp"
namespace Bloom
namespace Bloom::TargetController
{
/**
* The TargetController possesses full control of the debugging target and the debug tool.

View File

@@ -3,7 +3,7 @@
#include "src/EventManager/Events/Events.hpp"
#include "src/Logger/Logger.hpp"
namespace Bloom
namespace Bloom::TargetController
{
using namespace Bloom::Targets;
using namespace Bloom::Events;

View File

@@ -17,7 +17,7 @@
#include "src/Exceptions/Exception.hpp"
namespace Bloom
namespace Bloom::TargetController
{
/**
* The TargetControllerConsole provides an interface to the TargetController.

View File

@@ -2,7 +2,7 @@
#include <cstdint>
namespace Bloom
namespace Bloom::TargetController
{
enum class TargetControllerState: std::uint8_t
{