Skip to content

Commit

Permalink
Selected Current Data and select one device, IN TESTING
Browse files Browse the repository at this point in the history
  • Loading branch information
AKMaily committed Oct 2, 2024
1 parent f8929de commit a1213f3
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 97 deletions.
139 changes: 83 additions & 56 deletions src/analyze_data.cpp
Original file line number Diff line number Diff line change
@@ -1,78 +1,105 @@
#include "analyze_data.hpp"

void generate_analyze_menu(bool &open_analyze_menu){
void generate_analyze_menu( // generate the whole menu: Startpoint
bool &open_analyze_menu,
const std::map<Omniscope::Id, std::vector<std::pair<double, double>>>
&captureData) {
// Initialize AnalyzeStateManager

// Initialize AnalyzeStateManager
static AnalyzeStateManager stateManager;
// generate the PopUpMenu

static AnalyzeStateManager stateManager;

// generate the PopUpMenu
ImGui::OpenPopup(appLanguage[Key::AnalyzeData]);

ImGui::OpenPopup(appLanguage[Key::AnalyzeData]);
if (ImGui::BeginPopupModal(appLanguage[Key::AnalyzeData], nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {

if(ImGui::BeginPopupModal(appLanguage[Key::AnalyzeData], nullptr, ImGuiWindowFlags_AlwaysAutoResize)){
// Frame
ImGui::Text(appLanguage[Key::AnalyzeData]);

ImGui::Text(appLanguage[Key::AnalyzeData]);
// select Data from File or current Data
stateManager.selectData(stateManager, open_analyze_menu, captureData);
}

if(ImGui::RadioButton(appLanguage[Key::Usr_curnt_wave], radioButtonCurrentData)){
radioButtonCurrentData = !radioButtonCurrentData;
stateManager.setState(State::CurrentDataSelected);
}
// Close PopUp
if (ImGui::Button(appLanguage[Key::Back])) {
open_analyze_menu = false;
ImGui::CloseCurrentPopup();
}

}
ImGui::EndPopup();
}

void AnalyzeStateManager::setState(State state) {
this->currentState = state;
std::cout << "Changed state" << std::endl;
}

//Close PopUp
if (ImGui::Button(appLanguage[Key::Back])) {
open_analyze_menu = false;
ImGui::CloseCurrentPopup();
State AnalyzeStateManager::getState() { return this->currentState; }

void AnalyzeStateManager::selectData(
AnalyzeStateManager &stateManager, bool &open_analyze_menu,
const std::map<Omniscope::Id, std::vector<std::pair<double, double>>>
&captureData) {

// Select Current Wave
if (ImGui::RadioButton(appLanguage[Key::Usr_curnt_wave],
radioButtonCurrentData)) {
radioButtonCurrentData = !radioButtonCurrentData;
// Check for current measurement, else error Popup
if (!captureData.size()) {
ImGui::OpenPopup(appLanguage[Key::WvForms_warning],
ImGuiPopupFlags_NoOpenOverExistingPopup);
radioButtonCurrentData = false;
} else {
stateManager.setState(State::CurrentDataSelected);
if(ImGui::BeginCombo("##ComboDevice", "Devices & Waveforms Menu")){ //choose the device from which the data is taken
stateManager.selectCurrentDevice(captureData);
}
}
}

ImGui::EndPopup();
// Else select File from Browser

// Default info popup for rendering

info_popup(appLanguage[Key::WvForms_warning], appLanguage[Key::No_wave_made]);
}
void AnalyzeStateManager::loadData() { std::cout << "Not used" << std::endl; }

void AnalyzeStateManager::reset() { std::cout << "Not used" << std::endl; }

void AnalyzeStateManager::setState(State state){

this->currentState= state ;
std::cout << "Changed state" << std::endl;
}
State AnalyzeStateManager::getState(){
return this->currentState;
}

void AnalyzeStateManager::selectData(){
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::loadData(){
std::cout << "Not used" << std::endl;
}

void AnalyzeStateManager::reset(){
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::setMetaData() {
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::clearMetaData() {
std::cout << "Not used" << std::endl;
}

void AnalyzeStateManager::setMetaData(){
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::clearMetaData(){
std::cout << "Not used" << std::endl;
// extra functions:

void AnalyzeStateManager::selectCurrentDevice( const std::map<Omniscope::Id, std::vector<std::pair<double, double>>> &captureData) {
for(const auto &[device, values] : captureData){
if(ImGui::Checkbox(device.serial.c_str(), &DeviceChecked)){
if(DeviceChecked){
selectedDevice = device;
std::cout << "Device selected:" << device.serial.c_str() << std::endl;
}
else {
selectedDevice = {};
std::cout << "Device Changed:" << device.serial.c_str() << std::endl;
}
}
}
}

// extra functions:

void AnalyzeStateManager::selectCurrentDevice(){
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::selectFileData(){
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::checkFileFormat(){
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::selectFileData() {
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::checkFileFormat() {
std::cout << "Not used" << std::endl;
}

void AnalyzeStateManager::writeAnalysisAnswerIntoFile(){
std::cout << "Not used" << std::endl;
}
void AnalyzeStateManager::writeAnalysisAnswerIntoFile() {
std::cout << "Not used" << std::endl;
}
77 changes: 37 additions & 40 deletions src/analyze_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,55 @@
#include "sendData.hpp"
#include "../imgui-stdlib/imgui_stdlib.h"
#include "jasonhandler.hpp"
// extra boolean references for the RadioButtons

static bool radioButtonCurrentData{false}, radioButtonFileData{false}, DeviceChecked{false};

Check warning on line 17 in src/analyze_data.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-C++ CI

‘DeviceChecked’ defined but not used [-Wunused-variable]

Check warning on line 17 in src/analyze_data.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-C++ CI

‘radioButtonFileData’ defined but not used [-Wunused-variable]

Check warning on line 17 in src/analyze_data.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-C++ CI

‘radioButtonCurrentData’ defined but not used [-Wunused-variable]
static Omniscope::Id selectedDevice{};

// extra boolean references for the RadioButtons
// declare functions and classes

static bool radioButtonCurrentData{false}, radioButtonFileData{false};
void generate_analyze_menu(
bool &,
const std::map<Omniscope::Id, std::vector<std::pair<double, double>>> &);


// declare functions and classes

void generate_analyze_menu(bool &);


// Menustates
// Menustates
enum class State {
NoDataSelected,
FileDataSelected,
FileDataLoaded,
CurrentDataSelected,
CurrentDataLoaded,
DataWasSend,
Reset
};

class AnalyzeStateManager{
public:
AnalyzeStateManager(){
currentState = State::NoDataSelected;
}
~AnalyzeStateManager() = default;

void setState(State state = State::NoDataSelected);
State getState();
NoDataSelected,
FileDataSelected,
FileDataLoaded,
CurrentDataSelected,
CurrentDataLoaded,
DataWasSend,
Reset
};

void selectData();
void loadData();
class AnalyzeStateManager {
public:
AnalyzeStateManager() { currentState = State::NoDataSelected; }
~AnalyzeStateManager() = default;

void reset();
void setState(State state = State::NoDataSelected);
State getState();

void setMetaData();
void clearMetaData();
void selectData(
AnalyzeStateManager &, bool &,
const std::map<Omniscope::Id, std::vector<std::pair<double, double>>> &);
void loadData();

// extra functions:
void reset();

void selectCurrentDevice();
void selectFileData();
void checkFileFormat();
void setMetaData();
void clearMetaData();

void writeAnalysisAnswerIntoFile();
// extra functions:

void selectCurrentDevice(const std::map<Omniscope::Id, std::vector<std::pair<double, double>>> &);
void selectFileData();
void checkFileFormat();

private:
void writeAnalysisAnswerIntoFile();

State currentState;
const std::map<Omniscope::Id, std::vector<std::pair<double, double>>> data;
private:
State currentState;
const std::map<Omniscope::Id, std::vector<std::pair<double, double>>> data;
};
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main() {

// Generate analyze data popup
if (open_analyze_menu)
generate_analyze_menu(open_analyze_menu);
generate_analyze_menu(open_analyze_menu, captureData);

// ############################ addPlots("Recording the data", ...)
ImGui::Dummy({0.f, windowSize.y * .01f});
Expand Down

0 comments on commit a1213f3

Please sign in to comment.