2017-01-29 13:51:45 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include "scopevisng.h"
|
2017-01-31 02:26:13 -05:00
|
|
|
#include "dsp/dspcommands.h"
|
2017-01-29 13:51:45 -05:00
|
|
|
#include "gui/glscopeng.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgConfigureScopeVisNG, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGAddTrigger, Message)
|
2017-01-29 18:36:27 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGChangeTrigger, Message)
|
2017-01-29 13:51:45 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGRemoveTrigger, Message)
|
2017-01-29 18:36:27 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGAddTrace, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGChangeTrace, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(ScopeVisNG::MsgScopeVisNGRemoveTrace, Message)
|
2017-01-29 13:51:45 -05:00
|
|
|
|
|
|
|
const uint ScopeVisNG::m_traceChunkSize = 4800;
|
|
|
|
const Real ScopeVisNG::ProjectorMagDB::mult = (10.0f / log2f(10.0f));
|
|
|
|
|
|
|
|
|
|
|
|
ScopeVisNG::ScopeVisNG(GLScopeNG* glScope) :
|
|
|
|
m_glScope(glScope),
|
|
|
|
m_preTriggerDelay(0),
|
|
|
|
m_currentTriggerIndex(0),
|
|
|
|
m_triggerState(TriggerUntriggered),
|
|
|
|
m_traceSize(m_traceChunkSize),
|
2017-02-01 12:31:16 -05:00
|
|
|
m_memTraceSize(0),
|
2017-01-29 13:51:45 -05:00
|
|
|
m_traceStart(true),
|
|
|
|
m_traceFill(0),
|
|
|
|
m_zTraceIndex(-1),
|
2017-01-29 16:52:38 -05:00
|
|
|
m_traceCompleteCount(0),
|
|
|
|
m_timeOfsProMill(0),
|
2017-02-01 12:31:16 -05:00
|
|
|
m_sampleRate(0),
|
2017-02-05 20:40:31 -05:00
|
|
|
m_traceDiscreteMemory(10),
|
|
|
|
m_freeRun(true),
|
|
|
|
m_maxTraceDelay(0)
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
|
|
|
setObjectName("ScopeVisNG");
|
2017-02-01 12:31:16 -05:00
|
|
|
m_traceDiscreteMemory.resize(m_traceChunkSize); // arbitrary
|
2017-02-05 20:40:31 -05:00
|
|
|
m_glScope->setTraces(&m_traces.m_tracesData, &m_traces.m_traces[0]);
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ScopeVisNG::~ScopeVisNG()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-29 16:52:38 -05:00
|
|
|
void ScopeVisNG::setSampleRate(int sampleRate)
|
|
|
|
{
|
|
|
|
if (sampleRate != m_sampleRate)
|
|
|
|
{
|
|
|
|
m_sampleRate = sampleRate;
|
|
|
|
if (m_glScope) m_glScope->setSampleRate(m_sampleRate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-07 12:50:08 -05:00
|
|
|
void ScopeVisNG::configure(uint32_t traceSize, uint32_t timeOfsProMill, uint32_t triggerPre, bool freeRun)
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
2017-02-07 12:50:08 -05:00
|
|
|
Message* cmd = MsgConfigureScopeVisNG::create(traceSize, timeOfsProMill, triggerPre, freeRun);
|
2017-01-29 18:36:27 -05:00
|
|
|
getInputMessageQueue()->push(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::addTrace(const TraceData& traceData)
|
|
|
|
{
|
|
|
|
Message* cmd = MsgScopeVisNGAddTrace::create(traceData);
|
|
|
|
getInputMessageQueue()->push(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::changeTrace(const TraceData& traceData, uint32_t traceIndex)
|
|
|
|
{
|
2017-02-07 20:13:53 -05:00
|
|
|
qDebug() << "ScopeVisNG::changeTrace:"
|
|
|
|
<< " trace: " << traceIndex
|
|
|
|
<< " m_amp: " << traceData.m_amp
|
|
|
|
<< " m_ofs: " << traceData.m_ofs;
|
2017-01-29 18:36:27 -05:00
|
|
|
Message* cmd = MsgScopeVisNGChangeTrace::create(traceData, traceIndex);
|
|
|
|
getInputMessageQueue()->push(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::removeTrace(uint32_t traceIndex)
|
|
|
|
{
|
|
|
|
Message* cmd = MsgScopeVisNGRemoveTrace::create(traceIndex);
|
|
|
|
getInputMessageQueue()->push(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::addTrigger(const TriggerData& triggerData)
|
|
|
|
{
|
|
|
|
Message* cmd = MsgScopeVisNGAddTrigger::create(triggerData);
|
|
|
|
getInputMessageQueue()->push(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::changeTrigger(const TriggerData& triggerData, uint32_t triggerIndex)
|
|
|
|
{
|
|
|
|
Message* cmd = MsgScopeVisNGChangeTrigger::create(triggerData, triggerIndex);
|
|
|
|
getInputMessageQueue()->push(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::removeTrigger(uint32_t triggerIndex)
|
|
|
|
{
|
|
|
|
Message* cmd = MsgScopeVisNGRemoveTrigger::create(triggerIndex);
|
|
|
|
getInputMessageQueue()->push(cmd);
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScopeVisNG::feed(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, bool positiveOnly)
|
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
if (m_freeRun) {
|
2017-01-29 13:51:45 -05:00
|
|
|
m_triggerPoint = cbegin;
|
|
|
|
}
|
|
|
|
else if (m_triggerState == TriggerTriggered) {
|
|
|
|
m_triggerPoint = cbegin;
|
|
|
|
}
|
|
|
|
else if (m_triggerState == TriggerUntriggered) {
|
|
|
|
m_triggerPoint = end;
|
|
|
|
}
|
|
|
|
else if (m_triggerState == TriggerWait) {
|
|
|
|
m_triggerPoint = end;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_triggerPoint = cbegin;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_triggerState == TriggerNewConfig)
|
|
|
|
{
|
|
|
|
m_triggerState = TriggerUntriggered;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_triggerConditions.size() > 0) && (m_triggerState == TriggerWait)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SampleVector::const_iterator begin(cbegin);
|
2017-02-01 12:31:16 -05:00
|
|
|
|
2017-02-08 16:22:27 -05:00
|
|
|
while (begin < end)
|
|
|
|
{
|
|
|
|
if (begin + m_traceSize > end)
|
|
|
|
{
|
|
|
|
processTrace(begin, end);
|
|
|
|
begin = end;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
processTrace(begin, begin + m_traceSize);
|
|
|
|
begin += m_traceSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::processTrace(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end)
|
|
|
|
{
|
|
|
|
SampleVector::const_iterator begin(cbegin);
|
|
|
|
|
2017-02-01 12:31:16 -05:00
|
|
|
// memory storage
|
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
m_traceDiscreteMemory.current().write(cbegin, end);
|
2017-02-01 12:31:16 -05:00
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
if (m_traceDiscreteMemory.current().absoluteFill() < m_traceSize)
|
|
|
|
{
|
|
|
|
return; // not enough samples in memory
|
|
|
|
}
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
// trigger process
|
2017-02-01 12:31:16 -05:00
|
|
|
|
2017-02-08 18:00:21 -05:00
|
|
|
if ((m_freeRun) || (m_triggerConditions.size() == 0)) // immediate re-trigger
|
|
|
|
{
|
|
|
|
m_traceStart = true; // start trace processing
|
|
|
|
m_triggerState = TriggerTriggered;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((m_triggerState == TriggerUntriggered) || (m_triggerState == TriggerDelay))
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
2017-02-08 18:00:21 -05:00
|
|
|
TriggerCondition& triggerCondition = m_triggerConditions[m_currentTriggerIndex]; // current trigger condition
|
|
|
|
|
|
|
|
while (begin < end)
|
2017-02-07 20:13:53 -05:00
|
|
|
{
|
2017-02-08 18:00:21 -05:00
|
|
|
// look for trigger
|
|
|
|
if (m_triggerComparator.triggered(*begin, triggerCondition))
|
|
|
|
{
|
|
|
|
m_traceStart = true; // start trace processing
|
|
|
|
m_triggerPoint = begin;
|
|
|
|
m_triggerComparator.reset();
|
|
|
|
m_triggerState = TriggerTriggered;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++begin;
|
2017-02-07 20:13:53 -05:00
|
|
|
}
|
|
|
|
}
|
2017-02-08 18:00:21 -05:00
|
|
|
}
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
int remainder = -1;
|
|
|
|
int count = end - begin; // number of samples in traceback buffer past the current point
|
|
|
|
SampleVector::iterator nend = m_traceDiscreteMemory.current().current();
|
|
|
|
SampleVector::iterator nbegin = nend - count;
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
// trace process
|
2017-02-08 18:00:21 -05:00
|
|
|
if (m_triggerState == TriggerTriggered)
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
|
|
|
// trace back
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
if ((m_traceStart) && (m_preTriggerDelay + m_maxTraceDelay > 0))
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
remainder = processTraces(count + m_preTriggerDelay + m_maxTraceDelay, count, m_traceDiscreteMemory.current(), true);
|
2017-02-02 02:27:49 -05:00
|
|
|
m_traceStart = false;
|
|
|
|
}
|
2017-02-01 12:31:16 -05:00
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
if (remainder < 0)
|
|
|
|
{
|
|
|
|
// live trace
|
|
|
|
remainder = processTraces(count, 0, m_traceDiscreteMemory.current());
|
|
|
|
}
|
2017-02-01 12:31:16 -05:00
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
if (remainder >= 0) // finished
|
|
|
|
{
|
|
|
|
nbegin = nend - remainder;
|
|
|
|
m_traceDiscreteMemory.current().m_endPoint = nbegin;
|
|
|
|
m_traceDiscreteMemory.store(); // next memory trace
|
|
|
|
m_traceCompleteCount = 0;
|
2017-02-07 01:45:42 -05:00
|
|
|
m_triggerState = TriggerUntriggered;
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
2017-02-02 02:27:49 -05:00
|
|
|
}
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
// process remainder recursively
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
if (remainder > 0)
|
|
|
|
{
|
2017-02-08 16:22:27 -05:00
|
|
|
processTrace(nbegin, nend);
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-01 12:31:16 -05:00
|
|
|
bool ScopeVisNG::nextTrigger()
|
|
|
|
{
|
|
|
|
TriggerCondition& triggerCondition = m_triggerConditions[m_currentTriggerIndex]; // current trigger condition
|
|
|
|
|
|
|
|
if (triggerCondition.m_triggerData.m_triggerRepeat > 0)
|
|
|
|
{
|
|
|
|
if (triggerCondition.m_triggerCounter < triggerCondition.m_triggerData.m_triggerRepeat)
|
|
|
|
{
|
|
|
|
triggerCondition.m_triggerCounter++;
|
|
|
|
m_triggerState = TriggerUntriggered; // repeat operations for next occurence
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
triggerCondition.m_triggerCounter = 0; // reset for next time
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-07 01:45:42 -05:00
|
|
|
if (m_currentTriggerIndex < m_triggerConditions.size() - 1)
|
2017-02-01 12:31:16 -05:00
|
|
|
{
|
|
|
|
m_currentTriggerIndex++;
|
|
|
|
m_triggerState = TriggerUntriggered; // repeat operations for next trigger
|
|
|
|
return true; // not final keep going
|
|
|
|
}
|
2017-02-07 01:45:42 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// now this is really finished
|
|
|
|
m_triggerState = TriggerTriggered;
|
|
|
|
m_currentTriggerIndex = 0;
|
|
|
|
return false; // final
|
|
|
|
}
|
2017-02-01 12:31:16 -05:00
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
int ScopeVisNG::processTraces(int beginPointDelta, int endPointDelta, TraceBackBuffer& traceBuffer, bool traceBack)
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
2017-02-02 02:27:49 -05:00
|
|
|
SampleVector::iterator begin = traceBuffer.current() - beginPointDelta;
|
|
|
|
SampleVector::const_iterator end = traceBuffer.current() - endPointDelta;
|
2017-01-29 13:51:45 -05:00
|
|
|
int shift = (m_timeOfsProMill / 1000.0) * m_traceSize;
|
|
|
|
|
|
|
|
while (begin < end)
|
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
std::vector<TraceControl>::iterator itCtl = m_traces.m_tracesControl.begin();
|
|
|
|
std::vector<TraceData>::iterator itData = m_traces.m_tracesData.begin();
|
|
|
|
std::vector<float *>::iterator itTrace = m_traces.m_traces[m_traces.currentBufferIndex()].begin();
|
|
|
|
|
|
|
|
for (; itCtl != m_traces.m_tracesControl.end(); ++itCtl, ++itData, ++itTrace)
|
2017-02-02 02:27:49 -05:00
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
if (traceBack && ((end - begin) > m_preTriggerDelay + itData->m_traceDelay)) {
|
2017-02-02 02:27:49 -05:00
|
|
|
continue;
|
|
|
|
}
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
if (itCtl->m_traceCount[m_traces.currentBufferIndex()] < m_traceSize)
|
2017-02-02 02:27:49 -05:00
|
|
|
{
|
2017-02-06 18:25:40 -05:00
|
|
|
ProjectionType projectionType = itData->m_projectionType;
|
|
|
|
float v;
|
|
|
|
|
|
|
|
if (projectionType == ProjectionMagLin) {
|
2017-02-07 20:13:53 -05:00
|
|
|
v = (itCtl->m_projector->run(*begin) - itData->m_ofs)*itData->m_amp - 1.0f;
|
|
|
|
} else if (projectionType == ProjectionMagDB) {
|
|
|
|
float p = itCtl->m_projector->run(*begin) - (100.0f * itData->m_ofs);
|
|
|
|
v = ((p/50.0f) + 2.0f)*itData->m_amp - 1.0f;
|
2017-02-06 18:25:40 -05:00
|
|
|
} else {
|
2017-02-07 20:13:53 -05:00
|
|
|
v = (itCtl->m_projector->run(*begin) - itData->m_ofs) * itData->m_amp;
|
2017-02-06 18:25:40 -05:00
|
|
|
}
|
2017-02-02 02:27:49 -05:00
|
|
|
|
2017-02-07 20:13:53 -05:00
|
|
|
if(v > 1.0f) {
|
|
|
|
v = 1.0f;
|
|
|
|
} else if (v < -1.0f) {
|
|
|
|
v = -1.0f;
|
2017-02-02 02:27:49 -05:00
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
(*itTrace)[2*(itCtl->m_traceCount[m_traces.currentBufferIndex()])]
|
|
|
|
= (itCtl->m_traceCount[m_traces.currentBufferIndex()] - shift); // display x
|
|
|
|
(*itTrace)[2*(itCtl->m_traceCount[m_traces.currentBufferIndex()]) + 1] = v; // display y
|
|
|
|
itCtl->m_traceCount[m_traces.currentBufferIndex()]++;
|
2017-02-02 02:27:49 -05:00
|
|
|
}
|
2017-02-05 20:40:31 -05:00
|
|
|
else
|
2017-02-02 02:27:49 -05:00
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
itCtl->m_traceCount[m_traces.currentBufferIndex()]++;
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
if (m_traceCompleteCount < m_traces.size())
|
|
|
|
{
|
|
|
|
m_traceCompleteCount++;
|
|
|
|
}
|
|
|
|
else // finished
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
++begin;
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
2017-02-02 02:27:49 -05:00
|
|
|
|
|
|
|
if (m_traceCompleteCount == m_traces.size()) // finished
|
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
m_glScope->newTraces(&m_traces.m_traces[m_traces.currentBufferIndex()]);
|
|
|
|
m_traces.switchBuffer();
|
2017-02-02 02:27:49 -05:00
|
|
|
traceBuffer.m_endPoint = begin;
|
|
|
|
return end - begin; // return remainder count
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1; // mark not finished
|
|
|
|
}
|
2017-02-04 22:41:32 -05:00
|
|
|
}
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
void ScopeVisNG::start()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::stop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScopeVisNG::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
qDebug() << "ScopeVisNG::handleMessage" << message.getIdentifier();
|
2017-01-31 02:26:13 -05:00
|
|
|
|
|
|
|
if (DSPSignalNotification::match(message))
|
|
|
|
{
|
|
|
|
DSPSignalNotification& notif = (DSPSignalNotification&) message;
|
|
|
|
setSampleRate(notif.getSampleRate());
|
|
|
|
qDebug() << "ScopeVisNG::handleMessage: DSPSignalNotification: m_sampleRate: " << m_sampleRate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureScopeVisNG::match(message))
|
|
|
|
{
|
|
|
|
MsgConfigureScopeVisNG& conf = (MsgConfigureScopeVisNG&) message;
|
|
|
|
|
2017-02-04 22:41:32 -05:00
|
|
|
uint32_t traceSize = conf.getTraceSize();
|
|
|
|
uint32_t timeOfsProMill = conf.getTimeOfsProMill();
|
2017-02-07 12:50:08 -05:00
|
|
|
uint32_t triggerPre = conf.getTriggerPre();
|
2017-02-05 20:40:31 -05:00
|
|
|
bool freeRun = conf.getFreeRun();
|
2017-02-04 22:41:32 -05:00
|
|
|
|
|
|
|
if (m_traceSize != traceSize)
|
|
|
|
{
|
|
|
|
m_traceSize = traceSize;
|
2017-02-05 20:40:31 -05:00
|
|
|
m_traces.resize(m_traceSize);
|
2017-02-04 22:41:32 -05:00
|
|
|
m_traceDiscreteMemory.resize(m_traceSize);
|
2017-02-05 20:40:31 -05:00
|
|
|
initTraceBuffers();
|
2017-02-04 22:41:32 -05:00
|
|
|
|
|
|
|
if (m_glScope) {
|
|
|
|
m_glScope->setTraceSize(m_traceSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_timeOfsProMill != timeOfsProMill)
|
|
|
|
{
|
|
|
|
m_timeOfsProMill = timeOfsProMill;
|
|
|
|
|
|
|
|
if (m_glScope) {
|
|
|
|
m_glScope->setTimeOfsProMill(m_timeOfsProMill);
|
|
|
|
}
|
2017-02-03 02:27:03 -05:00
|
|
|
}
|
|
|
|
|
2017-02-07 12:50:08 -05:00
|
|
|
if (m_preTriggerDelay != triggerPre)
|
|
|
|
{
|
|
|
|
m_preTriggerDelay = triggerPre;
|
|
|
|
m_glScope->setTriggerPre(m_preTriggerDelay);
|
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
if (freeRun != m_freeRun)
|
|
|
|
{
|
|
|
|
m_freeRun = freeRun;
|
|
|
|
}
|
|
|
|
|
2017-02-04 22:41:32 -05:00
|
|
|
qDebug() << "ScopeVisNG::handleMessage: MsgConfigureScopeVisNG:"
|
|
|
|
<< " m_traceSize: " << m_traceSize
|
2017-02-05 20:40:31 -05:00
|
|
|
<< " m_timeOfsProMill: " << m_timeOfsProMill
|
2017-02-07 12:50:08 -05:00
|
|
|
<< " m_preTriggerDelay: " << m_preTriggerDelay
|
2017-02-05 20:40:31 -05:00
|
|
|
<< " m_freeRun: " << m_freeRun;
|
2017-02-03 02:27:03 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgScopeVisNGAddTrigger::match(message))
|
|
|
|
{
|
|
|
|
MsgScopeVisNGAddTrigger& conf = (MsgScopeVisNGAddTrigger&) message;
|
|
|
|
m_triggerConditions.push_back(TriggerCondition(conf.getTriggerData()));
|
2017-02-04 22:41:32 -05:00
|
|
|
m_triggerConditions.back().init();
|
2017-02-03 02:27:03 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgScopeVisNGChangeTrigger::match(message))
|
|
|
|
{
|
|
|
|
MsgScopeVisNGChangeTrigger& conf = (MsgScopeVisNGChangeTrigger&) message;
|
|
|
|
int triggerIndex = conf.getTriggerIndex();
|
|
|
|
|
|
|
|
if (triggerIndex < m_triggerConditions.size()) {
|
|
|
|
m_triggerConditions[triggerIndex].setData(conf.getTriggerData());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgScopeVisNGRemoveTrigger::match(message))
|
|
|
|
{
|
|
|
|
MsgScopeVisNGRemoveTrigger& conf = (MsgScopeVisNGRemoveTrigger&) message;
|
|
|
|
int triggerIndex = conf.getTriggerIndex();
|
|
|
|
|
|
|
|
if (triggerIndex < m_triggerConditions.size()) {
|
|
|
|
m_triggerConditions.erase(m_triggerConditions.begin() + triggerIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgScopeVisNGAddTrace::match(message))
|
|
|
|
{
|
|
|
|
MsgScopeVisNGAddTrace& conf = (MsgScopeVisNGAddTrace&) message;
|
2017-02-05 20:40:31 -05:00
|
|
|
m_traces.addTrace(conf.getTraceData(), m_traceSize);
|
|
|
|
initTraceBuffers();
|
|
|
|
updateMaxTraceDelay();
|
2017-02-03 02:27:03 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgScopeVisNGChangeTrace::match(message))
|
|
|
|
{
|
|
|
|
MsgScopeVisNGChangeTrace& conf = (MsgScopeVisNGChangeTrace&) message;
|
2017-02-05 20:40:31 -05:00
|
|
|
m_traces.changeTrace(conf.getTraceData(), conf.getTraceIndex());
|
|
|
|
updateMaxTraceDelay();
|
2017-02-05 07:26:07 -05:00
|
|
|
m_glScope->updateDisplay();
|
|
|
|
|
2017-02-03 02:27:03 -05:00
|
|
|
return true;
|
2017-01-31 02:26:13 -05:00
|
|
|
}
|
2017-02-03 02:27:03 -05:00
|
|
|
else if (MsgScopeVisNGRemoveTrace::match(message))
|
|
|
|
{
|
|
|
|
MsgScopeVisNGRemoveTrace& conf = (MsgScopeVisNGRemoveTrace&) message;
|
2017-02-05 20:40:31 -05:00
|
|
|
m_traces.removeTrace(conf.getTraceIndex());
|
|
|
|
updateMaxTraceDelay();
|
2017-02-03 02:27:03 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
|
|
|
|
void ScopeVisNG::updateMaxTraceDelay()
|
|
|
|
{
|
|
|
|
int maxTraceDelay = 0;
|
|
|
|
|
|
|
|
for (std::vector<TraceData>::iterator itData = m_traces.m_tracesData.begin(); itData != m_traces.m_tracesData.end(); ++itData)
|
|
|
|
{
|
|
|
|
if (itData->m_traceDelay > maxTraceDelay)
|
|
|
|
{
|
|
|
|
maxTraceDelay = itData->m_traceDelay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_maxTraceDelay = maxTraceDelay;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScopeVisNG::initTraceBuffers()
|
|
|
|
{
|
|
|
|
int shift = (m_timeOfsProMill / 1000.0) * m_traceSize;
|
|
|
|
|
|
|
|
std::vector<float *>::iterator it0 = m_traces.m_traces[0].begin();
|
|
|
|
std::vector<float *>::iterator it1 = m_traces.m_traces[1].begin();
|
|
|
|
|
|
|
|
for (; it0 != m_traces.m_traces[0].end(); ++it0, ++it1)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_traceSize; i++)
|
|
|
|
{
|
|
|
|
(*it0)[2*i] = (i - shift); // display x
|
|
|
|
(*it0)[2*i + 1] = 0.0f; // display y
|
|
|
|
(*it1)[2*i] = (i - shift); // display x
|
|
|
|
(*it1)[2*i + 1] = 0.0f; // display y
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|