mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-23 18:52:28 -04:00
ScopeNG: use dynamic storage for TriggerCondition objects. Fixed destructors
This commit is contained in:
parent
26b4b50d23
commit
c9861c455b
@ -69,6 +69,9 @@ ScopeVisNG::ScopeVisNG(GLScopeNG* glScope) :
|
|||||||
|
|
||||||
ScopeVisNG::~ScopeVisNG()
|
ScopeVisNG::~ScopeVisNG()
|
||||||
{
|
{
|
||||||
|
for (std::vector<TriggerCondition*>::iterator it = m_triggerConditions.begin(); it != m_triggerConditions.end(); ++ it) {
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeVisNG::setSampleRate(int sampleRate)
|
void ScopeVisNG::setSampleRate(int sampleRate)
|
||||||
@ -267,15 +270,15 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
|
|||||||
{
|
{
|
||||||
if ((m_triggerState == TriggerUntriggered) || (m_triggerState == TriggerDelay))
|
if ((m_triggerState == TriggerUntriggered) || (m_triggerState == TriggerDelay))
|
||||||
{
|
{
|
||||||
TriggerCondition& triggerCondition = m_triggerConditions[m_currentTriggerIndex]; // current trigger condition
|
TriggerCondition* triggerCondition = m_triggerConditions[m_currentTriggerIndex]; // current trigger condition
|
||||||
|
|
||||||
while (begin < end)
|
while (begin < end)
|
||||||
{
|
{
|
||||||
if (m_triggerState == TriggerDelay)
|
if (m_triggerState == TriggerDelay)
|
||||||
{
|
{
|
||||||
if (triggerCondition.m_triggerDelayCount > 0) // skip samples during delay period
|
if (triggerCondition->m_triggerDelayCount > 0) // skip samples during delay period
|
||||||
{
|
{
|
||||||
triggerCondition.m_triggerDelayCount--;
|
triggerCondition->m_triggerDelayCount--;
|
||||||
++begin;
|
++begin;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -301,11 +304,11 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// look for trigger
|
// look for trigger
|
||||||
if (m_triggerComparator.triggered(*begin, triggerCondition))
|
if (m_triggerComparator.triggered(*begin, *triggerCondition))
|
||||||
{
|
{
|
||||||
if (triggerCondition.m_triggerData.m_triggerDelay > 0)
|
if (triggerCondition->m_triggerData.m_triggerDelay > 0)
|
||||||
{
|
{
|
||||||
triggerCondition.m_triggerDelayCount = triggerCondition.m_triggerData.m_triggerDelay; // initialize delayed samples counter
|
triggerCondition->m_triggerDelayCount = triggerCondition->m_triggerData.m_triggerDelay; // initialize delayed samples counter
|
||||||
m_triggerState = TriggerDelay;
|
m_triggerState = TriggerDelay;
|
||||||
++begin;
|
++begin;
|
||||||
continue;
|
continue;
|
||||||
@ -398,18 +401,18 @@ void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const
|
|||||||
|
|
||||||
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++;
|
||||||
return true; // not final keep going
|
return true; // not final keep going
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
triggerCondition.m_triggerCounter = 0; // reset for next time
|
triggerCondition->m_triggerCounter = 0; // reset for next time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,8 +626,8 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
{
|
{
|
||||||
QMutexLocker configLocker(&m_mutex);
|
QMutexLocker configLocker(&m_mutex);
|
||||||
MsgScopeVisNGAddTrigger& conf = (MsgScopeVisNGAddTrigger&) message;
|
MsgScopeVisNGAddTrigger& conf = (MsgScopeVisNGAddTrigger&) message;
|
||||||
m_triggerConditions.push_back(TriggerCondition(conf.getTriggerData()));
|
m_triggerConditions.push_back(new TriggerCondition(conf.getTriggerData()));
|
||||||
m_triggerConditions.back().initProjector();
|
m_triggerConditions.back()->initProjector();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (MsgScopeVisNGChangeTrigger::match(message))
|
else if (MsgScopeVisNGChangeTrigger::match(message))
|
||||||
@ -635,12 +638,12 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
|
|
||||||
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)
|
if (triggerIndex == m_focusedTriggerIndex)
|
||||||
{
|
{
|
||||||
computeDisplayTriggerLevels();
|
computeDisplayTriggerLevels();
|
||||||
m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex].m_triggerData);
|
m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData);
|
||||||
updateGLScopeDisplay();
|
updateGLScopeDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -653,8 +656,11 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
MsgScopeVisNGRemoveTrigger& conf = (MsgScopeVisNGRemoveTrigger&) message;
|
MsgScopeVisNGRemoveTrigger& conf = (MsgScopeVisNGRemoveTrigger&) message;
|
||||||
uint32_t triggerIndex = conf.getTriggerIndex();
|
uint32_t triggerIndex = conf.getTriggerIndex();
|
||||||
|
|
||||||
if (triggerIndex < m_triggerConditions.size()) {
|
if (triggerIndex < m_triggerConditions.size())
|
||||||
|
{
|
||||||
|
TriggerCondition *triggerCondition = m_triggerConditions[triggerIndex];
|
||||||
m_triggerConditions.erase(m_triggerConditions.begin() + triggerIndex);
|
m_triggerConditions.erase(m_triggerConditions.begin() + triggerIndex);
|
||||||
|
delete triggerCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -671,12 +677,12 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
|
|
||||||
int nextTriggerIndex = (triggerIndex + (conf.getMoveUp() ? 1 : -1)) % m_triggerConditions.size();
|
int nextTriggerIndex = (triggerIndex + (conf.getMoveUp() ? 1 : -1)) % m_triggerConditions.size();
|
||||||
|
|
||||||
TriggerCondition nextTrigger = m_triggerConditions[nextTriggerIndex];
|
TriggerCondition *nextTrigger = m_triggerConditions[nextTriggerIndex];
|
||||||
m_triggerConditions[nextTriggerIndex] = m_triggerConditions[triggerIndex];
|
m_triggerConditions[nextTriggerIndex] = m_triggerConditions[triggerIndex];
|
||||||
m_triggerConditions[triggerIndex] = nextTrigger;
|
m_triggerConditions[triggerIndex] = nextTrigger;
|
||||||
|
|
||||||
computeDisplayTriggerLevels();
|
computeDisplayTriggerLevels();
|
||||||
m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex].m_triggerData);
|
m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData);
|
||||||
updateGLScopeDisplay();
|
updateGLScopeDisplay();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -690,7 +696,7 @@ bool ScopeVisNG::handleMessage(const Message& message)
|
|||||||
{
|
{
|
||||||
m_focusedTriggerIndex = triggerIndex;
|
m_focusedTriggerIndex = triggerIndex;
|
||||||
computeDisplayTriggerLevels();
|
computeDisplayTriggerLevels();
|
||||||
m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex].m_triggerData);
|
m_glScope->setFocusedTriggerData(m_triggerConditions[m_focusedTriggerIndex]->m_triggerData);
|
||||||
updateGLScopeDisplay();
|
updateGLScopeDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -854,9 +860,9 @@ void ScopeVisNG::computeDisplayTriggerLevels()
|
|||||||
|
|
||||||
for (; itData != m_traces.m_tracesData.end(); ++itData)
|
for (; itData != m_traces.m_tracesData.end(); ++itData)
|
||||||
{
|
{
|
||||||
if ((m_focusedTriggerIndex < m_triggerConditions.size()) && (m_triggerConditions[m_focusedTriggerIndex].m_projector.getProjectionType() == itData->m_projectionType))
|
if ((m_focusedTriggerIndex < m_triggerConditions.size()) && (m_triggerConditions[m_focusedTriggerIndex]->m_projector.getProjectionType() == itData->m_projectionType))
|
||||||
{
|
{
|
||||||
float level = m_triggerConditions[m_focusedTriggerIndex].m_triggerData.m_triggerLevel;
|
float level = m_triggerConditions[m_focusedTriggerIndex]->m_triggerData.m_triggerLevel;
|
||||||
float levelPowerLin = level + 1.0f;
|
float levelPowerLin = level + 1.0f;
|
||||||
float levelPowerdB = (100.0f * (level - 1.0f));
|
float levelPowerdB = (100.0f * (level - 1.0f));
|
||||||
float v;
|
float v;
|
||||||
|
@ -169,7 +169,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (triggerIndex < m_triggerConditions.size())
|
if (triggerIndex < m_triggerConditions.size())
|
||||||
{
|
{
|
||||||
triggerData = m_triggerConditions[triggerIndex].m_triggerData;
|
triggerData = m_triggerConditions[triggerIndex]->m_triggerData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TriggerData& getTriggerData(uint32_t triggerIndex) const { return m_triggerConditions[triggerIndex].m_triggerData; }
|
const TriggerData& getTriggerData(uint32_t triggerIndex) const { return m_triggerConditions[triggerIndex]->m_triggerData; }
|
||||||
const std::vector<TraceData>& getTracesData() const { return m_traces.m_tracesData; }
|
const std::vector<TraceData>& getTracesData() const { return m_traces.m_tracesData; }
|
||||||
uint32_t getNbTriggers() const { return m_triggerConditions.size(); }
|
uint32_t getNbTriggers() const { return m_triggerConditions.size(); }
|
||||||
|
|
||||||
@ -529,12 +529,10 @@ private:
|
|||||||
m_triggerDelayCount(0),
|
m_triggerDelayCount(0),
|
||||||
m_triggerCounter(0)
|
m_triggerCounter(0)
|
||||||
{
|
{
|
||||||
qDebug("TriggerCondition");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~TriggerCondition()
|
~TriggerCondition()
|
||||||
{
|
{
|
||||||
qDebug("~TriggerCondition");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initProjector()
|
void initProjector()
|
||||||
@ -689,13 +687,11 @@ private:
|
|||||||
|
|
||||||
TraceControl() : m_projector(Projector::ProjectionReal)
|
TraceControl() : m_projector(Projector::ProjectionReal)
|
||||||
{
|
{
|
||||||
qDebug("TraceControl::TraceControl");
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
~TraceControl()
|
~TraceControl()
|
||||||
{
|
{
|
||||||
qDebug("TraceControl::~TraceControl");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initProjector(Projector::ProjectionType projectionType)
|
void initProjector(Projector::ProjectionType projectionType)
|
||||||
@ -737,8 +733,18 @@ private:
|
|||||||
|
|
||||||
~Traces()
|
~Traces()
|
||||||
{
|
{
|
||||||
if (m_x0) delete[] m_x0;
|
for (std::vector<TraceControl*>::iterator it = m_tracesControl.begin(); it != m_tracesControl.end(); ++it) {
|
||||||
if (m_x1) delete[] m_x1;
|
delete *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_x0) {
|
||||||
|
delete[] m_x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_x1) {
|
||||||
|
delete[] m_x1;
|
||||||
|
}
|
||||||
|
|
||||||
m_maxTraceSize = 0;
|
m_maxTraceSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,7 +943,7 @@ private:
|
|||||||
|
|
||||||
GLScopeNG* m_glScope;
|
GLScopeNG* m_glScope;
|
||||||
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
|
||||||
uint32_t m_currentTriggerIndex; //!< Index of current index in the chain
|
uint32_t m_currentTriggerIndex; //!< Index of current index in the chain
|
||||||
uint32_t m_focusedTriggerIndex; //!< Index of the trigger that has focus
|
uint32_t m_focusedTriggerIndex; //!< Index of the trigger that has focus
|
||||||
TriggerState m_triggerState; //!< Current trigger state
|
TriggerState m_triggerState; //!< Current trigger state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user