Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5ff7cfd22d8d
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cbb37dde6a55
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Feb 19, 2021

  1. Copy the full SHA
    fef1160 View commit details

Commits on Feb 24, 2021

  1. Load BIN from CLI

    sam210723 committed Feb 24, 2021
    Copy the full SHA
    37c22de View commit details

Commits on Apr 12, 2021

  1. Merge pull request #307 from sam210723/master

    Add *.bin filter to Import dialog
    azonenberg authored Apr 12, 2021
    Copy the full SHA
    cbb37dd View commit details
Showing with 86 additions and 6 deletions.
  1. +81 −5 src/glscopeclient/OscilloscopeWindow.cpp
  2. +1 −0 src/glscopeclient/OscilloscopeWindow.h
  3. +4 −1 src/glscopeclient/ScopeApp.cpp
86 changes: 81 additions & 5 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -643,18 +643,32 @@ void OscilloscopeWindow::OnFileImport()
//TODO: prompt to save changes to the current session
Gtk::FileChooserDialog dlg(*this, "Import", Gtk::FILE_CHOOSER_ACTION_OPEN);

auto filter = Gtk::FileFilter::create();
filter->add_pattern("*.csv");
filter->set_name("Comma Separated Value (*.csv)");
dlg.add_filter(filter);
auto csvFilter = Gtk::FileFilter::create();
csvFilter->add_pattern("*.csv");
csvFilter->set_name("Comma Separated Value (*.csv)");

auto binFilter = Gtk::FileFilter::create();
binFilter->add_pattern("*.bin");
binFilter->set_name("Agilent/Keysight/Rigol Binary Capture (*.bin)");

dlg.add_filter(csvFilter);
dlg.add_filter(binFilter);
dlg.add_button("Open", Gtk::RESPONSE_OK);
dlg.add_button("Cancel", Gtk::RESPONSE_CANCEL);
auto response = dlg.run();

if(response != Gtk::RESPONSE_OK)
return;

DoImportCSV(dlg.get_filename());
auto filterName = dlg.get_filter()->get_name();
if(filterName == "Comma Separated Value (*.csv)")
{
DoImportCSV(dlg.get_filename());
}
else if(filterName == "Agilent/Keysight/Rigol Binary Capture (*.bin)")
{
DoImportBIN(dlg.get_filename());
}
}

/**
@@ -719,6 +733,68 @@ void OscilloscopeWindow::DoImportCSV(const string& filename)
OnAllWaveformsUpdated();
}

/**
@brief Import a Agilent/Keysight BIN file
*/
void OscilloscopeWindow::DoImportBIN(const string& filename)
{
LogDebug("Importing BIN file \"%s\"\n", filename.c_str());
{
LogIndenter li;

//Setup
CloseSession();
m_currentFileName = filename;
m_loadInProgress = true;

//Clear performance counters
m_totalWaveforms = 0;
m_lastWaveformTimes.clear();

//Create the mock scope
auto scope = new MockOscilloscope("Binary Import", "Agilent/Keysight/Rigol", "0");
scope->m_nickname = "import";
g_app->m_scopes.push_back(scope);
m_scopes.push_back(scope);

//Set up history for it
auto hist = new HistoryWindow(this, scope);
hist->hide();
m_historyWindows[scope] = hist;

//Load the waveform
if(!scope->LoadBIN(filename))
{
Gtk::MessageDialog dlg(
*this,
"BIN import failed",
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true);
dlg.run();
}
}

//Add the top level splitter right before the status bar
auto split = new Gtk::VPaned;
m_splitters.emplace(split);
m_vbox.remove(m_statusbar);
m_vbox.pack_start(*split, Gtk::PACK_EXPAND_WIDGET);
m_vbox.pack_start(m_statusbar, Gtk::PACK_SHRINK);

//Add all of the UI stuff
CreateDefaultWaveformAreas(split);

//Done
SetTitle();
OnLoadComplete();

//Process the new data
m_historyWindows[m_scopes[0]]->OnWaveformDataReady();
OnAllWaveformsUpdated();
}

/**
@brief Open a saved configuration
*/
1 change: 1 addition & 0 deletions src/glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -240,6 +240,7 @@ class OscilloscopeWindow : public Gtk::Window
void DoFileOpen(const std::string& filename, bool loadLayout = true, bool loadWaveform = true, bool reconnect = true);
void OnFileImport();
void DoImportCSV(const std::string& filename);
void DoImportBIN(const std::string& filename);
void LoadInstruments(const YAML::Node& node, bool reconnect, IDTable& table);
void LoadDecodes(const YAML::Node& node, IDTable& table);
void LoadUIConfiguration(const YAML::Node& node, IDTable& table);
5 changes: 4 additions & 1 deletion src/glscopeclient/ScopeApp.cpp
Original file line number Diff line number Diff line change
@@ -53,10 +53,13 @@ void ScopeApp::run(string fileToLoad, bool reconnect, bool nodata, bool retrigge
//Handle file loads specified on the command line
if(!fileToLoad.empty())
{
//Guess CSV files by extension
//Guess files by extension
if(fileToLoad.find(".csv") != string::npos)
m_window->DoImportCSV(fileToLoad);

else if (fileToLoad.find(".bin") != string::npos)
m_window->DoImportBIN(fileToLoad);

//Assume anything else is a scopesession
else
m_window->DoFileOpen(fileToLoad, true, !nodata, reconnect);