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: 828cc897f92c
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: 1e684817ef7f
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Mar 5, 2020

  1. Copy the full SHA
    1e68481 View commit details
Showing with 21 additions and 98 deletions.
  1. +20 −98 glscopeclient/OscilloscopeWindow.cpp
  2. +1 −0 glscopeclient/OscilloscopeWindow.h
118 changes: 20 additions & 98 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -517,119 +517,39 @@ string OscilloscopeWindow::SerializeConfiguration(bool saveLayout)
//Save instrument config regardless, since data etc needs it
config += SerializeInstrumentConfiguration(idmap, nextID);

//Decodes depend on scope channels, but need to happen before UI elements that use them
if(!m_decoders.empty())
config += SerializeDecodeConfiguration(idmap, nextID);

//UI config
if(saveLayout)
config += SerializeUIConfiguration(idmap, nextID);

return config;
}

/**
@brief Serialize the configuration for all oscilloscopes
*/
string OscilloscopeWindow::SerializeInstrumentConfiguration(std::map<void*, int>& idmap, int& nextID)
{
char tmp[1024];
string config = "instruments: @\n";

for(auto scope : m_scopes)
{
//Name it
int id = nextID ++;
idmap[scope] = id;

//Save basic scope info
snprintf(tmp, sizeof(tmp), " : %%\n");
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;
snprintf(tmp, sizeof(tmp), " nick: \"%s\"\n", scope->m_nickname.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " name: \"%s\"\n", scope->GetName().c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " vendor: \"%s\"\n", scope->GetVendor().c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " serial: \"%s\"\n", scope->GetSerial().c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " path: \"%s\"\n", "connection_string_not_yet_implemented");
config += tmp;
config += scope->SerializeConfiguration(idmap, nextID);

//Save channels
config += " channels: @\n";
for(size_t i=0; i<scope->GetChannelCount(); i++)
{
auto chan = scope->GetChannel(i);
if(!chan->IsPhysicalChannel())
continue; //skip any kind of math functions etc

id = nextID ++;
idmap[chan] = id;

//Basic channel info
snprintf(tmp, sizeof(tmp), " : %%\n");
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;
snprintf(tmp, sizeof(tmp), " index: %zu\n", i);
config += tmp;
snprintf(tmp, sizeof(tmp), " color: \"%s\"\n", chan->m_displaycolor.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " nick: \"%s\"\n", chan->m_displayname.c_str());
config += tmp;
snprintf(tmp, sizeof(tmp), " name: \"%s\"\n", chan->GetHwname().c_str());
config += tmp;
switch(chan->GetType())
{
case OscilloscopeChannel::CHANNEL_TYPE_ANALOG:
config += " type: analog\n";
break;
case OscilloscopeChannel::CHANNEL_TYPE_DIGITAL:
config += " type: digital\n";
break;
case OscilloscopeChannel::CHANNEL_TYPE_TRIGGER:
config += " type: trigger\n";
break;

//should never get complex channels on a scope
default:
break;
}
return config;
}

//Current channel configuration
if(chan->IsEnabled())
config += " enabled: 1\n";
else
config += " enabled: 0\n";
switch(chan->GetCoupling())
{
case OscilloscopeChannel::COUPLE_DC_1M:
config += " coupling: dc_1M\n";
break;
case OscilloscopeChannel::COUPLE_AC_1M:
config += " coupling: ac_1M\n";
break;
case OscilloscopeChannel::COUPLE_DC_50:
config += " coupling: dc_50\n";
break;
case OscilloscopeChannel::COUPLE_GND:
config += " coupling: gnd\n";
break;

//should never get synthetic coupling on a scope channel
default:
break;
}
/**
@brief Serialize the configuration for all protocol decoders
*/
string OscilloscopeWindow::SerializeDecodeConfiguration(std::map<void*, int>& idmap, int& nextID)
{
string config = "decodes: %\n";

if(chan->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG)
{
snprintf(tmp, sizeof(tmp), " attenuation: %f\n", chan->GetAttenuation());
config += tmp;
snprintf(tmp, sizeof(tmp), " bwlimit: %d\n", chan->GetBandwidthLimit());
config += tmp;
snprintf(tmp, sizeof(tmp), " vrange: %f\n", chan->GetVoltageRange());
config += tmp;
snprintf(tmp, sizeof(tmp), " offset: %f\n", chan->GetOffset());
config += tmp;
}
}
}
for(auto d : m_decoders)
config += d->SerializeConfiguration(idmap, nextID);

return config;
}
@@ -656,6 +576,8 @@ string OscilloscopeWindow::SerializeUIConfiguration(std::map<void*, int>& idmap,
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;

//Channels
}

//Waveform groups
1 change: 1 addition & 0 deletions glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -212,6 +212,7 @@ class OscilloscopeWindow : public Gtk::Window

std::string SerializeConfiguration(bool saveLayout);
std::string SerializeInstrumentConfiguration(std::map<void*, int>& idmap, int& nextID);
std::string SerializeDecodeConfiguration(std::map<void*, int>& idmap, int& nextID);
std::string SerializeUIConfiguration(std::map<void*, int>& idmap, int& nextID);

//Performance counters