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

Feature save calibrated values2 #175

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
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
19 changes: 12 additions & 7 deletions src/saves_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ 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
// ten bytes for each y_value, nine for the number
// and one new line as a separator between the numbers
values.size() * 4, [&values, &y_indx](char *begin, std::size_t) {
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++) {
end = std::to_chars(end, end + 3, values[y_indx].second).ptr;
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;
Expand Down Expand Up @@ -216,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

Expand All @@ -229,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
Expand All @@ -254,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();
Expand Down
Loading