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: 5801996b97ab
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: 2906048b2a1b
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jun 29, 2020

  1. Copy the full SHA
    72784b8 View commit details
  2. Copy the full SHA
    2906048 View commit details
Showing with 142 additions and 21 deletions.
  1. +142 −21 glscopeclient/HaltConditionsDialog.cpp
163 changes: 142 additions & 21 deletions glscopeclient/HaltConditionsDialog.cpp
Original file line number Diff line number Diff line change
@@ -56,8 +56,14 @@ HaltConditionsDialog::HaltConditionsDialog(
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);
m_operatorBox.append("<");
m_operatorBox.append("<=");
m_operatorBox.append("==");
m_operatorBox.append(">");
m_operatorBox.append(">=");
m_operatorBox.append("!=");
m_operatorBox.append("starts with");
m_operatorBox.append("contains");
m_grid.attach_next_to(m_targetEntry, m_operatorBox, Gtk::POS_RIGHT, 1, 1);

show_all();
@@ -73,35 +79,38 @@ HaltConditionsDialog::~HaltConditionsDialog()

void HaltConditionsDialog::RefreshChannels()
{
//TODO: save previous state
string old_chan = m_channelNameBox.get_active_text();

m_channelNameBox.remove_all();
m_chanptrs.clear();

//Populate channel list
/*
bool first = true;
for(size_t j=0; j<m_parent->GetScopeCount(); j++)
{
auto scope = m_parent->GetScope(j);
for(size_t k=0; k<scope->GetChannelCount(); k++)
{
auto c = scope->GetChannel(k);
m_channelNameBox.append(c->m_displayname);
m_chanptrs[c->m_displayname] = c;

if(first && (old_chan == ""))
{
first = false;
m_channelNameBox.set_active_text(c->m_displayname);
}
}
}
*/

//For now, only allow conditional triggering on complex decodes
auto decodes = ProtocolDecoder::EnumDecodes();
for(auto d : decodes)
{
if(d->GetType() != OscilloscopeChannel::CHANNEL_TYPE_COMPLEX)
continue;
m_channelNameBox.append(d->m_displayname);
m_chanptrs[d->m_displayname] = d;
}

if(old_chan != "")
m_channelNameBox.set_active_text(old_chan);
}

/**
@@ -116,31 +125,143 @@ bool HaltConditionsDialog::ShouldHalt()
//Get the channel we're looking at
auto chan = m_chanptrs[m_channelNameBox.get_active_text()];
auto decode = dynamic_cast<ProtocolDecoder*>(chan);
if(decode == NULL)
return false;

//Don't check if no data to look at
auto data = decode->GetData();
auto data = chan->GetData();
auto adata = dynamic_cast<AnalogWaveform*>(data);
if(data->m_offsets.empty())
return false;

//TODO: support more than just == / !=
bool match_equal = (m_operatorBox.get_active_text() == "==");
//Target for matching
auto text = m_targetEntry.get_text();
double value = chan->GetYAxisUnits().ParseString(text);

//Loop over the decode and see if anything matches
//Figure out the match filter and check
auto sfilter = m_operatorBox.get_active_text();
size_t len = data->m_offsets.size();
auto text = m_targetEntry.get_text();
for(size_t i=0; i<len; i++)
if(sfilter == "<")
{
auto target = decode->GetText(i);
if(match_equal)
//Expect analog data
if(adata == NULL)
return false;

for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] < value)
return true;
}
}

else if(sfilter == "<=")
{
//Expect analog data
if(adata == NULL)
return false;

for(size_t i=0; i<len; i++)
{
if(target == text)
if(adata->m_samples[i] <= value)
return true;
}
else
}

else if(sfilter == "==")
{
//Match analog data
if(adata != NULL)
{
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] == value)
return true;
}
}

//TODO: match digital data

//Match protocol decodes
else if(decode != NULL)
{
for(size_t i=0; i<len; i++)
{
if(decode->GetText(i) == text)
return true;
}
}
}
else if(sfilter == ">=")
{
//Expect analog data
if(adata == NULL)
return false;

for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] >= value)
return true;
}
}

else if(sfilter == ">")
{
//Expect analog data
if(adata == NULL)
return false;

for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] > value)
return true;
}
}

else if(sfilter == "!=")
{
//Match analog data
if(adata != NULL)
{
for(size_t i=0; i<len; i++)
{
if(adata->m_samples[i] != value)
return true;
}
}

//TODO: match digital data

//Match protocol decodes
else if(decode != NULL)
{
for(size_t i=0; i<len; i++)
{
if(decode->GetText(i) != text)
return true;
}
}
}

else if(sfilter == "starts with")
{
//Expect decode data
if(decode == NULL)
return false;

for(size_t i=0; i<len; i++)
{
if(decode->GetText(i).find(text) == 0)
return true;
}
}

else if(sfilter == "contains")
{
//Expect decode data
if(decode == NULL)
return false;

for(size_t i=0; i<len; i++)
{
if(target != text)
if(decode->GetText(i).find(text) != string::npos)
return true;
}
}