Replaced InsightWorker signals with InsightSignals singleton

This commit is contained in:
Nav
2022-09-07 22:25:28 +01:00
parent 227f0d4092
commit 0a45bca30a
16 changed files with 292 additions and 215 deletions

View File

@@ -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

View File

@@ -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<Events::TargetControllerStateChanged>(
std::bind(&Insight::onTargetControllerStateChangedEvent, this, std::placeholders::_1)
);
this->eventListener.registerCallbackForEventType<Events::TargetExecutionStopped>(
std::bind(&Insight::onTargetStoppedEvent, this, std::placeholders::_1)
);
this->eventListener.registerCallbackForEventType<Events::TargetExecutionResumed>(
std::bind(&Insight::onTargetResumedEvent, this, std::placeholders::_1)
);
this->eventListener.registerCallbackForEventType<Events::TargetReset>(
std::bind(&Insight::onTargetResetEvent, this, std::placeholders::_1)
);
this->eventListener.registerCallbackForEventType<Events::RegistersWrittenToTarget>(
std::bind(&Insight::onTargetRegistersWrittenEvent, this, std::placeholders::_1)
);
this->eventListener.registerCallbackForEventType<Events::ProgrammingModeEnabled>(
std::bind(&Insight::onProgrammingModeEnabledEvent, this, std::placeholders::_1)
);
this->eventListener.registerCallbackForEventType<Events::ProgrammingModeDisabled>(
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();
}
}

View File

@@ -4,13 +4,18 @@
#include <QApplication>
#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);
};
}

View File

@@ -0,0 +1,43 @@
#pragma once
#include <QObject>
#include <QDateTime>
#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;
};
}

View File

@@ -1,10 +1,8 @@
#include "InsightWorker.hpp"
#include <QObject>
#include <QTimer>
#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<Events::TargetControllerStateChanged>(
std::bind(&InsightWorker::onTargetControllerStateChangedEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::TargetExecutionStopped>(
std::bind(&InsightWorker::onTargetStoppedEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::TargetExecutionResumed>(
std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::TargetReset>(
std::bind(&InsightWorker::onTargetResetEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::ProgrammingModeEnabled>(
std::bind(&InsightWorker::onProgrammingModeEnabledEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::ProgrammingModeDisabled>(
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<Events::InsightThreadStateChanged>(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<InsightWorkerTask*> InsightWorker::getQueuedTask() {
auto task = std::optional<InsightWorkerTask*>();
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<InsightWorkerTask*>();
auto queuedTask = std::optional<InsightWorkerTask*>();
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();
}
}
}

View File

@@ -1,20 +1,13 @@
#pragma once
#include <QtCore>
#include <QApplication>
#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 <queue>
#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<EventListener>("InsightWorkerEventListener");
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole();
Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN;
QTimer* eventDispatchTimer = nullptr;
SyncSafe<std::queue<InsightWorkerTask*>> queuedTasks;
void dispatchEvents() {
this->eventListener->dispatchCurrentEvents();
}
std::optional<InsightWorkerTask*> 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<std::queue<InsightWorkerTask*>> queuedTasks = {};
static std::optional<InsightWorkerTask*> getQueuedTask();
void executeTasks();
};
}

View File

@@ -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() {

View File

@@ -2,6 +2,8 @@
#include <cmath>
#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
);

View File

@@ -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
);

View File

@@ -4,6 +4,8 @@
#include <QToolButton>
#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) {

View File

@@ -7,6 +7,7 @@
#include <set>
#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
);

View File

@@ -6,6 +6,8 @@
#include <QPlainTextEdit>
#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() {

View File

@@ -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() {

View File

@@ -4,6 +4,8 @@
#include <set>
#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) {

View File

@@ -2,6 +2,8 @@
#include <QEvent>
#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) {

View File

@@ -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);
}
}
}