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: 8c5ed874686c
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: d8bd049352b8
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Oct 1, 2020

  1. Copy the full SHA
    d8bd049 View commit details
Showing with 83 additions and 47 deletions.
  1. +1 −1 lib
  2. +67 −39 src/glscopeclient/TimebasePropertiesDialog.cpp
  3. +15 −7 src/glscopeclient/TimebasePropertiesDialog.h
106 changes: 67 additions & 39 deletions src/glscopeclient/TimebasePropertiesDialog.cpp
Original file line number Diff line number Diff line change
@@ -43,21 +43,32 @@ using namespace std;

void TimebasePropertiesPage::AddWidgets()
{
m_grid.set_margin_left(10);
m_grid.set_margin_right(10);
m_grid.set_column_spacing(10);
m_grid.set_row_spacing(5);
//Stack setup
m_box.pack_start(m_sidebar, Gtk::PACK_EXPAND_WIDGET);
m_box.pack_start(m_stack, Gtk::PACK_EXPAND_WIDGET);
m_sidebar.set_stack(m_stack);
m_stack.set_homogeneous();

m_grid.attach(m_sampleRateLabel, 0, 0, 1, 1);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Time domain settings

m_stack.add(m_tgrid, "Time Domain", "Time Domain");

m_tgrid.set_margin_left(10);
m_tgrid.set_margin_right(10);
m_tgrid.set_column_spacing(10);
m_tgrid.set_row_spacing(5);

m_tgrid.attach(m_sampleRateLabel, 0, 0, 1, 1);
m_sampleRateLabel.set_text("Sample Rate");
m_grid.attach_next_to(m_sampleRateBox, m_sampleRateLabel, Gtk::POS_RIGHT, 1, 1);
m_grid.attach_next_to(m_memoryDepthLabel, m_sampleRateLabel, Gtk::POS_BOTTOM, 1, 1);
m_tgrid.attach_next_to(m_sampleRateBox, m_sampleRateLabel, Gtk::POS_RIGHT, 1, 1);
m_tgrid.attach_next_to(m_memoryDepthLabel, m_sampleRateLabel, Gtk::POS_BOTTOM, 1, 1);
m_memoryDepthLabel.set_text("Memory Depth");
m_grid.attach_next_to(m_memoryDepthBox, m_memoryDepthLabel, Gtk::POS_RIGHT, 1, 1);
m_tgrid.attach_next_to(m_memoryDepthBox, m_memoryDepthLabel, Gtk::POS_RIGHT, 1, 1);

m_grid.attach_next_to(m_interleaveLabel, m_memoryDepthLabel, Gtk::POS_BOTTOM, 1, 1);
m_tgrid.attach_next_to(m_interleaveLabel, m_memoryDepthLabel, Gtk::POS_BOTTOM, 1, 1);
m_interleaveLabel.set_text("Channel Combining");
m_grid.attach_next_to(m_interleaveSwitch, m_interleaveLabel, Gtk::POS_RIGHT, 1, 1);
m_tgrid.attach_next_to(m_interleaveSwitch, m_interleaveLabel, Gtk::POS_RIGHT, 1, 1);

bool interleaving = m_scope->IsInterleaving();
m_interleaveSwitch.set_state(interleaving);
@@ -66,6 +77,32 @@ void TimebasePropertiesPage::AddWidgets()
m_interleaveSwitch.signal_state_set().connect(
sigc::mem_fun(*this, &TimebasePropertiesPage::OnInterleaveSwitchChanged), false);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Frequency domain settings

if(m_scope->HasFrequencyControls())
{
m_stack.add(m_fgrid, "Frequency Domain", "Frequency Domain");

m_fgrid.set_margin_left(10);
m_fgrid.set_margin_right(10);
m_fgrid.set_column_spacing(10);
m_fgrid.set_row_spacing(5);

m_fgrid.attach(m_spanLabel, 0, 0, 1, 1);
m_spanLabel.set_text("Span");
m_fgrid.attach_next_to(m_spanEntry, m_spanLabel, Gtk::POS_RIGHT, 1, 1);
m_spanEntry.set_text(Unit(Unit::UNIT_HZ).PrettyPrint(m_scope->GetSpan()));

m_fgrid.attach_next_to(m_rbwLabel, m_spanLabel, Gtk::POS_BOTTOM, 1, 1);
m_rbwLabel.set_text("RBW");
m_fgrid.attach_next_to(m_rbwEntry, m_rbwLabel, Gtk::POS_RIGHT, 1, 1);
m_rbwEntry.set_text(Unit(Unit::UNIT_HZ).PrettyPrint(m_scope->GetResolutionBandwidth()));
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Done, pull stuff from the instrment

RefreshSampleRates(interleaving);
RefreshSampleDepths(interleaving);
}
@@ -155,7 +192,7 @@ TimebasePropertiesDialog::TimebasePropertiesDialog(
for(auto scope : scopes)
{
TimebasePropertiesPage* page = new TimebasePropertiesPage(scope);
m_tabs.append_page(page->m_grid, scope->m_nickname);
m_tabs.append_page(page->m_box, scope->m_nickname);
page->AddWidgets();
m_pages[scope] = page;
}
@@ -174,37 +211,28 @@ TimebasePropertiesDialog::~TimebasePropertiesDialog()

void TimebasePropertiesDialog::ConfigureTimebase()
{
Unit hz(Unit::UNIT_HZ);
Unit depth(Unit::UNIT_SAMPLEDEPTH);
Unit rate(Unit::UNIT_SAMPLERATE);

for(auto it : m_pages)
{
auto page = it.second;
auto scope = it.first;

//Configure interleaving
it.first->SetInterleaving(it.second->m_interleaveSwitch.get_state());

//Figure out the requested sample rate
char scale;
long rate;
sscanf(it.second->m_sampleRateBox.get_active_text().c_str(), "%ld %cS/s", &rate, &scale);
uint64_t frate = rate;
if(scale == 'k')
frate *= 1000;
else if(scale == 'M')
frate *= 1000000;
else if(scale == 'G')
frate *= 1000000000;

//Figure out the memory depth
long depth;
sscanf(it.second->m_memoryDepthBox.get_active_text().c_str(), "%ld %cS", &depth, &scale);
uint64_t fdepth = depth;
if(scale == 'k')
fdepth *= 1000;
else if(scale == 'M')
fdepth *= 1000000;
else if(scale == 'G')
fdepth *= 1000000000;

//Apply changes
it.first->SetSampleDepth(fdepth);
it.first->SetSampleRate(frate);
scope->SetInterleaving(page->m_interleaveSwitch.get_state());

//Set timebase
scope->SetSampleDepth(round(depth.ParseString(page->m_memoryDepthBox.get_active_text())));
scope->SetSampleRate(round(rate.ParseString(page->m_sampleRateBox.get_active_text())));

//Frequency domain options
if(scope->HasFrequencyControls())
{
scope->SetSpan(round(hz.ParseString(page->m_spanEntry.get_text())));
scope->SetResolutionBandwidth(round(hz.ParseString(page->m_rbwEntry.get_text())));
}
}
}

22 changes: 15 additions & 7 deletions src/glscopeclient/TimebasePropertiesDialog.h
Original file line number Diff line number Diff line change
@@ -45,13 +45,21 @@ class TimebasePropertiesPage

Oscilloscope* m_scope;

Gtk::Grid m_grid;
Gtk::Label m_sampleRateLabel;
Gtk::ComboBoxText m_sampleRateBox;
Gtk::Label m_memoryDepthLabel;
Gtk::ComboBoxText m_memoryDepthBox;
Gtk::Label m_interleaveLabel;
Gtk::Switch m_interleaveSwitch;
Gtk::HBox m_box;
Gtk::StackSidebar m_sidebar;
Gtk::Stack m_stack;
Gtk::Grid m_tgrid;
Gtk::Label m_sampleRateLabel;
Gtk::ComboBoxText m_sampleRateBox;
Gtk::Label m_memoryDepthLabel;
Gtk::ComboBoxText m_memoryDepthBox;
Gtk::Label m_interleaveLabel;
Gtk::Switch m_interleaveSwitch;
Gtk::Grid m_fgrid;
Gtk::Label m_spanLabel;
Gtk::Entry m_spanEntry;
Gtk::Label m_rbwLabel;
Gtk::Entry m_rbwEntry;

void RefreshSampleRates(bool interleaving);
void RefreshSampleDepths(bool interleaving);