From ae1b0c000d74cc23172607016d8522740dfd8e6e Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 22 Aug 2021 20:46:52 +0100 Subject: [PATCH] Tidying --- src/Application.cpp | 3 +- src/Insight/Insight.cpp | 44 +++++++++---------- src/Insight/Insight.hpp | 3 +- src/Insight/InsightWorker.hpp | 1 - .../InsightWindow/Widgets/ClickableWidget.hpp | 2 - .../ExpandingHeightScrollAreaWidget.hpp | 4 +- .../InsightWindow/Widgets/ExpandingWidget.hpp | 4 +- .../InsightWindow/Widgets/RotatableLabel.cpp | 2 - .../Widgets/SlidingHandleWidget.hpp | 2 - .../InsightWindow/Widgets/SvgToolButton.hpp | 1 - .../InsightWindow/Widgets/SvgWidget.cpp | 1 - .../InsightWindow/Widgets/SvgWidget.hpp | 5 --- .../TargetDescriptionFile.cpp | 14 +++--- .../TargetDescriptionFile.hpp | 15 ++++++- 14 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 86c1b05d..2822b2b9 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -1,3 +1,5 @@ +#include "Application.hpp" + #include #include #include @@ -6,7 +8,6 @@ #include #include -#include "Application.hpp" #include "src/Logger/Logger.hpp" #include "src/Helpers/Paths.hpp" #include "SignalHandler/SignalHandler.hpp" diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index d0b78297..ba0b5361 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -62,16 +62,6 @@ void Insight::startup() { qRegisterMetaType(); qRegisterMetaType>(); - this->mainWindow.setInsightConfig(this->insightConfig); - this->mainWindow.setEnvironmentConfig(this->environmentConfig); - - this->mainWindow.init( - this->application, - targetDescriptor - ); - - this->mainWindow.show(); - /* * We can't run our own event loop here - we have to use Qt's event loop. But we still need to be able to * process our events. To address this, we use a QTimer to dispatch our events on an interval. @@ -83,22 +73,32 @@ void Insight::startup() { eventDispatchTimer->start(100); // Prepare worker thread - auto worker = new InsightWorker(this->eventManager); this->workerThread = new QThread(); this->workerThread->setObjectName("IW"); - worker->moveToThread(this->workerThread); - connect(this->workerThread, &QThread::started, worker, &InsightWorker::startup); - connect(this->workerThread, &QThread::finished, worker, &QObject::deleteLater); + this->insightWorker->moveToThread(this->workerThread); + connect(this->workerThread, &QThread::started, this->insightWorker, &InsightWorker::startup); + connect(this->workerThread, &QThread::finished, this->insightWorker, &QObject::deleteLater); connect(this->workerThread, &QThread::finished, this->workerThread, &QThread::deleteLater); - connect(worker, &InsightWorker::targetControllerSuspended, &(this->mainWindow), &InsightWindow::onTargetControllerSuspended); - connect(worker, &InsightWorker::targetControllerResumed, &(this->mainWindow), &InsightWindow::onTargetControllerResumed); - connect(worker, &InsightWorker::targetStateUpdated, &(this->mainWindow), &InsightWindow::onTargetStateUpdate); - connect(worker, &InsightWorker::targetProgramCounterUpdated, &(this->mainWindow), &InsightWindow::onTargetProgramCounterUpdate); - connect(worker, &InsightWorker::targetPinStatesUpdated, &(this->mainWindow), &InsightWindow::onTargetPinStatesUpdate); - connect(worker, &InsightWorker::targetIoPortsUpdated, &(this->mainWindow), &InsightWindow::onTargetIoPortsUpdate); - connect(&(this->mainWindow), &InsightWindow::refreshTargetPinStates, worker, &InsightWorker::requestPinStates); - connect(&(this->mainWindow), &InsightWindow::setTargetPinState, worker, &InsightWorker::requestPinStateUpdate); + connect(this->insightWorker, &InsightWorker::targetControllerSuspended, &(this->mainWindow), &InsightWindow::onTargetControllerSuspended); + connect(this->insightWorker, &InsightWorker::targetControllerResumed, &(this->mainWindow), &InsightWindow::onTargetControllerResumed); + connect(this->insightWorker, &InsightWorker::targetStateUpdated, &(this->mainWindow), &InsightWindow::onTargetStateUpdate); + connect(this->insightWorker, &InsightWorker::targetProgramCounterUpdated, &(this->mainWindow), &InsightWindow::onTargetProgramCounterUpdate); + connect(this->insightWorker, &InsightWorker::targetPinStatesUpdated, &(this->mainWindow), &InsightWindow::onTargetPinStatesUpdate); + connect(this->insightWorker, &InsightWorker::targetIoPortsUpdated, &(this->mainWindow), &InsightWindow::onTargetIoPortsUpdate); + connect(&(this->mainWindow), &InsightWindow::refreshTargetPinStates, this->insightWorker, &InsightWorker::requestPinStates); + connect(&(this->mainWindow), &InsightWindow::setTargetPinState, this->insightWorker, &InsightWorker::requestPinStateUpdate); + + this->mainWindow.setInsightConfig(this->insightConfig); + this->mainWindow.setEnvironmentConfig(this->environmentConfig); + + this->mainWindow.init( + this->application, + *(this->insightWorker), + targetDescriptor + ); + + this->mainWindow.show(); } void Insight::shutdown() { diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index d6b2c7d9..12e49057 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -2,12 +2,12 @@ #include #include -#include "UserInterfaces/InsightWindow/InsightWindow.hpp" #include "src/Helpers/Thread.hpp" #include "src/ApplicationConfig.hpp" #include "src/EventManager/EventManager.hpp" #include "src/EventManager/EventListener.hpp" +#include "UserInterfaces/InsightWindow/InsightWindow.hpp" #include "src/TargetController/TargetControllerConsole.hpp" namespace Bloom @@ -36,6 +36,7 @@ namespace Bloom EventListenerPointer eventListener = std::make_shared("InsightEventListener"); QApplication application; + InsightWorker* insightWorker = new InsightWorker(this->eventManager); InsightWindow mainWindow; TargetControllerConsole targetControllerConsole = TargetControllerConsole( diff --git a/src/Insight/InsightWorker.hpp b/src/Insight/InsightWorker.hpp index f585f3b4..c08cc0cd 100644 --- a/src/Insight/InsightWorker.hpp +++ b/src/Insight/InsightWorker.hpp @@ -3,7 +3,6 @@ #include #include -#include "UserInterfaces/InsightWindow/InsightWindow.hpp" #include "src/Helpers/Thread.hpp" #include "src/ApplicationConfig.hpp" #include "src/EventManager/EventManager.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp index 3c94eb4b..8abf2924 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.hpp @@ -4,8 +4,6 @@ #include #include -#include "src/Logger/Logger.hpp" - namespace Bloom::Widgets { class Q_WIDGETS_EXPORT ClickableWidget: public QFrame diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp index c5123194..86a4cb06 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp @@ -4,8 +4,6 @@ #include #include -#include "src/Logger/Logger.hpp" - namespace Bloom::Widgets { class Q_WIDGETS_EXPORT ExpandingHeightScrollAreaWidget: public QScrollArea @@ -37,8 +35,8 @@ namespace Bloom::Widgets return this->scrollAreaSize(); }; - public: explicit ExpandingHeightScrollAreaWidget(QWidget* parent): QScrollArea(parent) {}; + }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp index fc2d994b..46354f57 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp @@ -3,8 +3,6 @@ #include #include -#include "src/Logger/Logger.hpp" - namespace Bloom::Widgets { class Q_WIDGETS_EXPORT ExpandingWidget: public QWidget @@ -25,8 +23,8 @@ namespace Bloom::Widgets return this->minimumSizeHint(); }; - public: explicit ExpandingWidget(QWidget* parent): QWidget(parent) {}; + }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp index 4bf81060..7b8d5f3b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp @@ -2,8 +2,6 @@ #include -#include "src/Logger/Logger.hpp" - using namespace Bloom::Widgets; void RotatableLabel::paintEvent(QPaintEvent* event) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp index 65963254..98368e16 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp @@ -6,8 +6,6 @@ #include #include -#include "src/Logger/Logger.hpp" - namespace Bloom::Widgets { class Q_WIDGETS_EXPORT SlidingHandleWidget: public QFrame diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp index 7ae2165d..f9e7f1e0 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp @@ -4,7 +4,6 @@ #include #include "SvgWidget.hpp" -#include "src/Logger/Logger.hpp" namespace Bloom::Widgets { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp index eb94dc4e..f8ee9361 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp @@ -2,7 +2,6 @@ #include #include -#include "src/Logger/Logger.hpp" using namespace Bloom::Widgets; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp index 7647c205..996a85e8 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp @@ -5,8 +5,6 @@ #include #include -#include "src/Logger/Logger.hpp" - namespace Bloom::Widgets { class SvgWidget: public QFrame @@ -63,8 +61,5 @@ namespace Bloom::Widgets return this->angle; } -// [[nodiscard]] QSize sizeHint() const override { -// return QSize(this->containerWidth, this->containerHeight); -// }; }; } diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp index 86797032..fdd8a664 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp @@ -124,21 +124,21 @@ TargetSignature TargetDescriptionFile::getTargetSignature() const { std::optional signatureByteOne; std::optional signatureByteTwo; - if (signatureProperties.find("signature0") != signatureProperties.end()) { + if (signatureProperties.contains("signature0")) { signatureByteZero = static_cast( - signatureProperties.find("signature0")->second.value.toShort(nullptr, 16) + signatureProperties.at("signature0").value.toShort(nullptr, 16) ); } - if (signatureProperties.find("signature1") != signatureProperties.end()) { + if (signatureProperties.contains("signature1")) { signatureByteOne = static_cast( - signatureProperties.find("signature1")->second.value.toShort(nullptr, 16) + signatureProperties.at("signature1").value.toShort(nullptr, 16) ); } - if (signatureProperties.find("signature2") != signatureProperties.end()) { + if (signatureProperties.contains("signature2")) { signatureByteTwo = static_cast( - signatureProperties.find("signature2")->second.value.toShort(nullptr, 16) + signatureProperties.at("signature2").value.toShort(nullptr, 16) ); } @@ -262,7 +262,7 @@ TargetParameters TargetDescriptionFile::getTargetParameters() const { if (supportedPhysicalInterfaces.contains(PhysicalInterface::DEBUG_WIRE) || supportedPhysicalInterfaces.contains(PhysicalInterface::JTAG) - ) { + ) { this->loadDebugWireAndJtagTargetParameters(targetParameters); } diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp index b8051640..1c72a9d8 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.hpp @@ -10,6 +10,7 @@ #include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp" #include "src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp" #include "src/Targets/TargetVariant.hpp" +#include "src/Targets/TargetRegister.hpp" namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription { @@ -184,12 +185,22 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription */ [[nodiscard]] const auto& getSupportedDebugPhysicalInterfaces() const { return this->supportedDebugPhysicalInterfaces; - }; + } + /** + * Returns a mapping of all pad descriptors extracted from TDF, mapped by name. + * + * @return + */ [[nodiscard]] const auto& getPadDescriptorsMappedByName() const { return this->padDescriptorsByName; - }; + } + /** + * Returns a mapping of all target variants extracted from the TDF, mapped by ID. + * + * @return + */ [[nodiscard]] const auto& getVariantsMappedById() const { return this->targetVariantsById; }