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: a7b548721c70
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: 917c9569ad0f
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Sep 5, 2020

  1. Copy the full SHA
    917c956 View commit details
Showing with 104 additions and 58 deletions.
  1. +1 −1 lib
  2. +101 −57 src/glscopeclient/ProtocolAnalyzerWindow.cpp
  3. +2 −0 src/glscopeclient/ProtocolAnalyzerWindow.h
2 changes: 1 addition & 1 deletion lib
Submodule lib updated from 8cb296 to 6b2b87
158 changes: 101 additions & 57 deletions src/glscopeclient/ProtocolAnalyzerWindow.cpp
Original file line number Diff line number Diff line change
@@ -127,71 +127,46 @@ void ProtocolAnalyzerWindow::OnWaveformDataReady()

m_updating = true;

for(auto p : packets)
Packet* first_packet_in_group = NULL;
Gtk::TreeModel::iterator last_top_row = m_model->children().end();

auto npackets = packets.size();
for(size_t i=0; i<npackets; i++)
{
//Need a bit of math in case the capture is >1 second long
time_t capstart = data->m_startTimestamp;
int64_t ps = data->m_startPicoseconds + p->m_offset;
const int64_t seconds_per_ps = 1000ll * 1000ll * 1000ll * 1000ll;
if(ps > seconds_per_ps)
{
capstart += (ps / seconds_per_ps);
ps %= seconds_per_ps;
}
auto p = packets[i];

//Format timestamp
char tmp[128];
strftime(tmp, sizeof(tmp), "%H:%M:%S.", localtime(&capstart));
string stime = tmp;
snprintf(tmp, sizeof(tmp), "%010zu", ps / 100); //round to nearest 100ps for display
stime += tmp;

//Create the row
auto row = *m_model->append();
row[m_columns.m_timestamp] = stime;
row[m_columns.m_capturekey] = TimePoint(data->m_startTimestamp, data->m_startPicoseconds);
row[m_columns.m_offset] = p->m_offset;

//Just copy headers without any processing
for(size_t i=0; i<headers.size(); i++)
row[m_columns.m_headers[i]] = p->m_headers[headers[i]];

//Convert data to hex
string sdata;
for(auto b : p->m_data)
//See if we should start a new merge group
if( (first_packet_in_group == NULL) &&
(i+1 < npackets) &&
m_decoder->CanMerge(p, packets[i+1]) )
{
char t[4];
snprintf(t, sizeof(t), "%02x ", b);
sdata += t;
//Create the summary packet
first_packet_in_group = p;
auto parent_packet = m_decoder->CreateMergedHeader(p);

//Add it
last_top_row = *m_model->append();
FillOutRow(*last_top_row, parent_packet, data, headers);
delete parent_packet;
}
row[m_columns.m_data] = sdata;

//Add the image for video packets
auto vp = dynamic_cast<VideoScanlinePacket*>(p);
if(vp != NULL)
//End a merge group
else if( (first_packet_in_group != NULL) && !m_decoder->CanMerge(first_packet_in_group, p) )
first_packet_in_group = NULL;

//Create a row for the new packet. This might be top level or under a merge group
Gtk::TreeModel::iterator row;
if(first_packet_in_group != NULL)
row = m_model->append(last_top_row->children());
else
{
size_t rowsize = p->m_data.size();
size_t width = rowsize / 3;
size_t height = 24;

Glib::RefPtr<Gdk::Pixbuf> image = Gdk::Pixbuf::create(
Gdk::COLORSPACE_RGB,
false,
8,
width,
height);

//Make a 2D image
uint8_t* pixels = image->get_pixels();
size_t bcount = rowsize * height;
for(size_t y=0; y<height; y++)
memcpy(pixels + y*rowsize, &p->m_data[0], rowsize);

row[m_columns.m_image] = image;
row = m_model->append();
last_top_row = row;
}

//Select the newly added row
m_tree.get_selection()->select(row);
//Populate the row
FillOutRow(*row, p, data, headers);
m_tree.get_selection()->select(*row);
}

//auto scroll to bottom
@@ -201,6 +176,72 @@ void ProtocolAnalyzerWindow::OnWaveformDataReady()
m_updating = false;
}

void ProtocolAnalyzerWindow::FillOutRow(
const Gtk::TreeRow& row,
Packet* p,
WaveformBase* data,
vector<string>& headers)
{
//Need a bit of math in case the capture is >1 second long
time_t capstart = data->m_startTimestamp;
int64_t ps = data->m_startPicoseconds + p->m_offset;
const int64_t seconds_per_ps = 1000ll * 1000ll * 1000ll * 1000ll;
if(ps > seconds_per_ps)
{
capstart += (ps / seconds_per_ps);
ps %= seconds_per_ps;
}

//Format timestamp
char tmp[128];
strftime(tmp, sizeof(tmp), "%H:%M:%S.", localtime(&capstart));
string stime = tmp;
snprintf(tmp, sizeof(tmp), "%010zu", ps / 100); //round to nearest 100ps for display
stime += tmp;

//Create the row
row[m_columns.m_timestamp] = stime;
row[m_columns.m_capturekey] = TimePoint(data->m_startTimestamp, data->m_startPicoseconds);
row[m_columns.m_offset] = p->m_offset;

//Just copy headers without any processing
for(size_t i=0; i<headers.size(); i++)
row[m_columns.m_headers[i]] = p->m_headers[headers[i]];

//Convert data to hex
string sdata;
for(auto b : p->m_data)
{
char t[4];
snprintf(t, sizeof(t), "%02x ", b);
sdata += t;
}
row[m_columns.m_data] = sdata;

//Add the image for video packets
auto vp = dynamic_cast<VideoScanlinePacket*>(p);
if(vp != NULL)
{
size_t rowsize = p->m_data.size();
size_t width = rowsize / 3;
size_t height = 24;

Glib::RefPtr<Gdk::Pixbuf> image = Gdk::Pixbuf::create(
Gdk::COLORSPACE_RGB,
false,
8,
width,
height);

//Make a 2D image
uint8_t* pixels = image->get_pixels();
for(size_t y=0; y<height; y++)
memcpy(pixels + y*rowsize, &p->m_data[0], rowsize);

row[m_columns.m_image] = image;
}
}

void ProtocolAnalyzerWindow::OnSelectionChanged()
{
//If we're updating with a new waveform we're already on the newest waveform.
@@ -221,6 +262,9 @@ void ProtocolAnalyzerWindow::OnSelectionChanged()
m_area->m_group->m_frame.queue_draw();
}

/**
@brief Remove history before a certain point
*/
void ProtocolAnalyzerWindow::RemoveHistory(TimePoint timestamp)
{
//This always happens from the start of time, so just remove from the beginning of our list
2 changes: 2 additions & 0 deletions src/glscopeclient/ProtocolAnalyzerWindow.h
Original file line number Diff line number Diff line change
@@ -78,6 +78,8 @@ class ProtocolAnalyzerWindow : public Gtk::Dialog

void OnSelectionChanged();

void FillOutRow(const Gtk::TreeRow& row, Packet* p, WaveformBase* data, std::vector<std::string>& headers);

bool m_updating;
};