1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

New scope: added trigger delay, mutiple occurences and chained triggers features

This commit is contained in:
f4exb 2017-02-09 18:45:06 +01:00
parent c56f852a85
commit 1f37bcf3de

View File

@ -34,19 +34,19 @@ const Real ScopeVisNG::ProjectorMagDB::mult = (10.0f / log2f(10.0f));
ScopeVisNG::ScopeVisNG(GLScopeNG* glScope) : ScopeVisNG::ScopeVisNG(GLScopeNG* glScope) :
m_glScope(glScope), m_glScope(glScope),
m_preTriggerDelay(0), m_preTriggerDelay(0),
m_currentTriggerIndex(0), m_currentTriggerIndex(0),
m_triggerState(TriggerUntriggered), m_triggerState(TriggerUntriggered),
m_traceSize(m_traceChunkSize), m_traceSize(m_traceChunkSize),
m_nbSamples(0), m_nbSamples(0),
m_traceStart(true), m_traceStart(true),
m_traceFill(0), m_traceFill(0),
m_zTraceIndex(-1), m_zTraceIndex(-1),
m_timeOfsProMill(0), m_timeOfsProMill(0),
m_sampleRate(0), m_sampleRate(0),
m_traceDiscreteMemory(10), m_traceDiscreteMemory(10),
m_freeRun(true), m_freeRun(true),
m_maxTraceDelay(0) m_maxTraceDelay(0)
{ {
setObjectName("ScopeVisNG"); setObjectName("ScopeVisNG");
m_traceDiscreteMemory.resize(m_traceChunkSize); // arbitrary m_traceDiscreteMemory.resize(m_traceChunkSize); // arbitrary
@ -131,47 +131,47 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
m_triggerPoint = cbegin; m_triggerPoint = cbegin;
} }
if (m_triggerState == TriggerNewConfig) if (m_triggerState == TriggerNewConfig)
{ {
m_triggerState = TriggerUntriggered; m_triggerState = TriggerUntriggered;
return; return;
} }
if ((m_triggerConditions.size() > 0) && (m_triggerState == TriggerWait)) { if ((m_triggerConditions.size() > 0) && (m_triggerState == TriggerWait)) {
return; return;
} }
SampleVector::const_iterator begin(cbegin); SampleVector::const_iterator begin(cbegin);
int triggerPointToEnd; int triggerPointToEnd;
while (begin < end) while (begin < end)
{ {
if (begin + m_traceSize > end) if (begin + m_traceSize > end)
{ {
triggerPointToEnd = -1;
processTrace(begin, end, triggerPointToEnd);
if (triggerPointToEnd >= 0) {
m_triggerPoint = end - triggerPointToEnd;
}
begin = end;
}
else
{
triggerPointToEnd = -1; triggerPointToEnd = -1;
processTrace(begin, begin + m_traceSize, triggerPointToEnd); processTrace(begin, end, triggerPointToEnd);
if (triggerPointToEnd >= 0) {
m_triggerPoint = end - triggerPointToEnd;
}
begin = end;
}
else
{
triggerPointToEnd = -1;
processTrace(begin, begin + m_traceSize, triggerPointToEnd);
if (triggerPointToEnd >= 0) { if (triggerPointToEnd >= 0) {
m_triggerPoint = begin + m_traceSize -triggerPointToEnd; m_triggerPoint = begin + m_traceSize -triggerPointToEnd;
} }
begin += m_traceSize; begin += m_traceSize;
} }
} }
} }
void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, int& triggerPointToEnd) void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, int& triggerPointToEnd)
{ {
SampleVector::const_iterator begin(cbegin); SampleVector::const_iterator begin(cbegin);
// memory storage // memory storage
m_traceDiscreteMemory.current().write(cbegin, end); m_traceDiscreteMemory.current().write(cbegin, end);
@ -199,15 +199,60 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
while (begin < end) while (begin < end)
{ {
if (m_triggerState == TriggerDelay)
{
if (triggerCondition.m_triggerDelayCount > 0) // skip samples during delay period
{
triggerCondition.m_triggerDelayCount--;
++begin;
continue;
}
else // process trigger
{
if (nextTrigger()) // move to next trigger and keep going
{
m_triggerComparator.reset();
m_triggerState = TriggerUntriggered;
++begin;
continue;
}
else // this was the last trigger then start trace
{
m_traceStart = true; // start trace processing
m_nbSamples = m_traceSize + m_maxTraceDelay;
m_triggerComparator.reset();
m_triggerState = TriggerTriggered;
triggerPointToEnd = end - begin;
break;
}
}
}
// look for trigger // look for trigger
if (m_triggerComparator.triggered(*begin, triggerCondition)) if (m_triggerComparator.triggered(*begin, triggerCondition))
{ {
m_traceStart = true; // start trace processing if (triggerCondition.m_triggerData.m_triggerDelay > 0)
m_nbSamples = m_traceSize + m_maxTraceDelay; {
m_triggerComparator.reset(); triggerCondition.m_triggerDelayCount = triggerCondition.m_triggerData.m_triggerDelay; // initialize delayed samples counter
m_triggerState = TriggerTriggered; m_triggerState = TriggerDelay;
triggerPointToEnd = end - begin; ++begin;
break; continue;
}
if (nextTrigger()) // move to next trigger and keep going
{
m_triggerComparator.reset();
m_triggerState = TriggerUntriggered;
}
else // this was the last trigger then start trace
{
m_traceStart = true; // start trace processing
m_nbSamples = m_traceSize + m_maxTraceDelay;
m_triggerComparator.reset();
m_triggerState = TriggerTriggered;
triggerPointToEnd = end - begin;
break;
}
} }
++begin; ++begin;
@ -215,43 +260,43 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
} }
} }
// trace process // trace process
if (m_triggerState == TriggerTriggered) if (m_triggerState == TriggerTriggered)
{ {
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
SampleVector::iterator mend = m_traceDiscreteMemory.current().current(); SampleVector::iterator mend = m_traceDiscreteMemory.current().current();
SampleVector::iterator mbegin = mend - count; SampleVector::iterator mbegin = mend - count;
if (m_traceStart) if (m_traceStart)
{
// trace back
if (m_maxTraceDelay > 0)
{
processTraces(mbegin - m_preTriggerDelay - m_maxTraceDelay, mbegin - m_preTriggerDelay, true);
}
// pre-trigger
if (m_preTriggerDelay > 0)
{
remainder = processTraces(mbegin - m_preTriggerDelay, mbegin);
}
m_traceStart = false;
}
if (remainder < 0)
{ {
// live trace // trace back
if (m_maxTraceDelay > 0)
{
processTraces(mbegin - m_preTriggerDelay - m_maxTraceDelay, mbegin - m_preTriggerDelay, true);
}
// pre-trigger
if (m_preTriggerDelay > 0)
{
remainder = processTraces(mbegin - m_preTriggerDelay, mbegin);
}
m_traceStart = false;
}
if (remainder < 0)
{
// live trace
remainder = processTraces(mbegin, mend); remainder = processTraces(mbegin, mend);
} }
if (remainder >= 0) // finished if (remainder >= 0) // finished
{ {
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_triggerState = TriggerUntriggered; m_triggerState = TriggerUntriggered;
// process remainder recursively // process remainder recursively
@ -267,41 +312,38 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
//qDebug("ScopeVisNG::processTrace: process remainder recursively (%d %d)", mpoint, mTriggerPoint); //qDebug("ScopeVisNG::processTrace: process remainder recursively (%d %d)", mpoint, mTriggerPoint);
} }
} }
} }
} }
bool ScopeVisNG::nextTrigger() bool ScopeVisNG::nextTrigger()
{ {
TriggerCondition& triggerCondition = m_triggerConditions[m_currentTriggerIndex]; // current trigger condition TriggerCondition& triggerCondition = m_triggerConditions[m_currentTriggerIndex]; // current trigger condition
if (triggerCondition.m_triggerData.m_triggerRepeat > 0) if (triggerCondition.m_triggerData.m_triggerRepeat > 0)
{ {
if (triggerCondition.m_triggerCounter < triggerCondition.m_triggerData.m_triggerRepeat) if (triggerCondition.m_triggerCounter < triggerCondition.m_triggerData.m_triggerRepeat)
{ {
triggerCondition.m_triggerCounter++; triggerCondition.m_triggerCounter++;
m_triggerState = TriggerUntriggered; // repeat operations for next occurence return true; // not final keep going
return true; }
} else
else {
{ triggerCondition.m_triggerCounter = 0; // reset for next time
triggerCondition.m_triggerCounter = 0; // reset for next time }
} }
}
if (m_currentTriggerIndex < m_triggerConditions.size() - 1) if (m_currentTriggerIndex < m_triggerConditions.size() - 1) // check if next trigger is available
{ {
m_currentTriggerIndex++; m_currentTriggerIndex++;
m_triggerState = TriggerUntriggered; // repeat operations for next trigger return true; // not final keep going
return true; // not final keep going }
} else
else {
{ // now this is really finished
// now this is really finished m_currentTriggerIndex = 0;
m_triggerState = TriggerTriggered; return false; // final
m_currentTriggerIndex = 0; }
return false; // final
}
} }
int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool traceBack) int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool traceBack)
@ -416,8 +458,8 @@ bool ScopeVisNG::handleMessage(const Message& message)
if (m_preTriggerDelay != triggerPre) if (m_preTriggerDelay != triggerPre)
{ {
m_preTriggerDelay = triggerPre; m_preTriggerDelay = triggerPre;
m_glScope->setTriggerPre(m_preTriggerDelay); m_glScope->setTriggerPre(m_preTriggerDelay);
} }
if (freeRun != m_freeRun) if (freeRun != m_freeRun)