Automatically trigger refreshing of register widgets, in the TargetRegistersPane, upon a registers written event

This commit is contained in:
Nav
2021-09-11 20:45:06 +01:00
parent 12a7d58b59
commit 63a080d821
4 changed files with 43 additions and 0 deletions

View File

@@ -32,6 +32,10 @@ void InsightWorker::startup() {
std::bind(&InsightWorker::onTargetIoPortsUpdatedEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::RegistersWrittenToTarget>(
std::bind(&InsightWorker::onTargetRegistersWrittenEvent, this, std::placeholders::_1)
);
this->eventDispatchTimer = new QTimer(this);
this->connect(this->eventDispatchTimer, &QTimer::timeout, this, &InsightWorker::dispatchEvents);
this->eventDispatchTimer->start(5);
@@ -117,6 +121,10 @@ void InsightWorker::onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdat
emit this->targetIoPortsUpdated();
}
void InsightWorker::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) {
emit this->targetRegistersWritten(event.descriptors);
}
void InsightWorker::onTargetControllerStateReported(const Events::TargetControllerStateReported& event) {
if (this->lastTargetControllerState == TargetControllerState::ACTIVE
&& event.state == TargetControllerState::SUSPENDED

View File

@@ -41,6 +41,7 @@ namespace Bloom
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
void onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event);
void onTargetControllerStateReported(const Events::TargetControllerStateReported& event);
void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event);
private slots:
void executeTasks();
@@ -65,5 +66,6 @@ namespace Bloom
void targetIoPortsUpdated();
void targetControllerSuspended();
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
void targetRegistersWritten(const Bloom::Targets::TargetRegisterDescriptors& descriptors);
};
}

View File

@@ -112,6 +112,13 @@ TargetRegistersPaneWidget::TargetRegistersPaneWidget(
this,
&TargetRegistersPaneWidget::onTargetStateChanged
);
this->connect(
&insightWorker,
&InsightWorker::targetRegistersWritten,
this,
&TargetRegistersPaneWidget::onRegistersWritten
);
}
void TargetRegistersPaneWidget::resizeEvent(QResizeEvent* event) {
@@ -142,6 +149,31 @@ void TargetRegistersPaneWidget::onTargetStateChanged(Targets::TargetState newSta
}
}
void TargetRegistersPaneWidget::onRegistersWritten(const Bloom::Targets::TargetRegisterDescriptors& descriptors) {
if (this->targetState != Targets::TargetState::STOPPED) {
return;
}
/*
* Don't bother refreshing individual registers if it will involve more than two refresh calls - In this case, it
* will be faster to just refresh all of them at once.
*/
if (descriptors.size() <= 2) {
for (const auto& descriptor : descriptors) {
for (const auto& registerGroupWidget : this->registerGroupWidgets) {
if (registerGroupWidget->registerWidgetsMappedByDescriptor.contains(descriptor)) {
registerGroupWidget->registerWidgetsMappedByDescriptor.at(descriptor)->refreshValue();
break;
}
}
}
} else {
this->refreshRegisterValues();
}
}
void TargetRegistersPaneWidget::filterRegisters(const QString& keyword) {
auto stdKeyword = keyword.toLower().toStdString();

View File

@@ -44,6 +44,7 @@ namespace Bloom::Widgets
private slots:
void onTargetStateChanged(Targets::TargetState newState);
void onRegistersWritten(const Bloom::Targets::TargetRegisterDescriptors& descriptors);
protected:
void resizeEvent(QResizeEvent* event) override;