This commit is contained in:
Nav
2021-08-22 20:46:52 +01:00
parent 5e280f9327
commit ae1b0c000d
14 changed files with 48 additions and 53 deletions

View File

@@ -1,3 +1,5 @@
#include "Application.hpp"
#include <iostream> #include <iostream>
#include <csignal> #include <csignal>
#include <QtCore> #include <QtCore>
@@ -6,7 +8,6 @@
#include <unistd.h> #include <unistd.h>
#include <filesystem> #include <filesystem>
#include "Application.hpp"
#include "src/Logger/Logger.hpp" #include "src/Logger/Logger.hpp"
#include "src/Helpers/Paths.hpp" #include "src/Helpers/Paths.hpp"
#include "SignalHandler/SignalHandler.hpp" #include "SignalHandler/SignalHandler.hpp"

View File

@@ -62,16 +62,6 @@ void Insight::startup() {
qRegisterMetaType<Bloom::Targets::TargetState>(); qRegisterMetaType<Bloom::Targets::TargetState>();
qRegisterMetaType<std::map<int, Bloom::Targets::TargetPinState>>(); qRegisterMetaType<std::map<int, Bloom::Targets::TargetPinState>>();
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 * 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. * 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); eventDispatchTimer->start(100);
// Prepare worker thread // Prepare worker thread
auto worker = new InsightWorker(this->eventManager);
this->workerThread = new QThread(); this->workerThread = new QThread();
this->workerThread->setObjectName("IW"); this->workerThread->setObjectName("IW");
worker->moveToThread(this->workerThread); this->insightWorker->moveToThread(this->workerThread);
connect(this->workerThread, &QThread::started, worker, &InsightWorker::startup); connect(this->workerThread, &QThread::started, this->insightWorker, &InsightWorker::startup);
connect(this->workerThread, &QThread::finished, worker, &QObject::deleteLater); connect(this->workerThread, &QThread::finished, this->insightWorker, &QObject::deleteLater);
connect(this->workerThread, &QThread::finished, this->workerThread, &QThread::deleteLater); connect(this->workerThread, &QThread::finished, this->workerThread, &QThread::deleteLater);
connect(worker, &InsightWorker::targetControllerSuspended, &(this->mainWindow), &InsightWindow::onTargetControllerSuspended); connect(this->insightWorker, &InsightWorker::targetControllerSuspended, &(this->mainWindow), &InsightWindow::onTargetControllerSuspended);
connect(worker, &InsightWorker::targetControllerResumed, &(this->mainWindow), &InsightWindow::onTargetControllerResumed); connect(this->insightWorker, &InsightWorker::targetControllerResumed, &(this->mainWindow), &InsightWindow::onTargetControllerResumed);
connect(worker, &InsightWorker::targetStateUpdated, &(this->mainWindow), &InsightWindow::onTargetStateUpdate); connect(this->insightWorker, &InsightWorker::targetStateUpdated, &(this->mainWindow), &InsightWindow::onTargetStateUpdate);
connect(worker, &InsightWorker::targetProgramCounterUpdated, &(this->mainWindow), &InsightWindow::onTargetProgramCounterUpdate); connect(this->insightWorker, &InsightWorker::targetProgramCounterUpdated, &(this->mainWindow), &InsightWindow::onTargetProgramCounterUpdate);
connect(worker, &InsightWorker::targetPinStatesUpdated, &(this->mainWindow), &InsightWindow::onTargetPinStatesUpdate); connect(this->insightWorker, &InsightWorker::targetPinStatesUpdated, &(this->mainWindow), &InsightWindow::onTargetPinStatesUpdate);
connect(worker, &InsightWorker::targetIoPortsUpdated, &(this->mainWindow), &InsightWindow::onTargetIoPortsUpdate); connect(this->insightWorker, &InsightWorker::targetIoPortsUpdated, &(this->mainWindow), &InsightWindow::onTargetIoPortsUpdate);
connect(&(this->mainWindow), &InsightWindow::refreshTargetPinStates, worker, &InsightWorker::requestPinStates); connect(&(this->mainWindow), &InsightWindow::refreshTargetPinStates, this->insightWorker, &InsightWorker::requestPinStates);
connect(&(this->mainWindow), &InsightWindow::setTargetPinState, worker, &InsightWorker::requestPinStateUpdate); 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() { void Insight::shutdown() {

View File

@@ -2,12 +2,12 @@
#include <QtCore> #include <QtCore>
#include <QApplication> #include <QApplication>
#include "UserInterfaces/InsightWindow/InsightWindow.hpp"
#include "src/Helpers/Thread.hpp" #include "src/Helpers/Thread.hpp"
#include "src/ApplicationConfig.hpp" #include "src/ApplicationConfig.hpp"
#include "src/EventManager/EventManager.hpp" #include "src/EventManager/EventManager.hpp"
#include "src/EventManager/EventListener.hpp" #include "src/EventManager/EventListener.hpp"
#include "UserInterfaces/InsightWindow/InsightWindow.hpp"
#include "src/TargetController/TargetControllerConsole.hpp" #include "src/TargetController/TargetControllerConsole.hpp"
namespace Bloom namespace Bloom
@@ -36,6 +36,7 @@ namespace Bloom
EventListenerPointer eventListener = std::make_shared<EventListener>("InsightEventListener"); EventListenerPointer eventListener = std::make_shared<EventListener>("InsightEventListener");
QApplication application; QApplication application;
InsightWorker* insightWorker = new InsightWorker(this->eventManager);
InsightWindow mainWindow; InsightWindow mainWindow;
TargetControllerConsole targetControllerConsole = TargetControllerConsole( TargetControllerConsole targetControllerConsole = TargetControllerConsole(

View File

@@ -3,7 +3,6 @@
#include <QtCore> #include <QtCore>
#include <QApplication> #include <QApplication>
#include "UserInterfaces/InsightWindow/InsightWindow.hpp"
#include "src/Helpers/Thread.hpp" #include "src/Helpers/Thread.hpp"
#include "src/ApplicationConfig.hpp" #include "src/ApplicationConfig.hpp"
#include "src/EventManager/EventManager.hpp" #include "src/EventManager/EventManager.hpp"

View File

@@ -4,8 +4,6 @@
#include <QEvent> #include <QEvent>
#include <QMouseEvent> #include <QMouseEvent>
#include "src/Logger/Logger.hpp"
namespace Bloom::Widgets namespace Bloom::Widgets
{ {
class Q_WIDGETS_EXPORT ClickableWidget: public QFrame class Q_WIDGETS_EXPORT ClickableWidget: public QFrame

View File

@@ -4,8 +4,6 @@
#include <QScrollArea> #include <QScrollArea>
#include <QSize> #include <QSize>
#include "src/Logger/Logger.hpp"
namespace Bloom::Widgets namespace Bloom::Widgets
{ {
class Q_WIDGETS_EXPORT ExpandingHeightScrollAreaWidget: public QScrollArea class Q_WIDGETS_EXPORT ExpandingHeightScrollAreaWidget: public QScrollArea
@@ -37,8 +35,8 @@ namespace Bloom::Widgets
return this->scrollAreaSize(); return this->scrollAreaSize();
}; };
public: public:
explicit ExpandingHeightScrollAreaWidget(QWidget* parent): QScrollArea(parent) {}; explicit ExpandingHeightScrollAreaWidget(QWidget* parent): QScrollArea(parent) {};
}; };
} }

View File

@@ -3,8 +3,6 @@
#include <QWidget> #include <QWidget>
#include <QSize> #include <QSize>
#include "src/Logger/Logger.hpp"
namespace Bloom::Widgets namespace Bloom::Widgets
{ {
class Q_WIDGETS_EXPORT ExpandingWidget: public QWidget class Q_WIDGETS_EXPORT ExpandingWidget: public QWidget
@@ -25,8 +23,8 @@ namespace Bloom::Widgets
return this->minimumSizeHint(); return this->minimumSizeHint();
}; };
public: public:
explicit ExpandingWidget(QWidget* parent): QWidget(parent) {}; explicit ExpandingWidget(QWidget* parent): QWidget(parent) {};
}; };
} }

View File

@@ -2,8 +2,6 @@
#include <QPainter> #include <QPainter>
#include "src/Logger/Logger.hpp"
using namespace Bloom::Widgets; using namespace Bloom::Widgets;
void RotatableLabel::paintEvent(QPaintEvent* event) { void RotatableLabel::paintEvent(QPaintEvent* event) {

View File

@@ -6,8 +6,6 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QEnterEvent> #include <QEnterEvent>
#include "src/Logger/Logger.hpp"
namespace Bloom::Widgets namespace Bloom::Widgets
{ {
class Q_WIDGETS_EXPORT SlidingHandleWidget: public QFrame class Q_WIDGETS_EXPORT SlidingHandleWidget: public QFrame

View File

@@ -4,7 +4,6 @@
#include <QString> #include <QString>
#include "SvgWidget.hpp" #include "SvgWidget.hpp"
#include "src/Logger/Logger.hpp"
namespace Bloom::Widgets namespace Bloom::Widgets
{ {

View File

@@ -2,7 +2,6 @@
#include <QPainter> #include <QPainter>
#include <cmath> #include <cmath>
#include "src/Logger/Logger.hpp"
using namespace Bloom::Widgets; using namespace Bloom::Widgets;

View File

@@ -5,8 +5,6 @@
#include <QString> #include <QString>
#include <QSize> #include <QSize>
#include "src/Logger/Logger.hpp"
namespace Bloom::Widgets namespace Bloom::Widgets
{ {
class SvgWidget: public QFrame class SvgWidget: public QFrame
@@ -63,8 +61,5 @@ namespace Bloom::Widgets
return this->angle; return this->angle;
} }
// [[nodiscard]] QSize sizeHint() const override {
// return QSize(this->containerWidth, this->containerHeight);
// };
}; };
} }

View File

@@ -124,21 +124,21 @@ TargetSignature TargetDescriptionFile::getTargetSignature() const {
std::optional<unsigned char> signatureByteOne; std::optional<unsigned char> signatureByteOne;
std::optional<unsigned char> signatureByteTwo; std::optional<unsigned char> signatureByteTwo;
if (signatureProperties.find("signature0") != signatureProperties.end()) { if (signatureProperties.contains("signature0")) {
signatureByteZero = static_cast<unsigned char>( signatureByteZero = static_cast<unsigned char>(
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<unsigned char>( signatureByteOne = static_cast<unsigned char>(
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<unsigned char>( signatureByteTwo = static_cast<unsigned char>(
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) if (supportedPhysicalInterfaces.contains(PhysicalInterface::DEBUG_WIRE)
|| supportedPhysicalInterfaces.contains(PhysicalInterface::JTAG) || supportedPhysicalInterfaces.contains(PhysicalInterface::JTAG)
) { ) {
this->loadDebugWireAndJtagTargetParameters(targetParameters); this->loadDebugWireAndJtagTargetParameters(targetParameters);
} }

View File

@@ -10,6 +10,7 @@
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp" #include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
#include "src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp" #include "src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp"
#include "src/Targets/TargetVariant.hpp" #include "src/Targets/TargetVariant.hpp"
#include "src/Targets/TargetRegister.hpp"
namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
{ {
@@ -184,12 +185,22 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
*/ */
[[nodiscard]] const auto& getSupportedDebugPhysicalInterfaces() const { [[nodiscard]] const auto& getSupportedDebugPhysicalInterfaces() const {
return this->supportedDebugPhysicalInterfaces; return this->supportedDebugPhysicalInterfaces;
}; }
/**
* Returns a mapping of all pad descriptors extracted from TDF, mapped by name.
*
* @return
*/
[[nodiscard]] const auto& getPadDescriptorsMappedByName() const { [[nodiscard]] const auto& getPadDescriptorsMappedByName() const {
return this->padDescriptorsByName; return this->padDescriptorsByName;
}; }
/**
* Returns a mapping of all target variants extracted from the TDF, mapped by ID.
*
* @return
*/
[[nodiscard]] const auto& getVariantsMappedById() const { [[nodiscard]] const auto& getVariantsMappedById() const {
return this->targetVariantsById; return this->targetVariantsById;
} }