mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-20 00:25:53 -05:00
New scope: Trigger line display interim state (1)
This commit is contained in:
parent
ec604c21c9
commit
fa47e7064f
@ -31,10 +31,12 @@ MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGRemoveTrace, Message)
|
|||||||
const uint ScopeVisNG::m_traceChunkSize = 4800;
|
const uint ScopeVisNG::m_traceChunkSize = 4800;
|
||||||
const Real ScopeVisNG::ProjectorMagDB::mult = (10.0f / log2f(10.0f));
|
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_focusedTriggerIndex(0),
|
||||||
m_triggerState(TriggerUntriggered),
|
m_triggerState(TriggerUntriggered),
|
||||||
m_traceSize(m_traceChunkSize),
|
m_traceSize(m_traceChunkSize),
|
||||||
m_nbSamples(0),
|
m_nbSamples(0),
|
||||||
@ -101,13 +103,6 @@ void ScopeVisNG::addTrigger(const TriggerData& triggerData)
|
|||||||
|
|
||||||
void ScopeVisNG::changeTrigger(const TriggerData& triggerData, uint32_t triggerIndex)
|
void ScopeVisNG::changeTrigger(const TriggerData& triggerData, uint32_t triggerIndex)
|
||||||
{
|
{
|
||||||
qDebug() << "ScopeVisNG::changeTrigger:"
|
|
||||||
<< " trigger: " << triggerIndex
|
|
||||||
<< " m_projectionType: " << triggerData.m_projectionType
|
|
||||||
<< " m_triggerRepeat: " << triggerData.m_triggerRepeat
|
|
||||||
<< " m_triggerPositiveEdge: " << triggerData.m_triggerPositiveEdge
|
|
||||||
<< " m_triggerBothEdges: " << triggerData.m_triggerBothEdges;
|
|
||||||
;
|
|
||||||
Message* cmd = MsgScopeVisNGChangeTrigger::create(triggerData, triggerIndex);
|
Message* cmd = MsgScopeVisNGChangeTrigger::create(triggerData, triggerIndex);
|
||||||
getInputMessageQueue()->push(cmd);
|
getInputMessageQueue()->push(cmd);
|
||||||
}
|
}
|
||||||
@ -493,8 +488,13 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
MsgScopeVisNGChangeTrigger& conf = (MsgScopeVisNGChangeTrigger&) message;
|
MsgScopeVisNGChangeTrigger& conf = (MsgScopeVisNGChangeTrigger&) message;
|
||||||
int triggerIndex = conf.getTriggerIndex();
|
int triggerIndex = conf.getTriggerIndex();
|
||||||
|
|
||||||
if (triggerIndex < m_triggerConditions.size()) {
|
if (triggerIndex < m_triggerConditions.size())
|
||||||
|
{
|
||||||
m_triggerConditions[triggerIndex].setData(conf.getTriggerData());
|
m_triggerConditions[triggerIndex].setData(conf.getTriggerData());
|
||||||
|
|
||||||
|
if (triggerIndex == m_focusedTriggerIndex) {
|
||||||
|
computeTriggerLevelsOnDisplay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -505,7 +505,6 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
int triggerIndex = conf.getTriggerIndex();
|
int triggerIndex = conf.getTriggerIndex();
|
||||||
|
|
||||||
if (triggerIndex < m_triggerConditions.size()) {
|
if (triggerIndex < m_triggerConditions.size()) {
|
||||||
m_triggerConditions[triggerIndex].releaseProjector();
|
|
||||||
m_triggerConditions.erase(m_triggerConditions.begin() + triggerIndex);
|
m_triggerConditions.erase(m_triggerConditions.begin() + triggerIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,15 +516,18 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
m_traces.addTrace(conf.getTraceData(), m_traceSize);
|
m_traces.addTrace(conf.getTraceData(), m_traceSize);
|
||||||
initTraceBuffers();
|
initTraceBuffers();
|
||||||
updateMaxTraceDelay();
|
updateMaxTraceDelay();
|
||||||
|
computeTriggerLevelsOnDisplay();
|
||||||
|
m_glScope->updateDisplay();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (MsgScopeVisNGChangeTrace::match(message))
|
else if (MsgScopeVisNGChangeTrace::match(message))
|
||||||
{
|
{
|
||||||
MsgScopeVisNGChangeTrace& conf = (MsgScopeVisNGChangeTrace&) message;
|
MsgScopeVisNGChangeTrace& conf = (MsgScopeVisNGChangeTrace&) message;
|
||||||
|
bool doComputeTriggerLevelsOnDisplay = m_traces.isVerticalDisplayChange(conf.getTraceData(), conf.getTraceIndex());
|
||||||
m_traces.changeTrace(conf.getTraceData(), conf.getTraceIndex());
|
m_traces.changeTrace(conf.getTraceData(), conf.getTraceIndex());
|
||||||
updateMaxTraceDelay();
|
updateMaxTraceDelay();
|
||||||
|
if (doComputeTriggerLevelsOnDisplay) computeTriggerLevelsOnDisplay();
|
||||||
m_glScope->updateDisplay();
|
m_glScope->updateDisplay();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (MsgScopeVisNGRemoveTrace::match(message))
|
else if (MsgScopeVisNGRemoveTrace::match(message))
|
||||||
@ -533,6 +535,8 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
MsgScopeVisNGRemoveTrace& conf = (MsgScopeVisNGRemoveTrace&) message;
|
MsgScopeVisNGRemoveTrace& conf = (MsgScopeVisNGRemoveTrace&) message;
|
||||||
m_traces.removeTrace(conf.getTraceIndex());
|
m_traces.removeTrace(conf.getTraceIndex());
|
||||||
updateMaxTraceDelay();
|
updateMaxTraceDelay();
|
||||||
|
computeTriggerLevelsOnDisplay();
|
||||||
|
m_glScope->updateDisplay();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -576,3 +580,34 @@ void ScopeVisNG::initTraceBuffers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScopeVisNG::computeTriggerLevelsOnDisplay()
|
||||||
|
{
|
||||||
|
const TriggerCondition& focusedTriggerCondition = m_triggerConditions[m_focusedTriggerIndex];
|
||||||
|
std::vector<TraceData>::const_iterator itData = m_traces.m_tracesData.begin();
|
||||||
|
float v;
|
||||||
|
|
||||||
|
for (; itData != m_traces.m_tracesData.end(); ++itData)
|
||||||
|
{
|
||||||
|
if (focusedTriggerCondition.m_projector->getProjectionType() == itData->m_projectionType)
|
||||||
|
{
|
||||||
|
if (itData->m_projectionType == ProjectionMagLin) {
|
||||||
|
v = (focusedTriggerCondition.m_triggerData.m_triggerLevel - itData->m_ofs)*itData->m_amp - 1.0f;
|
||||||
|
} else if (itData->m_projectionType == ProjectionMagDB) {
|
||||||
|
float p = focusedTriggerCondition.m_triggerData.m_triggerLevel - (100.0f * itData->m_ofs);
|
||||||
|
v = ((p/50.0f) + 2.0f)*itData->m_amp - 1.0f;
|
||||||
|
} else {
|
||||||
|
v = (focusedTriggerCondition.m_triggerData.m_triggerLevel - itData->m_ofs) * itData->m_amp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(v > 1.0f) {
|
||||||
|
v = 1.0f;
|
||||||
|
} else if (v < -1.0f) {
|
||||||
|
v = -1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v = 2.0f; // clamp high
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -51,13 +51,15 @@ public:
|
|||||||
float m_amp; //!< Amplification factor
|
float m_amp; //!< Amplification factor
|
||||||
float m_ofs; //!< Offset factor
|
float m_ofs; //!< Offset factor
|
||||||
int m_traceDelay; //!< Trace delay in number of samples
|
int m_traceDelay; //!< Trace delay in number of samples
|
||||||
|
float m_triggerDisplayLevel; //!< Displayable trigger display level in -1:+1 scale. Off scale if not displayable.
|
||||||
|
|
||||||
TraceData() :
|
TraceData() :
|
||||||
m_projectionType(ProjectionReal),
|
m_projectionType(ProjectionReal),
|
||||||
m_inputIndex(0),
|
m_inputIndex(0),
|
||||||
m_amp(1.0f),
|
m_amp(1.0f),
|
||||||
m_ofs(0.0f),
|
m_ofs(0.0f),
|
||||||
m_traceDelay(0)
|
m_traceDelay(0),
|
||||||
|
m_triggerDisplayLevel(2.0) // OVer scale by default (2.0)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -590,12 +592,16 @@ private:
|
|||||||
if (m_projector) delete m_projector;
|
if (m_projector) delete m_projector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(ProjectionType projectionType)
|
void initProjector(ProjectionType projectionType)
|
||||||
{
|
{
|
||||||
if (m_projector) delete m_projector;
|
|
||||||
m_projector = createProjector(projectionType);
|
m_projector = createProjector(projectionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void releaseProjector()
|
||||||
|
{
|
||||||
|
delete m_projector;
|
||||||
|
}
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
m_traceCount[0] = 0;
|
m_traceCount[0] = 0;
|
||||||
@ -626,13 +632,20 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isVerticalDisplayChange(const TraceData& traceData, uint32_t traceIndex)
|
||||||
|
{
|
||||||
|
return (m_tracesData[traceIndex].m_projectionType != traceData.m_projectionType)
|
||||||
|
|| (m_tracesData[traceIndex].m_amp != traceData.m_amp)
|
||||||
|
|| (m_tracesData[traceIndex].m_ofs != traceData.m_ofs);
|
||||||
|
}
|
||||||
|
|
||||||
void addTrace(const TraceData& traceData, int traceSize)
|
void addTrace(const TraceData& traceData, int traceSize)
|
||||||
{
|
{
|
||||||
resize(traceSize);
|
resize(traceSize);
|
||||||
|
|
||||||
m_tracesData.push_back(traceData);
|
m_tracesData.push_back(traceData);
|
||||||
m_tracesControl.push_back(TraceControl());
|
m_tracesControl.push_back(TraceControl());
|
||||||
m_tracesControl.back().init(traceData.m_projectionType);
|
m_tracesControl.back().initProjector(traceData.m_projectionType);
|
||||||
float *x0 = new float[2*m_traceSize];
|
float *x0 = new float[2*m_traceSize];
|
||||||
float *x1 = new float[2*m_traceSize];
|
float *x1 = new float[2*m_traceSize];
|
||||||
m_traces[0].push_back(x0);
|
m_traces[0].push_back(x0);
|
||||||
@ -642,7 +655,8 @@ private:
|
|||||||
void changeTrace(const TraceData& traceData, uint32_t traceIndex)
|
void changeTrace(const TraceData& traceData, uint32_t traceIndex)
|
||||||
{
|
{
|
||||||
if (traceIndex < m_tracesControl.size()) {
|
if (traceIndex < m_tracesControl.size()) {
|
||||||
m_tracesControl[traceIndex].init(traceData.m_projectionType);
|
m_tracesControl[traceIndex].releaseProjector();
|
||||||
|
m_tracesControl[traceIndex].initProjector(traceData.m_projectionType);
|
||||||
m_tracesData[traceIndex] = traceData;
|
m_tracesData[traceIndex] = traceData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -651,6 +665,7 @@ private:
|
|||||||
{
|
{
|
||||||
if (traceIndex < m_tracesControl.size())
|
if (traceIndex < m_tracesControl.size())
|
||||||
{
|
{
|
||||||
|
m_tracesControl[traceIndex].releaseProjector();
|
||||||
m_tracesControl.erase(m_tracesControl.begin() + traceIndex);
|
m_tracesControl.erase(m_tracesControl.begin() + traceIndex);
|
||||||
m_tracesData.erase(m_tracesData.begin() + traceIndex);
|
m_tracesData.erase(m_tracesData.begin() + traceIndex);
|
||||||
delete[] (m_traces[0])[traceIndex];
|
delete[] (m_traces[0])[traceIndex];
|
||||||
@ -770,6 +785,7 @@ private:
|
|||||||
uint32_t m_preTriggerDelay; //!< Pre-trigger delay in number of samples
|
uint32_t m_preTriggerDelay; //!< Pre-trigger delay in number of samples
|
||||||
std::vector<TriggerCondition> m_triggerConditions; //!< Chain of triggers
|
std::vector<TriggerCondition> m_triggerConditions; //!< Chain of triggers
|
||||||
int m_currentTriggerIndex; //!< Index of current index in the chain
|
int m_currentTriggerIndex; //!< Index of current index in the chain
|
||||||
|
int m_focusedTriggerIndex; //!< Index of the trigger that has focus
|
||||||
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
|
||||||
@ -813,6 +829,15 @@ private:
|
|||||||
* Initialize trace buffers
|
* Initialize trace buffers
|
||||||
*/
|
*/
|
||||||
void initTraceBuffers();
|
void initTraceBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate trigger levels on display
|
||||||
|
* - every time a trigger condition focus changes TBD
|
||||||
|
* - every time the focused trigger condition changes its projection type or level
|
||||||
|
* - every time a trace data changes: projection type, amp, offset
|
||||||
|
* - every time a trace data is added or removed
|
||||||
|
*/
|
||||||
|
void computeTriggerLevelsOnDisplay();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -314,6 +314,27 @@ void GLScopeNG::paintGL()
|
|||||||
mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY);
|
mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY);
|
||||||
mat.scale(2.0f * rectW, -2.0f * rectH);
|
mat.scale(2.0f * rectW, -2.0f * rectH);
|
||||||
m_glShaderSimple.drawPolyline(mat, color, (GLfloat *) &trace[2*start], end - start);
|
m_glShaderSimple.drawPolyline(mat, color, (GLfloat *) &trace[2*start], end - start);
|
||||||
|
|
||||||
|
// Paint trigger level if any
|
||||||
|
if ((traceData.m_triggerDisplayLevel > -1.0f) && (traceData.m_triggerDisplayLevel < 1.0f))
|
||||||
|
{
|
||||||
|
GLfloat q3[] {
|
||||||
|
0, traceData.m_triggerDisplayLevel,
|
||||||
|
1, traceData.m_triggerDisplayLevel
|
||||||
|
};
|
||||||
|
|
||||||
|
float rectX = m_glScopeRect1.x();
|
||||||
|
float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f;
|
||||||
|
float rectW = m_glScopeRect1.width();
|
||||||
|
float rectH = -m_glScopeRect1.height() / 2.0f;
|
||||||
|
|
||||||
|
QVector4D color(0.0f, 1.0f, 0.0f, 0.4f);
|
||||||
|
QMatrix4x4 mat;
|
||||||
|
mat.setToIdentity();
|
||||||
|
mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY);
|
||||||
|
mat.scale(2.0f * rectW, -2.0f * rectH);
|
||||||
|
m_glShaderSimple.drawSegments(mat, color, q3, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user