From b60c437dadf0d7fdbb1b5b0581b14139ed2ce4eb Mon Sep 17 00:00:00 2001 From: R-Abbasi Date: Mon, 2 Sep 2024 03:44:21 -0400 Subject: [PATCH 1/2] save calibrated values --- src/saves_popup.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/saves_popup.cpp b/src/saves_popup.cpp index f667a481..e218bea9 100644 --- a/src/saves_popup.cpp +++ b/src/saves_popup.cpp @@ -17,16 +17,21 @@ static void save(const Omniscope::Id &device, device.sampleRate); std::string fileContent; fileContent.resize_and_overwrite( - // four bytes for each y_value, three for the number - // and one new line as a separator between the numbers - values.size() * 4, [&values, &y_indx](char *begin, std::size_t) { - auto end = begin; - for (; y_indx < values.size(); y_indx++) { - end = std::to_chars(end, end + 3, values[y_indx].second).ptr; - *end++ = '\n'; - } - return end - begin; - }); + // ten bytes for each y_value, nine for the number + // and one new line as a separator between the numbers + values.size() * 10, // take const ref to values + [&values = std::as_const(values), &y_indx](char *begin, std::size_t) { + auto end = begin; + constexpr unsigned factor{100'000}; + for (; y_indx < values.size(); y_indx++) { + double value = values[y_indx].second * factor; + value = std::floor(value); + value /= factor; + end = std::to_chars(end, end + 9, value).ptr; + *end++ = '\n'; + } + return end - begin; + }); // create a .csv file to write to it std::ofstream file(outFile, std::ios::app); if (!file.is_open()) { From 0e728b523035d01d2818e5c66fb9421b894dd160 Mon Sep 17 00:00:00 2001 From: R-Abbasi Date: Mon, 2 Sep 2024 03:58:30 -0400 Subject: [PATCH 2/2] format --- src/saves_popup.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/saves_popup.cpp b/src/saves_popup.cpp index e218bea9..751f1d11 100644 --- a/src/saves_popup.cpp +++ b/src/saves_popup.cpp @@ -17,21 +17,21 @@ static void save(const Omniscope::Id &device, device.sampleRate); std::string fileContent; fileContent.resize_and_overwrite( - // ten bytes for each y_value, nine for the number - // and one new line as a separator between the numbers - values.size() * 10, // take const ref to values - [&values = std::as_const(values), &y_indx](char *begin, std::size_t) { - auto end = begin; - constexpr unsigned factor{100'000}; - for (; y_indx < values.size(); y_indx++) { - double value = values[y_indx].second * factor; - value = std::floor(value); - value /= factor; - end = std::to_chars(end, end + 9, value).ptr; - *end++ = '\n'; - } - return end - begin; - }); + // ten bytes for each y_value, nine for the number + // and one new line as a separator between the numbers + values.size() * 10, // take const ref to values + [&values = std::as_const(values), &y_indx](char *begin, std::size_t) { + auto end = begin; + constexpr unsigned factor{100'000}; + for (; y_indx < values.size(); y_indx++) { + double value = values[y_indx].second * factor; + value = std::floor(value); + value /= factor; + end = std::to_chars(end, end + 9, value).ptr; + *end++ = '\n'; + } + return end - begin; + }); // create a .csv file to write to it std::ofstream file(outFile, std::ios::app); if (!file.is_open()) { @@ -221,7 +221,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, ImGui::Separator(); ImGui::NewLine(); - if (ImGui::Button(appLanguage[Key::Back])) + if (ImGui::Button(appLanguage[Key::Back])) ImGui::CloseCurrentPopup(); ImGui::SameLine(ImGui::GetWindowWidth() * 0.75f); // offset from start x @@ -234,7 +234,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, if (ImGui::Button(appLanguage[Key::Save])) { checked_devices_cnt = count_checked_devices(); flagDataNotSaved = false; - future = std::async( // const reference to the container + future = std::async( // const reference to the container std::launch::async, [=, &liveDvcs = std::as_const(liveDvcs)] { for (size_t i{}; const auto &[device, values] : liveDvcs) { // measurement saving preparation if device is checked @@ -259,11 +259,11 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language, }); progress = true; } - if (progress) { // check selected devices are saved + if (progress) { // check selected devices are saved if (saved_files_cnt == checked_devices_cnt) { future.get(); progress = false; - inptTxtFields.clear(); // reset storage location(s) + inptTxtFields.clear(); // reset storage location(s) dvcCheckedArr.clear(); // rest check boxes saved_files_cnt = 0; ImGui::CloseCurrentPopup();