Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sawmill: A CLI tool for exporting and trimming WPILib DataLogs #7656

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4d906cb
no fmt :/
DeltaDizzy Sep 11, 2024
42ba6b6
add argparse
DeltaDizzy Sep 11, 2024
5a2cd7e
turn stuff back on
DeltaDizzy Sep 11, 2024
e8a88ad
add cli commands
DeltaDizzy Sep 11, 2024
41a3623
notional log reader impl
DeltaDizzy Sep 12, 2024
b357389
rename to datalogcli
DeltaDizzy Jan 5, 2025
3b3c215
remove local argparse
DeltaDizzy Jan 5, 2025
403a627
move ehader to indclude directory
DeltaDizzy Jan 5, 2025
14d9280
use wpilib argparse
DeltaDizzy Jan 5, 2025
ae19546
apply datalog move to wpiutil
DeltaDizzy Jan 5, 2025
44ed25d
extract regards and stub writer methods
DeltaDizzy Jan 5, 2025
19c7ca1
need copy constructor
DeltaDizzy Jan 5, 2025
b63d2e7
just make the loader in situ
DeltaDizzy Jan 5, 2025
e0ca3c1
rename and add csv header
DeltaDizzy Jan 5, 2025
a89787b
make writer a class
DeltaDizzy Jan 5, 2025
46bbeef
format
DeltaDizzy Jan 7, 2025
e9e197b
add json writer files
DeltaDizzy Jan 7, 2025
7f18c55
rename to sawmill
DeltaDizzy Jan 7, 2025
b40d315
add getallrecords
DeltaDizzy Jan 7, 2025
447dc6d
format
DeltaDizzy Jan 8, 2025
140b858
undo root cmakelists changes
DeltaDizzy Jan 8, 2025
451042b
rename namespace to sawmill
DeltaDizzy Jan 8, 2025
07859a8
parse data up front
DeltaDizzy Jan 8, 2025
7103788
add entry map to loader
DeltaDizzy Jan 8, 2025
fd72191
use sawmill records
DeltaDizzy Jan 8, 2025
904cc20
first attempt at csv writing
DeltaDizzy Jan 8, 2025
063411a
use Entry struct from datalogtool
DeltaDizzy Jan 8, 2025
7630870
using namespace so dont need it in method definitions
DeltaDizzy Jan 8, 2025
ae35c0d
emplace instead of []
DeltaDizzy Jan 8, 2025
7a7c9d3
remove json temporarily
DeltaDizzy Jan 8, 2025
8f6d3bb
start cli args refactor
DeltaDizzy Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ if(WITH_NTCORE)
add_subdirectory(ntcore)
endif()

add_subdirectory(sawmill)

if(WITH_WPIMATH)
if(WITH_JAVA)
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
Expand Down
10 changes: 5 additions & 5 deletions datalogtool/src/main/native/cpp/Exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <glass/Storage.h>
#include <glass/support/DataLogReaderThread.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <imgui_stdlib.h>
#include <portable-file-dialogs.h>
#include <wpi/DataLogReaderThread.h>
#include <wpi/DenseMap.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/SmallVector.h>
Expand All @@ -40,7 +40,7 @@

namespace {
struct InputFile {
explicit InputFile(std::unique_ptr<glass::DataLogReaderThread> datalog);
explicit InputFile(std::unique_ptr<wpi::DataLogReaderThread> datalog);

InputFile(std::string_view filename, std::string_view status)
: filename{filename},
Expand All @@ -51,7 +51,7 @@ struct InputFile {

std::string filename;
std::string stem;
std::unique_ptr<glass::DataLogReaderThread> datalog;
std::unique_ptr<wpi::DataLogReaderThread> datalog;
std::string status;
bool highlight = false;
};
Expand Down Expand Up @@ -139,7 +139,7 @@ static void RebuildEntryTree() {
}
}

InputFile::InputFile(std::unique_ptr<glass::DataLogReaderThread> datalog_)
InputFile::InputFile(std::unique_ptr<wpi::DataLogReaderThread> datalog_)
: filename{datalog_->GetBufferIdentifier()},
stem{fs::path{filename}.stem().string()},
datalog{std::move(datalog_)} {
Expand Down Expand Up @@ -195,7 +195,7 @@ static std::unique_ptr<InputFile> LoadDataLog(std::string_view filename) {
}

return std::make_unique<InputFile>(
std::make_unique<glass::DataLogReaderThread>(std::move(reader)));
std::make_unique<wpi::DataLogReaderThread>(std::move(reader)));
}

void DisplayInputFiles() {
Expand Down
33 changes: 33 additions & 0 deletions sawmill/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
project(sawmill)

include(CompileWarnings)
include(GenResources)

configure_file(src/main/generate/WPILibVersion.cpp.in WPILibVersion.cpp)
generate_resources(src/main/native/resources generated/main/cpp DLT dlt sawmill_resources_src)

# Generate compile_commands.json by default
if(NOT CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_EXPORT_COMPILE_COMMANDS "YES" CACHE STRING "" FORCE)
endif()

file(GLOB sawmill_src src/main/native/cpp/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)

if(WIN32)
set(sawmill_rc src/main/native/win/sawmill.rc)
elseif(APPLE)
set(MACOSX_BUNDLE_ICON_FILE sawmill.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()

add_executable(sawmill ${sawmill_src} ${sawmill_resources_src} ${sawmill_rc} ${APP_ICON_MACOSX})

target_include_directories(sawmill PUBLIC src/main/native/include)

target_link_libraries(sawmill PRIVATE wpiutil)

if(WIN32)
set_target_properties(sawmill PROPERTIES WIN32_EXECUTABLE YES)
elseif(APPLE)
set_target_properties(sawmill PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "sawmill")
endif()
7 changes: 7 additions & 0 deletions sawmill/src/main/generate/WPILibVersion.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Autogenerated file! Do not manually edit this file. This version is regenerated
* any time the publish task is run, or when this file is deleted.
*/
const char* GetWPILibVersion() {
return "${wpilib_version}";
}
Loading
Loading