Removed redundant 'Bloom' namespace from entire codebase
This commit is contained in:
@@ -8,104 +8,101 @@
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
CaptureMemorySnapshot::CaptureMemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const std::vector<FocusedMemoryRegion>& focusedRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedRegions,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data
|
||||
)
|
||||
: name(name)
|
||||
, description(description)
|
||||
, memoryType(memoryType)
|
||||
, focusedRegions(focusedRegions)
|
||||
, excludedRegions(excludedRegions)
|
||||
, data(data)
|
||||
{}
|
||||
CaptureMemorySnapshot::CaptureMemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const std::vector<FocusedMemoryRegion>& focusedRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedRegions,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data
|
||||
)
|
||||
: name(name)
|
||||
, description(description)
|
||||
, memoryType(memoryType)
|
||||
, focusedRegions(focusedRegions)
|
||||
, excludedRegions(excludedRegions)
|
||||
, data(data)
|
||||
{}
|
||||
|
||||
void CaptureMemorySnapshot::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
void CaptureMemorySnapshot::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
Logger::info("Capturing snapshot");
|
||||
Logger::info("Capturing snapshot");
|
||||
|
||||
const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
|
||||
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
|
||||
const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
|
||||
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
|
||||
|
||||
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
throw Exceptions::Exception("Invalid memory type");
|
||||
}
|
||||
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
throw Exceptions::Exception("Invalid memory type");
|
||||
}
|
||||
|
||||
const auto& memoryDescriptor = memoryDescriptorIt->second;
|
||||
const auto memorySize = memoryDescriptor.size();
|
||||
const auto& memoryDescriptor = memoryDescriptorIt->second;
|
||||
const auto memorySize = memoryDescriptor.size();
|
||||
|
||||
if (!this->data.has_value()) {
|
||||
Logger::info("Reading data for snapshot capture");
|
||||
if (!this->data.has_value()) {
|
||||
Logger::info("Reading data for snapshot capture");
|
||||
|
||||
this->data = Targets::TargetMemoryBuffer();
|
||||
this->data->reserve(memorySize);
|
||||
this->data = Targets::TargetMemoryBuffer();
|
||||
this->data->reserve(memorySize);
|
||||
|
||||
const auto readSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
);
|
||||
const auto readsRequired = static_cast<std::uint32_t>(
|
||||
std::ceil(static_cast<float>(memorySize) / static_cast<float>(readSize))
|
||||
);
|
||||
|
||||
for (std::uint32_t i = 0; i < readsRequired; i++) {
|
||||
auto dataSegment = targetControllerService.readMemory(
|
||||
this->memoryType,
|
||||
memoryDescriptor.addressRange.startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
|
||||
(memorySize - this->data->size()) >= readSize
|
||||
? readSize
|
||||
: static_cast<Targets::TargetMemorySize>(memorySize - this->data->size()),
|
||||
{}
|
||||
);
|
||||
|
||||
std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(*this->data));
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(i) + 1) / (static_cast<float>(readsRequired + 1) / 100)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
assert(this->data->size() == memorySize);
|
||||
|
||||
auto snapshot = MemorySnapshot(
|
||||
std::move(this->name),
|
||||
std::move(this->description),
|
||||
this->memoryType,
|
||||
std::move(*this->data),
|
||||
targetControllerService.getProgramCounter(),
|
||||
targetControllerService.getStackPointer(),
|
||||
std::move(this->focusedRegions),
|
||||
std::move(this->excludedRegions)
|
||||
const auto readSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
);
|
||||
const auto readsRequired = static_cast<std::uint32_t>(
|
||||
std::ceil(static_cast<float>(memorySize) / static_cast<float>(readSize))
|
||||
);
|
||||
|
||||
const auto snapshotDirPath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(snapshot.memoryType);
|
||||
for (std::uint32_t i = 0; i < readsRequired; i++) {
|
||||
auto dataSegment = targetControllerService.readMemory(
|
||||
this->memoryType,
|
||||
memoryDescriptor.addressRange.startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
|
||||
(memorySize - this->data->size()) >= readSize
|
||||
? readSize
|
||||
: static_cast<Targets::TargetMemorySize>(memorySize - this->data->size()),
|
||||
{}
|
||||
);
|
||||
|
||||
QDir().mkpath(snapshotDirPath);
|
||||
|
||||
const auto snapshotFilePath = snapshotDirPath + "/" + snapshot.id + ".json";
|
||||
|
||||
auto outputFile = QFile(snapshotFilePath);
|
||||
|
||||
if (!outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
|
||||
Logger::error("Failed to save snapshot - cannot open " + snapshotFilePath.toStdString());
|
||||
return;
|
||||
std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(*this->data));
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(i) + 1) / (static_cast<float>(readsRequired + 1) / 100)
|
||||
));
|
||||
}
|
||||
|
||||
outputFile.write(QJsonDocument(snapshot.toJson()).toJson(QJsonDocument::JsonFormat::Compact));
|
||||
outputFile.close();
|
||||
|
||||
Logger::info("Snapshot captured - UUID: " + snapshot.id.toStdString());
|
||||
|
||||
emit this->memorySnapshotCaptured(std::move(snapshot));
|
||||
}
|
||||
|
||||
assert(this->data->size() == memorySize);
|
||||
|
||||
auto snapshot = MemorySnapshot(
|
||||
std::move(this->name),
|
||||
std::move(this->description),
|
||||
this->memoryType,
|
||||
std::move(*this->data),
|
||||
targetControllerService.getProgramCounter(),
|
||||
targetControllerService.getStackPointer(),
|
||||
std::move(this->focusedRegions),
|
||||
std::move(this->excludedRegions)
|
||||
);
|
||||
|
||||
const auto snapshotDirPath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(snapshot.memoryType);
|
||||
|
||||
QDir().mkpath(snapshotDirPath);
|
||||
|
||||
const auto snapshotFilePath = snapshotDirPath + "/" + snapshot.id + ".json";
|
||||
|
||||
auto outputFile = QFile(snapshotFilePath);
|
||||
|
||||
if (!outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) {
|
||||
Logger::error("Failed to save snapshot - cannot open " + snapshotFilePath.toStdString());
|
||||
return;
|
||||
}
|
||||
|
||||
outputFile.write(QJsonDocument(snapshot.toJson()).toJson(QJsonDocument::JsonFormat::Compact));
|
||||
outputFile.close();
|
||||
|
||||
Logger::info("Snapshot captured - UUID: " + snapshot.id.toStdString());
|
||||
|
||||
emit this->memorySnapshotCaptured(std::move(snapshot));
|
||||
}
|
||||
|
||||
@@ -8,45 +8,42 @@
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class CaptureMemorySnapshot: public InsightWorkerTask
|
||||
{
|
||||
class CaptureMemorySnapshot: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CaptureMemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const std::vector<FocusedMemoryRegion>& focusedRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedRegions,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data
|
||||
);
|
||||
public:
|
||||
CaptureMemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const std::vector<FocusedMemoryRegion>& focusedRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedRegions,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data
|
||||
);
|
||||
|
||||
QString brief() const override {
|
||||
return "Capturing memory snapshot";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Capturing memory snapshot";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void memorySnapshotCaptured(MemorySnapshot snapshot);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
QString name;
|
||||
QString description;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
std::vector<FocusedMemoryRegion> focusedRegions;
|
||||
std::vector<ExcludedMemoryRegion> excludedRegions;
|
||||
|
||||
std::optional<Targets::TargetMemoryBuffer> data;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void memorySnapshotCaptured(MemorySnapshot snapshot);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
QString name;
|
||||
QString description;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
std::vector<FocusedMemoryRegion> focusedRegions;
|
||||
std::vector<ExcludedMemoryRegion> excludedRegions;
|
||||
|
||||
std::optional<Targets::TargetMemoryBuffer> data;
|
||||
};
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
#include "ConstructHexViewerTopLevelGroupItem.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
ConstructHexViewerTopLevelGroupItem::ConstructHexViewerTopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const Widgets::HexViewerSharedState& hexViewerState
|
||||
)
|
||||
: focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, hexViewerState(hexViewerState)
|
||||
{}
|
||||
ConstructHexViewerTopLevelGroupItem::ConstructHexViewerTopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const Widgets::HexViewerSharedState& hexViewerState
|
||||
)
|
||||
: focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, hexViewerState(hexViewerState)
|
||||
{}
|
||||
|
||||
void ConstructHexViewerTopLevelGroupItem::run(Services::TargetControllerService&) {
|
||||
auto* item = new Widgets::TopLevelGroupItem(
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->hexViewerState
|
||||
);
|
||||
item->rebuildItemHierarchy();
|
||||
void ConstructHexViewerTopLevelGroupItem::run(Services::TargetControllerService&) {
|
||||
auto* item = new Widgets::TopLevelGroupItem(
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->hexViewerState
|
||||
);
|
||||
item->rebuildItemHierarchy();
|
||||
|
||||
emit this->topLevelGroupItem(item);
|
||||
}
|
||||
emit this->topLevelGroupItem(item);
|
||||
}
|
||||
|
||||
@@ -8,36 +8,33 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/TopLevelGroupItem.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class ConstructHexViewerTopLevelGroupItem: public InsightWorkerTask
|
||||
{
|
||||
class ConstructHexViewerTopLevelGroupItem: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConstructHexViewerTopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const Widgets::HexViewerSharedState& hexViewerState
|
||||
);
|
||||
public:
|
||||
ConstructHexViewerTopLevelGroupItem(
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
const Widgets::HexViewerSharedState& hexViewerState
|
||||
);
|
||||
|
||||
QString brief() const override {
|
||||
return "Preparing hex viewer";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Preparing hex viewer";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups();
|
||||
};
|
||||
|
||||
signals:
|
||||
void topLevelGroupItem(Widgets::TopLevelGroupItem* item);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService&) override;
|
||||
|
||||
private:
|
||||
const Widgets::HexViewerSharedState& hexViewerState;
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups();
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void topLevelGroupItem(Widgets::TopLevelGroupItem* item);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService&) override;
|
||||
|
||||
private:
|
||||
const Widgets::HexViewerSharedState& hexViewerState;
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
};
|
||||
|
||||
@@ -6,37 +6,34 @@
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
DeleteMemorySnapshot::DeleteMemorySnapshot(
|
||||
const QString& snapshotId,
|
||||
Targets::TargetMemoryType memoryType
|
||||
)
|
||||
: snapshotId(snapshotId)
|
||||
, memoryType(memoryType)
|
||||
{}
|
||||
DeleteMemorySnapshot::DeleteMemorySnapshot(
|
||||
const QString& snapshotId,
|
||||
Targets::TargetMemoryType memoryType
|
||||
)
|
||||
: snapshotId(snapshotId)
|
||||
, memoryType(memoryType)
|
||||
{}
|
||||
|
||||
void DeleteMemorySnapshot::run(TargetControllerService&) {
|
||||
using Targets::TargetMemorySize;
|
||||
void DeleteMemorySnapshot::run(TargetControllerService&) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
Logger::info("Deleting snapshot " + this->snapshotId.toStdString());
|
||||
Logger::info("Deleting snapshot " + this->snapshotId.toStdString());
|
||||
|
||||
const auto snapshotFilePath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(this->memoryType) + "/"
|
||||
+ this->snapshotId + ".json";
|
||||
const auto snapshotFilePath = QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(this->memoryType) + "/"
|
||||
+ this->snapshotId + ".json";
|
||||
|
||||
auto snapshotFile = QFile(snapshotFilePath);
|
||||
auto snapshotFile = QFile(snapshotFilePath);
|
||||
|
||||
if (!snapshotFile.exists()) {
|
||||
Logger::warning(
|
||||
"Could not find snapshot file for " + this->snapshotId.toStdString() + " - expected path: "
|
||||
+ snapshotFilePath.toStdString()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
snapshotFile.remove();
|
||||
if (!snapshotFile.exists()) {
|
||||
Logger::warning(
|
||||
"Could not find snapshot file for " + this->snapshotId.toStdString() + " - expected path: "
|
||||
+ snapshotFilePath.toStdString()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
snapshotFile.remove();
|
||||
}
|
||||
|
||||
@@ -6,24 +6,21 @@
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class DeleteMemorySnapshot: public InsightWorkerTask
|
||||
{
|
||||
class DeleteMemorySnapshot: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeleteMemorySnapshot(const QString& snapshotId, Targets::TargetMemoryType memoryType);
|
||||
public:
|
||||
DeleteMemorySnapshot(const QString& snapshotId, Targets::TargetMemoryType memoryType);
|
||||
|
||||
QString brief() const override {
|
||||
return "Deleting memory snapshot " + this->snapshotId;
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Deleting memory snapshot " + this->snapshotId;
|
||||
}
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
QString snapshotId;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
};
|
||||
}
|
||||
private:
|
||||
QString snapshotId;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "GetTargetDescriptor.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void GetTargetDescriptor::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetDescriptor(targetControllerService.getTargetDescriptor());
|
||||
}
|
||||
void GetTargetDescriptor::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetDescriptor(targetControllerService.getTargetDescriptor());
|
||||
}
|
||||
|
||||
@@ -4,29 +4,26 @@
|
||||
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class GetTargetDescriptor: public InsightWorkerTask
|
||||
{
|
||||
class GetTargetDescriptor: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GetTargetDescriptor() = default;
|
||||
public:
|
||||
GetTargetDescriptor() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Obtaining target descriptor";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Obtaining target descriptor";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetDescriptor(Targets::TargetDescriptor targetDescriptor);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void targetDescriptor(Targets::TargetDescriptor targetDescriptor);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "GetTargetState.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void GetTargetState::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetState(targetControllerService.getTargetState());
|
||||
}
|
||||
void GetTargetState::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetState(targetControllerService.getTargetState());
|
||||
}
|
||||
|
||||
@@ -4,29 +4,26 @@
|
||||
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class GetTargetState: public InsightWorkerTask
|
||||
{
|
||||
class GetTargetState: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GetTargetState() = default;
|
||||
public:
|
||||
GetTargetState() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Obtaining target state";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Obtaining target state";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetState(Targets::TargetState state);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void targetState(Targets::TargetState state);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
};
|
||||
|
||||
@@ -2,36 +2,33 @@
|
||||
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
InsightWorkerTask::InsightWorkerTask()
|
||||
: QObject(nullptr)
|
||||
{}
|
||||
InsightWorkerTask::InsightWorkerTask()
|
||||
: QObject(nullptr)
|
||||
{}
|
||||
|
||||
void InsightWorkerTask::execute(TargetControllerService& targetControllerService) {
|
||||
try {
|
||||
this->state = InsightWorkerTaskState::STARTED;
|
||||
emit this->started();
|
||||
void InsightWorkerTask::execute(TargetControllerService& targetControllerService) {
|
||||
try {
|
||||
this->state = InsightWorkerTaskState::STARTED;
|
||||
emit this->started();
|
||||
|
||||
this->run(targetControllerService);
|
||||
this->run(targetControllerService);
|
||||
|
||||
this->state = InsightWorkerTaskState::COMPLETED;
|
||||
this->setProgressPercentage(100);
|
||||
emit this->completed();
|
||||
this->state = InsightWorkerTaskState::COMPLETED;
|
||||
this->setProgressPercentage(100);
|
||||
emit this->completed();
|
||||
|
||||
} catch (std::exception& exception) {
|
||||
this->state = InsightWorkerTaskState::FAILED;
|
||||
Logger::debug("InsightWorker task failed - " + std::string(exception.what()));
|
||||
emit this->failed(QString::fromStdString(exception.what()));
|
||||
}
|
||||
|
||||
emit this->finished();
|
||||
} catch (std::exception& exception) {
|
||||
this->state = InsightWorkerTaskState::FAILED;
|
||||
Logger::debug("InsightWorker task failed - " + std::string(exception.what()));
|
||||
emit this->failed(QString::fromStdString(exception.what()));
|
||||
}
|
||||
|
||||
void InsightWorkerTask::setProgressPercentage(std::uint8_t percentage) {
|
||||
this->progressPercentage = percentage;
|
||||
emit this->progressUpdate(this->progressPercentage);
|
||||
}
|
||||
emit this->finished();
|
||||
}
|
||||
|
||||
void InsightWorkerTask::setProgressPercentage(std::uint8_t percentage) {
|
||||
this->progressPercentage = percentage;
|
||||
emit this->progressUpdate(this->progressPercentage);
|
||||
}
|
||||
|
||||
@@ -8,81 +8,78 @@
|
||||
#include "TaskGroup.hpp"
|
||||
#include "src/Services/TargetControllerService.hpp"
|
||||
|
||||
namespace Bloom
|
||||
enum class InsightWorkerTaskState: std::uint8_t
|
||||
{
|
||||
enum class InsightWorkerTaskState: std::uint8_t
|
||||
{
|
||||
CREATED,
|
||||
STARTED,
|
||||
FAILED,
|
||||
COMPLETED,
|
||||
CREATED,
|
||||
STARTED,
|
||||
FAILED,
|
||||
COMPLETED,
|
||||
};
|
||||
|
||||
static_assert(std::atomic<InsightWorkerTaskState>::is_always_lock_free);
|
||||
static_assert(std::atomic<std::uint8_t>::is_always_lock_free);
|
||||
|
||||
class InsightWorkerTask: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using IdType = std::uint64_t;
|
||||
const InsightWorkerTask::IdType id = ++(InsightWorkerTask::lastId);
|
||||
std::atomic<InsightWorkerTaskState> state = InsightWorkerTaskState::CREATED;
|
||||
std::atomic<std::uint8_t> progressPercentage = 0;
|
||||
|
||||
InsightWorkerTask();
|
||||
|
||||
virtual QString brief() const = 0;
|
||||
|
||||
virtual TaskGroups taskGroups() const {
|
||||
return TaskGroups();
|
||||
};
|
||||
|
||||
static_assert(std::atomic<InsightWorkerTaskState>::is_always_lock_free);
|
||||
static_assert(std::atomic<std::uint8_t>::is_always_lock_free);
|
||||
void execute(Services::TargetControllerService& targetControllerService);
|
||||
|
||||
class InsightWorkerTask: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
/**
|
||||
* The InsightWorkerTask::started() signal will be emitted once the task has started (InsightWorker::run() is
|
||||
* called)
|
||||
*/
|
||||
void started();
|
||||
|
||||
public:
|
||||
using IdType = std::uint64_t;
|
||||
const InsightWorkerTask::IdType id = ++(InsightWorkerTask::lastId);
|
||||
std::atomic<InsightWorkerTaskState> state = InsightWorkerTaskState::CREATED;
|
||||
std::atomic<std::uint8_t> progressPercentage = 0;
|
||||
/**
|
||||
* Some tasks will emit an InsightWorkerTask::progressUpdate() signal to provide an update on their progress.
|
||||
*
|
||||
* This is used for progress bar widgets.
|
||||
*
|
||||
* NOTE: A task doesn't have to emit this signal. Currently, the time-expensive tasks (like ReadTargetMemory)
|
||||
* emit this signal.
|
||||
*
|
||||
* @param progressPercentage
|
||||
* The task's current progress.
|
||||
*/
|
||||
void progressUpdate(std::uint8_t progressPercentage);
|
||||
|
||||
InsightWorkerTask();
|
||||
/**
|
||||
* The InsightWorkerTask::completed() signal will be emitted once the task has successfully completed.
|
||||
*/
|
||||
void completed();
|
||||
|
||||
virtual QString brief() const = 0;
|
||||
/**
|
||||
* The InsightWorkerTask::failed() signal will be emitted when the task fails (InsightWorkerTask::run() throws
|
||||
* an exception).
|
||||
*/
|
||||
void failed(QString errorMessage);
|
||||
|
||||
virtual TaskGroups taskGroups() const {
|
||||
return TaskGroups();
|
||||
};
|
||||
/**
|
||||
* The InsightWorkerTask::finished() signal will be emitted at the end of the task, regardless to whether it
|
||||
* completed successfully or failed.
|
||||
*/
|
||||
void finished();
|
||||
|
||||
void execute(Services::TargetControllerService& targetControllerService);
|
||||
protected:
|
||||
virtual void run(Services::TargetControllerService& targetControllerService) = 0;
|
||||
void setProgressPercentage(std::uint8_t percentage);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* The InsightWorkerTask::started() signal will be emitted once the task has started (InsightWorker::run() is
|
||||
* called)
|
||||
*/
|
||||
void started();
|
||||
|
||||
/**
|
||||
* Some tasks will emit an InsightWorkerTask::progressUpdate() signal to provide an update on their progress.
|
||||
*
|
||||
* This is used for progress bar widgets.
|
||||
*
|
||||
* NOTE: A task doesn't have to emit this signal. Currently, the time-expensive tasks (like ReadTargetMemory)
|
||||
* emit this signal.
|
||||
*
|
||||
* @param progressPercentage
|
||||
* The task's current progress.
|
||||
*/
|
||||
void progressUpdate(std::uint8_t progressPercentage);
|
||||
|
||||
/**
|
||||
* The InsightWorkerTask::completed() signal will be emitted once the task has successfully completed.
|
||||
*/
|
||||
void completed();
|
||||
|
||||
/**
|
||||
* The InsightWorkerTask::failed() signal will be emitted when the task fails (InsightWorkerTask::run() throws
|
||||
* an exception).
|
||||
*/
|
||||
void failed(QString errorMessage);
|
||||
|
||||
/**
|
||||
* The InsightWorkerTask::finished() signal will be emitted at the end of the task, regardless to whether it
|
||||
* completed successfully or failed.
|
||||
*/
|
||||
void finished();
|
||||
|
||||
protected:
|
||||
virtual void run(Services::TargetControllerService& targetControllerService) = 0;
|
||||
void setProgressPercentage(std::uint8_t percentage);
|
||||
|
||||
private:
|
||||
static inline std::atomic<InsightWorkerTask::IdType> lastId = 0;
|
||||
};
|
||||
}
|
||||
private:
|
||||
static inline std::atomic<InsightWorkerTask::IdType> lastId = 0;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "ReadProgramCounter.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void ReadProgramCounter::run(TargetControllerService& targetControllerService) {
|
||||
emit this->programCounterRead(targetControllerService.getProgramCounter());
|
||||
}
|
||||
void ReadProgramCounter::run(TargetControllerService& targetControllerService) {
|
||||
emit this->programCounterRead(targetControllerService.getProgramCounter());
|
||||
}
|
||||
|
||||
@@ -4,29 +4,26 @@
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class ReadProgramCounter: public InsightWorkerTask
|
||||
{
|
||||
class ReadProgramCounter: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReadProgramCounter() = default;
|
||||
public:
|
||||
ReadProgramCounter() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading program counter";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Reading program counter";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void programCounterRead(Targets::TargetProgramCounter programCounter);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void programCounterRead(Targets::TargetProgramCounter programCounter);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "ReadStackPointer.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void ReadStackPointer::run(TargetControllerService& targetControllerService) {
|
||||
emit this->stackPointerRead(targetControllerService.getStackPointer());
|
||||
}
|
||||
void ReadStackPointer::run(TargetControllerService& targetControllerService) {
|
||||
emit this->stackPointerRead(targetControllerService.getStackPointer());
|
||||
}
|
||||
|
||||
@@ -4,29 +4,26 @@
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class ReadStackPointer: public InsightWorkerTask
|
||||
{
|
||||
class ReadStackPointer: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReadStackPointer() = default;
|
||||
public:
|
||||
ReadStackPointer() = default;
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading stack pointer";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Reading stack pointer";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void stackPointerRead(Targets::TargetStackPointer stackPointer);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void stackPointerRead(Targets::TargetStackPointer stackPointer);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
};
|
||||
|
||||
@@ -6,54 +6,51 @@
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void ReadTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
void ReadTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
|
||||
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
|
||||
const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
|
||||
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
|
||||
|
||||
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
throw Exceptions::Exception("Invalid memory type");
|
||||
}
|
||||
|
||||
const auto& memoryDescriptor = memoryDescriptorIt->second;
|
||||
|
||||
/*
|
||||
* To prevent locking up the TargetController for too long, we split the read into numerous reads.
|
||||
*
|
||||
* This allows the TargetController to service other commands in-between reads, reducing the likelihood of
|
||||
* command timeouts when we're reading lots of data.
|
||||
*/
|
||||
const auto readSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
);
|
||||
const auto readsRequired = static_cast<std::uint32_t>(
|
||||
std::ceil(static_cast<float>(this->size) / static_cast<float>(readSize))
|
||||
);
|
||||
|
||||
Targets::TargetMemoryBuffer data;
|
||||
|
||||
for (std::uint32_t i = 0; i < readsRequired; i++) {
|
||||
auto dataSegment = targetControllerService.readMemory(
|
||||
this->memoryType,
|
||||
this->startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
|
||||
(this->size - data.size()) >= readSize
|
||||
? readSize
|
||||
: static_cast<Targets::TargetMemorySize>(this->size - data.size()),
|
||||
this->excludedAddressRanges
|
||||
);
|
||||
|
||||
std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(data));
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(i) + 1) / (static_cast<float>(readsRequired) / 100)
|
||||
));
|
||||
}
|
||||
|
||||
emit this->targetMemoryRead(data);
|
||||
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
|
||||
throw Exceptions::Exception("Invalid memory type");
|
||||
}
|
||||
|
||||
const auto& memoryDescriptor = memoryDescriptorIt->second;
|
||||
|
||||
/*
|
||||
* To prevent locking up the TargetController for too long, we split the read into numerous reads.
|
||||
*
|
||||
* This allows the TargetController to service other commands in-between reads, reducing the likelihood of
|
||||
* command timeouts when we're reading lots of data.
|
||||
*/
|
||||
const auto readSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
);
|
||||
const auto readsRequired = static_cast<std::uint32_t>(
|
||||
std::ceil(static_cast<float>(this->size) / static_cast<float>(readSize))
|
||||
);
|
||||
|
||||
Targets::TargetMemoryBuffer data;
|
||||
|
||||
for (std::uint32_t i = 0; i < readsRequired; i++) {
|
||||
auto dataSegment = targetControllerService.readMemory(
|
||||
this->memoryType,
|
||||
this->startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
|
||||
(this->size - data.size()) >= readSize
|
||||
? readSize
|
||||
: static_cast<Targets::TargetMemorySize>(this->size - data.size()),
|
||||
this->excludedAddressRanges
|
||||
);
|
||||
|
||||
std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(data));
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(i) + 1) / (static_cast<float>(readsRequired) / 100)
|
||||
));
|
||||
}
|
||||
|
||||
emit this->targetMemoryRead(data);
|
||||
}
|
||||
|
||||
@@ -7,45 +7,42 @@
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class ReadTargetMemory: public InsightWorkerTask
|
||||
{
|
||||
class ReadTargetMemory: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReadTargetMemory(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
Targets::TargetMemorySize size,
|
||||
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
|
||||
)
|
||||
: memoryType(memoryType)
|
||||
, startAddress(startAddress)
|
||||
, size(size)
|
||||
, excludedAddressRanges(excludedAddressRanges)
|
||||
{}
|
||||
public:
|
||||
ReadTargetMemory(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
Targets::TargetMemorySize size,
|
||||
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
|
||||
)
|
||||
: memoryType(memoryType)
|
||||
, startAddress(startAddress)
|
||||
, size(size)
|
||||
, excludedAddressRanges(excludedAddressRanges)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading target " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper();
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Reading target " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper();
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetMemoryRead(Targets::TargetMemoryBuffer buffer);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryType memoryType;
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
Targets::TargetMemorySize size;
|
||||
std::set<Targets::TargetMemoryAddressRange> excludedAddressRanges;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void targetMemoryRead(Targets::TargetMemoryBuffer buffer);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryType memoryType;
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
Targets::TargetMemorySize size;
|
||||
std::set<Targets::TargetMemoryAddressRange> excludedAddressRanges;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "ReadTargetRegisters.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void ReadTargetRegisters::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetRegistersRead(targetControllerService.readRegisters(this->descriptorIds));
|
||||
}
|
||||
void ReadTargetRegisters::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetRegistersRead(targetControllerService.readRegisters(this->descriptorIds));
|
||||
}
|
||||
|
||||
@@ -3,34 +3,31 @@
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class ReadTargetRegisters: public InsightWorkerTask
|
||||
{
|
||||
class ReadTargetRegisters: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ReadTargetRegisters(const Targets::TargetRegisterDescriptorIds& descriptorIds)
|
||||
: descriptorIds(descriptorIds)
|
||||
{}
|
||||
public:
|
||||
explicit ReadTargetRegisters(const Targets::TargetRegisterDescriptorIds& descriptorIds)
|
||||
: descriptorIds(descriptorIds)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading " + QString::number(this->descriptorIds.size()) + " target register(s)";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Reading " + QString::number(this->descriptorIds.size()) + " target register(s)";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetRegistersRead(Targets::TargetRegisters registers);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetRegisterDescriptorIds descriptorIds;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void targetRegistersRead(Targets::TargetRegisters registers);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetRegisterDescriptorIds descriptorIds;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "RefreshTargetPinStates.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void RefreshTargetPinStates::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetPinStatesRetrieved(targetControllerService.getPinStates(this->variantId));
|
||||
}
|
||||
void RefreshTargetPinStates::run(TargetControllerService& targetControllerService) {
|
||||
emit this->targetPinStatesRetrieved(targetControllerService.getPinStates(this->variantId));
|
||||
}
|
||||
|
||||
@@ -4,34 +4,31 @@
|
||||
#include "src/Targets/TargetVariant.hpp"
|
||||
#include "src/Targets/TargetPinDescriptor.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class RefreshTargetPinStates: public InsightWorkerTask
|
||||
{
|
||||
class RefreshTargetPinStates: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RefreshTargetPinStates(int variantId)
|
||||
: variantId(variantId)
|
||||
{}
|
||||
public:
|
||||
explicit RefreshTargetPinStates(int variantId)
|
||||
: variantId(variantId)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Reading target pin states";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Reading target pin states";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
signals:
|
||||
void targetPinStatesRetrieved(Bloom::Targets::TargetPinStateMapping pinStatesByNumber);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
int variantId;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
signals:
|
||||
void targetPinStatesRetrieved(Targets::TargetPinStateMapping pinStatesByNumber);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
int variantId;
|
||||
};
|
||||
|
||||
@@ -10,64 +10,61 @@
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
RetrieveMemorySnapshots::RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType)
|
||||
: memoryType(memoryType)
|
||||
{}
|
||||
RetrieveMemorySnapshots::RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType)
|
||||
: memoryType(memoryType)
|
||||
{}
|
||||
|
||||
void RetrieveMemorySnapshots::run(TargetControllerService& targetControllerService) {
|
||||
emit this->memorySnapshotsRetrieved(this->getSnapshots(this->memoryType));
|
||||
}
|
||||
|
||||
std::vector<MemorySnapshot> RetrieveMemorySnapshots::getSnapshots(Targets::TargetMemoryType memoryType) {
|
||||
constexpr auto MAX_SNAPSHOTS = 30;
|
||||
auto snapshotDir = QDir(QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(memoryType));
|
||||
|
||||
if (!snapshotDir.exists()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto snapshots = std::vector<MemorySnapshot>();
|
||||
|
||||
const auto snapshotFileEntries = snapshotDir.entryInfoList(
|
||||
QStringList("*.json"),
|
||||
QDir::Files,
|
||||
QDir::SortFlag::Time
|
||||
);
|
||||
|
||||
for (const auto& snapshotFileEntry : snapshotFileEntries) {
|
||||
auto snapshotFile = QFile(snapshotFileEntry.absoluteFilePath());
|
||||
|
||||
if (snapshots.size() >= MAX_SNAPSHOTS) {
|
||||
Logger::warning(
|
||||
"The total number of " + EnumToStringMappings::targetMemoryTypes.at(memoryType).toUpper().toStdString()
|
||||
+ " snapshots exceeds the hard limit of " + std::to_string(MAX_SNAPSHOTS)
|
||||
+ ". Only the most recent " + std::to_string(MAX_SNAPSHOTS) + " snapshots will be loaded."
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!snapshotFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
throw Exceptions::Exception("Failed to open snapshot file");
|
||||
}
|
||||
|
||||
snapshots.emplace_back(QJsonDocument::fromJson(snapshotFile.readAll()).object());
|
||||
|
||||
} catch (const Exceptions::Exception& exception) {
|
||||
Logger::error(
|
||||
"Failed to load snapshot " + snapshotFileEntry.absoluteFilePath().toStdString() + " - "
|
||||
+ exception.getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
snapshotFile.close();
|
||||
}
|
||||
|
||||
return snapshots;
|
||||
}
|
||||
void RetrieveMemorySnapshots::run(TargetControllerService& targetControllerService) {
|
||||
emit this->memorySnapshotsRetrieved(this->getSnapshots(this->memoryType));
|
||||
}
|
||||
|
||||
std::vector<MemorySnapshot> RetrieveMemorySnapshots::getSnapshots(Targets::TargetMemoryType memoryType) {
|
||||
constexpr auto MAX_SNAPSHOTS = 30;
|
||||
auto snapshotDir = QDir(QString::fromStdString(Services::PathService::projectSettingsDirPath())
|
||||
+ "/memory_snapshots/" + EnumToStringMappings::targetMemoryTypes.at(memoryType));
|
||||
|
||||
if (!snapshotDir.exists()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto snapshots = std::vector<MemorySnapshot>();
|
||||
|
||||
const auto snapshotFileEntries = snapshotDir.entryInfoList(
|
||||
QStringList("*.json"),
|
||||
QDir::Files,
|
||||
QDir::SortFlag::Time
|
||||
);
|
||||
|
||||
for (const auto& snapshotFileEntry : snapshotFileEntries) {
|
||||
auto snapshotFile = QFile(snapshotFileEntry.absoluteFilePath());
|
||||
|
||||
if (snapshots.size() >= MAX_SNAPSHOTS) {
|
||||
Logger::warning(
|
||||
"The total number of " + EnumToStringMappings::targetMemoryTypes.at(memoryType).toUpper().toStdString()
|
||||
+ " snapshots exceeds the hard limit of " + std::to_string(MAX_SNAPSHOTS)
|
||||
+ ". Only the most recent " + std::to_string(MAX_SNAPSHOTS) + " snapshots will be loaded."
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!snapshotFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
throw Exceptions::Exception("Failed to open snapshot file");
|
||||
}
|
||||
|
||||
snapshots.emplace_back(QJsonDocument::fromJson(snapshotFile.readAll()).object());
|
||||
|
||||
} catch (const Exceptions::Exception& exception) {
|
||||
Logger::error(
|
||||
"Failed to load snapshot " + snapshotFileEntry.absoluteFilePath().toStdString() + " - "
|
||||
+ exception.getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
snapshotFile.close();
|
||||
}
|
||||
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
@@ -8,29 +8,26 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class RetrieveMemorySnapshots: public InsightWorkerTask
|
||||
{
|
||||
class RetrieveMemorySnapshots: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType);
|
||||
public:
|
||||
RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType);
|
||||
|
||||
QString brief() const override {
|
||||
return "Loading saved " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper()
|
||||
+ " memory snapshots";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Loading saved " + EnumToStringMappings::targetMemoryTypes.at(this->memoryType).toUpper()
|
||||
+ " memory snapshots";
|
||||
}
|
||||
|
||||
signals:
|
||||
void memorySnapshotsRetrieved(std::vector<MemorySnapshot> snapshots);
|
||||
signals:
|
||||
void memorySnapshotsRetrieved(std::vector<MemorySnapshot> snapshots);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryType memoryType;
|
||||
private:
|
||||
Targets::TargetMemoryType memoryType;
|
||||
|
||||
std::vector<MemorySnapshot> getSnapshots(Targets::TargetMemoryType memoryType);
|
||||
};
|
||||
}
|
||||
std::vector<MemorySnapshot> getSnapshots(Targets::TargetMemoryType memoryType);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "SetTargetPinState.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void SetTargetPinState::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.setPinState(this->pinDescriptor, this->pinState);
|
||||
}
|
||||
void SetTargetPinState::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.setPinState(this->pinDescriptor, this->pinState);
|
||||
}
|
||||
|
||||
@@ -3,33 +3,30 @@
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetPinDescriptor.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class SetTargetPinState: public InsightWorkerTask
|
||||
{
|
||||
class SetTargetPinState: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetTargetPinState(const Targets::TargetPinDescriptor& pinDescriptor, const Targets::TargetPinState& pinState)
|
||||
: pinDescriptor(pinDescriptor)
|
||||
, pinState(pinState)
|
||||
{}
|
||||
public:
|
||||
SetTargetPinState(const Targets::TargetPinDescriptor& pinDescriptor, const Targets::TargetPinState& pinState)
|
||||
: pinDescriptor(pinDescriptor)
|
||||
, pinState(pinState)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Updating target pin state";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Updating target pin state";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetPinDescriptor pinDescriptor;
|
||||
Targets::TargetPinState pinState;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetPinDescriptor pinDescriptor;
|
||||
Targets::TargetPinState pinState;
|
||||
};
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
namespace Bloom
|
||||
enum class TaskGroup: std::uint16_t
|
||||
{
|
||||
enum class TaskGroup: std::uint16_t
|
||||
{
|
||||
USES_TARGET_CONTROLLER,
|
||||
};
|
||||
USES_TARGET_CONTROLLER,
|
||||
};
|
||||
|
||||
using TaskGroups = std::set<TaskGroup>;
|
||||
}
|
||||
using TaskGroups = std::set<TaskGroup>;
|
||||
|
||||
@@ -6,69 +6,66 @@
|
||||
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void WriteTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
void WriteTargetMemory::run(TargetControllerService& targetControllerService) {
|
||||
using Targets::TargetMemorySize;
|
||||
|
||||
if (!this->memoryDescriptor.access.writeableDuringDebugSession) {
|
||||
throw Exceptions::Exception("Invalid request - cannot write to this memory type during a debug session.");
|
||||
}
|
||||
|
||||
/*
|
||||
* To prevent locking up the TargetController for too long, we split the write operation into numerous
|
||||
* operations.
|
||||
*
|
||||
* This allows the TargetController to service other commands in-between reads, reducing the likelihood of
|
||||
* command timeouts when we're writing lots of data.
|
||||
*/
|
||||
const auto maxBlockSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
this->memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
);
|
||||
|
||||
const TargetMemorySize totalBytesToWrite = std::accumulate(
|
||||
this->blocks.begin(),
|
||||
this->blocks.end(),
|
||||
TargetMemorySize{0},
|
||||
[] (TargetMemorySize bytes, const Block& block) {
|
||||
return bytes + block.data.size();
|
||||
}
|
||||
);
|
||||
|
||||
TargetMemorySize totalBytesWritten = 0;
|
||||
|
||||
for (const auto& block : this->blocks) {
|
||||
const auto totalBytes = block.data.size();
|
||||
|
||||
TargetMemorySize bytesWritten = 0;
|
||||
|
||||
while (bytesWritten < totalBytes) {
|
||||
const auto bytesToWrite = std::min(
|
||||
maxBlockSize,
|
||||
static_cast<decltype(maxBlockSize)>(totalBytes - bytesWritten)
|
||||
);
|
||||
|
||||
targetControllerService.writeMemory(
|
||||
this->memoryDescriptor.type,
|
||||
block.startAddress + bytesWritten,
|
||||
Targets::TargetMemoryBuffer(
|
||||
block.data.begin() + bytesWritten,
|
||||
block.data.begin() + bytesWritten + bytesToWrite
|
||||
)
|
||||
);
|
||||
|
||||
bytesWritten += bytesToWrite;
|
||||
totalBytesWritten += bytesToWrite;
|
||||
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(totalBytesWritten) + 1) / (static_cast<float>(totalBytesToWrite) / 100)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
emit this->targetMemoryWritten(totalBytesWritten);
|
||||
if (!this->memoryDescriptor.access.writeableDuringDebugSession) {
|
||||
throw Exceptions::Exception("Invalid request - cannot write to this memory type during a debug session.");
|
||||
}
|
||||
|
||||
/*
|
||||
* To prevent locking up the TargetController for too long, we split the write operation into numerous
|
||||
* operations.
|
||||
*
|
||||
* This allows the TargetController to service other commands in-between reads, reducing the likelihood of
|
||||
* command timeouts when we're writing lots of data.
|
||||
*/
|
||||
const auto maxBlockSize = std::max(
|
||||
TargetMemorySize(256),
|
||||
this->memoryDescriptor.pageSize.value_or(TargetMemorySize(0))
|
||||
);
|
||||
|
||||
const TargetMemorySize totalBytesToWrite = std::accumulate(
|
||||
this->blocks.begin(),
|
||||
this->blocks.end(),
|
||||
TargetMemorySize{0},
|
||||
[] (TargetMemorySize bytes, const Block& block) {
|
||||
return bytes + block.data.size();
|
||||
}
|
||||
);
|
||||
|
||||
TargetMemorySize totalBytesWritten = 0;
|
||||
|
||||
for (const auto& block : this->blocks) {
|
||||
const auto totalBytes = block.data.size();
|
||||
|
||||
TargetMemorySize bytesWritten = 0;
|
||||
|
||||
while (bytesWritten < totalBytes) {
|
||||
const auto bytesToWrite = std::min(
|
||||
maxBlockSize,
|
||||
static_cast<decltype(maxBlockSize)>(totalBytes - bytesWritten)
|
||||
);
|
||||
|
||||
targetControllerService.writeMemory(
|
||||
this->memoryDescriptor.type,
|
||||
block.startAddress + bytesWritten,
|
||||
Targets::TargetMemoryBuffer(
|
||||
block.data.begin() + bytesWritten,
|
||||
block.data.begin() + bytesWritten + bytesToWrite
|
||||
)
|
||||
);
|
||||
|
||||
bytesWritten += bytesToWrite;
|
||||
totalBytesWritten += bytesToWrite;
|
||||
|
||||
this->setProgressPercentage(static_cast<std::uint8_t>(
|
||||
(static_cast<float>(totalBytesWritten) + 1) / (static_cast<float>(totalBytesToWrite) / 100)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
emit this->targetMemoryWritten(totalBytesWritten);
|
||||
}
|
||||
|
||||
@@ -7,67 +7,64 @@
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class WriteTargetMemory: public InsightWorkerTask
|
||||
{
|
||||
class WriteTargetMemory: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*
|
||||
* A Block is just a block of contiguous data to write. A single WriteTargetMemory task can write multiple
|
||||
* blocks to a particular memory.
|
||||
*/
|
||||
struct Block {
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
const Targets::TargetMemoryBuffer data;
|
||||
public:
|
||||
/*
|
||||
* A Block is just a block of contiguous data to write. A single WriteTargetMemory task can write multiple
|
||||
* blocks to a particular memory.
|
||||
*/
|
||||
struct Block {
|
||||
Targets::TargetMemoryAddress startAddress;
|
||||
const Targets::TargetMemoryBuffer data;
|
||||
|
||||
Block(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
const Targets::TargetMemoryBuffer& data
|
||||
)
|
||||
: startAddress(startAddress)
|
||||
, data(data)
|
||||
{}
|
||||
};
|
||||
|
||||
WriteTargetMemory(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
std::vector<Block>&& blocks
|
||||
)
|
||||
: memoryDescriptor(memoryDescriptor)
|
||||
, blocks(std::move(blocks))
|
||||
{}
|
||||
|
||||
WriteTargetMemory(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
Block(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
const Targets::TargetMemoryBuffer& data
|
||||
)
|
||||
: WriteTargetMemory(memoryDescriptor, std::vector<Block>({{startAddress, data}}))
|
||||
: startAddress(startAddress)
|
||||
, data(data)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return
|
||||
"Writing to target " + EnumToStringMappings::targetMemoryTypes.at(
|
||||
this->memoryDescriptor.type
|
||||
).toUpper();
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
}
|
||||
|
||||
signals:
|
||||
void targetMemoryWritten(Targets::TargetMemorySize bytesWritten);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryDescriptor memoryDescriptor;
|
||||
std::vector<Block> blocks;
|
||||
};
|
||||
}
|
||||
|
||||
WriteTargetMemory(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
std::vector<Block>&& blocks
|
||||
)
|
||||
: memoryDescriptor(memoryDescriptor)
|
||||
, blocks(std::move(blocks))
|
||||
{}
|
||||
|
||||
WriteTargetMemory(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
const Targets::TargetMemoryBuffer& data
|
||||
)
|
||||
: WriteTargetMemory(memoryDescriptor, std::vector<Block>({{startAddress, data}}))
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return
|
||||
"Writing to target " + EnumToStringMappings::targetMemoryTypes.at(
|
||||
this->memoryDescriptor.type
|
||||
).toUpper();
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
}
|
||||
|
||||
signals:
|
||||
void targetMemoryWritten(Targets::TargetMemorySize bytesWritten);
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetMemoryDescriptor memoryDescriptor;
|
||||
std::vector<Block> blocks;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#include "WriteTargetRegister.hpp"
|
||||
|
||||
namespace Bloom
|
||||
{
|
||||
using Services::TargetControllerService;
|
||||
using Services::TargetControllerService;
|
||||
|
||||
void WriteTargetRegister::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.writeRegisters({this->targetRegister});
|
||||
}
|
||||
void WriteTargetRegister::run(TargetControllerService& targetControllerService) {
|
||||
targetControllerService.writeRegisters({this->targetRegister});
|
||||
}
|
||||
|
||||
@@ -3,31 +3,28 @@
|
||||
#include "InsightWorkerTask.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
|
||||
namespace Bloom
|
||||
class WriteTargetRegister: public InsightWorkerTask
|
||||
{
|
||||
class WriteTargetRegister: public InsightWorkerTask
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WriteTargetRegister(const Targets::TargetRegister& targetRegister)
|
||||
: targetRegister(targetRegister)
|
||||
{}
|
||||
public:
|
||||
explicit WriteTargetRegister(const Targets::TargetRegister& targetRegister)
|
||||
: targetRegister(targetRegister)
|
||||
{}
|
||||
|
||||
QString brief() const override {
|
||||
return "Writing target register";
|
||||
}
|
||||
QString brief() const override {
|
||||
return "Writing target register";
|
||||
}
|
||||
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetRegister targetRegister;
|
||||
TaskGroups taskGroups() const override {
|
||||
return TaskGroups({
|
||||
TaskGroup::USES_TARGET_CONTROLLER,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
protected:
|
||||
void run(Services::TargetControllerService& targetControllerService) override;
|
||||
|
||||
private:
|
||||
Targets::TargetRegister targetRegister;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user