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

Commits on May 17, 2021

  1. Moved LoadParameters / LoadInputs to FLowGraphNode. Triggers now can …

    …load config from scopesession files. Fixes #101.
    azonenberg committed May 17, 2021
    Copy the full SHA
    aecc8c1 View commit details
Showing with 55 additions and 39 deletions.
  1. +9 −35 scopehal/Filter.cpp
  2. +0 −4 scopehal/Filter.h
  3. +31 −0 scopehal/FlowGraphNode.cpp
  4. +6 −0 scopehal/FlowGraphNode.h
  5. +9 −0 scopehal/Oscilloscope.cpp
44 changes: 9 additions & 35 deletions scopehal/Filter.cpp
Original file line number Diff line number Diff line change
@@ -687,41 +687,6 @@ void Filter::FindFallingEdges(DigitalWaveform* data, vector<int64_t>& edges)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

void Filter::LoadParameters(const YAML::Node& node, IDTable& /*table*/)
{
//id, protocol, color are already loaded
m_displayname = node["nick"].as<string>();
m_hwname = node["name"].as<string>();

auto parameters = node["parameters"];
for(auto it : parameters)
GetParameter(it.first.as<string>()).ParseString(it.second.as<string>());
}

void Filter::LoadInputs(const YAML::Node& node, IDTable& table)
{
int index;
int stream;

auto inputs = node["inputs"];
for(auto it : inputs)
{
//Inputs are formatted as %d/%d. Stream index may be omitted.
auto sin = it.second.as<string>();
if(2 != sscanf(sin.c_str(), "%d/%d", &index, &stream))
{
index = atoi(sin.c_str());
stream = 0;
}

SetInput(
it.first.as<string>(),
StreamDescriptor(static_cast<OscilloscopeChannel*>(table[index]), stream),
true
);
}
}

string Filter::SerializeConfiguration(IDTable& table, size_t /*indent*/)
{
string config = " : \n";
@@ -741,6 +706,15 @@ string Filter::SerializeConfiguration(IDTable& table, size_t /*indent*/)
return config;
}

void Filter::LoadParameters(const YAML::Node& node, IDTable& table)
{
FlowGraphNode::LoadParameters(node, table);

//id, protocol, color are already loaded
m_displayname = node["nick"].as<string>();
m_hwname = node["name"].as<string>();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Complex protocol decodes

4 changes: 0 additions & 4 deletions scopehal/Filter.h
Original file line number Diff line number Diff line change
@@ -141,11 +141,7 @@ class Filter : public OscilloscopeChannel
*/
virtual std::string SerializeConfiguration(IDTable& table, size_t indent = 8);

/**
@brief Load configuration from a save file
*/
virtual void LoadParameters(const YAML::Node& node, IDTable& table);
virtual void LoadInputs(const YAML::Node& node, IDTable& table);

/**
@brief Standard colors for protocol decode overlays.
31 changes: 31 additions & 0 deletions scopehal/FlowGraphNode.cpp
Original file line number Diff line number Diff line change
@@ -269,3 +269,34 @@ string FlowGraphNode::SerializeConfiguration(IDTable& table, size_t indent)

return config;
}

void FlowGraphNode::LoadParameters(const YAML::Node& node, IDTable& /*table*/)
{
auto parameters = node["parameters"];
for(auto it : parameters)
GetParameter(it.first.as<string>()).ParseString(it.second.as<string>());
}

void FlowGraphNode::LoadInputs(const YAML::Node& node, IDTable& table)
{
int index;
int stream;

auto inputs = node["inputs"];
for(auto it : inputs)
{
//Inputs are formatted as %d/%d. Stream index may be omitted.
auto sin = it.second.as<string>();
if(2 != sscanf(sin.c_str(), "%d/%d", &index, &stream))
{
index = atoi(sin.c_str());
stream = 0;
}

SetInput(
it.first.as<string>(),
StreamDescriptor(static_cast<OscilloscopeChannel*>(table[index]), stream),
true
);
}
}
6 changes: 6 additions & 0 deletions scopehal/FlowGraphNode.h
Original file line number Diff line number Diff line change
@@ -123,6 +123,12 @@ class FlowGraphNode
*/
virtual std::string SerializeConfiguration(IDTable& table, size_t indent = 8);

/**
@brief Load configuration from a save file
*/
virtual void LoadParameters(const YAML::Node& node, IDTable& table);
virtual void LoadInputs(const YAML::Node& node, IDTable& table);

//Input handling helpers
protected:

9 changes: 9 additions & 0 deletions scopehal/Oscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -412,6 +412,15 @@ void Oscilloscope::LoadConfiguration(const YAML::Node& node, IDTable& table)
SetSampleRate(node["rate"].as<unsigned long>());
if(node["depth"])
SetSampleDepth(node["depth"].as<unsigned long>());

auto tnode = node["trigger"];
if(tnode)
{
auto trig = Trigger::CreateTrigger(tnode["type"].as<string>(), this);
trig->LoadParameters(tnode, table);
trig->LoadInputs(tnode, table);
SetTrigger(trig);
}
}

void Oscilloscope::EnableTriggerOutput()