mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[datalog] Move all DataLog functionality to new datalog library (#7641)
Currently the major DataLog backend API (reading and writing) is split between wpiutil and glass. In the interest of allowing code that wants to use these APIs to not need to link to glass and declutter wpiutil, all of those APIs are moved to a new library named "datalog". Signed-off-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
This commit is contained in:
@@ -10,11 +10,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <glass/support/DataLogReaderThread.h>
|
||||
#include <imgui.h>
|
||||
#include <wpi/DataLogReader.h>
|
||||
#include <wpi/Logger.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLogReader.h>
|
||||
#include <wpi/datalog/DataLogReaderThread.h>
|
||||
|
||||
#include "sysid/Util.h"
|
||||
#include "sysid/analysis/AnalysisType.h"
|
||||
@@ -25,7 +25,7 @@ using namespace sysid;
|
||||
static constexpr const char* kAnalysisTypes[] = {"Elevator", "Arm", "Simple"};
|
||||
|
||||
static bool EmitEntryTarget(const char* name, bool isString,
|
||||
const glass::DataLogReaderEntry** entry) {
|
||||
const wpi::log::DataLogReaderEntry** entry) {
|
||||
if (*entry) {
|
||||
auto text =
|
||||
fmt::format("{}: {} ({})", name, (*entry)->name, (*entry)->type);
|
||||
@@ -38,8 +38,9 @@ static bool EmitEntryTarget(const char* name, bool isString,
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(
|
||||
isString ? "DataLogEntryString" : "DataLogEntry")) {
|
||||
assert(payload->DataSize == sizeof(const glass::DataLogReaderEntry*));
|
||||
*entry = *static_cast<const glass::DataLogReaderEntry**>(payload->Data);
|
||||
assert(payload->DataSize == sizeof(const wpi::log::DataLogReaderEntry*));
|
||||
*entry =
|
||||
*static_cast<const wpi::log::DataLogReaderEntry**>(payload->Data);
|
||||
rv = true;
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
@@ -179,7 +180,7 @@ void DataSelector::Reset() {
|
||||
}
|
||||
|
||||
DataSelector::Tests DataSelector::LoadTests(
|
||||
const glass::DataLogReaderEntry& testStateEntry) {
|
||||
const wpi::log::DataLogReaderEntry& testStateEntry) {
|
||||
Tests tests;
|
||||
for (auto&& range : testStateEntry.ranges) {
|
||||
std::string_view prevState;
|
||||
@@ -245,7 +246,7 @@ static void AddSamples(std::vector<MotorData::Run::Sample<T>>& samples,
|
||||
}
|
||||
|
||||
static std::vector<std::pair<int64_t, double>> GetData(
|
||||
const glass::DataLogReaderEntry& entry, double scale) {
|
||||
const wpi::log::DataLogReaderEntry& entry, double scale) {
|
||||
std::vector<std::pair<int64_t, double>> rv;
|
||||
bool isDouble = entry.type == "double";
|
||||
for (auto&& range : entry.ranges) {
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <glass/support/DataLogReaderThread.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_stdlib.h>
|
||||
#include <portable-file-dialogs.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/SpanExtras.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/datalog/DataLogReaderThread.h>
|
||||
#include <wpi/fs.h>
|
||||
|
||||
using namespace sysid;
|
||||
@@ -55,7 +55,7 @@ void LogLoader::Display() {
|
||||
}
|
||||
unload();
|
||||
m_reader =
|
||||
std::make_unique<glass::DataLogReaderThread>(std::move(reader));
|
||||
std::make_unique<wpi::log::DataLogReaderThread>(std::move(reader));
|
||||
m_entryTree.clear();
|
||||
}
|
||||
m_opener.reset();
|
||||
@@ -108,7 +108,7 @@ void LogLoader::Display() {
|
||||
void LogLoader::RebuildEntryTree() {
|
||||
m_entryTree.clear();
|
||||
wpi::SmallVector<std::string_view, 16> parts;
|
||||
m_reader->ForEachEntryName([&](const glass::DataLogReaderEntry& entry) {
|
||||
m_reader->ForEachEntryName([&](const wpi::log::DataLogReaderEntry& entry) {
|
||||
// only show double/float/string entries (TODO: support struct/protobuf)
|
||||
if (entry.type != "double" && entry.type != "float" &&
|
||||
entry.type != "string") {
|
||||
@@ -167,7 +167,7 @@ void LogLoader::RebuildEntryTree() {
|
||||
}
|
||||
|
||||
static void EmitEntry(const std::string& name,
|
||||
const glass::DataLogReaderEntry& entry) {
|
||||
const wpi::log::DataLogReaderEntry& entry) {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(name.c_str());
|
||||
if (ImGui::BeginDragDropSource()) {
|
||||
|
||||
@@ -12,17 +12,19 @@
|
||||
#include <vector>
|
||||
|
||||
#include <glass/View.h>
|
||||
#include <glass/support/DataLogReaderThread.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/datalog/DataLogReaderThread.h>
|
||||
|
||||
#include "sysid/analysis/Storage.h"
|
||||
|
||||
namespace glass {
|
||||
class DataLogReaderEntry;
|
||||
class Storage;
|
||||
} // namespace glass
|
||||
|
||||
namespace wpi {
|
||||
namespace log {
|
||||
class DataLogReaderEntry;
|
||||
} // namespace log
|
||||
class Logger;
|
||||
} // namespace wpi
|
||||
|
||||
@@ -64,10 +66,10 @@ class DataSelector : public glass::View {
|
||||
std::future<Tests> m_testsFuture;
|
||||
Tests m_tests;
|
||||
std::string m_selectedTest;
|
||||
const glass::DataLogReaderEntry* m_testStateEntry = nullptr;
|
||||
const glass::DataLogReaderEntry* m_velocityEntry = nullptr;
|
||||
const glass::DataLogReaderEntry* m_positionEntry = nullptr;
|
||||
const glass::DataLogReaderEntry* m_voltageEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_testStateEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_velocityEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_positionEntry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* m_voltageEntry = nullptr;
|
||||
double m_velocityScale = 1.0;
|
||||
double m_positionScale = 1.0;
|
||||
int m_selectedUnit = 0;
|
||||
@@ -75,7 +77,7 @@ class DataSelector : public glass::View {
|
||||
std::future<TestData> m_testdataFuture;
|
||||
std::vector<std::string> m_testdataStats;
|
||||
|
||||
static Tests LoadTests(const glass::DataLogReaderEntry& testStateEntry);
|
||||
static Tests LoadTests(const wpi::log::DataLogReaderEntry& testStateEntry);
|
||||
TestData BuildTestData();
|
||||
};
|
||||
} // namespace sysid
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <wpi/Signal.h>
|
||||
|
||||
namespace glass {
|
||||
class DataLogReaderEntry;
|
||||
class DataLogReaderThread;
|
||||
class Storage;
|
||||
} // namespace glass
|
||||
|
||||
@@ -23,6 +21,10 @@ class open_file;
|
||||
} // namespace pfd
|
||||
|
||||
namespace wpi {
|
||||
namespace log {
|
||||
class DataLogReaderEntry;
|
||||
class DataLogReaderThread;
|
||||
} // namespace log
|
||||
class Logger;
|
||||
} // namespace wpi
|
||||
|
||||
@@ -57,7 +59,7 @@ class LogLoader : public glass::View {
|
||||
|
||||
std::string m_filename;
|
||||
std::unique_ptr<pfd::open_file> m_opener;
|
||||
std::unique_ptr<glass::DataLogReaderThread> m_reader;
|
||||
std::unique_ptr<wpi::log::DataLogReaderThread> m_reader;
|
||||
|
||||
std::string m_error;
|
||||
|
||||
@@ -67,7 +69,7 @@ class LogLoader : public glass::View {
|
||||
explicit EntryTreeNode(std::string_view name) : name{name} {}
|
||||
std::string name; // name of just this node
|
||||
std::string path; // full path if entry is nullptr
|
||||
const glass::DataLogReaderEntry* entry = nullptr;
|
||||
const wpi::log::DataLogReaderEntry* entry = nullptr;
|
||||
std::vector<EntryTreeNode> children; // children, sorted by name
|
||||
};
|
||||
std::vector<EntryTreeNode> m_entryTree;
|
||||
|
||||
Reference in New Issue
Block a user