Skip to content

Commit

Permalink
Remove TelemetryManager and Logger, rename JSONConverter to LogLoader
Browse files Browse the repository at this point in the history
Implement tree view and DND source
  • Loading branch information
PeterJohnson committed Dec 29, 2023
1 parent 7d32738 commit bc925e4
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 990 deletions.
43 changes: 8 additions & 35 deletions sysid/src/main/native/cpp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@
#include <wpigui_openurl.h>

#include "sysid/view/Analyzer.h"
#include "sysid/view/JSONConverter.h"
#include "sysid/view/Logger.h"
#include "sysid/view/LogLoader.h"
#include "sysid/view/UILayout.h"

namespace gui = wpi::gui;

static std::unique_ptr<glass::WindowManager> gWindowManager;

glass::Window* gLoggerWindow;
glass::Window* gLogLoaderWindow;
glass::Window* gAnalyzerWindow;
glass::Window* gProgramLogWindow;
static glass::MainMenuBar gMainMenu;

std::unique_ptr<sysid::JSONConverter> gJSONConverter;

glass::LogData gLog;
wpi::Logger gLogger;

Expand Down Expand Up @@ -103,8 +100,8 @@ void Application(std::string_view saveDir) {
gWindowManager = std::make_unique<glass::WindowManager>(storage);
gWindowManager->GlobalInit();

gLoggerWindow = gWindowManager->AddWindow(
"Logger", std::make_unique<sysid::Logger>(storage, gLogger));
gLogLoaderWindow = gWindowManager->AddWindow(
"Log Loader", std::make_unique<sysid::LogLoader>(storage, gLogger));

gAnalyzerWindow = gWindowManager->AddWindow(
"Analyzer", std::make_unique<sysid::Analyzer>(storage, gLogger));
Expand All @@ -115,10 +112,10 @@ void Application(std::string_view saveDir) {
// Set default positions and sizes for windows.

// Logger window position/size
gLoggerWindow->SetDefaultPos(sysid::kLoggerWindowPos.x,
sysid::kLoggerWindowPos.y);
gLoggerWindow->SetDefaultSize(sysid::kLoggerWindowSize.x,
sysid::kLoggerWindowSize.y);
gLogLoaderWindow->SetDefaultPos(sysid::kLogLoaderWindowPos.x,
sysid::kLogLoaderWindowPos.y);
gLogLoaderWindow->SetDefaultSize(sysid::kLogLoaderWindowSize.x,
sysid::kLogLoaderWindowSize.y);

// Analyzer window position/size
gAnalyzerWindow->SetDefaultPos(sysid::kAnalyzerWindowPos.x,
Expand All @@ -133,8 +130,6 @@ void Application(std::string_view saveDir) {
sysid::kProgramLogWindowSize.y);
gProgramLogWindow->DisableRenamePopup();

gJSONConverter = std::make_unique<sysid::JSONConverter>(gLogger);

// Configure save file.
gui::ConfigurePlatformSaveFile("sysid.ini");

Expand All @@ -157,15 +152,6 @@ void Application(std::string_view saveDir) {
ImGui::EndMenu();
}

bool toCSV = false;
if (ImGui::BeginMenu("JSON Converters")) {
if (ImGui::MenuItem("JSON to CSV Converter")) {
toCSV = true;
}

ImGui::EndMenu();
}

if (ImGui::BeginMenu("Docs")) {
if (ImGui::MenuItem("Online documentation")) {
wpi::gui::OpenURL(
Expand All @@ -178,19 +164,6 @@ void Application(std::string_view saveDir) {

ImGui::EndMainMenuBar();

if (toCSV) {
ImGui::OpenPopup("SysId JSON to CSV Converter");
toCSV = false;
}

if (ImGui::BeginPopupModal("SysId JSON to CSV Converter")) {
gJSONConverter->DisplayCSVConvert();
if (ImGui::Button("Close")) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}

if (about) {
ImGui::OpenPopup("About");
about = false;
Expand Down
16 changes: 1 addition & 15 deletions sysid/src/main/native/cpp/analysis/AnalysisManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "sysid/Util.h"
#include "sysid/analysis/FilteringUtils.h"
#include "sysid/analysis/JSONConverter.h"
#include "sysid/analysis/TrackWidthAnalysis.h"

using namespace sysid;
Expand Down Expand Up @@ -464,20 +463,7 @@ AnalysisManager::AnalysisManager(std::string_view path, Settings& settings,

// Check that we have a sysid JSON
if (m_json.find("sysid") == m_json.end()) {
// If it's not a sysid JSON, try converting it from frc-char format
std::string newPath = sysid::ConvertJSON(path, logger);

// Read JSON from the specified path
std::error_code ec;
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(path, ec);
if (fileBuffer == nullptr || ec) {
throw FileReadingError(newPath);
}

m_json = wpi::json::parse(fileBuffer->GetCharBuffer());

WPI_INFO(m_logger, "Read {}", newPath);
throw FileReadingError(path);
}

WPI_INFO(m_logger, "Parsing initial data of {}", path);
Expand Down
Loading

0 comments on commit bc925e4

Please sign in to comment.