Replaced targetProgramCounterUpdated signal with new ReadProgramCounter Insight worker task.
Also some other bits of tidying
This commit is contained in:
@@ -27,6 +27,7 @@ target_sources(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadTargetMemory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadStackPointer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/QueryLatestVersionNumber.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/ReadProgramCounter.cpp
|
||||
|
||||
# Error dialogue window
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp
|
||||
|
||||
@@ -41,10 +41,6 @@ namespace Bloom
|
||||
std::bind(&InsightWorker::onTargetResetEvent, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener->registerCallbackForEventType<Events::RegistersWrittenToTarget>(
|
||||
std::bind(&InsightWorker::onTargetRegistersWrittenEvent, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener->registerCallbackForEventType<Events::ProgrammingModeEnabled>(
|
||||
std::bind(&InsightWorker::onProgrammingModeEnabledEvent, this, std::placeholders::_1)
|
||||
);
|
||||
@@ -92,7 +88,6 @@ namespace Bloom
|
||||
|
||||
this->lastTargetState = TargetState::STOPPED;
|
||||
emit this->targetStateUpdated(TargetState::STOPPED);
|
||||
emit this->targetProgramCounterUpdated(event.programCounter);
|
||||
}
|
||||
|
||||
void InsightWorker::onTargetResumedEvent(const Events::TargetExecutionResumed& event) {
|
||||
@@ -113,30 +108,13 @@ namespace Bloom
|
||||
emit this->targetStateUpdated(TargetState::STOPPED);
|
||||
}
|
||||
|
||||
emit this->targetProgramCounterUpdated(this->targetControllerConsole.getProgramCounter());
|
||||
emit this->targetReset();
|
||||
|
||||
} catch (const Exceptions::Exception& exception) {
|
||||
Logger::debug("Error handling TargetReset event - " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
void InsightWorker::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) {
|
||||
emit this->targetRegistersWritten(event.registers, event.createdTimestamp);
|
||||
|
||||
for (const auto& reg : event.registers) {
|
||||
if (reg.descriptor.type == Targets::TargetRegisterType::PROGRAM_COUNTER) {
|
||||
try {
|
||||
emit this->targetProgramCounterUpdated(this->targetControllerConsole.getProgramCounter());
|
||||
|
||||
} catch (const Exceptions::Exception& exception) {
|
||||
Logger::debug("Error reading program counter - " + exception.getMessage());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InsightWorker::onTargetControllerStateChangedEvent(const Events::TargetControllerStateChanged& event) {
|
||||
using TargetController::TargetControllerState;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Bloom
|
||||
void ready();
|
||||
void taskQueued();
|
||||
void targetStateUpdated(Bloom::Targets::TargetState newState);
|
||||
void targetProgramCounterUpdated(quint32 programCounter);
|
||||
void targetReset();
|
||||
void targetControllerSuspended();
|
||||
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
|
||||
void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp);
|
||||
@@ -65,7 +65,6 @@ namespace Bloom
|
||||
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);
|
||||
|
||||
10
src/Insight/InsightWorker/Tasks/ReadProgramCounter.cpp
Normal file
10
src/Insight/InsightWorker/Tasks/ReadProgramCounter.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "ReadProgramCounter.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using TargetController::TargetControllerConsole;
|
||||
|
||||
void ReadProgramCounter::run(TargetControllerConsole& targetControllerConsole) {
|
||||
emit this->programCounterRead(targetControllerConsole.getProgramCounter());
|
||||
}
|
||||
}
|
||||
20
src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp
Normal file
20
src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "InsightWorkerTask.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
class ReadProgramCounter: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReadProgramCounter() = default;
|
||||
|
||||
signals:
|
||||
void programCounterRead(std::uint32_t programCounter);
|
||||
|
||||
protected:
|
||||
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;
|
||||
};
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "src/Helpers/Paths.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using namespace Bloom::Exceptions;
|
||||
@@ -262,9 +264,11 @@ namespace Bloom
|
||||
);
|
||||
QObject::connect(
|
||||
&(this->insightWorker),
|
||||
&InsightWorker::targetProgramCounterUpdated,
|
||||
&InsightWorker::targetReset,
|
||||
this,
|
||||
&InsightWindow::onTargetProgramCounterUpdate
|
||||
[this] {
|
||||
this->refreshProgramCounter();
|
||||
}
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
@@ -533,11 +537,7 @@ namespace Bloom
|
||||
this->targetPackageWidget->setTargetState(this->targetState);
|
||||
|
||||
if (this->targetState == TargetState::STOPPED) {
|
||||
this->targetPackageWidget->refreshPinStates([this] {
|
||||
if (this->targetState == TargetState::STOPPED) {
|
||||
this->targetPackageWidget->setDisabled(false);
|
||||
}
|
||||
});
|
||||
this->refreshPinStates();
|
||||
}
|
||||
|
||||
this->adjustPanels();
|
||||
@@ -840,49 +840,79 @@ namespace Bloom
|
||||
this->programCounterValueLabel->setText("-");
|
||||
this->setUiDisabled(true);
|
||||
|
||||
if (this->targetPackageWidget != nullptr) {
|
||||
this->targetPackageWidget->setDisabled(true);
|
||||
}
|
||||
|
||||
} else if (newState == TargetState::STOPPED) {
|
||||
this->targetStatusLabel->setText("Stopped");
|
||||
this->setUiDisabled(false);
|
||||
this->refresh();
|
||||
|
||||
} else {
|
||||
this->targetStatusLabel->setText("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) {
|
||||
this->programCounterValueLabel->setText(
|
||||
"0x" + QString::number(programCounter, 16).toUpper() + " (" + QString::number(programCounter) + ")"
|
||||
);
|
||||
}
|
||||
|
||||
void InsightWindow::refresh() {
|
||||
if (this->targetState != TargetState::STOPPED || this->selectedVariant == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->setUiDisabled(true);
|
||||
this->refreshIoInspectionButton->startSpin();
|
||||
this->refreshIoInspectionButton->setDisabled(true);
|
||||
|
||||
if (this->targetPackageWidget != nullptr) {
|
||||
this->targetPackageWidget->setDisabled(true);
|
||||
this->targetPackageWidget->refreshPinStates([this] {
|
||||
if (this->targetState == TargetState::STOPPED) {
|
||||
this->targetPackageWidget->setDisabled(false);
|
||||
|
||||
if (this->targetRegistersSidePane == nullptr || !this->targetRegistersSidePane->state.activated) {
|
||||
this->refreshIoInspectionButton->stopSpin();
|
||||
this->setUiDisabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
this->refreshPinStates();
|
||||
}
|
||||
|
||||
if (this->targetRegistersSidePane != nullptr && this->targetRegistersSidePane->state.activated) {
|
||||
this->targetRegistersSidePane->refreshRegisterValues([this] {
|
||||
this->refreshIoInspectionButton->stopSpin();
|
||||
this->setUiDisabled(false);
|
||||
});
|
||||
if (this->targetRegistersSidePane != nullptr) {
|
||||
this->targetRegistersSidePane->refreshRegisterValues();
|
||||
}
|
||||
|
||||
this->refreshProgramCounter([this] {
|
||||
this->refreshIoInspectionButton->stopSpin();
|
||||
|
||||
if (this->targetState == TargetState::STOPPED) {
|
||||
this->refreshIoInspectionButton->setDisabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void InsightWindow::refreshPinStates() {
|
||||
this->targetPackageWidget->setDisabled(true);
|
||||
|
||||
this->targetPackageWidget->refreshPinStates([this] {
|
||||
if (this->targetState == TargetState::STOPPED) {
|
||||
this->targetPackageWidget->setDisabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void InsightWindow::refreshProgramCounter(std::optional<std::function<void(void)>> callback) {
|
||||
auto* readProgramCounterTask = new ReadProgramCounter();
|
||||
|
||||
QObject::connect(
|
||||
readProgramCounterTask,
|
||||
&ReadProgramCounter::programCounterRead,
|
||||
this,
|
||||
[this] (std::uint32_t programCounter) {
|
||||
this->programCounterValueLabel->setText(
|
||||
"0x" + QString::number(programCounter, 16).toUpper() + " (" + QString::number(programCounter) + ")"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
if (callback.has_value()) {
|
||||
QObject::connect(
|
||||
readProgramCounterTask,
|
||||
&ReadProgramCounter::finished,
|
||||
this,
|
||||
callback.value()
|
||||
);
|
||||
}
|
||||
|
||||
this->insightWorker.queueTask(readProgramCounterTask);
|
||||
}
|
||||
|
||||
void InsightWindow::openReportIssuesUrl() {
|
||||
@@ -985,6 +1015,10 @@ namespace Bloom
|
||||
|
||||
void InsightWindow::onRegistersPaneStateChanged() {
|
||||
this->targetRegistersButton->setChecked(this->targetRegistersSidePane->state.activated);
|
||||
|
||||
if (this->targetState == Targets::TargetState::STOPPED && this->targetRegistersSidePane->state.activated) {
|
||||
this->targetRegistersSidePane->refreshRegisterValues();
|
||||
}
|
||||
}
|
||||
|
||||
void InsightWindow::onRamInspectionPaneStateChanged() {
|
||||
|
||||
@@ -131,8 +131,9 @@ namespace Bloom
|
||||
void onTargetControllerSuspended();
|
||||
void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
|
||||
void onTargetStateUpdate(Targets::TargetState newState);
|
||||
void onTargetProgramCounterUpdate(quint32 programCounter);
|
||||
void refresh();
|
||||
void refreshPinStates();
|
||||
void refreshProgramCounter(std::optional<std::function<void(void)>> callback = std::nullopt);
|
||||
void openReportIssuesUrl();
|
||||
void openGettingStartedUrl();
|
||||
void openAboutWindow();
|
||||
|
||||
@@ -229,9 +229,5 @@ namespace Bloom::Widgets
|
||||
|
||||
void RegisterWidget::onTargetStateChange(Targets::TargetState newState) {
|
||||
this->targetState = newState;
|
||||
|
||||
if (this->targetState == Targets::TargetState::RUNNING) {
|
||||
this->clearInlineValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,20 +115,6 @@ namespace Bloom::Widgets
|
||||
|
||||
itemLayout->addStretch(1);
|
||||
|
||||
QObject::connect(
|
||||
this,
|
||||
&PaneWidget::paneActivated,
|
||||
this,
|
||||
&TargetRegistersPaneWidget::postActivate
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
this,
|
||||
&PaneWidget::paneDeactivated,
|
||||
this,
|
||||
&TargetRegistersPaneWidget::postDeactivate
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
&insightWorker,
|
||||
&InsightWorker::targetStateUpdated,
|
||||
@@ -240,26 +226,15 @@ namespace Bloom::Widgets
|
||||
PaneWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void TargetRegistersPaneWidget::postActivate() {
|
||||
if (this->targetState == Targets::TargetState::STOPPED) {
|
||||
this->refreshRegisterValues();
|
||||
}
|
||||
}
|
||||
|
||||
void TargetRegistersPaneWidget::postDeactivate() {
|
||||
|
||||
}
|
||||
|
||||
void TargetRegistersPaneWidget::onTargetStateChanged(Targets::TargetState newState) {
|
||||
if (this->targetState == newState) {
|
||||
return;
|
||||
}
|
||||
|
||||
using Targets::TargetState;
|
||||
this->targetState = newState;
|
||||
|
||||
if (newState == TargetState::STOPPED && this->state.activated) {
|
||||
this->refreshRegisterValues();
|
||||
if (this->targetState == Targets::TargetState::RUNNING) {
|
||||
this->clearInlineRegisterValues();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,4 +252,12 @@ namespace Bloom::Widgets
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TargetRegistersPaneWidget::clearInlineRegisterValues() {
|
||||
for (const auto& registerGroupWidget : this->registerGroupWidgets) {
|
||||
for (auto* registerWidget : registerGroupWidget->registerWidgets) {
|
||||
registerWidget->clearInlineValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +44,6 @@ namespace Bloom::Widgets
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
void postActivate();
|
||||
void postDeactivate();
|
||||
|
||||
private:
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
InsightWorker& insightWorker;
|
||||
@@ -70,5 +67,6 @@ namespace Bloom::Widgets
|
||||
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
void onRegistersRead(const Targets::TargetRegisters& registers);
|
||||
void clearInlineRegisterValues();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,17 +86,6 @@ namespace Bloom::Widgets::InsightTargetWidgets
|
||||
}
|
||||
|
||||
this->targetState = newState;
|
||||
|
||||
if (newState == TargetState::RUNNING) {
|
||||
this->setDisabled(true);
|
||||
|
||||
} else if (newState == TargetState::STOPPED) {
|
||||
this->refreshPinStates([this] {
|
||||
if (this->targetState == TargetState::STOPPED) {
|
||||
this->setDisabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void TargetPackageWidget::onProgrammingModeEnabled() {
|
||||
|
||||
Reference in New Issue
Block a user