mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-23 00:18:37 -05:00
New scope: make some trace and trigger data public
This commit is contained in:
parent
d69c6cc417
commit
cce5b29aa6
@ -107,33 +107,33 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
|
||||
TriggerCondition& triggerCondition = m_triggerConditions[m_currentTriggerIndex];
|
||||
|
||||
// trigger process
|
||||
if ((m_triggerConditions.size() > 0) && (feedIndex == triggerCondition.m_inputIndex))
|
||||
if ((m_triggerConditions.size() > 0) && (feedIndex == triggerCondition.m_triggerData.m_inputIndex))
|
||||
{
|
||||
while (begin < end)
|
||||
{
|
||||
if (m_triggerState == TriggerUntriggered)
|
||||
{
|
||||
bool condition = triggerCondition.m_projector->run(*begin) > triggerCondition.m_triggerLevel;
|
||||
bool condition = triggerCondition.m_projector->run(*begin) > triggerCondition.m_triggerData.m_triggerLevel;
|
||||
bool trigger;
|
||||
|
||||
if (triggerCondition.m_triggerBothEdges) {
|
||||
if (triggerCondition.m_triggerData.m_triggerBothEdges) {
|
||||
trigger = triggerCondition.m_prevCondition ^ condition;
|
||||
} else {
|
||||
trigger = condition ^ !triggerCondition.m_triggerPositiveEdge;
|
||||
trigger = condition ^ !triggerCondition.m_triggerData.m_triggerPositiveEdge;
|
||||
}
|
||||
|
||||
if (trigger)
|
||||
{
|
||||
if (triggerCondition.m_triggerDelay > 0)
|
||||
if (triggerCondition.m_triggerData.m_triggerDelay > 0)
|
||||
{
|
||||
triggerCondition.m_triggerDelayCount = triggerCondition.m_triggerDelay;
|
||||
triggerCondition.m_triggerDelayCount = triggerCondition.m_triggerData.m_triggerDelay;
|
||||
m_triggerState == TriggerDelay;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (triggerCondition.m_triggerCounts > 0)
|
||||
if (triggerCondition.m_triggerCounter > 0)
|
||||
{
|
||||
triggerCondition.m_triggerCounts--;
|
||||
triggerCondition.m_triggerCounter--;
|
||||
m_triggerState = TriggerUntriggered;
|
||||
}
|
||||
else
|
||||
@ -146,6 +146,7 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
|
||||
m_currentTriggerIndex = 0;
|
||||
m_triggerState = TriggerTriggered;
|
||||
m_triggerPoint = begin;
|
||||
triggerCondition.m_triggerCounter = triggerCondition.m_triggerData.m_triggerCounts;
|
||||
m_traceStart = true;
|
||||
break;
|
||||
}
|
||||
@ -175,6 +176,7 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
|
||||
m_currentTriggerIndex = 0;
|
||||
m_triggerState = TriggerTriggered;
|
||||
m_triggerPoint = begin;
|
||||
triggerCondition.m_triggerCounter = triggerCondition.m_triggerData.m_triggerCounts;
|
||||
m_traceStart = true;
|
||||
break;
|
||||
}
|
||||
@ -210,10 +212,10 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
|
||||
|
||||
for (;itTrace != m_traces.end(); ++itTrace)
|
||||
{
|
||||
if (itTrace->m_inputIndex == feedIndex)
|
||||
if (itTrace->m_traceData.m_inputIndex == feedIndex)
|
||||
{
|
||||
SampleVector::const_iterator startPoint = m_tracebackBuffers[feedIndex].getCurrent() - count;
|
||||
SampleVector::const_iterator prevPoint = m_tracebackBuffers[feedIndex].getCurrent() - count - m_preTriggerDelay - itTrace->m_traceDelay;
|
||||
SampleVector::const_iterator prevPoint = m_tracebackBuffers[feedIndex].getCurrent() - count - m_preTriggerDelay - itTrace->m_traceData.m_traceDelay;
|
||||
processPrevTrace(prevPoint, startPoint, itTrace);
|
||||
}
|
||||
}
|
||||
@ -229,14 +231,14 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
|
||||
{
|
||||
for (std::vector<Trace>::iterator itTrace = m_traces.begin(); itTrace != m_traces.end(); ++itTrace)
|
||||
{
|
||||
if (itTrace->m_inputIndex == feedIndex)
|
||||
if (itTrace->m_traceData.m_inputIndex == feedIndex)
|
||||
{
|
||||
float posLimit = 1.0 / itTrace->m_amp;
|
||||
float negLimit = -1.0 / itTrace->m_amp;
|
||||
float posLimit = 1.0 / itTrace->m_traceData.m_amp;
|
||||
float negLimit = -1.0 / itTrace->m_traceData.m_amp;
|
||||
|
||||
if (itTrace->m_traceCount < m_traceSize)
|
||||
{
|
||||
float v = itTrace->m_projector->run(*begin) * itTrace->m_amp + itTrace->m_shift;
|
||||
float v = itTrace->m_projector->run(*begin) * itTrace->m_traceData.m_amp + itTrace->m_traceData.m_ofs;
|
||||
|
||||
if(v > posLimit) {
|
||||
v = posLimit;
|
||||
@ -274,12 +276,12 @@ void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVe
|
||||
void ScopeVisNG::processPrevTrace(SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, std::vector<Trace>::iterator& trace)
|
||||
{
|
||||
int shift = (m_timeOfsProMill / 1000.0) * m_traceSize;
|
||||
float posLimit = 1.0 / trace->m_amp;
|
||||
float negLimit = -1.0 / trace->m_amp;
|
||||
float posLimit = 1.0 / trace->m_traceData.m_amp;
|
||||
float negLimit = -1.0 / trace->m_traceData.m_amp;
|
||||
|
||||
while (begin < end)
|
||||
{
|
||||
float v = trace->m_projector->run(*begin) * trace->m_amp + trace->m_shift;
|
||||
float v = trace->m_projector->run(*begin) * trace->m_traceData.m_amp + trace->m_traceData.m_ofs;
|
||||
|
||||
if(v > posLimit) {
|
||||
v = posLimit;
|
||||
|
@ -42,12 +42,48 @@ public:
|
||||
ProjectionDPhase //!< Calculate phase derivative i.e. instantaneous frequency scaled to sample rate
|
||||
};
|
||||
|
||||
struct TraceData
|
||||
{
|
||||
ProjectionType m_projectionType; //!< Complex to real projection type
|
||||
uint32_t m_inputIndex; //!< Input or feed index this trace is associated with
|
||||
float m_amp; //!< Amplification factor
|
||||
float m_ofs; //!< Offset factor
|
||||
int m_traceDelay; //!< Trace delay in number of samples
|
||||
|
||||
TraceData() :
|
||||
m_projectionType(ProjectionReal),
|
||||
m_inputIndex(0),
|
||||
m_amp(1.0f),
|
||||
m_ofs(0.0f),
|
||||
m_traceDelay(0)
|
||||
{}
|
||||
};
|
||||
|
||||
struct DisplayTrace
|
||||
{
|
||||
TraceData m_traceData; //!< Trace data
|
||||
float *m_trace; //!< Displayable trace (interleaved x,y of GLfloat)
|
||||
ProjectionType m_projectionType; //!< Complex to real projection type
|
||||
float m_amp; //!< Amplification factor
|
||||
float m_ofs; //!< Offset factor
|
||||
};
|
||||
|
||||
struct TriggerData
|
||||
{
|
||||
ProjectionType m_projectionType; //!< Complex to real projection type
|
||||
uint32_t m_inputIndex; //!< Input or feed index this trigger is associated with
|
||||
Real m_triggerLevel; //!< Level in real units
|
||||
bool m_triggerPositiveEdge; //!< Trigger on the positive edge (else negative)
|
||||
bool m_triggerBothEdges; //!< Trigger on both edges (else only one)
|
||||
uint32_t m_triggerDelay; //!< Delay before the trigger is kicked off in number of samples
|
||||
uint32_t m_triggerCounts; //!< Number of trigger conditions before the final decisive trigger
|
||||
|
||||
TriggerData() :
|
||||
m_projectionType(ProjectionReal),
|
||||
m_inputIndex(0),
|
||||
m_triggerLevel(0.0f),
|
||||
m_triggerPositiveEdge(true),
|
||||
m_triggerBothEdges(false),
|
||||
m_triggerDelay(0),
|
||||
m_triggerCounts(0)
|
||||
{}
|
||||
};
|
||||
|
||||
typedef std::vector<DisplayTrace> DisplayTraces;
|
||||
@ -231,46 +267,29 @@ private:
|
||||
{
|
||||
public:
|
||||
Projector *m_projector; //!< Projector transform from complex trace to reaL trace usable for triggering
|
||||
uint32_t m_inputIndex; //!< Input or feed index this trigger is associated with
|
||||
Real m_triggerLevel; //!< Level in real units
|
||||
bool m_triggerPositiveEdge; //!< Trigger on the positive edge (else negative)
|
||||
bool m_triggerBothEdges; //!< Trigger on both edges (else only one)
|
||||
TriggerData m_triggerData; //!< Trigger data
|
||||
bool m_prevCondition; //!< Condition (above threshold) at previous sample
|
||||
uint32_t m_triggerDelay; //!< Delay before the trigger is kicked off in number of samples
|
||||
uint32_t m_triggerDelayCount; //!< Counter of samples for delay
|
||||
uint32_t m_triggerCounts; //!< Number of trigger conditions before the final decisive trigger
|
||||
uint32_t m_triggerCounter; //!< Counter of trigger occurences
|
||||
|
||||
TriggerCondition(Projector *projector) :
|
||||
m_projector(projector),
|
||||
m_inputIndex(0),
|
||||
m_triggerLevel(0.0f),
|
||||
m_triggerPositiveEdge(true),
|
||||
m_triggerBothEdges(false),
|
||||
m_prevCondition(false),
|
||||
m_triggerDelay(0),
|
||||
m_triggerDelayCount(0),
|
||||
m_triggerCounts(0)
|
||||
m_triggerCounter(0)
|
||||
{}
|
||||
};
|
||||
|
||||
struct Trace : public DisplayTrace
|
||||
{
|
||||
Projector *m_projector; //!< Projector transform from complex trace to real (displayable) trace
|
||||
uint32_t m_inputIndex; //!< Input or feed index this trace is associated with
|
||||
int m_traceDelay; //!< Trace delay in number of samples
|
||||
int m_traceCount; //!< Count of samples processed
|
||||
float m_amp; //!< Linear trace amplifier factor
|
||||
float m_shift; //!< Linear trace shift
|
||||
|
||||
Trace(Projector *projector, Real *displayTraceBuffer) :
|
||||
m_projector(projector),
|
||||
m_inputIndex(0),
|
||||
m_traceDelay(0),
|
||||
m_traceCount(0),
|
||||
m_amp(1.0f),
|
||||
m_shift(0.0f)
|
||||
m_traceCount(0)
|
||||
{
|
||||
m_projectionType = m_projector->getProjectionType();
|
||||
m_traceData.m_projectionType = m_projector->getProjectionType();
|
||||
m_trace = displayTraceBuffer;
|
||||
}
|
||||
};
|
||||
|
@ -270,7 +270,7 @@ void GLScopeNG::paintGL()
|
||||
float rectX = m_glScopeRect1.x();
|
||||
float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f;
|
||||
float rectW = m_glScopeRect1.width() * (float)m_timeBase / (float)(m_traceSize - 1);
|
||||
float rectH = -(m_glScopeRect1.height() / 2.0f) * trace.m_amp;
|
||||
float rectH = -(m_glScopeRect1.height() / 2.0f) * trace.m_traceData.m_amp;
|
||||
|
||||
QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f);
|
||||
QMatrix4x4 mat;
|
||||
@ -943,19 +943,19 @@ void GLScopeNG::applyConfig()
|
||||
void GLScopeNG::setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex)
|
||||
{
|
||||
ScopeVisNG::DisplayTrace trace = (*m_traces)[highlightedTraceIndex];
|
||||
float amp_range = 2.0 / trace.m_amp;
|
||||
float amp_ofs = trace.m_ofs;
|
||||
float pow_floor = -100.0 + trace.m_ofs * 100.0;
|
||||
float pow_range = 100.0 / trace.m_amp;
|
||||
float amp_range = 2.0 / trace.m_traceData.m_amp;
|
||||
float amp_ofs = trace.m_traceData.m_ofs;
|
||||
float pow_floor = -100.0 + trace.m_traceData.m_ofs * 100.0;
|
||||
float pow_range = 100.0 / trace.m_traceData.m_amp;
|
||||
|
||||
switch (trace.m_projectionType)
|
||||
switch (trace.m_traceData.m_projectionType)
|
||||
{
|
||||
case ScopeVisNG::ProjectionMagDB: // dB scale
|
||||
scale.setRange(Unit::Decibel, pow_floor, pow_floor + pow_range);
|
||||
break;
|
||||
case ScopeVisNG::ProjectionPhase: // Phase or frequency
|
||||
case ScopeVisNG::ProjectionDPhase:
|
||||
scale.setRange(Unit::None, -1.0/trace.m_amp + amp_ofs, 1.0/trace.m_amp + amp_ofs);
|
||||
scale.setRange(Unit::None, -1.0/trace.m_traceData.m_amp + amp_ofs, 1.0/trace.m_traceData.m_amp + amp_ofs);
|
||||
break;
|
||||
case ScopeVisNG::ProjectionReal: // Linear generic
|
||||
case ScopeVisNG::ProjectionImag:
|
||||
|
Loading…
Reference in New Issue
Block a user