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

Commits on Oct 28, 2020

  1. EyePattern: made ReallocateWaveform/RecalculateUIWidth public methods…

    … so they can be called from glscopeclient
    azonenberg committed Oct 28, 2020
    Copy the full SHA
    ee94170 View commit details
Showing with 63 additions and 26 deletions.
  1. +60 −26 scopeprotocols/EyePattern.cpp
  2. +3 −0 scopeprotocols/EyePattern.h
86 changes: 60 additions & 26 deletions scopeprotocols/EyePattern.cpp
Original file line number Diff line number Diff line change
@@ -382,9 +382,8 @@ void EyePattern::Refresh()
//Initialize the capture
//TODO: timestamps? do we need those?
if(cap == NULL)
cap = new EyeWaveform(m_width, m_height, center);
cap = ReallocateWaveform();
cap->m_saturationLevel = m_parameters[m_saturationName].GetFloatVal();
cap->m_timescale = 1;
int64_t* data = cap->GetAccumData();

//Find all toggles in the clock
@@ -406,29 +405,7 @@ void EyePattern::Refresh()

//Calculate the nominal UI width
if(cap->m_uiWidth < FLT_EPSILON)
{
//Find width of each UI
vector<int64_t> ui_widths;
for(size_t i=0; i<clock_edges.size()-1; i++)
ui_widths.push_back(clock_edges[i+1] - clock_edges[i]);

//Need to average at least ten UIs to get meaningful data
size_t nuis = ui_widths.size();
if(nuis > 10)
{
//Sort, discard the top and bottom 10%, and average the rest to calculate nominal width
sort(ui_widths.begin(), ui_widths.end());
size_t navg = 0;
int64_t total = 0;
for(size_t i = nuis/10; i <= nuis*9/10; i++)
{
total += ui_widths[i];
navg ++;
}

cap->m_uiWidth = (1.0 * total) / navg;
}
}
RecalculateUIWidth();

//Process the eye
size_t cend = clock_edges.size();
@@ -517,7 +494,6 @@ void EyePattern::Refresh()
//Count total number of UIs we've integrated
cap->IntegrateUIs(clock_edges.size());
cap->Normalize();
SetData(cap, 0);

//If we have an eye mask, prepare it for processing
if(m_mask.GetFileName() != "")
@@ -529,6 +505,64 @@ void EyePattern::Refresh()
LogTrace("Refresh took %.3f ms (avg %.3f)\n", dt * 1000, (total_time * 1000) / total_frames);
}

EyeWaveform* EyePattern::ReallocateWaveform()
{
auto cap = new EyeWaveform(m_width, m_height, m_parameters[m_centerName].GetFloatVal());
cap->m_timescale = 1;
SetData(cap, 0);
return cap;
}

void EyePattern::RecalculateUIWidth()
{
auto cap = dynamic_cast<EyeWaveform*>(GetData(0));
if(!cap)
cap = ReallocateWaveform();

auto clock = GetDigitalInputWaveform(1);
if(!clock)
return;

//Find all toggles in the clock
vector<int64_t> clock_edges;
switch(m_parameters[m_polarityName].GetIntVal())
{
case CLOCK_RISING:
FindRisingEdges(clock, clock_edges);
break;

case CLOCK_FALLING:
FindFallingEdges(clock, clock_edges);
break;

case CLOCK_BOTH:
FindZeroCrossings(clock, clock_edges);
break;
}

//Find width of each UI
vector<int64_t> ui_widths;
for(size_t i=0; i<clock_edges.size()-1; i++)
ui_widths.push_back(clock_edges[i+1] - clock_edges[i]);

//Need to average at least ten UIs to get meaningful data
size_t nuis = ui_widths.size();
if(nuis > 10)
{
//Sort, discard the top and bottom 10%, and average the rest to calculate nominal width
sort(ui_widths.begin(), ui_widths.end());
size_t navg = 0;
int64_t total = 0;
for(size_t i = nuis/10; i <= nuis*9/10; i++)
{
total += ui_widths[i];
navg ++;
}

cap->m_uiWidth = (1.0 * total) / navg;
}
}

/**
@brief Checks the current capture against the eye mask
*/
3 changes: 3 additions & 0 deletions scopeprotocols/EyePattern.h
Original file line number Diff line number Diff line change
@@ -117,6 +117,9 @@ class EyePattern : public Filter

virtual void ClearSweeps();

void RecalculateUIWidth();
EyeWaveform* ReallocateWaveform();

void SetWidth(size_t width)
{
m_width = width;