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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef SDRBASE_DSP_SCOPEVISNG_H_
|
|
|
|
#define SDRBASE_DSP_SCOPEVISNG_H_
|
|
|
|
|
2017-02-09 22:35:08 -05:00
|
|
|
#include <QDebug>
|
2017-02-11 14:44:00 -05:00
|
|
|
#include <QColor>
|
2017-02-15 19:06:15 -05:00
|
|
|
#include <algorithm>
|
2017-02-26 05:26:23 -05:00
|
|
|
#include <utility>
|
2017-09-15 12:48:30 -04:00
|
|
|
#include <math.h>
|
2017-02-09 22:35:08 -05:00
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <boost/circular_buffer.hpp>
|
|
|
|
#include "dsp/dsptypes.h"
|
|
|
|
#include "dsp/basebandsamplesink.h"
|
2018-04-03 12:51:21 -04:00
|
|
|
#include "dsp/projector.h"
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2017-01-29 13:51:45 -05:00
|
|
|
#include "util/message.h"
|
|
|
|
#include "util/doublebuffer.h"
|
|
|
|
|
2017-09-15 12:48:30 -04:00
|
|
|
#undef M_PI
|
|
|
|
#define M_PI 3.14159265358979323846
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
class GLScopeNG;
|
|
|
|
|
2018-03-03 14:23:38 -05:00
|
|
|
class SDRGUI_API ScopeVisNG : public BasebandSampleSink {
|
2017-01-29 13:51:45 -05:00
|
|
|
|
|
|
|
public:
|
2017-01-31 02:26:13 -05:00
|
|
|
struct TraceData
|
|
|
|
{
|
2018-04-03 12:51:21 -04:00
|
|
|
Projector::ProjectionType m_projectionType; //!< Complex to real projection type
|
2017-01-29 18:07:20 -05:00
|
|
|
uint32_t m_inputIndex; //!< Input or feed index this trace is associated with
|
|
|
|
float m_amp; //!< Amplification factor
|
2017-02-12 19:32:02 -05:00
|
|
|
uint32_t m_ampIndex; //!< Index in list of amplification factors
|
2017-01-29 18:07:20 -05:00
|
|
|
float m_ofs; //!< Offset factor
|
2017-02-12 19:32:02 -05:00
|
|
|
int m_ofsCoarse; //!< Coarse offset slider value
|
|
|
|
int m_ofsFine; //!< Fine offset slider value
|
2017-01-29 18:07:20 -05:00
|
|
|
int m_traceDelay; //!< Trace delay in number of samples
|
2017-02-16 19:54:55 -05:00
|
|
|
int m_traceDelayCoarse; //!< Coarse delay slider value
|
|
|
|
int m_traceDelayFine; //!< Fine delay slider value
|
2017-02-10 12:28:19 -05:00
|
|
|
float m_triggerDisplayLevel; //!< Displayable trigger display level in -1:+1 scale. Off scale if not displayable.
|
2017-02-11 14:44:00 -05:00
|
|
|
QColor m_traceColor; //!< Trace display color
|
|
|
|
float m_traceColorR; //!< Trace display color - red shortcut
|
|
|
|
float m_traceColorG; //!< Trace display color - green shortcut
|
|
|
|
float m_traceColorB; //!< Trace display color - blue shortcut
|
2017-02-25 22:46:02 -05:00
|
|
|
bool m_hasTextOverlay; //!< True if a text overlay has to be displayed
|
|
|
|
QString m_textOverlay; //!< Text overlay to display
|
2017-02-26 16:27:03 -05:00
|
|
|
bool m_viewTrace; //!< Trace visibility
|
2017-01-29 18:07:20 -05:00
|
|
|
|
|
|
|
TraceData() :
|
2018-04-03 12:51:21 -04:00
|
|
|
m_projectionType(Projector::ProjectionReal),
|
2017-01-29 18:07:20 -05:00
|
|
|
m_inputIndex(0),
|
|
|
|
m_amp(1.0f),
|
2017-02-12 19:32:02 -05:00
|
|
|
m_ampIndex(0),
|
2017-01-29 18:07:20 -05:00
|
|
|
m_ofs(0.0f),
|
2017-02-12 19:32:02 -05:00
|
|
|
m_ofsCoarse(0),
|
|
|
|
m_ofsFine(0),
|
2017-02-10 12:28:19 -05:00
|
|
|
m_traceDelay(0),
|
2017-02-16 19:54:55 -05:00
|
|
|
m_traceDelayCoarse(0),
|
|
|
|
m_traceDelayFine(0),
|
2017-02-11 14:44:00 -05:00
|
|
|
m_triggerDisplayLevel(2.0), // OVer scale by default (2.0)
|
2017-02-25 22:46:02 -05:00
|
|
|
m_traceColor(255,255,64),
|
2017-02-26 16:27:03 -05:00
|
|
|
m_hasTextOverlay(false),
|
|
|
|
m_viewTrace(true)
|
2017-02-11 14:44:00 -05:00
|
|
|
{
|
|
|
|
setColor(m_traceColor);
|
|
|
|
}
|
|
|
|
|
2017-02-11 20:12:06 -05:00
|
|
|
void setColor(QColor color)
|
|
|
|
{
|
2017-02-11 14:44:00 -05:00
|
|
|
m_traceColor = color;
|
|
|
|
qreal r,g,b,a;
|
|
|
|
m_traceColor.getRgbF(&r, &g, &b, &a);
|
|
|
|
m_traceColorR = r;
|
|
|
|
m_traceColorG = g;
|
|
|
|
m_traceColorB = b;
|
|
|
|
}
|
2017-01-31 02:26:13 -05:00
|
|
|
};
|
2017-01-29 18:07:20 -05:00
|
|
|
|
2017-02-11 14:44:00 -05:00
|
|
|
|
2017-01-31 02:26:13 -05:00
|
|
|
struct TriggerData
|
|
|
|
{
|
2018-04-03 12:51:21 -04:00
|
|
|
Projector::ProjectionType m_projectionType; //!< Complex to real projection type
|
2017-01-29 18:07:20 -05:00
|
|
|
uint32_t m_inputIndex; //!< Input or feed index this trigger is associated with
|
|
|
|
Real m_triggerLevel; //!< Level in real units
|
2017-02-09 22:35:08 -05:00
|
|
|
int m_triggerLevelCoarse;
|
|
|
|
int m_triggerLevelFine;
|
2017-01-29 18:07:20 -05:00
|
|
|
bool m_triggerPositiveEdge; //!< Trigger on the positive edge (else negative)
|
|
|
|
bool m_triggerBothEdges; //!< Trigger on both edges (else only one)
|
2017-02-09 22:35:08 -05:00
|
|
|
uint32_t m_triggerDelay; //!< Delay before the trigger is kicked off in number of samples (trigger delay)
|
|
|
|
double m_triggerDelayMult; //!< Trigger delay as a multiplier of trace length
|
|
|
|
int m_triggerDelayCoarse;
|
|
|
|
int m_triggerDelayFine;
|
2017-02-01 12:31:16 -05:00
|
|
|
uint32_t m_triggerRepeat; //!< Number of trigger conditions before the final decisive trigger
|
2017-02-11 20:12:06 -05:00
|
|
|
QColor m_triggerColor; //!< Trigger line display color
|
|
|
|
float m_triggerColorR; //!< Trigger line display color - red shortcut
|
|
|
|
float m_triggerColorG; //!< Trigger line display color - green shortcut
|
|
|
|
float m_triggerColorB; //!< Trigger line display color - blue shortcut
|
2017-01-29 18:07:20 -05:00
|
|
|
|
|
|
|
TriggerData() :
|
2018-04-03 12:51:21 -04:00
|
|
|
m_projectionType(Projector::ProjectionReal),
|
2017-01-29 18:07:20 -05:00
|
|
|
m_inputIndex(0),
|
|
|
|
m_triggerLevel(0.0f),
|
2017-02-09 22:35:08 -05:00
|
|
|
m_triggerLevelCoarse(0),
|
|
|
|
m_triggerLevelFine(0),
|
2017-01-29 18:07:20 -05:00
|
|
|
m_triggerPositiveEdge(true),
|
|
|
|
m_triggerBothEdges(false),
|
|
|
|
m_triggerDelay(0),
|
2017-02-09 22:35:08 -05:00
|
|
|
m_triggerDelayMult(0.0),
|
|
|
|
m_triggerDelayCoarse(0),
|
|
|
|
m_triggerDelayFine(0),
|
2017-02-11 20:12:06 -05:00
|
|
|
m_triggerRepeat(0),
|
|
|
|
m_triggerColor(0,255,0)
|
|
|
|
{
|
|
|
|
setColor(m_triggerColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setColor(QColor color)
|
|
|
|
{
|
|
|
|
m_triggerColor = color;
|
|
|
|
qreal r,g,b,a;
|
|
|
|
m_triggerColor.getRgbF(&r, &g, &b, &a);
|
|
|
|
m_triggerColorR = r;
|
|
|
|
m_triggerColorG = g;
|
|
|
|
m_triggerColorB = b;
|
|
|
|
}
|
2017-01-31 02:26:13 -05:00
|
|
|
};
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-15 19:06:15 -05:00
|
|
|
static const uint32_t m_traceChunkSize;
|
|
|
|
static const uint32_t m_maxNbTriggers = 10;
|
|
|
|
static const uint32_t m_maxNbTraces = 10;
|
2017-02-23 02:18:03 -05:00
|
|
|
static const uint32_t m_nbTraceMemories = 16;
|
2017-01-29 13:51:45 -05:00
|
|
|
|
|
|
|
ScopeVisNG(GLScopeNG* glScope = 0);
|
|
|
|
virtual ~ScopeVisNG();
|
|
|
|
|
2017-01-29 16:52:38 -05:00
|
|
|
void setSampleRate(int sampleRate);
|
2017-02-25 22:55:15 -05:00
|
|
|
void configure(uint32_t traceSize, uint32_t timeBase, uint32_t timeOfsProMill, uint32_t triggerPre, bool freeRun);
|
2017-01-29 18:36:27 -05:00
|
|
|
void addTrace(const TraceData& traceData);
|
|
|
|
void changeTrace(const TraceData& traceData, uint32_t traceIndex);
|
|
|
|
void removeTrace(uint32_t traceIndex);
|
2017-02-26 05:26:23 -05:00
|
|
|
void moveTrace(uint32_t traceIndex, bool upElseDown);
|
2017-02-12 19:32:02 -05:00
|
|
|
void focusOnTrace(uint32_t traceIndex);
|
2017-01-29 18:36:27 -05:00
|
|
|
void addTrigger(const TriggerData& triggerData);
|
2017-02-09 22:35:08 -05:00
|
|
|
void changeTrigger(const TriggerData& triggerData, uint32_t triggerIndex);
|
2017-01-29 18:36:27 -05:00
|
|
|
void removeTrigger(uint32_t triggerIndex);
|
2017-02-26 05:26:23 -05:00
|
|
|
void moveTrigger(uint32_t triggerIndex, bool upElseDown);
|
2017-02-11 04:36:10 -05:00
|
|
|
void focusOnTrigger(uint32_t triggerIndex);
|
2017-02-21 19:18:50 -05:00
|
|
|
void setOneShot(bool oneShot);
|
2017-02-23 02:18:03 -05:00
|
|
|
void setMemoryIndex(uint32_t memoryIndex);
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-09 22:35:08 -05:00
|
|
|
void getTriggerData(TriggerData& triggerData, uint32_t triggerIndex)
|
|
|
|
{
|
|
|
|
if (triggerIndex < m_triggerConditions.size())
|
|
|
|
{
|
|
|
|
triggerData = m_triggerConditions[triggerIndex].m_triggerData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-11 14:44:00 -05:00
|
|
|
void getTraceData(TraceData& traceData, uint32_t traceIndex)
|
|
|
|
{
|
|
|
|
if (traceIndex < m_traces.m_tracesData.size())
|
|
|
|
{
|
|
|
|
traceData = m_traces.m_tracesData[traceIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-19 19:21:52 -05:00
|
|
|
const TriggerData& getTriggerData(uint32_t triggerIndex) const { return m_triggerConditions[triggerIndex].m_triggerData; }
|
|
|
|
const std::vector<TraceData>& getTracesData() const { return m_traces.m_tracesData; }
|
|
|
|
uint32_t getNbTriggers() const { return m_triggerConditions.size(); }
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
SampleVector::const_iterator getTriggerPoint() const { return m_triggerPoint; }
|
|
|
|
|
|
|
|
private:
|
2017-01-29 16:52:38 -05:00
|
|
|
// === messages ===
|
|
|
|
// ---------------------------------------------
|
2017-01-29 13:51:45 -05:00
|
|
|
class MsgConfigureScopeVisNG : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgConfigureScopeVisNG* create(
|
2017-02-04 22:41:32 -05:00
|
|
|
uint32_t traceSize,
|
2017-02-25 22:55:15 -05:00
|
|
|
uint32_t timeBase,
|
2017-02-05 20:40:31 -05:00
|
|
|
uint32_t timeOfsProMill,
|
2017-02-07 12:50:08 -05:00
|
|
|
uint32_t triggerPre,
|
2017-02-05 20:40:31 -05:00
|
|
|
bool freeRun)
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
2017-02-25 22:55:15 -05:00
|
|
|
return new MsgConfigureScopeVisNG(traceSize, timeBase, timeOfsProMill, triggerPre, freeRun);
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
|
|
|
|
2017-01-31 02:26:13 -05:00
|
|
|
uint32_t getTraceSize() const { return m_traceSize; }
|
2017-02-25 22:55:15 -05:00
|
|
|
uint32_t getTimeBase() const { return m_timeBase; }
|
2017-02-04 22:41:32 -05:00
|
|
|
uint32_t getTimeOfsProMill() const { return m_timeOfsProMill; }
|
2017-02-07 12:50:08 -05:00
|
|
|
uint32_t getTriggerPre() const { return m_triggerPre; }
|
2017-02-05 20:40:31 -05:00
|
|
|
bool getFreeRun() const { return m_freeRun; }
|
2017-01-31 02:26:13 -05:00
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
private:
|
|
|
|
uint32_t m_traceSize;
|
2017-02-25 22:55:15 -05:00
|
|
|
uint32_t m_timeBase;
|
2017-02-04 22:41:32 -05:00
|
|
|
uint32_t m_timeOfsProMill;
|
2017-02-07 12:50:08 -05:00
|
|
|
uint32_t m_triggerPre;
|
2017-02-05 20:40:31 -05:00
|
|
|
bool m_freeRun;
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-04 22:41:32 -05:00
|
|
|
MsgConfigureScopeVisNG(uint32_t traceSize,
|
2017-02-25 22:55:15 -05:00
|
|
|
uint32_t timeBase,
|
2017-02-05 20:40:31 -05:00
|
|
|
uint32_t timeOfsProMill,
|
2017-02-07 12:50:08 -05:00
|
|
|
uint32_t triggerPre,
|
2017-02-05 20:40:31 -05:00
|
|
|
bool freeRun) :
|
2017-02-04 22:41:32 -05:00
|
|
|
m_traceSize(traceSize),
|
2017-02-25 22:55:15 -05:00
|
|
|
m_timeBase(timeBase),
|
2017-02-05 20:40:31 -05:00
|
|
|
m_timeOfsProMill(timeOfsProMill),
|
2017-02-07 12:50:08 -05:00
|
|
|
m_triggerPre(triggerPre),
|
2017-02-05 20:40:31 -05:00
|
|
|
m_freeRun(freeRun)
|
2017-01-29 13:51:45 -05:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-01-29 16:52:38 -05:00
|
|
|
// ---------------------------------------------
|
2017-01-29 13:51:45 -05:00
|
|
|
class MsgScopeVisNGAddTrigger : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGAddTrigger* create(
|
2017-01-29 18:36:27 -05:00
|
|
|
const TriggerData& triggerData)
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
2017-01-29 18:36:27 -05:00
|
|
|
return new MsgScopeVisNGAddTrigger(triggerData);
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
|
|
|
|
2017-02-03 02:27:03 -05:00
|
|
|
const TriggerData& getTriggerData() const { return m_triggerData; }
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
private:
|
2017-01-29 18:36:27 -05:00
|
|
|
TriggerData m_triggerData;
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-01-29 18:36:27 -05:00
|
|
|
MsgScopeVisNGAddTrigger(const TriggerData& triggerData) :
|
|
|
|
m_triggerData(triggerData)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGChangeTrigger : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGChangeTrigger* create(
|
|
|
|
const TriggerData& triggerData, uint32_t triggerIndex)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGChangeTrigger(triggerData, triggerIndex);
|
|
|
|
}
|
|
|
|
|
2017-02-03 02:27:03 -05:00
|
|
|
const TriggerData& getTriggerData() const { return m_triggerData; }
|
|
|
|
uint32_t getTriggerIndex() const { return m_triggerIndex; }
|
|
|
|
|
2017-01-29 18:36:27 -05:00
|
|
|
private:
|
|
|
|
TriggerData m_triggerData;
|
|
|
|
uint32_t m_triggerIndex;
|
|
|
|
|
|
|
|
MsgScopeVisNGChangeTrigger(const TriggerData& triggerData, uint32_t triggerIndex) :
|
|
|
|
m_triggerData(triggerData),
|
|
|
|
m_triggerIndex(triggerIndex)
|
2017-01-29 13:51:45 -05:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-01-29 16:52:38 -05:00
|
|
|
// ---------------------------------------------
|
2017-01-29 13:51:45 -05:00
|
|
|
class MsgScopeVisNGRemoveTrigger : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGRemoveTrigger* create(
|
|
|
|
uint32_t triggerIndex)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGRemoveTrigger(triggerIndex);
|
|
|
|
}
|
|
|
|
|
2017-02-03 02:27:03 -05:00
|
|
|
uint32_t getTriggerIndex() const { return m_triggerIndex; }
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
private:
|
|
|
|
uint32_t m_triggerIndex;
|
|
|
|
|
|
|
|
MsgScopeVisNGRemoveTrigger(uint32_t triggerIndex) :
|
2017-01-31 02:26:13 -05:00
|
|
|
m_triggerIndex(triggerIndex)
|
2017-01-29 13:51:45 -05:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-02-26 05:26:23 -05:00
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGMoveTrigger : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGMoveTrigger* create(
|
|
|
|
uint32_t triggerIndex,
|
|
|
|
bool moveUpElseDown)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGMoveTrigger(triggerIndex, moveUpElseDown);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getTriggerIndex() const { return m_triggerIndex; }
|
|
|
|
bool getMoveUp() const { return m_moveUpElseDown; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t m_triggerIndex;
|
|
|
|
bool m_moveUpElseDown;
|
|
|
|
|
|
|
|
MsgScopeVisNGMoveTrigger(uint32_t triggerIndex, bool moveUpElseDown) :
|
|
|
|
m_triggerIndex(triggerIndex),
|
|
|
|
m_moveUpElseDown(moveUpElseDown)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-02-11 04:36:10 -05:00
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGFocusOnTrigger : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGFocusOnTrigger* create(
|
|
|
|
uint32_t triggerIndex)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGFocusOnTrigger(triggerIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getTriggerIndex() const { return m_triggerIndex; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t m_triggerIndex;
|
|
|
|
|
|
|
|
MsgScopeVisNGFocusOnTrigger(uint32_t triggerIndex) :
|
|
|
|
m_triggerIndex(triggerIndex)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-01-29 18:36:27 -05:00
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGAddTrace : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGAddTrace* create(
|
|
|
|
const TraceData& traceData)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGAddTrace(traceData);
|
|
|
|
}
|
|
|
|
|
2017-02-03 02:27:03 -05:00
|
|
|
const TraceData& getTraceData() const { return m_traceData; }
|
|
|
|
|
2017-01-29 18:36:27 -05:00
|
|
|
private:
|
|
|
|
TraceData m_traceData;
|
|
|
|
|
|
|
|
MsgScopeVisNGAddTrace(const TraceData& traceData) :
|
|
|
|
m_traceData(traceData)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGChangeTrace : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGChangeTrace* create(
|
|
|
|
const TraceData& traceData, uint32_t traceIndex)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGChangeTrace(traceData, traceIndex);
|
|
|
|
}
|
|
|
|
|
2017-02-03 02:27:03 -05:00
|
|
|
const TraceData& getTraceData() const { return m_traceData; }
|
|
|
|
uint32_t getTraceIndex() const { return m_traceIndex; }
|
|
|
|
|
2017-01-29 18:36:27 -05:00
|
|
|
private:
|
|
|
|
TraceData m_traceData;
|
|
|
|
uint32_t m_traceIndex;
|
|
|
|
|
|
|
|
MsgScopeVisNGChangeTrace(TraceData traceData, uint32_t traceIndex) :
|
|
|
|
m_traceData(traceData),
|
|
|
|
m_traceIndex(traceIndex)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGRemoveTrace : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGRemoveTrace* create(
|
|
|
|
uint32_t traceIndex)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGRemoveTrace(traceIndex);
|
|
|
|
}
|
|
|
|
|
2017-02-03 02:27:03 -05:00
|
|
|
uint32_t getTraceIndex() const { return m_traceIndex; }
|
|
|
|
|
2017-01-29 18:36:27 -05:00
|
|
|
private:
|
|
|
|
uint32_t m_traceIndex;
|
|
|
|
|
|
|
|
MsgScopeVisNGRemoveTrace(uint32_t traceIndex) :
|
|
|
|
m_traceIndex(traceIndex)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-02-26 05:26:23 -05:00
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGMoveTrace : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGMoveTrace* create(
|
|
|
|
uint32_t traceIndex,
|
|
|
|
bool moveUpElseDown)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGMoveTrace(traceIndex, moveUpElseDown);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getTraceIndex() const { return m_traceIndex; }
|
|
|
|
bool getMoveUp() const { return m_moveUpElseDown; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t m_traceIndex;
|
|
|
|
bool m_moveUpElseDown;
|
|
|
|
|
|
|
|
MsgScopeVisNGMoveTrace(uint32_t traceIndex, bool moveUpElseDown) :
|
|
|
|
m_traceIndex(traceIndex),
|
|
|
|
m_moveUpElseDown(moveUpElseDown)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-02-12 19:32:02 -05:00
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGFocusOnTrace : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGFocusOnTrace* create(
|
|
|
|
uint32_t traceIndex)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGFocusOnTrace(traceIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getTraceIndex() const { return m_traceIndex; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t m_traceIndex;
|
|
|
|
|
|
|
|
MsgScopeVisNGFocusOnTrace(uint32_t traceIndex) :
|
|
|
|
m_traceIndex(traceIndex)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-02-21 19:18:50 -05:00
|
|
|
// ---------------------------------------------
|
|
|
|
class MsgScopeVisNGOneShot : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGOneShot* create(
|
|
|
|
bool oneShot)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGOneShot(oneShot);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getOneShot() const { return m_oneShot; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_oneShot;
|
|
|
|
|
|
|
|
MsgScopeVisNGOneShot(bool oneShot) :
|
|
|
|
m_oneShot(oneShot)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2017-01-29 16:52:38 -05:00
|
|
|
// ---------------------------------------------
|
2017-02-23 02:18:03 -05:00
|
|
|
class MsgScopeVisNGMemoryTrace : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
static MsgScopeVisNGMemoryTrace* create(
|
|
|
|
uint32_t memoryIndex)
|
|
|
|
{
|
|
|
|
return new MsgScopeVisNGMemoryTrace(memoryIndex);
|
|
|
|
}
|
|
|
|
|
2017-02-24 17:24:47 -05:00
|
|
|
uint32_t getMemoryIndex() const { return m_memoryIndex; }
|
2017-02-23 02:18:03 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t m_memoryIndex;
|
|
|
|
|
|
|
|
MsgScopeVisNGMemoryTrace(uint32_t memoryIndex) :
|
|
|
|
m_memoryIndex(memoryIndex)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-02-01 12:31:16 -05:00
|
|
|
/**
|
|
|
|
* Trigger stuff
|
|
|
|
*/
|
2017-01-29 13:51:45 -05:00
|
|
|
enum TriggerState
|
2017-01-31 02:26:13 -05:00
|
|
|
{
|
|
|
|
TriggerUntriggered, //!< Trigger is not kicked off yet (or trigger list is empty)
|
|
|
|
TriggerTriggered, //!< Trigger has been kicked off
|
|
|
|
TriggerDelay, //!< Trigger conditions have been kicked off but it is waiting for delay before final kick off
|
|
|
|
TriggerNewConfig, //!< Special condition when a new configuration has been received
|
|
|
|
};
|
2017-01-29 13:51:45 -05:00
|
|
|
|
|
|
|
struct TriggerCondition
|
|
|
|
{
|
|
|
|
public:
|
2017-02-13 16:52:42 -05:00
|
|
|
Projector m_projector;
|
2017-01-31 02:26:13 -05:00
|
|
|
TriggerData m_triggerData; //!< Trigger data
|
2017-01-29 13:51:45 -05:00
|
|
|
bool m_prevCondition; //!< Condition (above threshold) at previous sample
|
|
|
|
uint32_t m_triggerDelayCount; //!< Counter of samples for delay
|
2017-01-29 18:07:20 -05:00
|
|
|
uint32_t m_triggerCounter; //!< Counter of trigger occurences
|
2017-01-29 13:51:45 -05:00
|
|
|
|
2017-01-31 02:26:13 -05:00
|
|
|
TriggerCondition(const TriggerData& triggerData) :
|
2018-04-03 12:51:21 -04:00
|
|
|
m_projector(Projector::ProjectionReal),
|
2017-01-31 02:26:13 -05:00
|
|
|
m_triggerData(triggerData),
|
|
|
|
m_prevCondition(false),
|
2017-01-29 13:51:45 -05:00
|
|
|
m_triggerDelayCount(0),
|
2017-01-29 18:07:20 -05:00
|
|
|
m_triggerCounter(0)
|
2017-01-31 02:26:13 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-04 22:41:32 -05:00
|
|
|
~TriggerCondition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-09 20:45:49 -05:00
|
|
|
void initProjector()
|
2017-02-04 22:41:32 -05:00
|
|
|
{
|
2017-02-13 16:52:42 -05:00
|
|
|
m_projector.settProjectionType(m_triggerData.m_projectionType);
|
2017-02-04 22:41:32 -05:00
|
|
|
}
|
2017-01-31 02:26:13 -05:00
|
|
|
|
2017-02-09 20:45:49 -05:00
|
|
|
void releaseProjector()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-31 02:26:13 -05:00
|
|
|
void setData(const TriggerData& triggerData)
|
|
|
|
{
|
|
|
|
m_triggerData = triggerData;
|
|
|
|
|
2017-02-13 16:52:42 -05:00
|
|
|
if (m_projector.getProjectionType() != m_triggerData.m_projectionType)
|
2017-01-31 02:26:13 -05:00
|
|
|
{
|
2017-02-13 16:52:42 -05:00
|
|
|
m_projector.settProjectionType(m_triggerData.m_projectionType);
|
2017-01-31 02:26:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_prevCondition = false;
|
|
|
|
m_triggerDelayCount = 0;
|
|
|
|
m_triggerCounter = 0;
|
|
|
|
}
|
2017-02-26 13:14:27 -05:00
|
|
|
|
|
|
|
void operator=(const TriggerCondition& other)
|
|
|
|
{
|
|
|
|
setData(other.m_triggerData);
|
|
|
|
}
|
2017-01-29 13:51:45 -05:00
|
|
|
};
|
|
|
|
|
2017-02-01 12:31:16 -05:00
|
|
|
/**
|
|
|
|
* Complex trace stuff
|
|
|
|
*/
|
|
|
|
typedef DoubleBufferSimple<Sample> TraceBuffer;
|
|
|
|
|
|
|
|
struct TraceBackBuffer
|
|
|
|
{
|
|
|
|
TraceBuffer m_traceBuffer;
|
|
|
|
SampleVector::iterator m_endPoint;
|
|
|
|
|
|
|
|
TraceBackBuffer()
|
|
|
|
{
|
|
|
|
m_endPoint = m_traceBuffer.getCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void resize(uint32_t size)
|
|
|
|
{
|
|
|
|
m_traceBuffer.resize(size);
|
|
|
|
}
|
|
|
|
|
2017-02-02 02:27:49 -05:00
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
m_traceBuffer.reset();
|
|
|
|
}
|
|
|
|
|
2017-02-01 12:31:16 -05:00
|
|
|
void write(const SampleVector::const_iterator begin, const SampleVector::const_iterator end)
|
|
|
|
{
|
|
|
|
m_traceBuffer.write(begin, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int absoluteFill() const {
|
|
|
|
return m_traceBuffer.absoluteFill();
|
|
|
|
}
|
|
|
|
|
|
|
|
SampleVector::iterator current() { return m_traceBuffer.getCurrent(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TraceBackDiscreteMemory
|
|
|
|
{
|
|
|
|
std::vector<TraceBackBuffer> m_traceBackBuffers;
|
|
|
|
uint32_t m_memSize;
|
|
|
|
uint32_t m_currentMemIndex;
|
2017-02-05 20:40:31 -05:00
|
|
|
uint32_t m_traceSize;
|
2017-02-01 12:31:16 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Give memory size in number of traces
|
|
|
|
*/
|
2017-02-05 20:40:31 -05:00
|
|
|
TraceBackDiscreteMemory(uint32_t size) : m_memSize(size), m_currentMemIndex(0), m_traceSize(0)
|
2017-02-01 12:31:16 -05:00
|
|
|
{
|
|
|
|
m_traceBackBuffers.resize(m_memSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resize all trace buffers in memory
|
|
|
|
*/
|
|
|
|
void resize(uint32_t size)
|
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
m_traceSize = size;
|
|
|
|
|
2017-02-01 12:31:16 -05:00
|
|
|
for (std::vector<TraceBackBuffer>::iterator it = m_traceBackBuffers.begin(); it != m_traceBackBuffers.end(); ++it)
|
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
it->resize(4*m_traceSize);
|
2017-02-01 12:31:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move index forward by one position and return reference to the trace at this position
|
2017-02-05 20:40:31 -05:00
|
|
|
* Copy a trace length of samples into the new memory slot
|
2017-02-01 12:31:16 -05:00
|
|
|
*/
|
|
|
|
TraceBackBuffer &store()
|
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
uint32_t nextMemIndex = m_currentMemIndex < (m_memSize-1) ? m_currentMemIndex+1 : 0;
|
|
|
|
m_traceBackBuffers[nextMemIndex].reset();
|
|
|
|
m_traceBackBuffers[nextMemIndex].write(m_traceBackBuffers[m_currentMemIndex].m_endPoint - m_traceSize,
|
|
|
|
m_traceBackBuffers[m_currentMemIndex].m_endPoint);
|
|
|
|
m_currentMemIndex = nextMemIndex;
|
2017-02-01 12:31:16 -05:00
|
|
|
return m_traceBackBuffers[m_currentMemIndex]; // new trace
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recalls trace at shift positions back. Therefore 0 is current. Wraps around memory size.
|
|
|
|
*/
|
|
|
|
TraceBackBuffer& recall(uint32_t shift)
|
|
|
|
{
|
|
|
|
int index = (m_currentMemIndex + (m_memSize - (shift % m_memSize))) % m_memSize;
|
|
|
|
return m_traceBackBuffers[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return trace at current memory position
|
|
|
|
*/
|
|
|
|
TraceBackBuffer& current()
|
|
|
|
{
|
|
|
|
return m_traceBackBuffers[m_currentMemIndex];
|
|
|
|
}
|
2017-02-05 20:40:31 -05:00
|
|
|
|
2017-02-24 02:31:25 -05:00
|
|
|
/**
|
|
|
|
* Return trace at given memory position
|
|
|
|
*/
|
|
|
|
TraceBackBuffer& at(int index)
|
|
|
|
{
|
|
|
|
return m_traceBackBuffers[index];
|
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
/**
|
|
|
|
* Return current memory index
|
|
|
|
*/
|
|
|
|
uint32_t currentIndex() const { return m_currentMemIndex; }
|
2017-02-01 12:31:16 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displayable trace stuff
|
|
|
|
*/
|
2017-02-05 20:40:31 -05:00
|
|
|
struct TraceControl
|
2017-01-29 13:51:45 -05:00
|
|
|
{
|
2017-05-25 14:13:34 -04:00
|
|
|
Projector m_projector; //!< Projector transform from complex trace to real (displayable) trace
|
|
|
|
uint32_t m_traceCount[2]; //!< Count of samples processed (double buffered)
|
|
|
|
Real m_maxPow; //!< Maximum power over the current trace for MagDB overlay display
|
|
|
|
Real m_sumPow; //!< Cumulative power over the current trace for MagDB overlay display
|
|
|
|
int m_nbPow; //!< Number of power samples over the current trace for MagDB overlay display
|
2017-01-31 02:26:13 -05:00
|
|
|
|
2018-04-03 12:51:21 -04:00
|
|
|
TraceControl() : m_projector(Projector::ProjectionReal)
|
2017-01-31 02:26:13 -05:00
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
reset();
|
2017-01-31 02:26:13 -05:00
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
~TraceControl()
|
2017-01-31 02:26:13 -05:00
|
|
|
{
|
2017-02-04 22:41:32 -05:00
|
|
|
}
|
|
|
|
|
2018-04-03 12:51:21 -04:00
|
|
|
void initProjector(Projector::ProjectionType projectionType)
|
2017-02-05 20:40:31 -05:00
|
|
|
{
|
2017-02-13 16:52:42 -05:00
|
|
|
m_projector.settProjectionType(projectionType);
|
2017-02-05 20:40:31 -05:00
|
|
|
}
|
|
|
|
|
2017-02-10 12:28:19 -05:00
|
|
|
void releaseProjector()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
m_traceCount[0] = 0;
|
|
|
|
m_traceCount[1] = 0;
|
2017-02-25 22:46:02 -05:00
|
|
|
m_maxPow = 0.0f;
|
|
|
|
m_sumPow = 0.0f;
|
|
|
|
m_nbPow = 0;
|
2017-02-05 20:40:31 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Traces
|
|
|
|
{
|
|
|
|
std::vector<TraceControl> m_tracesControl; //!< Corresponding traces control data
|
|
|
|
std::vector<TraceData> m_tracesData; //!< Corresponding traces data
|
|
|
|
std::vector<float *> m_traces[2]; //!< Double buffer of traces processed by glScope
|
|
|
|
int m_traceSize; //!< Current size of a trace in buffer
|
|
|
|
int m_maxTraceSize; //!< Maximum Size of a trace in buffer
|
|
|
|
bool evenOddIndex; //!< Even (true) or odd (false) index
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
Traces() :
|
|
|
|
m_traceSize(0),
|
|
|
|
m_maxTraceSize(0),
|
|
|
|
evenOddIndex(true),
|
|
|
|
m_x0(0),
|
|
|
|
m_x1(0)
|
2017-02-15 19:06:15 -05:00
|
|
|
{
|
|
|
|
}
|
2017-02-05 20:40:31 -05:00
|
|
|
|
|
|
|
~Traces()
|
|
|
|
{
|
2017-02-15 19:06:15 -05:00
|
|
|
if (m_x0) delete[] m_x0;
|
|
|
|
if (m_x1) delete[] m_x1;
|
|
|
|
m_maxTraceSize = 0;
|
2017-02-05 20:40:31 -05:00
|
|
|
}
|
|
|
|
|
2017-02-10 12:28:19 -05:00
|
|
|
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)
|
2017-02-11 20:12:06 -05:00
|
|
|
|| (m_tracesData[traceIndex].m_ofs != traceData.m_ofs
|
|
|
|
|| (m_tracesData[traceIndex].m_traceColor != traceData.m_traceColor));
|
2017-02-10 12:28:19 -05:00
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
void addTrace(const TraceData& traceData, int traceSize)
|
2017-02-04 22:41:32 -05:00
|
|
|
{
|
2017-02-15 19:06:15 -05:00
|
|
|
if (m_traces[0].size() < m_maxNbTraces)
|
|
|
|
{
|
|
|
|
m_traces[0].push_back(0);
|
|
|
|
m_traces[1].push_back(0);
|
|
|
|
m_tracesData.push_back(traceData);
|
|
|
|
m_tracesControl.push_back(TraceControl());
|
|
|
|
m_tracesControl.back().initProjector(traceData.m_projectionType);
|
2017-02-05 20:40:31 -05:00
|
|
|
|
2017-02-15 19:06:15 -05:00
|
|
|
resize(traceSize);
|
|
|
|
}
|
2017-01-31 02:26:13 -05:00
|
|
|
}
|
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
void changeTrace(const TraceData& traceData, uint32_t traceIndex)
|
2017-01-31 02:26:13 -05:00
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
if (traceIndex < m_tracesControl.size()) {
|
2017-02-10 12:28:19 -05:00
|
|
|
m_tracesControl[traceIndex].releaseProjector();
|
|
|
|
m_tracesControl[traceIndex].initProjector(traceData.m_projectionType);
|
2017-02-05 20:40:31 -05:00
|
|
|
m_tracesData[traceIndex] = traceData;
|
|
|
|
}
|
|
|
|
}
|
2017-01-31 02:26:13 -05:00
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
void removeTrace(uint32_t traceIndex)
|
|
|
|
{
|
|
|
|
if (traceIndex < m_tracesControl.size())
|
2017-01-31 02:26:13 -05:00
|
|
|
{
|
2017-02-15 19:06:15 -05:00
|
|
|
m_traces[0].erase(m_traces[0].begin() + traceIndex);
|
|
|
|
m_traces[1].erase(m_traces[1].begin() + traceIndex);
|
2017-02-10 12:28:19 -05:00
|
|
|
m_tracesControl[traceIndex].releaseProjector();
|
2017-02-05 20:40:31 -05:00
|
|
|
m_tracesControl.erase(m_tracesControl.begin() + traceIndex);
|
|
|
|
m_tracesData.erase(m_tracesData.begin() + traceIndex);
|
2017-02-15 19:06:15 -05:00
|
|
|
|
|
|
|
resize(m_traceSize); // reallocate pointers
|
2017-01-31 02:26:13 -05:00
|
|
|
}
|
2017-02-26 05:26:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void moveTrace(uint32_t traceIndex, bool upElseDown)
|
|
|
|
{
|
|
|
|
if ((!upElseDown) && (traceIndex == 0)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nextControlIndex = (traceIndex + (upElseDown ? 1 : -1)) % (m_tracesControl.size());
|
|
|
|
int nextDataIndex = (traceIndex + (upElseDown ? 1 : -1)) % (m_tracesData.size()); // should be the same
|
|
|
|
|
|
|
|
m_tracesControl[traceIndex].releaseProjector();
|
|
|
|
m_tracesControl[nextControlIndex].releaseProjector();
|
|
|
|
|
|
|
|
TraceControl nextControl = m_tracesControl[nextControlIndex];
|
|
|
|
m_tracesControl[nextControlIndex] = m_tracesControl[traceIndex];
|
|
|
|
m_tracesControl[traceIndex] = nextControl;
|
|
|
|
|
|
|
|
TraceData nextData = m_tracesData[nextDataIndex];
|
|
|
|
m_tracesData[nextDataIndex] = m_tracesData[traceIndex];
|
|
|
|
m_tracesData[traceIndex] = nextData;
|
2017-02-15 19:06:15 -05:00
|
|
|
|
2017-02-26 05:26:23 -05:00
|
|
|
m_tracesControl[traceIndex].initProjector(m_tracesData[traceIndex].m_projectionType);
|
|
|
|
m_tracesControl[nextControlIndex].initProjector(m_tracesData[nextDataIndex].m_projectionType);
|
2017-01-31 02:26:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void resize(int traceSize)
|
|
|
|
{
|
|
|
|
m_traceSize = traceSize;
|
|
|
|
|
|
|
|
if (m_traceSize > m_maxTraceSize)
|
|
|
|
{
|
2017-02-15 19:06:15 -05:00
|
|
|
delete[] m_x0;
|
|
|
|
delete[] m_x1;
|
|
|
|
m_x0 = new float[2*m_traceSize*m_maxNbTraces];
|
|
|
|
m_x1 = new float[2*m_traceSize*m_maxNbTraces];
|
2017-02-05 20:40:31 -05:00
|
|
|
|
2017-01-31 02:26:13 -05:00
|
|
|
m_maxTraceSize = m_traceSize;
|
|
|
|
}
|
2017-02-15 19:06:15 -05:00
|
|
|
|
|
|
|
std::fill_n(m_x0, 2*m_traceSize*m_traces[0].size(), 0.0f);
|
|
|
|
std::fill_n(m_x1, 2*m_traceSize*m_traces[0].size(), 0.0f);
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
for (unsigned int i = 0; i < m_traces[0].size(); i++)
|
2017-02-15 19:06:15 -05:00
|
|
|
{
|
|
|
|
(m_traces[0])[i] = &m_x0[2*m_traceSize*i];
|
|
|
|
(m_traces[1])[i] = &m_x1[2*m_traceSize*i];
|
|
|
|
}
|
2017-01-31 02:26:13 -05:00
|
|
|
}
|
2017-02-02 02:27:49 -05:00
|
|
|
|
2017-02-05 20:40:31 -05:00
|
|
|
uint32_t currentBufferIndex() const { return evenOddIndex? 0 : 1; }
|
|
|
|
uint32_t size() const { return m_tracesControl.size(); }
|
|
|
|
|
|
|
|
void switchBuffer()
|
2017-02-02 02:27:49 -05:00
|
|
|
{
|
2017-02-05 20:40:31 -05:00
|
|
|
evenOddIndex = !evenOddIndex;
|
|
|
|
|
|
|
|
for (std::vector<TraceControl>::iterator it = m_tracesControl.begin(); it != m_tracesControl.end(); ++it)
|
|
|
|
{
|
|
|
|
it->m_traceCount[currentBufferIndex()] = 0;
|
|
|
|
}
|
2017-02-02 02:27:49 -05:00
|
|
|
}
|
2017-02-15 19:06:15 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
float *m_x0;
|
|
|
|
float *m_x1;
|
2017-01-29 13:51:45 -05:00
|
|
|
};
|
|
|
|
|
2017-02-07 20:13:53 -05:00
|
|
|
class TriggerComparator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TriggerComparator() : m_level(0), m_reset(true)
|
|
|
|
{
|
|
|
|
computeLevels();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool triggered(const Sample& s, TriggerCondition& triggerCondition)
|
|
|
|
{
|
|
|
|
if (triggerCondition.m_triggerData.m_triggerLevel != m_level)
|
|
|
|
{
|
|
|
|
m_level = triggerCondition.m_triggerData.m_triggerLevel;
|
|
|
|
computeLevels();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool condition, trigger;
|
|
|
|
|
2018-04-03 12:51:21 -04:00
|
|
|
if (triggerCondition.m_projector.getProjectionType() == Projector::ProjectionMagDB) {
|
2017-02-13 16:52:42 -05:00
|
|
|
condition = triggerCondition.m_projector.run(s) > m_levelPowerDB;
|
2018-04-03 12:51:21 -04:00
|
|
|
} else if (triggerCondition.m_projector.getProjectionType() == Projector::ProjectionMagLin) {
|
2017-02-13 16:52:42 -05:00
|
|
|
condition = triggerCondition.m_projector.run(s) > m_levelPowerLin;
|
2017-02-07 20:13:53 -05:00
|
|
|
} else {
|
2017-02-13 16:52:42 -05:00
|
|
|
condition = triggerCondition.m_projector.run(s) > m_level;
|
2017-02-07 20:13:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_reset)
|
|
|
|
{
|
|
|
|
triggerCondition.m_prevCondition = condition;
|
|
|
|
m_reset = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (triggerCondition.m_triggerData.m_triggerBothEdges) {
|
|
|
|
trigger = triggerCondition.m_prevCondition ? !condition : condition; // This is a XOR between bools
|
|
|
|
} else if (triggerCondition.m_triggerData.m_triggerPositiveEdge) {
|
|
|
|
trigger = !triggerCondition.m_prevCondition && condition;
|
|
|
|
} else {
|
|
|
|
trigger = triggerCondition.m_prevCondition && !condition;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (trigger) {
|
|
|
|
// qDebug("ScopeVisNG::triggered: %s/%s %f/%f",
|
|
|
|
// triggerCondition.m_prevCondition ? "T" : "F",
|
|
|
|
// condition ? "T" : "F",
|
|
|
|
// triggerCondition.m_projector->run(s),
|
|
|
|
// triggerCondition.m_triggerData.m_triggerLevel);
|
|
|
|
// }
|
|
|
|
|
|
|
|
triggerCondition.m_prevCondition = condition;
|
|
|
|
return trigger;
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
m_reset = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void computeLevels()
|
|
|
|
{
|
|
|
|
m_levelPowerLin = m_level + 1.0f;
|
2017-02-11 02:35:33 -05:00
|
|
|
m_levelPowerDB = (100.0f * (m_level - 1.0f));
|
2017-02-07 20:13:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Real m_level;
|
2017-02-11 02:35:33 -05:00
|
|
|
Real m_levelPowerDB;
|
2017-02-07 20:13:53 -05:00
|
|
|
Real m_levelPowerLin;
|
|
|
|
bool m_reset;
|
|
|
|
};
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
GLScopeNG* m_glScope;
|
2017-02-07 12:50:08 -05:00
|
|
|
uint32_t m_preTriggerDelay; //!< Pre-trigger delay in number of samples
|
2017-01-29 13:51:45 -05:00
|
|
|
std::vector<TriggerCondition> m_triggerConditions; //!< Chain of triggers
|
2017-05-25 14:13:34 -04:00
|
|
|
uint32_t m_currentTriggerIndex; //!< Index of current index in the chain
|
|
|
|
uint32_t m_focusedTriggerIndex; //!< Index of the trigger that has focus
|
2017-02-01 12:31:16 -05:00
|
|
|
TriggerState m_triggerState; //!< Current trigger state
|
2017-02-05 20:40:31 -05:00
|
|
|
Traces m_traces; //!< Displayable traces
|
2017-02-12 19:32:02 -05:00
|
|
|
int m_focusedTraceIndex; //!< Index of the trace that has focus
|
2017-05-25 14:13:34 -04:00
|
|
|
uint32_t m_traceSize; //!< Size of traces in number of samples
|
2017-02-08 19:58:54 -05:00
|
|
|
int m_nbSamples; //!< Number of samples yet to process in one complex trace
|
2017-05-25 14:13:34 -04:00
|
|
|
uint32_t m_timeBase; //!< Trace display time divisor
|
|
|
|
uint32_t m_timeOfsProMill; //!< Start trace shift in 1/1000 trace size
|
2017-02-01 12:31:16 -05:00
|
|
|
bool m_traceStart; //!< Trace is at start point
|
|
|
|
SampleVector::const_iterator m_triggerPoint; //!< Trigger start location in the samples vector
|
2017-01-29 16:52:38 -05:00
|
|
|
int m_sampleRate;
|
2017-02-01 12:31:16 -05:00
|
|
|
TraceBackDiscreteMemory m_traceDiscreteMemory; //!< Complex trace memory for triggered states TODO: vectorize when more than on input is allowed
|
2017-02-05 20:40:31 -05:00
|
|
|
bool m_freeRun; //!< True if free running (trigger globally disabled)
|
|
|
|
int m_maxTraceDelay; //!< Maximum trace delay
|
2017-02-07 20:13:53 -05:00
|
|
|
TriggerComparator m_triggerComparator; //!< Compares sample level to trigger level
|
2017-02-12 21:23:29 -05:00
|
|
|
QMutex m_mutex;
|
2018-04-03 12:51:21 -04:00
|
|
|
Real m_projectorCache[(int) Projector::nbProjectionTypes];
|
2017-02-21 19:18:50 -05:00
|
|
|
bool m_triggerOneShot; //!< True when one shot mode is active
|
|
|
|
bool m_triggerWaitForReset; //!< In one shot mode suspended until reset by UI
|
2017-02-24 02:31:25 -05:00
|
|
|
uint32_t m_currentTraceMemoryIndex; //!< The current index of trace in memory (0: current)
|
2017-02-07 12:50:08 -05:00
|
|
|
|
2017-02-02 12:18:37 -05:00
|
|
|
/**
|
|
|
|
* Moves on to the next trigger if any or increments trigger count if in repeat mode
|
|
|
|
* - If not final it returns true
|
|
|
|
* - If final i.e. signal is actually triggerd it returns false
|
|
|
|
*/
|
|
|
|
bool nextTrigger(); //!< Returns true if not final
|
|
|
|
|
2017-02-08 16:22:27 -05:00
|
|
|
/**
|
|
|
|
* Process a sample trace which length is at most the trace length (m_traceSize)
|
|
|
|
*/
|
2017-02-08 20:16:43 -05:00
|
|
|
void processTrace(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, int& triggerPointToEnd);
|
2017-02-08 16:22:27 -05:00
|
|
|
|
2017-02-24 02:31:25 -05:00
|
|
|
/**
|
|
|
|
* process a trace in memory at current trace index in memory
|
|
|
|
*/
|
|
|
|
void processMemoryTrace();
|
|
|
|
|
2017-02-02 12:18:37 -05:00
|
|
|
/**
|
|
|
|
* Process traces from complex trace memory buffer.
|
|
|
|
* - if finished it returns the number of unprocessed samples left in the buffer
|
|
|
|
* - if not finished it returns -1
|
|
|
|
*/
|
2017-02-08 18:11:10 -05:00
|
|
|
int processTraces(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool traceBack = false);
|
2017-02-05 20:40:31 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get maximum trace delay
|
|
|
|
*/
|
|
|
|
void updateMaxTraceDelay();
|
2017-02-04 22:41:32 -05:00
|
|
|
|
|
|
|
/**
|
2017-02-05 20:40:31 -05:00
|
|
|
* Initialize trace buffers
|
2017-02-04 22:41:32 -05:00
|
|
|
*/
|
2017-02-05 20:40:31 -05:00
|
|
|
void initTraceBuffers();
|
2017-02-10 12:28:19 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2017-02-11 02:35:33 -05:00
|
|
|
void computeDisplayTriggerLevels();
|
2017-02-24 22:35:06 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update glScope display
|
|
|
|
* - Live trace: call glScipe update method
|
|
|
|
* - Trace in memory: call process memory trace
|
|
|
|
*/
|
|
|
|
void updateGLScopeDisplay();
|
2017-01-29 13:51:45 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SDRBASE_DSP_SCOPEVISNG_H_ */
|