Skip to content

Commit

Permalink
Axis still in testing, FFT menu structure corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
AKMaily committed Oct 17, 2024
1 parent 1bcd130 commit f3fd03b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 31 deletions.
57 changes: 31 additions & 26 deletions src/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static std::vector<AxisInfo> plotAxes;
static std::vector<AxisInfo> getDeviceInfos() {
std::vector<AxisInfo> axisInfos;
std::vector<Omniscope::Id> samplerDvcs; // store live devices
std::vector<std::pair<std::string, ImAxis_>> assignedEgus;
std::vector<std::pair<Omniscope::Id, ImAxis_>> assignedEgus;
if (sampler.has_value())
for (auto const &device : sampler->sampleDevices) {
std::string egu =
Expand All @@ -32,34 +32,39 @@ static std::vector<AxisInfo> getDeviceInfos() {
auto deviceId = id.value();
samplerDvcs.push_back(deviceId);
if (captureData.contains(deviceId)) {
if (!std::ranges::contains(assignedEgus, egu,
&std::pair<std::string, ImAxis_>::first)){
const int maxAxes = 3; // Maximale Anzahl der Achsen (hier 3)
if (assignedEgus.size() < maxAxes) {
static_assert((ImAxis_Y1 + 1) == ImAxis_Y2, "Achsenwerte haben sich geändert");

ImAxis_ nextYAxis = static_cast<ImAxis_>(ImAxis_Y1 + assignedEgus.size());

if (assignedEgus.size() < maxAxes) {
assignedEgus.emplace_back(egu, nextYAxis);
fmt::print("Achse hinzugefügt. Neue EGU-Achse für: {}\nDevice id: {}", egu, id.value());
} else {
fmt::print("Zu viele Achsen hinzugefügt. Keine weitere EGU-Achse für: {}\nDevice id: {}", egu, id.value());
}
}
else {
//Error print if more than 3 axis are used
fmt::print("Maximale Anzahl an Achsen (3) erreicht. Keine weitere Achse hinzugefügt für: "
"{}\nDevice id: {}", egu, id.value());
}
}
axisInfos.push_back({{deviceId, std::ref(captureData[deviceId])},
assignedEgus.back(),
std::to_string(deviceId.sampleRate)});
}
const int maxAxes = 3; // Maximale Anzahl der Achsen (hier 3)

auto deviceIdExists = std::find_if(assignedEgus.begin(), assignedEgus.end(),
[&deviceId](const auto& pair) {
return pair.first == deviceId;
}) != assignedEgus.end();

if (!deviceIdExists && assignedEgus.size() < maxAxes) {
static_assert((ImAxis_Y1 + 1) == ImAxis_Y2, "Achsenwerte haben sich geändert");

ImAxis_ nextYAxis = static_cast<ImAxis_>(ImAxis_Y1 + assignedEgus.size());

// Zuweisen einer neuen Achse, wenn noch weniger als maxAxes vorhanden sind
if (assignedEgus.size() < maxAxes) {
assignedEgus.emplace_back(std::make_pair(deviceId, nextYAxis));
fmt::print("Achse hinzugefügt. Neue EGU-Achse für: {}\nDevice id: {}", egu, deviceId.serial);
} else {
fmt::print("Zu viele Achsen hinzugefügt. Keine weitere EGU-Achse für: {}\nDevice id: {}", egu, deviceId.serial);
}
} else {
// Fehlermeldung, wenn zu viele Achsen verwendet werden oder das Gerät schon eine Achse hat
fmt::print("Maximale Anzahl an Achsen (3) erreicht oder Achse bereits vorhanden. "
"Keine weitere Achse hinzugefügt für: {}\nDevice id: {}", egu, deviceId.serial);
}

// Speichern der Achse in axisInfos
axisInfos.push_back({{deviceId, std::ref(captureData[deviceId])},
{egu, assignedEgus.back().second},
std::to_string(deviceId.sampleRate)});
} else
fmt::println("Error no device id found");
}
}
// also get loaded files info
for (auto &[device, values] : captureData)
if (std::ranges::find(samplerDvcs, device.serial, &Omniscope::Id::serial) ==
Expand Down
9 changes: 6 additions & 3 deletions src/languages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ enum class Key {
Path,
FFT_Analyze,
Analyse_Answer_Text,
SeeAnalyzeResults
SeeAnalyzeResults,
MathematicalAnalysis
};

inline const std::map<Key, const char *> englishLan{
Expand Down Expand Up @@ -185,7 +186,8 @@ inline const std::map<Key, const char *> englishLan{
{Key::ADC_counts, "ADC counts"},
{Key::FFT_Analyze, "FFT Analysis"},
{Key::Analyse_Answer_Text, "Your analysis results are ready! \n They are saved in the /analyze folder."},
{Key::SeeAnalyzeResults, "Load results"}};
{Key::SeeAnalyzeResults, "Load results"},
{Key::MathematicalAnalysis, "Mathematical Analysis"}};

inline const std::map<Key, const char *> germanLan{
{Key::Known_Car, "Fahrzeugauswahl"},
Expand Down Expand Up @@ -277,7 +279,8 @@ inline const std::map<Key, const char *> germanLan{
{Key::ADC_counts, "ADC Zählungen"},
{Key::FFT_Analyze, "FFT Analyse"},
{Key::Analyse_Answer_Text, "Deine Analyseergebnisse sind da ! \n Sie befinden sich im /analyze Ordner"},
{Key::SeeAnalyzeResults, "Lade Ergebnisse"}};
{Key::SeeAnalyzeResults, "Lade Ergebnisse"},
{Key::MathematicalAnalysis, "Mathematische Analysen"}};

inline auto appLanguage = englishLan;
namespace fs = std::filesystem;
Expand Down
4 changes: 2 additions & 2 deletions src/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ void set_side_menu(const nlohmann::json &config, bool &open_settings,

if (showDiag && !showDiagPrev)
ImGui::SetNextItemOpen(false);
if (showDiag && ImGui::TreeNode(appLanguage[Key::FFT_Analyze])) {
if (showDiag && ImGui::TreeNode(appLanguage[Key::MathematicalAnalysis])) {
ImGui::PushStyleColor(ImGuiCol_Text, inctColStyle);
if (ImGui::Button(appLanguage[Key::Anlyz_crnt_waveform])){
if (ImGui::Button(appLanguage[Key::FFT_Analyze])){
open_analyze_menu = true;
showDiag = false;
}
Expand Down

0 comments on commit f3fd03b

Please sign in to comment.