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

Commits on May 17, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    49e6738 View commit details
  2. Copy the full SHA
    e47f4e3 View commit details
Showing with 97 additions and 58 deletions.
  1. +4 −55 scopehal/Filter.cpp
  2. +1 −1 scopehal/Filter.h
  3. +63 −0 scopehal/FlowGraphNode.cpp
  4. +7 −0 scopehal/FlowGraphNode.h
  5. +4 −2 scopehal/Oscilloscope.cpp
  6. +11 −0 scopehal/Trigger.cpp
  7. +7 −0 scopehal/Trigger.h
59 changes: 4 additions & 55 deletions scopehal/Filter.cpp
Original file line number Diff line number Diff line change
@@ -722,16 +722,13 @@ void Filter::LoadInputs(const YAML::Node& node, IDTable& table)
}
}

string Filter::SerializeConfiguration(IDTable& table)
string Filter::SerializeConfiguration(IDTable& table, size_t /*indent*/)
{
//Save basic decode info
char tmp[1024];
snprintf(tmp, sizeof(tmp), " : \n");
string config = tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", table.emplace(this));
config += tmp;
string config = " : \n";
config += FlowGraphNode::SerializeConfiguration(table, 8);

//Channel info
char tmp[1024];
snprintf(tmp, sizeof(tmp), " protocol: \"%s\"\n", GetProtocolDisplayName().c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " color: \"%s\"\n", m_displaycolor.c_str());
@@ -741,54 +738,6 @@ string Filter::SerializeConfiguration(IDTable& table)
snprintf(tmp, sizeof(tmp), " name: \"%s\"\n", GetHwname().c_str());
config += tmp;

//Inputs
snprintf(tmp, sizeof(tmp), " inputs: \n");
config += tmp;
for(size_t i=0; i<m_inputs.size(); i++)
{
auto desc = m_inputs[i];
if(desc.m_channel == NULL)
snprintf(tmp, sizeof(tmp), " %-20s 0\n", (m_signalNames[i] + ":").c_str());
else
{
snprintf(tmp, sizeof(tmp), " %-20s %d/%zu\n",
(m_signalNames[i] + ":").c_str(),
table.emplace(desc.m_channel),
desc.m_stream
);
}
config += tmp;
}

//Parameters
snprintf(tmp, sizeof(tmp), " parameters: \n");
config += tmp;
for(auto it : m_parameters)
{
switch(it.second.GetType())
{
case FilterParameter::TYPE_FLOAT:
case FilterParameter::TYPE_INT:
case FilterParameter::TYPE_BOOL:
snprintf(
tmp,
sizeof(tmp),
" %-20s %s\n", (it.first+":").c_str(), it.second.ToString().c_str());
break;

case FilterParameter::TYPE_FILENAME:
case FilterParameter::TYPE_FILENAMES:
default:
snprintf(
tmp,
sizeof(tmp),
" %-20s \"%s\"\n", (it.first+":").c_str(), it.second.ToString().c_str());
break;
}

config += tmp;
}

return config;
}

2 changes: 1 addition & 1 deletion scopehal/Filter.h
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ class Filter : public OscilloscopeChannel
/**
@brief Serialize this decoder's configuration to a string
*/
virtual std::string SerializeConfiguration(IDTable& table);
virtual std::string SerializeConfiguration(IDTable& table, size_t indent = 8);

/**
@brief Load configuration from a save file
63 changes: 63 additions & 0 deletions scopehal/FlowGraphNode.cpp
Original file line number Diff line number Diff line change
@@ -206,3 +206,66 @@ string FlowGraphNode::GetInputDisplayName(size_t i)
else
return in.m_channel->GetDisplayName();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

string FlowGraphNode::SerializeConfiguration(IDTable& table, size_t indent)
{
string sindent = "";
for(size_t i=0; i<indent; i++)
sindent += ' ';

//Basic header
char tmp[1024];
snprintf(tmp, sizeof(tmp), "id: %d\n", table.emplace(this));
string config = sindent + tmp;

//Inputs
config += sindent + "inputs:\n";
for(size_t i=0; i<m_inputs.size(); i++)
{
auto desc = m_inputs[i];
if(desc.m_channel == NULL)
snprintf(tmp, sizeof(tmp), " %-20s 0\n", (m_signalNames[i] + ":").c_str());
else
{
snprintf(tmp, sizeof(tmp), " %-20s %d/%zu\n",
(m_signalNames[i] + ":").c_str(),
table.emplace(desc.m_channel),
desc.m_stream
);
}
config += sindent + tmp;
}

//Parameters
config += sindent + "parameters:\n";
for(auto it : m_parameters)
{
switch(it.second.GetType())
{
case FilterParameter::TYPE_FLOAT:
case FilterParameter::TYPE_INT:
case FilterParameter::TYPE_BOOL:
snprintf(
tmp,
sizeof(tmp),
" %-20s %s\n", (it.first+":").c_str(), it.second.ToString().c_str());
break;

case FilterParameter::TYPE_FILENAME:
case FilterParameter::TYPE_FILENAMES:
default:
snprintf(
tmp,
sizeof(tmp),
" %-20s \"%s\"\n", (it.first+":").c_str(), it.second.ToString().c_str());
break;
}

config += sindent + tmp;
}

return config;
}
7 changes: 7 additions & 0 deletions scopehal/FlowGraphNode.h
Original file line number Diff line number Diff line change
@@ -116,6 +116,13 @@ class FlowGraphNode
ParameterMapType::iterator GetParamEnd()
{ return m_parameters.end(); }

/**
@brief Serializes this trigger's configuration to a YAML string.
@return YAML block with this trigger's configuration
*/
virtual std::string SerializeConfiguration(IDTable& table, size_t indent = 8);

//Input handling helpers
protected:

6 changes: 4 additions & 2 deletions scopehal/Oscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -246,8 +246,6 @@ string Oscilloscope::SerializeConfiguration(IDTable& table)
snprintf(tmp, sizeof(tmp), " interleave: %d\n", IsInterleaving());
config += tmp;

//TODO: triggers

//Save channels
config += " channels:\n";
for(size_t i=0; i<GetChannelCount(); i++)
@@ -337,6 +335,10 @@ string Oscilloscope::SerializeConfiguration(IDTable& table)
}
}

//Save trigger
auto trig = GetTrigger();
config += trig->SerializeConfiguration(table);

return config;
}

11 changes: 11 additions & 0 deletions scopehal/Trigger.cpp
Original file line number Diff line number Diff line change
@@ -70,3 +70,14 @@ Trigger* Trigger::CreateTrigger(string name, Oscilloscope* scope)
LogError("Invalid trigger name: %s\n", name.c_str());
return NULL;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

string Trigger::SerializeConfiguration(IDTable& table, size_t /*indent*/)
{
string config = " trigger:\n";
config += FlowGraphNode::SerializeConfiguration(table, 12);
config += string(" type: ") + GetTriggerDisplayName() + "\n";
return config;
}
7 changes: 7 additions & 0 deletions scopehal/Trigger.h
Original file line number Diff line number Diff line change
@@ -79,6 +79,13 @@ class Trigger : public FlowGraphNode
static void EnumTriggers(std::vector<std::string>& names);
static Trigger* CreateTrigger(std::string name, Oscilloscope* scope);

/**
@brief Serializes this trigger's configuration to a YAML string.
@return YAML block with this trigger's configuration
*/
virtual std::string SerializeConfiguration(IDTable& table, size_t indent = 8);

protected:
//Class enumeration
typedef std::map< std::string, CreateProcType > CreateMapType;