mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-29 19:28:47 -05:00
New scope: use global number of samples to decide the end of a trace. Fixed triggerPoint calculation
This commit is contained in:
parent
a64fb01119
commit
758bc9a5dd
@ -38,11 +38,10 @@ ScopeVisNG::ScopeVisNG(GLScopeNG* glScope) :
|
|||||||
m_currentTriggerIndex(0),
|
m_currentTriggerIndex(0),
|
||||||
m_triggerState(TriggerUntriggered),
|
m_triggerState(TriggerUntriggered),
|
||||||
m_traceSize(m_traceChunkSize),
|
m_traceSize(m_traceChunkSize),
|
||||||
m_memTraceSize(0),
|
m_nbSamples(0),
|
||||||
m_traceStart(true),
|
m_traceStart(true),
|
||||||
m_traceFill(0),
|
m_traceFill(0),
|
||||||
m_zTraceIndex(-1),
|
m_zTraceIndex(-1),
|
||||||
m_traceCompleteCount(0),
|
|
||||||
m_timeOfsProMill(0),
|
m_timeOfsProMill(0),
|
||||||
m_sampleRate(0),
|
m_sampleRate(0),
|
||||||
m_traceDiscreteMemory(10),
|
m_traceDiscreteMemory(10),
|
||||||
@ -143,23 +142,32 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
|
|||||||
}
|
}
|
||||||
|
|
||||||
SampleVector::const_iterator begin(cbegin);
|
SampleVector::const_iterator begin(cbegin);
|
||||||
|
int triggerPoint;
|
||||||
|
|
||||||
while (begin < end)
|
while (begin < end)
|
||||||
{
|
{
|
||||||
if (begin + m_traceSize > end)
|
if (begin + m_traceSize > end)
|
||||||
{
|
{
|
||||||
processTrace(begin, end);
|
triggerPoint = -1;
|
||||||
|
processTrace(begin, end, triggerPoint);
|
||||||
|
if (triggerPoint >= 0) {
|
||||||
|
m_triggerPoint = begin + triggerPoint;
|
||||||
|
}
|
||||||
begin = end;
|
begin = end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
processTrace(begin, begin + m_traceSize);
|
triggerPoint = -1;
|
||||||
|
processTrace(begin, begin + m_traceSize, triggerPoint);
|
||||||
|
if (triggerPoint >= 0) {
|
||||||
|
m_triggerPoint = begin + triggerPoint;
|
||||||
|
}
|
||||||
begin += m_traceSize;
|
begin += m_traceSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end)
|
void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, int& triggerPoint)
|
||||||
{
|
{
|
||||||
SampleVector::const_iterator begin(cbegin);
|
SampleVector::const_iterator begin(cbegin);
|
||||||
|
|
||||||
@ -176,8 +184,12 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
|
|||||||
|
|
||||||
if ((m_freeRun) || (m_triggerConditions.size() == 0)) // immediate re-trigger
|
if ((m_freeRun) || (m_triggerConditions.size() == 0)) // immediate re-trigger
|
||||||
{
|
{
|
||||||
m_traceStart = true; // start trace processing
|
if (m_triggerState == TriggerUntriggered)
|
||||||
m_triggerState = TriggerTriggered;
|
{
|
||||||
|
m_traceStart = true; // start trace processing
|
||||||
|
m_nbSamples = m_traceSize + m_maxTraceDelay;
|
||||||
|
m_triggerState = TriggerTriggered;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -191,9 +203,10 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
|
|||||||
if (m_triggerComparator.triggered(*begin, triggerCondition))
|
if (m_triggerComparator.triggered(*begin, triggerCondition))
|
||||||
{
|
{
|
||||||
m_traceStart = true; // start trace processing
|
m_traceStart = true; // start trace processing
|
||||||
m_triggerPoint = begin;
|
m_nbSamples = m_traceSize + m_maxTraceDelay;
|
||||||
m_triggerComparator.reset();
|
m_triggerComparator.reset();
|
||||||
m_triggerState = TriggerTriggered;
|
m_triggerState = TriggerTriggered;
|
||||||
|
triggerPoint = begin - cbegin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,6 +220,7 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
|
|||||||
{
|
{
|
||||||
int remainder = -1;
|
int remainder = -1;
|
||||||
int count = end - begin; // number of samples in traceback buffer past the current point
|
int count = end - begin; // number of samples in traceback buffer past the current point
|
||||||
|
int mpoint = begin -cbegin;
|
||||||
SampleVector::iterator mend = m_traceDiscreteMemory.current().current();
|
SampleVector::iterator mend = m_traceDiscreteMemory.current().current();
|
||||||
SampleVector::iterator mbegin = mend - count;
|
SampleVector::iterator mbegin = mend - count;
|
||||||
|
|
||||||
@ -236,16 +250,24 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
|
|||||||
|
|
||||||
if (remainder >= 0) // finished
|
if (remainder >= 0) // finished
|
||||||
{
|
{
|
||||||
|
mpoint += (mend - mbegin) - remainder;
|
||||||
mbegin = mend - remainder;
|
mbegin = mend - remainder;
|
||||||
m_traceDiscreteMemory.current().m_endPoint = mbegin;
|
m_traceDiscreteMemory.current().m_endPoint = mbegin;
|
||||||
m_traceDiscreteMemory.store(); // next memory trace
|
m_traceDiscreteMemory.store(); // next memory trace
|
||||||
m_traceCompleteCount = 0;
|
|
||||||
m_triggerState = TriggerUntriggered;
|
m_triggerState = TriggerUntriggered;
|
||||||
|
|
||||||
// process remainder recursively
|
// process remainder recursively
|
||||||
if (remainder != 0)
|
if (remainder != 0)
|
||||||
{
|
{
|
||||||
processTrace(mbegin, mend);
|
int mTriggerPoint = -1;
|
||||||
|
|
||||||
|
processTrace(mbegin, mend, mTriggerPoint);
|
||||||
|
|
||||||
|
if (mTriggerPoint >= 0) {
|
||||||
|
triggerPoint = mpoint + mTriggerPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
//qDebug("ScopeVisNG::processTrace: process remainder recursively (%d %d)", mpoint, mTriggerPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +311,7 @@ int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const
|
|||||||
SampleVector::const_iterator begin(cbegin);
|
SampleVector::const_iterator begin(cbegin);
|
||||||
int shift = (m_timeOfsProMill / 1000.0) * m_traceSize;
|
int shift = (m_timeOfsProMill / 1000.0) * m_traceSize;
|
||||||
|
|
||||||
while (begin < end)
|
while ((begin < end) && (m_nbSamples > 0))
|
||||||
{
|
{
|
||||||
std::vector<TraceControl>::iterator itCtl = m_traces.m_tracesControl.begin();
|
std::vector<TraceControl>::iterator itCtl = m_traces.m_tracesControl.begin();
|
||||||
std::vector<TraceData>::iterator itData = m_traces.m_tracesData.begin();
|
std::vector<TraceData>::iterator itData = m_traces.m_tracesData.begin();
|
||||||
@ -297,7 +319,7 @@ int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const
|
|||||||
|
|
||||||
for (; itCtl != m_traces.m_tracesControl.end(); ++itCtl, ++itData, ++itTrace)
|
for (; itCtl != m_traces.m_tracesControl.end(); ++itCtl, ++itData, ++itTrace)
|
||||||
{
|
{
|
||||||
if (traceBack && ((end - begin) > itData->m_traceDelay)) {
|
if (traceBack && ((end - begin) > itData->m_traceDelay)) { // before start of trace
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,26 +348,15 @@ int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const
|
|||||||
(*itTrace)[2*(itCtl->m_traceCount[m_traces.currentBufferIndex()]) + 1] = v; // display y
|
(*itTrace)[2*(itCtl->m_traceCount[m_traces.currentBufferIndex()]) + 1] = v; // display y
|
||||||
itCtl->m_traceCount[m_traces.currentBufferIndex()]++;
|
itCtl->m_traceCount[m_traces.currentBufferIndex()]++;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
itCtl->m_traceCount[m_traces.currentBufferIndex()]++;
|
|
||||||
|
|
||||||
if (m_traceCompleteCount < m_traces.size())
|
|
||||||
{
|
|
||||||
m_traceCompleteCount++;
|
|
||||||
}
|
|
||||||
else // finished
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++begin;
|
++begin;
|
||||||
|
m_nbSamples--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_traceCompleteCount == m_traces.size()) // finished
|
if (m_nbSamples == 0) // finished
|
||||||
{
|
{
|
||||||
|
//sqDebug("ScopeVisNG::processTraces: m_traceCount: %d", m_traces.m_tracesControl.begin()->m_traceCount[m_traces.currentBufferIndex()]);
|
||||||
m_glScope->newTraces(&m_traces.m_traces[m_traces.currentBufferIndex()]);
|
m_glScope->newTraces(&m_traces.m_traces[m_traces.currentBufferIndex()]);
|
||||||
m_traces.switchBuffer();
|
m_traces.switchBuffer();
|
||||||
return end - begin; // return remainder count
|
return end - begin; // return remainder count
|
||||||
|
@ -757,12 +757,11 @@ private:
|
|||||||
TriggerState m_triggerState; //!< Current trigger state
|
TriggerState m_triggerState; //!< Current trigger state
|
||||||
Traces m_traces; //!< Displayable traces
|
Traces m_traces; //!< Displayable traces
|
||||||
int m_traceSize; //!< Size of traces in number of samples
|
int m_traceSize; //!< Size of traces in number of samples
|
||||||
int m_memTraceSize; //!< Trace size in memory in number of samples up to trace size
|
int m_nbSamples; //!< Number of samples yet to process in one complex trace
|
||||||
int m_timeOfsProMill; //!< Start trace shift in 1/1000 trace size
|
int m_timeOfsProMill; //!< Start trace shift in 1/1000 trace size
|
||||||
bool m_traceStart; //!< Trace is at start point
|
bool m_traceStart; //!< Trace is at start point
|
||||||
int m_traceFill; //!< Count of samples accumulated into trace
|
int m_traceFill; //!< Count of samples accumulated into trace
|
||||||
int m_zTraceIndex; //!< Index of the trace used for Z input (luminance or false colors)
|
int m_zTraceIndex; //!< Index of the trace used for Z input (luminance or false colors)
|
||||||
int m_traceCompleteCount; //!< Count of completed traces
|
|
||||||
SampleVector::const_iterator m_triggerPoint; //!< Trigger start location in the samples vector
|
SampleVector::const_iterator m_triggerPoint; //!< Trigger start location in the samples vector
|
||||||
int m_sampleRate;
|
int m_sampleRate;
|
||||||
TraceBackDiscreteMemory m_traceDiscreteMemory; //!< Complex trace memory for triggered states TODO: vectorize when more than on input is allowed
|
TraceBackDiscreteMemory m_traceDiscreteMemory; //!< Complex trace memory for triggered states TODO: vectorize when more than on input is allowed
|
||||||
@ -780,7 +779,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Process a sample trace which length is at most the trace length (m_traceSize)
|
* Process a sample trace which length is at most the trace length (m_traceSize)
|
||||||
*/
|
*/
|
||||||
void processTrace(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
|
void processTrace(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, int& triggerPoint);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process traces from complex trace memory buffer.
|
* Process traces from complex trace memory buffer.
|
||||||
|
Loading…
Reference in New Issue
Block a user