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
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e462a353ce7d
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 18c305b896d6
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Sep 3, 2020

  1. Filter: don't do type checking when loading save files when filters h…

    …aven't been evaluated yet. Fixes #235.
    azonenberg committed Sep 3, 2020
    Copy the full SHA
    18c305b View commit details
Showing with 39 additions and 11 deletions.
  1. +29 −8 scopehal/Filter.cpp
  2. +5 −2 scopehal/Filter.h
  3. +5 −1 scopehal/OscilloscopeChannel.h
37 changes: 29 additions & 8 deletions scopehal/Filter.cpp
Original file line number Diff line number Diff line change
@@ -295,7 +295,15 @@ string Filter::GetInputName(size_t i)
}
}

void Filter::SetInput(size_t i, StreamDescriptor stream)
/**
@brief Connects a stream to the input of this filter
@param i Index of the input port to connect
@param stream Input data stream
@param force Forcibly connect this stream without checking to make sure it's the right type.
Should only be set true by by Filter::LoadInputs() or in similar specialized situations.
*/
void Filter::SetInput(size_t i, StreamDescriptor stream, bool force)
{
if(i < m_signalNames.size())
{
@@ -305,11 +313,15 @@ void Filter::SetInput(size_t i, StreamDescriptor stream)
return;
}

if(!ValidateChannel(i, stream))
//If forcing, don't validate the channel
if(!force)
{
LogError("Invalid channel for input %zu of %s\n", i, m_displayname.c_str());
m_inputs[i] = StreamDescriptor(NULL, 0);
return;
if(!ValidateChannel(i, stream))
{
LogError("Invalid channel for input %zu of %s\n", i, m_displayname.c_str());
m_inputs[i] = StreamDescriptor(NULL, 0);
return;
}
}

//Deref whatever was there (if anything)
@@ -326,14 +338,22 @@ void Filter::SetInput(size_t i, StreamDescriptor stream)
}
}

void Filter::SetInput(string name, StreamDescriptor stream)
/**
@brief Connects a stream to the input of this filter
@param name Name of the input port to connect
@param stream Input data stream
@param force Forcibly connect this stream without checking to make sure it's the right type.
Should only be set true by by Filter::LoadInputs() or in similar specialized situations.
*/
void Filter::SetInput(string name, StreamDescriptor stream, bool force)
{
//Find the channel
for(size_t i=0; i<m_signalNames.size(); i++)
{
if(m_signalNames[i] == name)
{
SetInput(i, stream);
SetInput(i, stream, force);
return;
}
}
@@ -799,7 +819,8 @@ void Filter::LoadInputs(const YAML::Node& node, IDTable& table)

SetInput(
it.first.as<string>(),
StreamDescriptor(static_cast<OscilloscopeChannel*>(table[index]), stream)
StreamDescriptor(static_cast<OscilloscopeChannel*>(table[index]), stream),
true
);
}
}
7 changes: 5 additions & 2 deletions scopehal/Filter.h
Original file line number Diff line number Diff line change
@@ -163,6 +163,9 @@ class Filter : public OscilloscopeChannel
virtual void AddRef();
virtual void Release();

size_t GetRefCount()
{ return m_refcount; }

//Get all currently existing filters
static std::set<Filter*> GetAllInstances()
{ return m_filters; }
@@ -179,8 +182,8 @@ class Filter : public OscilloscopeChannel
//Channels
size_t GetInputCount();
std::string GetInputName(size_t i);
void SetInput(size_t i, StreamDescriptor stream);
void SetInput(std::string name, StreamDescriptor stream);
void SetInput(size_t i, StreamDescriptor stream, bool force = false);
void SetInput(std::string name, StreamDescriptor stream, bool force = false);

StreamDescriptor GetInput(size_t i);

6 changes: 5 additions & 1 deletion scopehal/OscilloscopeChannel.h
Original file line number Diff line number Diff line change
@@ -93,7 +93,11 @@ class OscilloscopeChannel

///Get the contents of a data stream
WaveformBase* GetData(size_t stream)
{ return m_streamData[stream]; }
{
if(stream >= m_streamData.size())
return NULL;
return m_streamData[stream];
}

///Detach the capture data from this channel
WaveformBase* Detach(size_t stream)