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: 3bedf89eccc5
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: e480351eeb62
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Sep 18, 2020

  1. Copy the full SHA
    d7e1d71 View commit details
  2. Copy the full SHA
    e480351 View commit details
56 changes: 54 additions & 2 deletions src/glscopeclient/ProtocolAnalyzerWindow.cpp
Original file line number Diff line number Diff line change
@@ -441,6 +441,8 @@ ProtocolAnalyzerWindow::ProtocolAnalyzerWindow(
m_fileMenuItem.set_submenu(m_fileMenu);
m_fileMenu.append(m_fileExportMenuItem);
m_fileExportMenuItem.set_label("Export...");
m_fileExportMenuItem.signal_activate().connect(sigc::mem_fun(
*this, &ProtocolAnalyzerWindow::OnFileExport));

get_vbox()->pack_start(m_filterRow, Gtk::PACK_SHRINK);
m_filterRow.pack_start(m_filterBox, Gtk::PACK_EXPAND_WIDGET);
@@ -592,8 +594,8 @@ void ProtocolAnalyzerWindow::FillOutRow(
snprintf(t, sizeof(t), "%02x ", b);
sdata += t;

//Truncate really long packets to keep UI responsive
if(sdata.length() > 1024)
//Truncate really long packets to keep UI from going nuts
if(sdata.length() > 2048)
break;
}
row[m_columns.m_data] = sdata;
@@ -721,3 +723,53 @@ void ProtocolAnalyzerWindow::OnFilterChanged()
m_filterApplyButton.set_sensitive(false);
}
}

void ProtocolAnalyzerWindow::OnFileExport()
{
//Prompt for the file
Gtk::FileChooserDialog dlg(*this, "Export CSV", Gtk::FILE_CHOOSER_ACTION_SAVE);
auto filter = Gtk::FileFilter::create();
filter->add_pattern("*.csv");
filter->set_name("CSV files (*.csv)");
dlg.add_filter(filter);
dlg.add_button("Save", Gtk::RESPONSE_OK);
dlg.add_button("Cancel", Gtk::RESPONSE_CANCEL);
dlg.set_do_overwrite_confirmation();
auto response = dlg.run();
if(response != Gtk::RESPONSE_OK)
return;

//Write initial headers
auto fname = dlg.get_filename();
FILE* fp = fopen(fname.c_str(), "w");
if(!fp)
{
string msg = string("Output file") + fname + " cannot be opened";
Gtk::MessageDialog errdlg(msg, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
errdlg.set_title("Cannot export protocol data\n");
errdlg.run();
return;
}
auto headers = m_decoder->GetHeaders();
fprintf(fp,"Time,");
for(auto h : headers)
fprintf(fp, "%s,", h.c_str());
fprintf(fp, "Data\n");

//Write packet data
auto children = m_internalmodel->children();
for(auto row : children)
{
//TODO: output individual sub-rows for child nodes?
//For now, just output top level rows
fprintf(fp, "%s,", static_cast<Glib::ustring>(row[m_columns.m_timestamp]).c_str());

for(size_t i=0; i<headers.size(); i++)
fprintf(fp, "%s,", static_cast<Glib::ustring>(row[m_columns.m_headers[i]]).c_str());

fprintf(fp, "%s\n", static_cast<Glib::ustring>(row[m_columns.m_data]).c_str());
}

//Done
fclose(fp);
}
1 change: 1 addition & 0 deletions src/glscopeclient/ProtocolAnalyzerWindow.h
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ class ProtocolAnalyzerWindow : public Gtk::Dialog

void OnApplyFilter();
void OnFilterChanged();
void OnFileExport();

Gtk::MenuBar m_menu;
Gtk::MenuItem m_fileMenuItem;
9 changes: 0 additions & 9 deletions src/glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -84,11 +84,6 @@ WaveformArea::WaveformArea(const WaveformArea* clone)

void WaveformArea::SharedCtorInit()
{
//performance counters
m_frameTime = 0;
m_frameCount = 0;
m_lastFrameStart = -1;

m_updatingContextMenu = false;
m_selectedChannel = m_channel;
m_dragState = DRAG_NONE;
@@ -132,10 +127,6 @@ void WaveformArea::SharedCtorInit()

WaveformArea::~WaveformArea()
{
double tavg = m_frameTime / m_frameCount;
LogDebug("Average frame interval for %s: %.3f ms (%.2f FPS, %zu frames)\n",
m_channel.m_channel->m_displayname.c_str(), tavg*1000, 1/tavg, m_frameCount);

m_channel.m_channel->Release();

for(auto d : m_overlays)
7 changes: 0 additions & 7 deletions src/glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -436,13 +436,6 @@ class WaveformArea : public Gtk::GLArea
std::vector<StreamDescriptor> m_overlays; //List of protocol decoders drawn on top of the signal
std::map<StreamDescriptor, int> m_overlayPositions;

double m_lastFrameStart;
double m_frameTime;
long m_frameCount;

double m_prepareTime;
double m_indexTime;

float m_pixelsPerVolt;
float m_padding;
float m_plotRight;
10 changes: 0 additions & 10 deletions src/glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -320,16 +320,6 @@ bool WaveformArea::on_render(const Glib::RefPtr<Gdk::GLContext>& /*context*/)

LogIndenter li;

double start = GetTime();
double dt = start - m_lastFrameStart;
if(m_lastFrameStart > 0)
{
//LogDebug("Inter-frame time: %.3f ms (%.2f FPS)\n", dt*1000, 1/dt);
m_frameTime += dt;
m_frameCount ++;
}
m_lastFrameStart = start;

//Update geometry if needed
if(m_geometryDirty || m_positionDirty)
{