From 38659d1a4534aa2de8370e2bb13c3931941cb111 Mon Sep 17 00:00:00 2001 From: R-Abbasi Date: Mon, 16 Sep 2024 13:32:08 +0330 Subject: [PATCH 01/11] 1st setp in refactoring --- src/handler.cpp | 2 +- src/handler.hpp | 2 +- src/main.cpp | 61 +++++++++++++++++++++---------------------------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/handler.cpp b/src/handler.cpp index c733792b..81e52048 100644 --- a/src/handler.cpp +++ b/src/handler.cpp @@ -58,7 +58,7 @@ std::vector getDeviceInfos() { return axisInfos; } -void addPlots(const char *name, bool const flagPaused, +void addPlots(const char *name, std::function axesSetup) { static std::set firstRun; diff --git a/src/handler.hpp b/src/handler.hpp index 6b695c04..0c76d1af 100644 --- a/src/handler.hpp +++ b/src/handler.hpp @@ -31,7 +31,7 @@ inline std::map>> inline std::vector plotAxes; void addPlots( - const char *, const bool, + const char *, std::function); void parseDeviceMetaData(Omniscope::MetaData, std::shared_ptr &); diff --git a/src/main.cpp b/src/main.cpp index fdd17d7c..fdd75558 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,21 +12,15 @@ int main() { load_json_file(load_json(config, "languagepath") + load_json(config, "language") + ".json"); // local variables - auto now = std::chrono::system_clock::now(); - std::time_t now_time_t = std::chrono::system_clock::to_time_t(now); - std::tm now_tm = *std::gmtime(&now_time_t); - bool flagPaused{true}; - bool Development{false}, flagInitState{true}, - open_generate_training_data{false}, open_settings{false}; + bool flagPaused{true}, development{false}, open_generate_training_data{false}, + open_settings{false}; + std::once_flag flag; auto loadedFiles = captureData; std::map loadedFilenames; // main loop auto render = [&]() { - if (flagInitState) { - set_inital_config(config); - flagInitState = false; - } + std::call_once(flag, set_inital_config, std::ref(config)); SetupImGuiStyle(false, 0.99f); ImGui::SetNextWindowPos({0.f, 0.f}); auto windowSize{ImGui::GetIO().DisplaySize}; @@ -35,7 +29,7 @@ int main() { ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar); - if (Development && ImGui::Button("Development")) + if (development && ImGui::Button("Development")) ImGui::OpenPopup("Development Colors"); // Popup-Window content @@ -91,36 +85,33 @@ int main() { ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, windowSize.x * .009f); ImGui::BeginChild("Record Data", {0.f, windowSize.y * 0.62f}, ImGuiChildFlags_Border); - // Axes 1 to 3 // Check if time base for axes are same // check if egu and timescale for plot are same // error if third device is added - addPlots( - "Recording the data", flagPaused, - [&flagPaused](double x_max, std::string yLabel, ImAxis_ axis, - double yMin, double yMax) { - ImPlot::SetupLegend(ImPlotLocation_NorthEast | - ImPlotLegendFlags_Outside); - auto auxFlagsMeasuring = - ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; - auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; - ImPlot::SetupAxisTicks(ImAxis_Y1, -10, 200, 22, nullptr, true); + addPlots("Recording the data", [flagPaused]( + double x_max, std::string yLabel, + ImAxis_ axis, double yMin, double yMax) { + ImPlot::SetupLegend(ImPlotLocation_NorthEast); + // auto auxFlagsMeasuring = + // ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; + // auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; + ImPlot::SetupAxisTicks(ImAxis_Y1, -10, 200, 22, nullptr, true); - if (!flagPaused) { - ImPlot::SetupAxis(axis, yLabel.c_str(), ImPlotAxisFlags_AutoFit); - ImPlot::SetupAxis(ImAxis_X1, "time [s]", ImPlotAxisFlags_AutoFit); - ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2, ImGuiCond_Always); - ImPlot::SetupAxisLimits(ImAxis_X1, x_max - 1, x_max + 9, - ImGuiCond_Always); + if (!flagPaused) { + ImPlot::SetupAxis(axis, yLabel.c_str(), ImPlotAxisFlags_AutoFit); + ImPlot::SetupAxis(ImAxis_X1, "time [s]", ImPlotAxisFlags_AutoFit); + ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2, ImGuiCond_Always); + ImPlot::SetupAxisLimits(ImAxis_X1, x_max - 1, x_max + 9, + ImGuiCond_Always); - } else { - ImPlot::SetupAxis(ImAxis_X1, "time [s]"); - ImPlot::SetupAxis(axis, yLabel.c_str()); - ImPlot::SetupAxisLimits(ImAxis_X1, 0, 10); - ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2); - } - }); + } else { + ImPlot::SetupAxis(ImAxis_X1, "time [s]"); + ImPlot::SetupAxis(axis, yLabel.c_str()); + ImPlot::SetupAxisLimits(ImAxis_X1, 0, 10); + ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2); + } + }); ImGui::EndChild(); // end child Record Data ImGui::PopStyleVar(); PopPlotRegionColors(); From f9e79d73781798e705077a2b63c2d5fe8359af12 Mon Sep 17 00:00:00 2001 From: R-Abbasi Date: Mon, 16 Sep 2024 16:01:42 +0330 Subject: [PATCH 02/11] identifier renaming --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fdd75558..90eae219 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,13 +14,13 @@ int main() { // local variables bool flagPaused{true}, development{false}, open_generate_training_data{false}, open_settings{false}; - std::once_flag flag; + std::once_flag configFlag; auto loadedFiles = captureData; std::map loadedFilenames; // main loop auto render = [&]() { - std::call_once(flag, set_inital_config, std::ref(config)); + std::call_once(configFlag, set_inital_config, std::ref(config)); SetupImGuiStyle(false, 0.99f); ImGui::SetNextWindowPos({0.f, 0.f}); auto windowSize{ImGui::GetIO().DisplaySize}; From c2145a310b0ab3b9f7dbda2e5344a7affab4af94 Mon Sep 17 00:00:00 2001 From: R-Abbasi Date: Tue, 17 Sep 2024 08:21:59 +0330 Subject: [PATCH 03/11] 2nd setp in refactoring --- src/handler.cpp | 134 ++++++++++++++++++++++------------------------ src/handler.hpp | 23 ++------ src/languages.hpp | 14 +++-- src/main.cpp | 44 +++++++-------- 4 files changed, 101 insertions(+), 114 deletions(-) diff --git a/src/handler.cpp b/src/handler.cpp index 81e52048..4f101d46 100644 --- a/src/handler.cpp +++ b/src/handler.cpp @@ -1,64 +1,68 @@ #include "handler.hpp" - #include #include #include - - #include "popups.hpp" #include "get_from_github.hpp" - #include "../imgui-stdlib/imgui_stdlib.h" -std::vector getDeviceInfos() { +struct AxisInfo { + const std::pair> &> data; + std::pair egu; + std::string timebase; // store sampleRate + + AxisInfo( + const std::pair> &> + data_, + std::pair egu_, std::string timebase_) + : data{data_}, egu{egu_}, timebase{timebase_} {} +}; + +static std::vector plotAxes; + +static std::vector getDeviceInfos() { std::vector axisInfos; std::vector samplerDvcs; // store live devices std::vector> assignedEgus; if (sampler.has_value()) for (auto const &device : sampler->sampleDevices) { - // TODO replace ADC counts with language variable - std::string egu = device.first->getEgu().value_or("ADC counts"); - auto id = device.first->getId(); - if (id.has_value()) { + std::string egu = + device.first->getEgu().value_or(appLanguage[Key::ADC_counts]); + if (auto id = device.first->getId(); id.has_value()) { auto deviceId = id.value(); samplerDvcs.push_back(deviceId); - std::string timebase{std::to_string(deviceId.sampleRate)}; - if (captureData.find(deviceId) != captureData.end()) { - auto eguIterator = std::ranges::find( - assignedEgus, egu, &std::pair::first); - if (eguIterator == assignedEgus.end()) { + if (captureData.contains(deviceId)) { + if (!std::ranges::contains(assignedEgus, egu, + &std::pair::first)) if (assignedEgus.size() <= 3) { + // make sure ImAxis_ values haven't changed + static_assert((ImAxis_Y1 + 1) == ImAxis_Y2); ImAxis_ nextYAxis = static_cast(ImAxis_Y1 + assignedEgus.size()); - assignedEgus.push_back(std::make_pair(egu, nextYAxis)); - eguIterator = (assignedEgus.end() - 1); + assignedEgus.push_back({egu, nextYAxis}); } else { - fmt::print("too many Axes added, egu not added: " - "{}\nDevice id: {}", - egu, id.value()); + fmt::println("too many Axes added, egu not added: " + "{}\nDevice id: {}", + egu, id.value()); break; } - } - AxisInfo axisInfo{ - std::make_pair(deviceId, std::ref(captureData[deviceId])), - *eguIterator, timebase}; - axisInfos.push_back(axisInfo); + axisInfos.push_back({{deviceId, captureData[deviceId]}, + assignedEgus.back(), + std::to_string(deviceId.sampleRate)}); } } else fmt::println("Error no device id found"); } - // also add loaded files into plotAxes + // also get loaded files info for (auto &[device, values] : captureData) - if (std::ranges::find(samplerDvcs, device.serial, &Omniscope::Id::serial) == - samplerDvcs.end()) { + if (!std::ranges::contains(samplerDvcs, device)) axisInfos.push_back({{device, values}, {"y [Volts]", ImAxis_Y1}, std::to_string(device.sampleRate)}); - } return axisInfos; } -void addPlots(const char *name, +void addPlots(const char *name, std::function axesSetup) { static std::set firstRun; @@ -71,18 +75,14 @@ void addPlots(const char *name, double x_max = std::numeric_limits::min(); for (auto const &axes : plotAxes) { - // fmt::print("data size:{}, egu: {}\n", axes.data.second.size(), - // axes.egu.first); - if (!axes.data.second.empty()) { - x_max = std::max(x_max, axes.data.second.back().first); - // TODO save max and min value over same axis - auto [min, max] = std::minmax_element(axes.data.second.begin(), - axes.data.second.end()); - double yMin = min->first + (min->first * 0.15); - double yMax = max->second + (max->second * 0.15); - // fmt::print("yMin {}, yMax{}\n", yMin, yMax); - axesSetup(x_max, axes.egu.first, axes.egu.second, yMin, yMax); - } + x_max = std::max(x_max, axes.data.second.back().first); + // TODO save max and min value over same axis + // find first and last pairs of values + auto [min, max] = + std::minmax_element(axes.data.second.begin(), axes.data.second.end()); + double yMin = min->first + (min->first * 0.15); + double yMax = max->second + (max->second * 0.15); + axesSetup(x_max, axes.egu.first, axes.egu.second, yMin, yMax); } auto const limits = [&]() { @@ -98,24 +98,18 @@ void addPlots(const char *name, auto const start = [&]() { auto p = std::lower_bound(plot.second.begin(), plot.second.end(), std::pair{limits.X.Min, 0}); - if (p != plot.second.begin()) - return p - 1; - return p; + return p != plot.second.begin() ? p - 1 : p; }(); auto const end = [&]() { auto p = std::upper_bound(start, plot.second.end(), std::pair{limits.X.Max, 0}); - if (p != plot.second.end()) - return p + 1; - return p; + return p != plot.second.end() ? p + 1 : p; }(); std::size_t const stride = [&]() -> std::size_t { auto const s = std::distance(start, end) / (plotRegion.x * 2.0); - if (1 >= s) - return 1; - return static_cast(s); + return s <= 1 ? 1 : static_cast(s); }(); // determine which axes is the right one to choose @@ -127,7 +121,7 @@ void addPlots(const char *name, 2 * sizeof(double) * stride); } }; - for (int count = 0; auto const &plot : plotAxes) { + for (auto const &plot : plotAxes) { ImPlot::SetNextLineStyle(ImVec4{colorMap[plot.data.first][0], colorMap[plot.data.first][1], colorMap[plot.data.first][2], 1.0f}); @@ -138,16 +132,16 @@ void addPlots(const char *name, } } -void parseDeviceMetaData(Omniscope::MetaData metaData, - std::shared_ptr &device) { +static void parseDeviceMetaData(Omniscope::MetaData metaData, + std::shared_ptr &device) { try { - nlohmann::json metaJson = nlohmann::json::parse(metaData.data); - fmt::print("{}\n", metaJson.dump()); - device->setScale(std::stod(metaJson["scale"].dump())); - device->setOffset(std::stod(metaJson["offset"].dump())); + nlohmann::json metaJson = metaData.data; + fmt::println("metaJson content is: {}", metaJson.dump()); + device->setScale(metaJson["scale"]); + device->setOffset(metaJson["offset"]); device->setEgu(metaJson["egu"]); } catch (...) { - fmt::print("parsing Meta Data error: {}", metaData.data); + fmt::println("Parsing Meta Data error: {}", metaData.data); } } @@ -164,7 +158,7 @@ void initDevices() { }; auto id = device->getId().value(); auto sampleRate = static_cast(id.sampleRate); - device->setTimeScale(static_cast(1 / sampleRate)); + device->setTimeScale(1 / sampleRate); if (!colorMap.contains(id)) { ImPlot::PushColormap(ImPlotColormap_Dark); auto c = ImPlot::GetColormapColor((colorMap.size() % 7) + 1); @@ -215,11 +209,10 @@ void devicesList(bool const &flagPaused) { if (sampler.has_value()) for (auto &device : sampler->sampleDevices) { - if (!flagPaused) { + if (!flagPaused) doDevice(device.first, appLanguage[Key::Measurement]); - } else { + else doDevice(device.first, appLanguage[Key::Stop]); - } } else for (auto &device : devices) @@ -252,7 +245,6 @@ void load_files(decltype(captureData) &loadedFiles, } // each y-value is recorded at 1/sampleRate time double step{0.00001}, base{step}; - size_t indx{2}; // y_values start from line 2 of the file while (!readfile.eof()) { // fill the vector of the values double value{}; readfile >> value; @@ -321,21 +313,21 @@ void load_files(decltype(captureData) &loadedFiles, } } -void set_config(const std::string &configpath) { +void set_config(std::string_view configpath) { if (fs::exists(configpath)) - fmt::print("found config.json\n\r"); + fmt::println("Found config.json\r"); else { - fmt::print("Did not find config.json.\n Download from Github\n\r"); + fmt::println("Did not find config.json.\nDownload from Github\r"); update_config_from_github(); } } -void set_json(nlohmann::json &config) { - if (fs::exists(load_json(config, ("languagepath")))) - fmt::print("Found language: {}\n\r", appLanguage[Key::German]); +void set_json(const nlohmann::json &config) { + if (fs::exists(load_json(config, "languagepath"))) + fmt::println("Found language: {}\r", appLanguage[Key::German]); else { - fmt::print("Did not find {}.\n Download from Github\n\r", - appLanguage[Key::German]); + fmt::println("Did not find {}.\nDownload from Github\n", + appLanguage[Key::German]); update_language_from_github(); } } diff --git a/src/handler.hpp b/src/handler.hpp index 0c76d1af..49ce0340 100644 --- a/src/handler.hpp +++ b/src/handler.hpp @@ -4,21 +4,10 @@ #include "../ai_omniscope-v2-communication_sw/src/OmniscopeSampler.hpp" #include "languages.hpp" +#include #include #include #include -#include - -struct AxisInfo { - std::pair> &> data; - std::pair egu; - std::string timebase; - - AxisInfo( - std::pair> &> data_, - std::pair egu_, std::string timebase_) - : data{data_}, egu{egu_}, timebase{timebase_} {} -}; // global variables inline OmniscopeDeviceManager deviceManager{}; @@ -28,20 +17,16 @@ inline std::set savedFileNames; // unique and ordered filenames inline std::optional sampler{}; inline std::map>> captureData; - -inline std::vector plotAxes; void addPlots( const char *, std::function); -void parseDeviceMetaData(Omniscope::MetaData, - std::shared_ptr &); void initDevices(); void devicesList(bool const &flagPaused); void load_files(decltype(captureData) &, std::map &, bool &); -void set_config(const std::string &); -void set_json(nlohmann::json &); +void set_config(std::string_view); +void set_json(const nlohmann::json &); void set_inital_config(nlohmann::json &); void rstSettings(const decltype(captureData) &); -#endif +#endif \ No newline at end of file diff --git a/src/languages.hpp b/src/languages.hpp index 2d1fbb8a..01ff2617 100644 --- a/src/languages.hpp +++ b/src/languages.hpp @@ -12,6 +12,8 @@ enum class Key { Devices_Menu, Select_Devices, Save_Recorded_Data, + Recording_Data, + ADC_counts, Select_Storage_Location, Browse, Menu, @@ -81,6 +83,7 @@ enum class Key { y_label, Voltage, Time, + Time_sec, FontSize, SettingsText, Saving, @@ -97,6 +100,7 @@ inline const std::map englishLan{ {Key::Devices_Menu, "Devices Menu"}, {Key::Select_Devices, "Select Devices"}, {Key::Save_Recorded_Data, "Save recorded Data"}, + {Key::Recording_Data, "Recording the data"}, {Key::Select_Storage_Location, "Select the storage location"}, {Key::Browse, "Browse"}, {Key::Menu, "Menu"}, @@ -167,14 +171,15 @@ inline const std::map englishLan{ {Key::y_label, "x [data points]"}, {Key::Voltage, "Voltage"}, {Key::Time, "Time"}, + {Key::Time_sec, "time [s]"}, {Key::FontSize, "Fontsize"}, {Key::SettingsText, "Set your personal settings for the software"}, {Key::Saving, "saving ..."}, {Key::Load_file, "Load file"}, {Key::Load_file_data, "Load file data"}, {Key::Load_another_file, "Load another file"}, - {Key::Path, "Path"}}; - + {Key::Path, "Path"}, + {Key::ADC_counts, "ADC counts"}}; inline const std::map germanLan{ {Key::Known_Car, "Fahrzeugauswahl"}, @@ -183,6 +188,7 @@ inline const std::map germanLan{ {Key::Devices_Menu, "Geräteliste"}, {Key::Select_Devices, "Geräteauswahl"}, {Key::Save_Recorded_Data, "Speichern der aufgenommenen Daten"}, + {Key::Recording_Data, "Aufzeichnen der Daten"}, {Key::Select_Storage_Location, "Wählen Sie den Speicherort"}, {Key::Browse, "Durchsuchen"}, {Key::Menu, "Menü"}, @@ -254,13 +260,15 @@ inline const std::map germanLan{ {Key::y_label, "x [Datenpunkte]"}, {Key::Voltage, "Spannung"}, {Key::Time, "Zeit"}, + {Key::Time_sec, "Zeit [s]"}, {Key::FontSize, "Schriftgröße"}, {Key::SettingsText, "Legen sie hier ihre persönlichen Einstellungen fest"}, {Key::Saving, "speichern ..."}, {Key::Load_file, "Datei laden"}, {Key::Load_file_data, "Alte Daten laden"}, {Key::Load_another_file, "Eine weitere Datei laden"}, - {Key::Path, "Pfad"}}; + {Key::Path, "Pfad"}, + {Key::ADC_counts, "ADC Zählungen"}}; inline auto appLanguage = englishLan; namespace fs = std::filesystem; diff --git a/src/main.cpp b/src/main.cpp index 90eae219..49d82f77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -89,29 +89,31 @@ int main() { // Check if time base for axes are same // check if egu and timescale for plot are same // error if third device is added - addPlots("Recording the data", [flagPaused]( - double x_max, std::string yLabel, - ImAxis_ axis, double yMin, double yMax) { - ImPlot::SetupLegend(ImPlotLocation_NorthEast); - // auto auxFlagsMeasuring = - // ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; - // auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; - ImPlot::SetupAxisTicks(ImAxis_Y1, -10, 200, 22, nullptr, true); + addPlots( + appLanguage[Key::Recording_Data], + [flagPaused](double x_max, std::string yLabel, ImAxis_ axis, + double yMin, double yMax) { + ImPlot::SetupLegend(ImPlotLocation_NorthEast); + // auto auxFlagsMeasuring = + // ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; + // auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; + ImPlot::SetupAxisTicks(ImAxis_Y1, -10, 200, 22, nullptr, true); - if (!flagPaused) { - ImPlot::SetupAxis(axis, yLabel.c_str(), ImPlotAxisFlags_AutoFit); - ImPlot::SetupAxis(ImAxis_X1, "time [s]", ImPlotAxisFlags_AutoFit); - ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2, ImGuiCond_Always); - ImPlot::SetupAxisLimits(ImAxis_X1, x_max - 1, x_max + 9, - ImGuiCond_Always); + if (!flagPaused) { + ImPlot::SetupAxis(axis, yLabel.c_str(), ImPlotAxisFlags_AutoFit); + ImPlot::SetupAxis(ImAxis_X1, appLanguage[Key::Time_sec], + ImPlotAxisFlags_AutoFit); + ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2, ImGuiCond_Always); + ImPlot::SetupAxisLimits(ImAxis_X1, x_max - 1, x_max + 9, + ImGuiCond_Always); - } else { - ImPlot::SetupAxis(ImAxis_X1, "time [s]"); - ImPlot::SetupAxis(axis, yLabel.c_str()); - ImPlot::SetupAxisLimits(ImAxis_X1, 0, 10); - ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2); - } - }); + } else { + ImPlot::SetupAxis(ImAxis_X1, appLanguage[Key::Time_sec]); + ImPlot::SetupAxis(axis, yLabel.c_str()); + ImPlot::SetupAxisLimits(ImAxis_X1, 0, 10); + ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2); + } + }); ImGui::EndChild(); // end child Record Data ImGui::PopStyleVar(); PopPlotRegionColors(); From 10fc36aac4ece156a57adfb39a08c3ea8276146c Mon Sep 17 00:00:00 2001 From: R-Abbasi Date: Tue, 17 Sep 2024 14:50:42 +0330 Subject: [PATCH 04/11] bug fix --- src/handler.cpp | 82 ++++++++++++++++++++++++++----------------------- src/handler.hpp | 9 ++++-- src/main.cpp | 6 ++-- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/handler.cpp b/src/handler.cpp index 4f101d46..14e6e8fe 100644 --- a/src/handler.cpp +++ b/src/handler.cpp @@ -1,15 +1,15 @@ #include "handler.hpp" +#include "../imgui-stdlib/imgui_stdlib.h" +#include "get_from_github.hpp" +#include "popups.hpp" #include -#include #include -#include "popups.hpp" -#include "get_from_github.hpp" -#include "../imgui-stdlib/imgui_stdlib.h" +#include struct AxisInfo { const std::pair> &> data; std::pair egu; - std::string timebase; // store sampleRate + std::string timebase; AxisInfo( const std::pair> &> @@ -39,14 +39,14 @@ static std::vector getDeviceInfos() { static_assert((ImAxis_Y1 + 1) == ImAxis_Y2); ImAxis_ nextYAxis = static_cast(ImAxis_Y1 + assignedEgus.size()); - assignedEgus.push_back({egu, nextYAxis}); + assignedEgus.push_back(std::make_pair(egu, nextYAxis)); } else { - fmt::println("too many Axes added, egu not added: " - "{}\nDevice id: {}", - egu, id.value()); + fmt::print("too many Axes added, egu not added: " + "{}\nDevice id: {}", + egu, id.value()); break; } - axisInfos.push_back({{deviceId, captureData[deviceId]}, + axisInfos.push_back({{deviceId, std::ref(captureData[deviceId])}, assignedEgus.back(), std::to_string(deviceId.sampleRate)}); } @@ -55,7 +55,8 @@ static std::vector getDeviceInfos() { } // also get loaded files info for (auto &[device, values] : captureData) - if (!std::ranges::contains(samplerDvcs, device)) + if (std::ranges::find(samplerDvcs, device.serial, &Omniscope::Id::serial) == + samplerDvcs.end()) axisInfos.push_back({{device, values}, {"y [Volts]", ImAxis_Y1}, std::to_string(device.sampleRate)}); @@ -74,16 +75,17 @@ void addPlots(const char *name, double x_min = std::numeric_limits::max(); double x_max = std::numeric_limits::min(); - for (auto const &axes : plotAxes) { - x_max = std::max(x_max, axes.data.second.back().first); - // TODO save max and min value over same axis - // find first and last pairs of values - auto [min, max] = - std::minmax_element(axes.data.second.begin(), axes.data.second.end()); - double yMin = min->first + (min->first * 0.15); - double yMax = max->second + (max->second * 0.15); - axesSetup(x_max, axes.egu.first, axes.egu.second, yMin, yMax); - } + for (auto const &axes : plotAxes) + if (!axes.data.second.empty()) { + x_max = std::max(x_max, axes.data.second.back().first); + // TODO save max and min value over same axis + auto [min, max] = std::minmax_element(axes.data.second.begin(), + axes.data.second.end()); + double yMin = min->first + (min->first * 0.15); + double yMax = max->second + (max->second * 0.15); + // fmt::print("yMin {}, yMax{}\n", yMin, yMax); + axesSetup(x_max, axes.egu.first, axes.egu.second, yMin, yMax); + } auto const limits = [&]() { if (!firstRun.contains(name)) { @@ -132,16 +134,16 @@ void addPlots(const char *name, } } -static void parseDeviceMetaData(Omniscope::MetaData metaData, - std::shared_ptr &device) { +void parseDeviceMetaData(Omniscope::MetaData metaData, + std::shared_ptr &device) { try { - nlohmann::json metaJson = metaData.data; - fmt::println("metaJson content is: {}", metaJson.dump()); - device->setScale(metaJson["scale"]); - device->setOffset(metaJson["offset"]); + nlohmann::json metaJson = nlohmann::json::parse(metaData.data); + fmt::println("{}", metaJson.dump()); + device->setScale(std::stod(metaJson["scale"].dump())); + device->setOffset(std::stod(metaJson["offset"].dump())); device->setEgu(metaJson["egu"]); } catch (...) { - fmt::println("Parsing Meta Data error: {}", metaData.data); + fmt::print("parsing Meta Data error: {}", metaData.data); } } @@ -158,7 +160,7 @@ void initDevices() { }; auto id = device->getId().value(); auto sampleRate = static_cast(id.sampleRate); - device->setTimeScale(1 / sampleRate); + device->setTimeScale(static_cast(1 / sampleRate)); if (!colorMap.contains(id)) { ImPlot::PushColormap(ImPlotColormap_Dark); auto c = ImPlot::GetColormapColor((colorMap.size() % 7) + 1); @@ -209,10 +211,11 @@ void devicesList(bool const &flagPaused) { if (sampler.has_value()) for (auto &device : sampler->sampleDevices) { - if (!flagPaused) + if (!flagPaused) { doDevice(device.first, appLanguage[Key::Measurement]); - else + } else { doDevice(device.first, appLanguage[Key::Stop]); + } } else for (auto &device : devices) @@ -245,6 +248,7 @@ void load_files(decltype(captureData) &loadedFiles, } // each y-value is recorded at 1/sampleRate time double step{0.00001}, base{step}; + size_t indx{2}; // y_values start from line 2 of the file while (!readfile.eof()) { // fill the vector of the values double value{}; readfile >> value; @@ -313,21 +317,21 @@ void load_files(decltype(captureData) &loadedFiles, } } -void set_config(std::string_view configpath) { +void set_config(const std::string &configpath) { if (fs::exists(configpath)) - fmt::println("Found config.json\r"); + fmt::print("found config.json\n\r"); else { - fmt::println("Did not find config.json.\nDownload from Github\r"); + fmt::print("Did not find config.json.\n Download from Github\n\r"); update_config_from_github(); } } -void set_json(const nlohmann::json &config) { - if (fs::exists(load_json(config, "languagepath"))) - fmt::println("Found language: {}\r", appLanguage[Key::German]); +void set_json(nlohmann::json &config) { + if (fs::exists(load_json(config, ("languagepath")))) + fmt::print("Found language: {}\n\r", appLanguage[Key::German]); else { - fmt::println("Did not find {}.\nDownload from Github\n", - appLanguage[Key::German]); + fmt::print("Did not find {}.\n Download from Github\n\r", + appLanguage[Key::German]); update_language_from_github(); } } diff --git a/src/handler.hpp b/src/handler.hpp index 49ce0340..f5daa0c9 100644 --- a/src/handler.hpp +++ b/src/handler.hpp @@ -17,16 +17,19 @@ inline std::set savedFileNames; // unique and ordered filenames inline std::optional sampler{}; inline std::map>> captureData; + void addPlots( const char *, std::function); +void parseDeviceMetaData(Omniscope::MetaData, + std::shared_ptr &); void initDevices(); void devicesList(bool const &flagPaused); void load_files(decltype(captureData) &, std::map &, bool &); -void set_config(std::string_view); -void set_json(const nlohmann::json &); +void set_config(const std::string &); +void set_json(nlohmann::json &); void set_inital_config(nlohmann::json &); void rstSettings(const decltype(captureData) &); -#endif \ No newline at end of file +#endif diff --git a/src/main.cpp b/src/main.cpp index 49d82f77..e3d1f8dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -94,9 +94,9 @@ int main() { [flagPaused](double x_max, std::string yLabel, ImAxis_ axis, double yMin, double yMax) { ImPlot::SetupLegend(ImPlotLocation_NorthEast); - // auto auxFlagsMeasuring = - // ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; - // auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; + // auto auxFlagsMeasuring = + // ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; + // auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; ImPlot::SetupAxisTicks(ImAxis_Y1, -10, 200, 22, nullptr, true); if (!flagPaused) { From 9b54490722b4f2a936ec5f70b431a5fc6f4466b4 Mon Sep 17 00:00:00 2001 From: AKMaily Date: Fri, 20 Sep 2024 10:04:36 +0200 Subject: [PATCH 05/11] Changes for version 1.0.1 in testing: - new helplink in the config - greyed out diagnose button - optional options for car analysis in the saving menu - saved file is save with the measurement name - lighter buttons for loaded files to be visible --- config/config.json | 2 +- src/languages.hpp | 4 ++-- src/look_up_saves.hpp | 9 +++++---- src/saves_popup.cpp | 6 +++--- src/style.cpp | 14 +++++++++++--- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/config/config.json b/config/config.json index 3f391373..248b265e 100644 --- a/config/config.json +++ b/config/config.json @@ -77,7 +77,7 @@ "language": "https://raw.githubusercontent.com/skunkforce/omniview/master/languages/Deutsch.json" } }, - "helplink": "https://moodle.aw4null.de/", + "helplink": "https://omni-scope.auto-intern.de/support/", "language": "Deutsch", "languagepath": "languages/", "menubar": { diff --git a/src/languages.hpp b/src/languages.hpp index 01ff2617..3506ab91 100644 --- a/src/languages.hpp +++ b/src/languages.hpp @@ -96,7 +96,7 @@ enum class Key { inline const std::map englishLan{ {Key::Known_Car, "Known Cars"}, {Key::New_Car, "New_Car"}, - {Key::Additional_Information, "Additional_Information"}, + {Key::Additional_Information, "Additional_Information for car analysis"}, {Key::Devices_Menu, "Devices Menu"}, {Key::Select_Devices, "Select Devices"}, {Key::Save_Recorded_Data, "Save recorded Data"}, @@ -184,7 +184,7 @@ inline const std::map englishLan{ inline const std::map germanLan{ {Key::Known_Car, "Fahrzeugauswahl"}, {Key::New_Car, "Neues Fahrzeug"}, - {Key::Additional_Information, "Weiterführende Information"}, + {Key::Additional_Information, "Optionale Angaben für KFZ-Analysen"}, {Key::Devices_Menu, "Geräteliste"}, {Key::Select_Devices, "Geräteauswahl"}, {Key::Save_Recorded_Data, "Speichern der aufgenommenen Daten"}, diff --git a/src/look_up_saves.hpp b/src/look_up_saves.hpp index 3d01b85c..d5af43f0 100644 --- a/src/look_up_saves.hpp +++ b/src/look_up_saves.hpp @@ -34,6 +34,7 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, vins[i] = strdup(subdirectories[i].c_str()); if (isTxtInptFieldsEmpty) { + ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); const std::string newcar = appLanguage[Key::New_Car]; ImGui::Separator(); ImGui::NewLine(); @@ -56,6 +57,10 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, // Using vins (char* array) with ImGui }else { + ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); + ImGui::Separator(); + ImGui::Text(appLanguage[Key::Additional_Information]); + ImGui::NewLine(); ImGui::Combo(appLanguage[Key::Known_Car], &selectedOption, vins, static_cast(subdirectories.size())); @@ -66,10 +71,6 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, static char VIN[18]; const std::string newcar = appLanguage[Key::New_Car]; - ImGui::Separator(); - ImGui::Text(appLanguage[Key::Additional_Information]); - ImGui::NewLine(); - ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); ImGui::InputText(appLanguage[Key::Mileage], mileage, 10); } } diff --git a/src/saves_popup.cpp b/src/saves_popup.cpp index 751f1d11..e686047b 100644 --- a/src/saves_popup.cpp +++ b/src/saves_popup.cpp @@ -165,11 +165,11 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, // ############# End popup // make a .csv file name - auto mkFileName = [&](const std::string &name) { + auto mkFileName = [&](const std::string &name, const std::string &measurement) { now = std::chrono::system_clock::now(); now_time_t = std::chrono::system_clock::to_time_t(now); now_tm = *std::gmtime(&now_time_t); - std::string filename{fmt::format("{}-{:%Y-%m-%dT%H-%M}.csv", name, now)}; + std::string filename{fmt::format("{}-{}-{:%Y-%m-%dT%H-%M}.csv", name, measurement, now)}; return filename; }; @@ -240,7 +240,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, // measurement saving preparation if device is checked if (dvcCheckedArr[i].b) { fs::path path; - auto filename = mkFileName(fmt::format("device{}", i + 1)); + auto filename = mkFileName(fmt::format("device{}", i + 1), scantype); if (hasSelectedPathArr[i].b) { path = mkdir(true, selectedPathArr[i], "", filename); hasSelectedPathArr[i].b = false; diff --git a/src/style.cpp b/src/style.cpp index b067f468..be9ba00b 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -134,6 +134,7 @@ void SetDeviceMenuStyle() { ImGuiStyle &style = ImGui::GetStyle(); style.Colors[ImGuiCol_Border] = {0.14f, 0.15f, 0.17f, 1.0f}; + style.Colors[ImGuiCol_Button] = {0.9f, 0.9f, 0.9f, 1.0f}; } namespace ImGui { @@ -309,13 +310,20 @@ void set_side_menu(const nlohmann::json &config, bool &open_settings, static bool showDiag = false; const bool showDiagPrev = showDiag; + + ImGui::PushStyleColor(ImGuiCol_Text, {0.8f, 0.8f, 0.8f, 0.7f}); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, {0.8f, 0.8f, 0.8f, 0.0f}); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, {0.8f, 0.8f, 0.8f, 0.0f}); if (loaded_png[++PngRenderedCnt] && // render Diagnostics ImGui::ImageButtonWithText( (void *)(intptr_t)image_texture[PngRenderedCnt], appLanguage[Key::Diagnostics])) { - showDiag = !showDiag; + //showDiag = !showDiag; } - if (showDiag && !showDiagPrev) + ImGui::PopStyleColor(3); + + + /*if (showDiag && !showDiagPrev) ImGui::SetNextItemOpen(false); if (showDiag && ImGui::TreeNode(appLanguage[Key::Battery_measure])) { ImGui::PushStyleColor(ImGuiCol_Text, inctColStyle); @@ -327,7 +335,7 @@ void set_side_menu(const nlohmann::json &config, bool &open_settings, showDiag = false; } ImGui::TreePop(); - } + }*/ static bool showSettings = false; if (loaded_png[++PngRenderedCnt] && // render Settings From 810bb0915990a27123daeecccca5c6d8a8d01f3f Mon Sep 17 00:00:00 2001 From: AKMaily Date: Fri, 20 Sep 2024 10:29:56 +0200 Subject: [PATCH 06/11] Changed the Checkbox color instead of the button color, Trying to fix the parse error --- src/look_up_saves.hpp | 1 - src/style.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/look_up_saves.hpp b/src/look_up_saves.hpp index d5af43f0..6d6bc904 100644 --- a/src/look_up_saves.hpp +++ b/src/look_up_saves.hpp @@ -44,7 +44,6 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, ImGui::Combo(appLanguage[Key::Known_Car], &selectedOption, vins, static_cast(subdirectories.size())); - ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); if (selectedOption == 0) { ImGui::InputText("Fin/Vin", inputvin, 19, ImGuiInputTextFlags_CharsUppercase | diff --git a/src/style.cpp b/src/style.cpp index be9ba00b..268af2f0 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -134,7 +134,7 @@ void SetDeviceMenuStyle() { ImGuiStyle &style = ImGui::GetStyle(); style.Colors[ImGuiCol_Border] = {0.14f, 0.15f, 0.17f, 1.0f}; - style.Colors[ImGuiCol_Button] = {0.9f, 0.9f, 0.9f, 1.0f}; + style.Colors[ImGuiCol_CheckMark ] = {0.9f, 0.9f, 0.9f, 1.0f}; } namespace ImGui { From ebba13e912640399f2a46362ff9e373853906c9b Mon Sep 17 00:00:00 2001 From: AKMaily Date: Fri, 20 Sep 2024 10:49:53 +0200 Subject: [PATCH 07/11] Fixing the color and trying to find the reason for the parse error --- src/saves_popup.cpp | 6 +++--- src/style.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/saves_popup.cpp b/src/saves_popup.cpp index e686047b..c4a7f148 100644 --- a/src/saves_popup.cpp +++ b/src/saves_popup.cpp @@ -165,11 +165,11 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, // ############# End popup // make a .csv file name - auto mkFileName = [&](const std::string &name, const std::string &measurement) { + auto mkFileName = [&](const std::string &name) { now = std::chrono::system_clock::now(); now_time_t = std::chrono::system_clock::to_time_t(now); now_tm = *std::gmtime(&now_time_t); - std::string filename{fmt::format("{}-{}-{:%Y-%m-%dT%H-%M}.csv", name, measurement, now)}; + std::string filename{fmt::format("{}-{}-{:%Y-%m-%dT%H-%M}.csv", name, now)}; return filename; }; @@ -240,7 +240,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, // measurement saving preparation if device is checked if (dvcCheckedArr[i].b) { fs::path path; - auto filename = mkFileName(fmt::format("device{}", i + 1), scantype); + auto filename = mkFileName(fmt::format("device{}", i + 1)); if (hasSelectedPathArr[i].b) { path = mkdir(true, selectedPathArr[i], "", filename); hasSelectedPathArr[i].b = false; diff --git a/src/style.cpp b/src/style.cpp index 268af2f0..680bdca3 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -134,7 +134,9 @@ void SetDeviceMenuStyle() { ImGuiStyle &style = ImGui::GetStyle(); style.Colors[ImGuiCol_Border] = {0.14f, 0.15f, 0.17f, 1.0f}; - style.Colors[ImGuiCol_CheckMark ] = {0.9f, 0.9f, 0.9f, 1.0f}; + style.Colors[ImGuiCol_FrameBg] = {0.9f, 0.9f, 0.9f, 1.0f}; + style.Colors[ImGuiCol_FrameBgHovered] = {1.0f, 1.0f, 1.0f, 1.0f}; + style.Colors[ImGuiCol_FrameBgActive] = {0.8f, 0.8f, 0.8f, 0.8f}; } namespace ImGui { From 3527d131eef0992767f10f99b23391a8a506b92a Mon Sep 17 00:00:00 2001 From: AKMaily Date: Fri, 20 Sep 2024 11:26:26 +0200 Subject: [PATCH 08/11] Test --- src/saves_popup.cpp | 2 +- src/style.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/saves_popup.cpp b/src/saves_popup.cpp index c4a7f148..751f1d11 100644 --- a/src/saves_popup.cpp +++ b/src/saves_popup.cpp @@ -169,7 +169,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, now = std::chrono::system_clock::now(); now_time_t = std::chrono::system_clock::to_time_t(now); now_tm = *std::gmtime(&now_time_t); - std::string filename{fmt::format("{}-{}-{:%Y-%m-%dT%H-%M}.csv", name, now)}; + std::string filename{fmt::format("{}-{:%Y-%m-%dT%H-%M}.csv", name, now)}; return filename; }; diff --git a/src/style.cpp b/src/style.cpp index 680bdca3..36411eea 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -135,8 +135,8 @@ void SetDeviceMenuStyle() { ImGuiStyle &style = ImGui::GetStyle(); style.Colors[ImGuiCol_Border] = {0.14f, 0.15f, 0.17f, 1.0f}; style.Colors[ImGuiCol_FrameBg] = {0.9f, 0.9f, 0.9f, 1.0f}; - style.Colors[ImGuiCol_FrameBgHovered] = {1.0f, 1.0f, 1.0f, 1.0f}; - style.Colors[ImGuiCol_FrameBgActive] = {0.8f, 0.8f, 0.8f, 0.8f}; + style.Colors[ImGuiCol_FrameBgHovered] = {1.0f, 1.0f, 1.0f, 1.0f}; + style.Colors[ImGuiCol_FrameBgActive] = {0.8f, 0.8f, 0.8f, 0.8f}; } namespace ImGui { From 09c7bfb8617f97f1e5db5b24dd056aaca5295d95 Mon Sep 17 00:00:00 2001 From: AKMaily Date: Fri, 20 Sep 2024 12:12:04 +0200 Subject: [PATCH 09/11] Test2 --- src/look_up_saves.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/look_up_saves.hpp b/src/look_up_saves.hpp index 6d6bc904..3d01b85c 100644 --- a/src/look_up_saves.hpp +++ b/src/look_up_saves.hpp @@ -34,7 +34,6 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, vins[i] = strdup(subdirectories[i].c_str()); if (isTxtInptFieldsEmpty) { - ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); const std::string newcar = appLanguage[Key::New_Car]; ImGui::Separator(); ImGui::NewLine(); @@ -44,6 +43,7 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, ImGui::Combo(appLanguage[Key::Known_Car], &selectedOption, vins, static_cast(subdirectories.size())); + ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); if (selectedOption == 0) { ImGui::InputText("Fin/Vin", inputvin, 19, ImGuiInputTextFlags_CharsUppercase | @@ -56,10 +56,6 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, // Using vins (char* array) with ImGui }else { - ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); - ImGui::Separator(); - ImGui::Text(appLanguage[Key::Additional_Information]); - ImGui::NewLine(); ImGui::Combo(appLanguage[Key::Known_Car], &selectedOption, vins, static_cast(subdirectories.size())); @@ -70,6 +66,10 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, static char VIN[18]; const std::string newcar = appLanguage[Key::New_Car]; + ImGui::Separator(); + ImGui::Text(appLanguage[Key::Additional_Information]); + ImGui::NewLine(); + ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); ImGui::InputText(appLanguage[Key::Mileage], mileage, 10); } } From e26a5c0729af98a76018d23f3ad34206598d4dd6 Mon Sep 17 00:00:00 2001 From: AKMaily Date: Fri, 20 Sep 2024 12:52:26 +0200 Subject: [PATCH 10/11] Measurement as name of saved file testing --- src/look_up_saves.hpp | 17 +++++++++-------- src/saves_popup.cpp | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/look_up_saves.hpp b/src/look_up_saves.hpp index 3d01b85c..dd2ac72a 100644 --- a/src/look_up_saves.hpp +++ b/src/look_up_saves.hpp @@ -34,16 +34,17 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, vins[i] = strdup(subdirectories[i].c_str()); if (isTxtInptFieldsEmpty) { - const std::string newcar = appLanguage[Key::New_Car]; + ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); ImGui::Separator(); ImGui::NewLine(); ImGui::Text(appLanguage[Key::Additional_Information]); ImGui::NewLine(); - + + const std::string newcar = appLanguage[Key::New_Car]; + ImGui::Combo(appLanguage[Key::Known_Car], &selectedOption, vins, static_cast(subdirectories.size())); - ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); if (selectedOption == 0) { ImGui::InputText("Fin/Vin", inputvin, 19, ImGuiInputTextFlags_CharsUppercase | @@ -56,6 +57,10 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, // Using vins (char* array) with ImGui }else { + ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); + ImGui::Separator(); + ImGui::Text(appLanguage[Key::Additional_Information]); + ImGui::NewLine(); ImGui::Combo(appLanguage[Key::Known_Car], &selectedOption, vins, static_cast(subdirectories.size())); @@ -65,11 +70,7 @@ inline std::string getSubdirectoriesInFolder(nlohmann::json language, } static char VIN[18]; const std::string newcar = appLanguage[Key::New_Car]; - - ImGui::Separator(); - ImGui::Text(appLanguage[Key::Additional_Information]); - ImGui::NewLine(); - ImGui::InputText(appLanguage[Key::Measurement], scantype, 255); + ImGui::InputText(appLanguage[Key::Mileage], mileage, 10); } } diff --git a/src/saves_popup.cpp b/src/saves_popup.cpp index 751f1d11..e686047b 100644 --- a/src/saves_popup.cpp +++ b/src/saves_popup.cpp @@ -165,11 +165,11 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, // ############# End popup // make a .csv file name - auto mkFileName = [&](const std::string &name) { + auto mkFileName = [&](const std::string &name, const std::string &measurement) { now = std::chrono::system_clock::now(); now_time_t = std::chrono::system_clock::to_time_t(now); now_tm = *std::gmtime(&now_time_t); - std::string filename{fmt::format("{}-{:%Y-%m-%dT%H-%M}.csv", name, now)}; + std::string filename{fmt::format("{}-{}-{:%Y-%m-%dT%H-%M}.csv", name, measurement, now)}; return filename; }; @@ -240,7 +240,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, // measurement saving preparation if device is checked if (dvcCheckedArr[i].b) { fs::path path; - auto filename = mkFileName(fmt::format("device{}", i + 1)); + auto filename = mkFileName(fmt::format("device{}", i + 1), scantype); if (hasSelectedPathArr[i].b) { path = mkdir(true, selectedPathArr[i], "", filename); hasSelectedPathArr[i].b = false; From f6d28ab93a9af398596530ef5ca832dd1d115568 Mon Sep 17 00:00:00 2001 From: AKMaily Date: Fri, 20 Sep 2024 14:53:27 +0200 Subject: [PATCH 11/11] Version update --- src/style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style.cpp b/src/style.cpp index 36411eea..475dcada 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -357,7 +357,7 @@ void set_side_menu(const nlohmann::json &config, bool &open_settings, } ImGui::SetCursorPosY(windowSize.y * 0.9f); ImGui::Text(fmt::format("{}: {}", appLanguage[Key::Version], - CMakeGitVersion::VersionWithGit) + "1.0.1") .c_str()); }