diff --git a/src/Insight/CMakeLists.txt b/src/Insight/CMakeLists.txt index e4c3bc58..bb812749 100755 --- a/src/Insight/CMakeLists.txt +++ b/src/Insight/CMakeLists.txt @@ -2,6 +2,7 @@ target_sources( Bloom PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Insight.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/InsightSignals.hpp ${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/InsightWorker.cpp ${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/UiLoader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/BloomProxyStyle.cpp diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index 7cae516d..ff055502 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -8,11 +8,15 @@ #include "UserInterfaces/InsightWindow/BloomProxyStyle.hpp" #include "src/Application.hpp" + #include "InsightWorker/Tasks/QueryLatestVersionNumber.hpp" +#include "InsightWorker/Tasks/GetTargetState.hpp" +#include "InsightWorker/Tasks/GetTargetDescriptor.hpp" namespace Bloom { using namespace Bloom::Exceptions; + using Bloom::Targets::TargetState; Insight::Insight( EventListener& eventListener, @@ -62,7 +66,33 @@ namespace Bloom Logger::info("Starting Insight"); this->setThreadState(ThreadState::STARTING); - auto targetDescriptor = this->targetControllerConsole.getTargetDescriptor(); + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetControllerStateChangedEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetStoppedEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetResumedEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetResetEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onTargetRegistersWrittenEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onProgrammingModeEnabledEvent, this, std::placeholders::_1) + ); + + this->eventListener.registerCallbackForEventType( + std::bind(&Insight::onProgrammingModeDisabledEvent, this, std::placeholders::_1) + ); QApplication::setQuitOnLastWindowClosed(true); QApplication::setStyle(new BloomProxyStyle()); @@ -137,13 +167,13 @@ namespace Bloom */ auto* eventDispatchTimer = new QTimer(&(this->application)); QObject::connect(eventDispatchTimer, &QTimer::timeout, this, &Insight::dispatchEvents); - eventDispatchTimer->start(100); + eventDispatchTimer->start(50); QObject::connect( this->mainWindow, &InsightWindow::activatedSignal, - this->insightWorker, - &InsightWorker::onInsightWindowActivated + this, + &Insight::onInsightWindowActivated ); this->mainWindow->setInsightConfig(this->insightConfig); @@ -157,7 +187,7 @@ namespace Bloom QObject::connect(this->workerThread, &QThread::finished, this->insightWorker, &QObject::deleteLater); QObject::connect(this->workerThread, &QThread::finished, this->workerThread, &QThread::deleteLater); - this->mainWindow->init(targetDescriptor); + this->mainWindow->init(this->targetControllerConsole.getTargetDescriptor()); QObject::connect(this->insightWorker, &InsightWorker::ready, this, [this] { this->checkBloomVersion(); @@ -209,4 +239,87 @@ namespace Bloom this->insightWorker->queueTask(versionQueryTask); } + + void Insight::onInsightWindowActivated() { + auto* getTargetStateTask = new GetTargetState(); + QObject::connect( + getTargetStateTask, + &GetTargetState::targetState, + this, + [this] (Targets::TargetState targetState) { + this->lastTargetState = targetState; + emit this->insightSignals->targetStateUpdated(this->lastTargetState); + } + ); + + InsightWorker::queueTask(getTargetStateTask); + } + + void Insight::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) { + if (this->lastTargetState == TargetState::STOPPED) { + return; + } + + this->lastTargetState = TargetState::STOPPED; + emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); + } + + void Insight::onTargetResumedEvent(const Events::TargetExecutionResumed& event) { + if (this->lastTargetState != TargetState::RUNNING) { + this->lastTargetState = TargetState::RUNNING; + emit this->insightSignals->targetStateUpdated(TargetState::RUNNING); + } + } + + void Insight::onTargetResetEvent(const Events::TargetReset& event) { + try { + if (this->targetControllerConsole.getTargetState() != TargetState::STOPPED) { + return; + } + + if (this->lastTargetState != TargetState::STOPPED) { + this->lastTargetState = TargetState::STOPPED; + emit this->insightSignals->targetStateUpdated(TargetState::STOPPED); + } + + emit this->insightSignals->targetReset(); + + } catch (const Exceptions::Exception& exception) { + Logger::debug("Error handling TargetReset event - " + exception.getMessage()); + } + } + + void Insight::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) { + emit this->insightSignals->targetRegistersWritten(event.registers, event.createdTimestamp); + } + + void Insight::onTargetControllerStateChangedEvent(const Events::TargetControllerStateChanged& event) { + using TargetController::TargetControllerState; + + if (event.state == TargetControllerState::SUSPENDED) { + emit this->insightSignals->targetControllerSuspended(); + + } else if (event.state == TargetControllerState::ACTIVE) { + auto* getTargetDescriptorTask = new GetTargetDescriptor(); + + QObject::connect( + getTargetDescriptorTask, + &GetTargetDescriptor::targetDescriptor, + this, + [this] (Targets::TargetDescriptor targetDescriptor) { + emit this->insightSignals->targetControllerResumed(targetDescriptor); + } + ); + + InsightWorker::queueTask(getTargetDescriptorTask); + } + } + + void Insight::onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event) { + emit this->insightSignals->programmingModeEnabled(); + } + + void Insight::onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event) { + emit this->insightSignals->programmingModeDisabled(); + } } diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index 761065bf..23030dd9 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -4,13 +4,18 @@ #include #include "src/Helpers/Thread.hpp" -#include "src/TargetController/TargetControllerConsole.hpp" #include "src/Helpers/Paths.hpp" #include "src/ProjectConfig.hpp" #include "src/ProjectSettings.hpp" #include "src/EventManager/EventManager.hpp" #include "src/EventManager/EventListener.hpp" +#include "src/EventManager/Events/Events.hpp" + +#include "src/TargetController/TargetControllerConsole.hpp" +#include "src/Targets/TargetState.hpp" + +#include "InsightSignals.hpp" #include "InsightWorker/InsightWorker.hpp" #include "UserInterfaces/InsightWindow/InsightWindow.hpp" @@ -79,6 +84,8 @@ namespace Bloom ); TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(); + Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN; + InsightSignals* insightSignals = InsightSignals::instance(); /** * Insight consists of two threads - the main thread where the main Qt event loop runs (for the GUI), and @@ -105,5 +112,14 @@ namespace Bloom void dispatchEvents() { this->eventListener.dispatchCurrentEvents(); }; + + void onInsightWindowActivated(); + void onTargetStoppedEvent(const Events::TargetExecutionStopped& event); + void onTargetResumedEvent(const Events::TargetExecutionResumed& event); + void onTargetResetEvent(const Events::TargetReset& event); + void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event); + void onTargetControllerStateChangedEvent(const Events::TargetControllerStateChanged& event); + void onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event); + void onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event); }; } diff --git a/src/Insight/InsightSignals.hpp b/src/Insight/InsightSignals.hpp new file mode 100644 index 00000000..08eb9c5a --- /dev/null +++ b/src/Insight/InsightSignals.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include +#include + +#include "src/Targets/TargetState.hpp" +#include "src/Targets/TargetDescriptor.hpp" +#include "src/Targets/TargetRegister.hpp" + +namespace Bloom +{ + /** + * Singleton class providing global signals to all Insight widgets that require them. The signals are emitted via + * the Insight class and InsightWorkerTasks. + */ + class InsightSignals: public QObject + { + Q_OBJECT + + public: + static InsightSignals* instance() { + static auto instance = InsightSignals(); + return &instance; + } + + InsightSignals(const InsightSignals&) = delete; + void operator = (const InsightSignals&) = delete; + + signals: + void taskQueued(); + + void targetStateUpdated(Bloom::Targets::TargetState newState); + void targetReset(); + void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp); + void targetControllerSuspended(); + void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor); + void programmingModeEnabled(); + void programmingModeDisabled(); + + private: + InsightSignals() = default; + }; +} diff --git a/src/Insight/InsightWorker/InsightWorker.cpp b/src/Insight/InsightWorker/InsightWorker.cpp index 5a705b58..31fffbd6 100644 --- a/src/Insight/InsightWorker/InsightWorker.cpp +++ b/src/Insight/InsightWorker/InsightWorker.cpp @@ -1,10 +1,8 @@ #include "InsightWorker.hpp" #include -#include - -#include "src/TargetController/TargetControllerState.hpp" +#include "src/Insight/InsightSignals.hpp" #include "src/Logger/Logger.hpp" namespace Bloom @@ -13,137 +11,52 @@ namespace Bloom using Bloom::Targets::TargetState; - void InsightWorker::queueTask(InsightWorkerTask* task) { - auto taskQueueLock = this->queuedTasks.acquireLock(); - task->moveToThread(this->thread()); - task->setParent(this); - this->queuedTasks.getValue().push(task); - emit this->taskQueued(); - } - void InsightWorker::startup() { Logger::debug("Starting InsightWorker thread"); - EventManager::registerListener(this->eventListener); - this->eventListener->registerCallbackForEventType( - std::bind(&InsightWorker::onTargetControllerStateChangedEvent, this, std::placeholders::_1) - ); - - this->eventListener->registerCallbackForEventType( - std::bind(&InsightWorker::onTargetStoppedEvent, this, std::placeholders::_1) - ); - - this->eventListener->registerCallbackForEventType( - std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1) - ); - - this->eventListener->registerCallbackForEventType( - std::bind(&InsightWorker::onTargetResetEvent, this, std::placeholders::_1) - ); - - this->eventListener->registerCallbackForEventType( - std::bind(&InsightWorker::onProgrammingModeEnabledEvent, this, std::placeholders::_1) - ); - - this->eventListener->registerCallbackForEventType( - std::bind(&InsightWorker::onProgrammingModeDisabledEvent, this, std::placeholders::_1) - ); - - this->eventDispatchTimer = new QTimer(this); - QObject::connect(this->eventDispatchTimer, &QTimer::timeout, this, &InsightWorker::dispatchEvents); - this->eventDispatchTimer->start(5); - - QObject::connect(this, &InsightWorker::taskQueued, this, &InsightWorker::executeTasks); - - EventManager::triggerEvent( - std::make_shared(ThreadState::READY) + QObject::connect( + InsightSignals::instance(), + &InsightSignals::taskQueued, + this, + &InsightWorker::executeTasks ); emit this->ready(); } - void InsightWorker::onInsightWindowActivated() { - this->lastTargetState = this->targetControllerConsole.getTargetState(); - emit this->targetStateUpdated(this->lastTargetState); + void InsightWorker::queueTask(InsightWorkerTask* task) { + task->moveToThread(nullptr); + + { + const auto taskQueueLock = InsightWorker::queuedTasks.acquireLock(); + InsightWorker::queuedTasks.getValue().push(task); + } + + emit InsightSignals::instance()->taskQueued(); } std::optional InsightWorker::getQueuedTask() { - auto task = std::optional(); - - auto& queuedTasks = this->queuedTasks.getValue(); - auto taskQueueLock = this->queuedTasks.acquireLock(); + auto taskQueueLock = InsightWorker::queuedTasks.acquireLock(); + auto& queuedTasks = InsightWorker::queuedTasks.getValue(); if (!queuedTasks.empty()) { - task = queuedTasks.front(); + auto* task = queuedTasks.front(); queuedTasks.pop(); + return task; } - return task; - } - - void InsightWorker::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) { - if (this->lastTargetState == TargetState::STOPPED) { - return; - } - - this->lastTargetState = TargetState::STOPPED; - emit this->targetStateUpdated(TargetState::STOPPED); - } - - void InsightWorker::onTargetResumedEvent(const Events::TargetExecutionResumed& event) { - if (this->lastTargetState != TargetState::RUNNING) { - this->lastTargetState = TargetState::RUNNING; - emit this->targetStateUpdated(TargetState::RUNNING); - } - } - - void InsightWorker::onTargetResetEvent(const Events::TargetReset& event) { - try { - if (this->targetControllerConsole.getTargetState() != TargetState::STOPPED) { - return; - } - - if (this->lastTargetState != TargetState::STOPPED) { - this->lastTargetState = TargetState::STOPPED; - emit this->targetStateUpdated(TargetState::STOPPED); - } - - emit this->targetReset(); - - } catch (const Exceptions::Exception& exception) { - Logger::debug("Error handling TargetReset event - " + exception.getMessage()); - } - } - - void InsightWorker::onTargetControllerStateChangedEvent(const Events::TargetControllerStateChanged& event) { - using TargetController::TargetControllerState; - - if (event.state == TargetControllerState::SUSPENDED) { - emit this->targetControllerSuspended(); - - } else if (event.state == TargetControllerState::ACTIVE) { - try { - emit this->targetControllerResumed(this->targetControllerConsole.getTargetDescriptor()); - - } catch (const Exception& exception) { - Logger::error("Insight resume failed - " + exception.getMessage()); - } - } - } - - void InsightWorker::onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event) { - emit this->programmingModeEnabled(); - } - - void InsightWorker::onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event) { - emit this->programmingModeDisabled(); + return std::nullopt; } void InsightWorker::executeTasks() { - auto task = std::optional(); + auto queuedTask = std::optional(); - while ((task = this->getQueuedTask()).has_value()) { - task.value()->execute(this->targetControllerConsole); + while ((queuedTask = InsightWorker::getQueuedTask()).has_value()) { + auto* task = queuedTask.value(); + task->moveToThread(this->thread()); + task->setParent(this); + task->execute(this->targetControllerConsole); + task->deleteLater(); } } } diff --git a/src/Insight/InsightWorker/InsightWorker.hpp b/src/Insight/InsightWorker/InsightWorker.hpp index ca6ae86c..4d4705da 100644 --- a/src/Insight/InsightWorker/InsightWorker.hpp +++ b/src/Insight/InsightWorker/InsightWorker.hpp @@ -1,20 +1,13 @@ #pragma once #include -#include - -#include "src/Helpers/Thread.hpp" -#include "src/Helpers/SyncSafe.hpp" -#include "src/ProjectConfig.hpp" - -#include "src/EventManager/EventManager.hpp" -#include "src/EventManager/EventListener.hpp" -#include "src/EventManager/Events/Events.hpp" - -#include "src/TargetController/TargetControllerConsole.hpp" +#include #include "Tasks/InsightWorkerTask.hpp" +#include "src/Helpers/SyncSafe.hpp" +#include "src/TargetController/TargetControllerConsole.hpp" + namespace Bloom { /** @@ -28,47 +21,18 @@ namespace Bloom public: InsightWorker() = default; - void queueTask(InsightWorkerTask* task); - void startup(); - - void onInsightWindowActivated(); + static void queueTask(InsightWorkerTask* task); signals: void ready(); - void taskQueued(); - void targetStateUpdated(Bloom::Targets::TargetState newState); - void targetReset(); - void targetControllerSuspended(); - void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor); - void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp); - void programmingModeEnabled(); - void programmingModeDisabled(); private: - EventListenerPointer eventListener = std::make_shared("InsightWorkerEventListener"); - TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(); - Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN; - - QTimer* eventDispatchTimer = nullptr; - - SyncSafe> queuedTasks; - - void dispatchEvents() { - this->eventListener->dispatchCurrentEvents(); - } - - std::optional getQueuedTask(); - - void onTargetStoppedEvent(const Events::TargetExecutionStopped& event); - void onTargetResumedEvent(const Events::TargetExecutionResumed& event); - void onTargetResetEvent(const Events::TargetReset& event); - void onTargetControllerStateChangedEvent(const Events::TargetControllerStateChanged& event); - void onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event); - void onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event); + static inline SyncSafe> queuedTasks = {}; + static std::optional getQueuedTask(); void executeTasks(); }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index cd4f66f2..136bafc7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -16,6 +16,8 @@ #include "src/Targets/TargetMemory.hpp" +#include "src/Insight/InsightSignals.hpp" +#include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp" namespace Bloom @@ -244,28 +246,30 @@ namespace Bloom &InsightWindow::toggleEepromInspectionPane ); - // InsightWorker connections + // InsightSignal connections + auto* insightSignals = InsightSignals::instance(); + QObject::connect( - &(this->insightWorker), - &InsightWorker::targetControllerSuspended, + insightSignals, + &InsightSignals::targetControllerSuspended, this, &InsightWindow::onTargetControllerSuspended ); QObject::connect( - &(this->insightWorker), - &InsightWorker::targetControllerResumed, + insightSignals, + &InsightSignals::targetControllerResumed, this, &InsightWindow::onTargetControllerResumed ); QObject::connect( - &(this->insightWorker), - &InsightWorker::targetStateUpdated, + insightSignals, + &InsightSignals::targetStateUpdated, this, &InsightWindow::onTargetStateUpdate ); QObject::connect( - &(this->insightWorker), - &InsightWorker::targetReset, + insightSignals, + &InsightSignals::targetReset, this, [this] { this->refreshProgramCounter(); @@ -273,14 +277,14 @@ namespace Bloom ); QObject::connect( - &(this->insightWorker), - &InsightWorker::programmingModeEnabled, + insightSignals, + &InsightSignals::programmingModeEnabled, this, &InsightWindow::onProgrammingModeEnabled ); QObject::connect( - &(this->insightWorker), - &InsightWorker::programmingModeDisabled, + insightSignals, + &InsightSignals::programmingModeDisabled, this, &InsightWindow::onProgrammingModeDisabled ); @@ -913,7 +917,7 @@ namespace Bloom ); } - this->insightWorker.queueTask(readProgramCounterTask); + InsightWorker::queueTask(readProgramCounterTask); } void InsightWindow::openReportIssuesUrl() { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp index f7a09e50..223f90a8 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp @@ -2,6 +2,8 @@ #include +#include "src/Insight/InsightSignals.hpp" + namespace Bloom::Widgets { using Bloom::Targets::TargetMemoryDescriptor; @@ -54,8 +56,8 @@ namespace Bloom::Widgets } QObject::connect( - &insightWorker, - &InsightWorker::targetStateUpdated, + InsightSignals::instance(), + &InsightSignals::targetStateUpdated, this, &ByteItemGraphicsScene::onTargetStateChanged ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp index d71a18e7..00f3efcc 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp @@ -1,6 +1,7 @@ #include "HexViewerWidget.hpp" #include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp" +#include "src/Insight/InsightSignals.hpp" #include "src/Helpers/Paths.hpp" #include "src/Exceptions/Exception.hpp" @@ -156,8 +157,8 @@ namespace Bloom::Widgets ); QObject::connect( - &insightWorker, - &InsightWorker::targetStateUpdated, + InsightSignals::instance(), + &InsightSignals::targetStateUpdated, this, &HexViewerWidget::onTargetStateChanged ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp index c5fdd5ac..bed95428 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp @@ -4,6 +4,8 @@ #include #include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp" +#include "src/Insight/InsightSignals.hpp" +#include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" #include "src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp" @@ -169,23 +171,25 @@ namespace Bloom::Widgets &TargetMemoryInspectionPane::attach ); + auto* insightSignals = InsightSignals::instance(); + QObject::connect( - &insightWorker, - &InsightWorker::targetStateUpdated, + insightSignals, + &InsightSignals::targetStateUpdated, this, &TargetMemoryInspectionPane::onTargetStateChanged ); QObject::connect( - &insightWorker, - &InsightWorker::programmingModeEnabled, + insightSignals, + &InsightSignals::programmingModeEnabled, this, &TargetMemoryInspectionPane::onProgrammingModeEnabled ); QObject::connect( - &insightWorker, - &InsightWorker::programmingModeDisabled, + insightSignals, + &InsightSignals::programmingModeDisabled, this, &TargetMemoryInspectionPane::onProgrammingModeDisabled ); @@ -268,7 +272,7 @@ namespace Bloom::Widgets ); } - this->insightWorker.queueTask(readStackPointerTask); + InsightWorker::queueTask(readStackPointerTask); } } ); @@ -312,7 +316,7 @@ namespace Bloom::Widgets ); } - this->insightWorker.queueTask(readMemoryTask); + InsightWorker::queueTask(readMemoryTask); } void TargetMemoryInspectionPane::resizeEvent(QResizeEvent* event) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp index 772b54e1..c4292134 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/RegisterHistoryWidget.cpp @@ -7,6 +7,7 @@ #include #include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp" +#include "src/Insight/InsightSignals.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" #include "src/Helpers/Paths.hpp" @@ -60,16 +61,18 @@ namespace Bloom::Widgets titleBar->setContentsMargins(0, 0, 0, 0); title->setFixedHeight(titleBar->height()); + auto* insightSignals = InsightSignals::instance(); + QObject::connect( - &insightWorker, - &InsightWorker::targetStateUpdated, + insightSignals, + &InsightSignals::targetStateUpdated, this, &RegisterHistoryWidget::onTargetStateChanged ); QObject::connect( - &insightWorker, - &InsightWorker::targetRegistersWritten, + insightSignals, + &InsightSignals::targetRegistersWritten, this, &RegisterHistoryWidget::onRegistersWritten ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp index 6569002a..835ccc4f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/TargetRegisterInspectorWindow.cpp @@ -6,6 +6,8 @@ #include #include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp" +#include "src/Insight/InsightSignals.hpp" +#include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp" #include "src/Helpers/Paths.hpp" @@ -200,8 +202,8 @@ namespace Bloom::Widgets ); QObject::connect( - &insightWorker, - &InsightWorker::targetStateUpdated, + InsightSignals::instance(), + &InsightSignals::targetStateUpdated, this, &TargetRegisterInspectorWindow::onTargetStateChanged ); @@ -345,7 +347,7 @@ namespace Bloom::Widgets } ); - this->insightWorker.queueTask(readTargetRegisterTask); + InsightWorker::queueTask(readTargetRegisterTask); } void TargetRegisterInspectorWindow::applyChanges() { @@ -374,7 +376,7 @@ namespace Bloom::Widgets errorDialogue->show(); }); - this->insightWorker.queueTask(writeRegisterTask); + InsightWorker::queueTask(writeRegisterTask); } void TargetRegisterInspectorWindow::openHelpPage() { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp index a481fef0..8d829b2a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterWidget.cpp @@ -7,6 +7,8 @@ #include "src/Helpers/Paths.hpp" +#include "src/Insight/InsightSignals.hpp" +#include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp" namespace Bloom::Widgets @@ -60,8 +62,8 @@ namespace Bloom::Widgets QObject::connect(this->copyValueBinaryAction, &QAction::triggered, this, &RegisterWidget::copyValueBinary); QObject::connect( - &(this->insightWorker), - &InsightWorker::targetStateUpdated, + InsightSignals::instance(), + &InsightSignals::targetStateUpdated, this, &RegisterWidget::onTargetStateChange ); @@ -174,7 +176,7 @@ namespace Bloom::Widgets } ); - this->insightWorker.queueTask(readRegisterTask); + InsightWorker::queueTask(readRegisterTask); } void RegisterWidget::copyName() { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp index 01c46e49..61a5f503 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp @@ -4,6 +4,8 @@ #include #include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp" +#include "src/Insight/InsightSignals.hpp" +#include "src/Insight/InsightWorker/InsightWorker.hpp" #include "RegisterGroupWidget.hpp" #include "RegisterWidget.hpp" @@ -115,16 +117,18 @@ namespace Bloom::Widgets itemLayout->addStretch(1); + auto* insightSignals = InsightSignals::instance(); + QObject::connect( - &insightWorker, - &InsightWorker::targetStateUpdated, + insightSignals, + &InsightSignals::targetStateUpdated, this, &TargetRegistersPaneWidget::onTargetStateChanged ); QObject::connect( - &insightWorker, - &InsightWorker::targetRegistersWritten, + insightSignals, + &InsightSignals::targetRegistersWritten, this, &TargetRegistersPaneWidget::onRegistersRead ); @@ -197,7 +201,7 @@ namespace Bloom::Widgets ); } - this->insightWorker.queueTask(readRegisterTask); + InsightWorker::queueTask(readRegisterTask); } void TargetRegistersPaneWidget::onItemSelectionChange(ItemWidget* newlySelectedWidget) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp index 6009d2e8..ae8672b5 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp @@ -2,6 +2,8 @@ #include +#include "src/Insight/InsightSignals.hpp" +#include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/InsightWorker/Tasks/RefreshTargetPinStates.hpp" namespace Bloom::Widgets::InsightTargetWidgets @@ -17,30 +19,32 @@ namespace Bloom::Widgets::InsightTargetWidgets , targetVariant(std::move(targetVariant)) , insightWorker(insightWorker) { + auto* insightSignals = InsightSignals::instance(); + QObject::connect( - &(this->insightWorker), - &InsightWorker::targetStateUpdated, + insightSignals, + &InsightSignals::targetStateUpdated, this, &TargetPackageWidget::onTargetStateChanged ); QObject::connect( - &(this->insightWorker), - &InsightWorker::targetRegistersWritten, + insightSignals, + &InsightSignals::targetRegistersWritten, this, &TargetPackageWidget::onRegistersWritten ); QObject::connect( - &(this->insightWorker), - &InsightWorker::programmingModeEnabled, + insightSignals, + &InsightSignals::programmingModeEnabled, this, &TargetPackageWidget::onProgrammingModeEnabled ); QObject::connect( - &(this->insightWorker), - &InsightWorker::programmingModeDisabled, + insightSignals, + &InsightSignals::programmingModeDisabled, this, &TargetPackageWidget::onProgrammingModeDisabled ); @@ -66,7 +70,7 @@ namespace Bloom::Widgets::InsightTargetWidgets ); } - this->insightWorker.queueTask(refreshTask); + InsightWorker::queueTask(refreshTask); } void TargetPackageWidget::updatePinStates(const Targets::TargetPinStateMappingType& pinStatesByNumber) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp index 4ca9d8e5..ac1e77da 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPinWidget.cpp @@ -1,5 +1,6 @@ #include "TargetPinWidget.hpp" +#include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Insight/InsightWorker/Tasks/SetTargetPinState.hpp" namespace Bloom::Widgets::InsightTargetWidgets @@ -46,7 +47,7 @@ namespace Bloom::Widgets::InsightTargetWidgets this->setDisabled(false); }); - this->insightWorker.queueTask(setPinStateTask); + InsightWorker::queueTask(setPinStateTask); } } }