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: 2906048b2a1b
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: 20393a91f983
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Jun 29, 2020

  1. Copy the full SHA
    20393a9 View commit details
Showing with 86 additions and 6 deletions.
  1. +35 −3 glscopeclient/HaltConditionsDialog.cpp
  2. +7 −1 glscopeclient/HaltConditionsDialog.h
  3. +41 −2 glscopeclient/OscilloscopeWindow.cpp
  4. +3 −0 glscopeclient/OscilloscopeWindow.h
38 changes: 35 additions & 3 deletions glscopeclient/HaltConditionsDialog.cpp
Original file line number Diff line number Diff line change
@@ -51,8 +51,10 @@ HaltConditionsDialog::HaltConditionsDialog(
get_vbox()->pack_start(m_grid, Gtk::PACK_EXPAND_WIDGET);
m_grid.attach(m_haltEnabledButton, 0, 0, 1, 1);
m_haltEnabledButton.set_label("Halt Enabled");
m_grid.attach_next_to(m_moveToEventButton, m_haltEnabledButton, Gtk::POS_BOTTOM, 1, 1);
m_moveToEventButton.set_label("Move To Event");

m_grid.attach_next_to(m_channelNameLabel, m_haltEnabledButton, Gtk::POS_BOTTOM, 1, 1);
m_grid.attach_next_to(m_channelNameLabel, m_moveToEventButton, Gtk::POS_BOTTOM, 1, 1);
m_channelNameLabel.set_label("Halt when");
m_grid.attach_next_to(m_channelNameBox, m_channelNameLabel, Gtk::POS_RIGHT, 1, 1);
m_grid.attach_next_to(m_operatorBox, m_channelNameBox, Gtk::POS_RIGHT, 1, 1);
@@ -116,14 +118,14 @@ void HaltConditionsDialog::RefreshChannels()
/**
@brief Check if we should halt the trigger
*/
bool HaltConditionsDialog::ShouldHalt()
bool HaltConditionsDialog::ShouldHalt(int64_t& timestamp)
{
//If conditional halt is not enabled, no sense checking conditions
if(!m_haltEnabledButton.get_active())
return false;

//Get the channel we're looking at
auto chan = m_chanptrs[m_channelNameBox.get_active_text()];
auto chan = GetHaltChannel();
auto decode = dynamic_cast<ProtocolDecoder*>(chan);

//Don't check if no data to look at
@@ -148,7 +150,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] < value)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

@@ -161,7 +166,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] <= value)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

@@ -173,7 +181,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] == value)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

@@ -185,7 +196,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(decode->GetText(i) == text)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}
}
@@ -198,7 +212,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] >= value)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

@@ -211,7 +228,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] > value)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

@@ -223,7 +243,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] != value)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

@@ -235,7 +258,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(decode->GetText(i) != text)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}
}
@@ -249,7 +275,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(decode->GetText(i).find(text) == 0)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

@@ -262,7 +291,10 @@ bool HaltConditionsDialog::ShouldHalt()
for(size_t i=0; i<len; i++)
{
if(decode->GetText(i).find(text) != string::npos)
{
timestamp = data->m_offsets[i] * data->m_timescale;
return true;
}
}
}

8 changes: 7 additions & 1 deletion glscopeclient/HaltConditionsDialog.h
Original file line number Diff line number Diff line change
@@ -47,11 +47,17 @@ class HaltConditionsDialog : public Gtk::Dialog

void RefreshChannels();

bool ShouldHalt();
bool ShouldHalt(int64_t& timestamp);
bool ShouldMoveToHalt()
{ return m_moveToEventButton.get_active(); }

OscilloscopeChannel* GetHaltChannel()
{ return m_chanptrs[m_channelNameBox.get_active_text()]; }

protected:
Gtk::Grid m_grid;
Gtk::CheckButton m_haltEnabledButton;
Gtk::CheckButton m_moveToEventButton;
Gtk::Label m_channelNameLabel;
Gtk::ComboBoxText m_channelNameBox;
Gtk::ComboBoxText m_operatorBox;
43 changes: 41 additions & 2 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ OscilloscopeWindow::OscilloscopeWindow(vector<Oscilloscope*> scopes, bool nodigi
, m_multiScopeFreeRun(false)
, m_scopeSyncWizard(NULL)
, m_haltConditionsDialog(this)
, m_triggerArmed(false)
{
SetTitle();

@@ -385,7 +386,16 @@ void OscilloscopeWindow::CreateWidgets(bool nodigital)

bool OscilloscopeWindow::OnTimer(int /*timer*/)
{
PollScopes();
if(m_triggerArmed)
PollScopes();

//Discard all pending waveform data if the trigger isn't armed.
//Failure to do this can lead to a spurious trigger after we wanted to stop.
else
{
for(auto scope : m_scopes)
scope->ClearPendingWaveforms();
}

//Clean up the scope sync wizard if it's completed
if(m_syncComplete)
@@ -1996,8 +2006,35 @@ void OscilloscopeWindow::OnAllWaveformsUpdated()
m_scopeSyncWizard->OnWaveformDataReady();

//Check if a conditional halt applies
if(m_haltConditionsDialog.ShouldHalt())
int64_t timestamp;
if(m_haltConditionsDialog.ShouldHalt(timestamp))
{
auto chan = m_haltConditionsDialog.GetHaltChannel();

OnStop();

if(m_haltConditionsDialog.ShouldMoveToHalt())
{
//Find the waveform area(s) for this channel
for(auto a : m_waveformAreas)
{
if(a->GetChannel() == chan)
{
a->m_group->m_xAxisOffset = timestamp;
a->m_group->m_frame.queue_draw();
}

for(size_t i=0; i<a->GetOverlayCount(); i++)
{
if(a->GetOverlay(i) == chan)
{
a->m_group->m_xAxisOffset = timestamp;
a->m_group->m_frame.queue_draw();
}
}
}
}
}
}

void OscilloscopeWindow::RefreshAllDecoders()
@@ -2114,6 +2151,7 @@ void OscilloscopeWindow::OnStartSingle()
void OscilloscopeWindow::OnStop()
{
m_multiScopeFreeRun = false;
m_triggerArmed = false;

for(auto scope : m_scopes)
scope->Stop();
@@ -2147,6 +2185,7 @@ void OscilloscopeWindow::ArmTrigger(bool oneshot)
m_scopes[i]->IDPing();
}
m_tArm = GetTime();
m_triggerArmed = true;
}

/**
3 changes: 3 additions & 0 deletions glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -268,6 +268,9 @@ class OscilloscopeWindow : public Gtk::Window

//Conditional halting
HaltConditionsDialog m_haltConditionsDialog;

//If false, ignore incoming waveforms (scope thread might have an extra trigger after you press stop)
bool m_triggerArmed;
};

#endif