2014-05-18 15:52:39 +00:00
|
|
|
#ifndef INCLUDE_SCOPEVIS_H
|
|
|
|
#define INCLUDE_SCOPEVIS_H
|
|
|
|
|
2015-07-20 20:51:49 +00:00
|
|
|
#include <boost/circular_buffer.hpp>
|
2016-10-02 20:29:04 +00:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "util/export.h"
|
2015-07-13 08:46:51 +00:00
|
|
|
#include "util/message.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
class GLScope;
|
|
|
|
class MessageQueue;
|
|
|
|
|
2018-03-03 19:23:38 +00:00
|
|
|
class SDRGUI_API ScopeVis : public BasebandSampleSink {
|
2014-05-18 15:52:39 +00:00
|
|
|
public:
|
|
|
|
enum TriggerChannel {
|
|
|
|
TriggerFreeRun,
|
|
|
|
TriggerChannelI,
|
2015-07-13 08:46:51 +00:00
|
|
|
TriggerChannelQ,
|
|
|
|
TriggerMagLin,
|
|
|
|
TriggerMagDb,
|
2015-11-04 03:29:26 +00:00
|
|
|
TriggerPhase,
|
|
|
|
TriggerDPhase
|
2014-05-18 15:52:39 +00:00
|
|
|
};
|
|
|
|
|
2015-07-21 19:38:36 +00:00
|
|
|
static const uint m_traceChunkSize;
|
2015-11-04 02:10:05 +00:00
|
|
|
static const uint m_nbTriggers = 10;
|
2015-07-21 19:38:36 +00:00
|
|
|
|
2018-01-22 13:07:24 +00:00
|
|
|
ScopeVis(Real scalef, GLScope* glScope = 0);
|
2015-08-14 03:00:28 +00:00
|
|
|
virtual ~ScopeVis();
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-11-04 02:10:05 +00:00
|
|
|
void configure(MessageQueue* msgQueue,
|
|
|
|
uint triggerIndex,
|
2018-02-22 02:04:42 +00:00
|
|
|
TriggerChannel triggerChannel,
|
|
|
|
Real triggerLevel,
|
|
|
|
bool triggerPositiveEdge,
|
2015-07-23 04:52:12 +00:00
|
|
|
bool triggerBothEdges,
|
2015-07-23 02:58:27 +00:00
|
|
|
uint triggerPre,
|
2015-11-04 23:07:51 +00:00
|
|
|
uint triggerDelay,
|
|
|
|
uint triggerCounts,
|
2015-07-23 02:58:27 +00:00
|
|
|
uint traceSize);
|
2015-07-14 00:18:55 +00:00
|
|
|
void setOneShot(bool oneShot);
|
2016-04-01 02:42:47 +00:00
|
|
|
void blockTrigger(bool blecked);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-08-25 06:24:23 +00:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
2015-08-14 03:00:28 +00:00
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& message);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-07-06 23:17:16 +00:00
|
|
|
void setSampleRate(int sampleRate);
|
|
|
|
int getSampleRate() const { return m_sampleRate; }
|
2015-07-14 23:19:39 +00:00
|
|
|
SampleVector::const_iterator getTriggerPoint() const { return m_triggerPoint; }
|
2015-07-06 23:17:16 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
private:
|
2015-07-13 08:46:51 +00:00
|
|
|
class MsgConfigureScopeVis : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2015-11-04 02:10:05 +00:00
|
|
|
uint getTriggerIndex() const { return m_triggerIndex; }
|
2015-07-13 08:46:51 +00:00
|
|
|
int getTriggerChannel() const { return m_triggerChannel; }
|
|
|
|
Real getTriggerLevel() const { return m_triggerLevel; }
|
2018-02-22 02:04:42 +00:00
|
|
|
bool getTriggerPositiveEdge() const { return m_triggerPositiveEdge; }
|
|
|
|
bool getTriggerBothEdges() const { return m_triggerBothEdges; }
|
2015-07-21 20:18:17 +00:00
|
|
|
uint getTriggerPre() const { return m_triggerPre; }
|
2015-07-23 02:58:27 +00:00
|
|
|
uint getTriggerDelay() const { return m_triggerDelay; }
|
2015-11-04 23:07:51 +00:00
|
|
|
uint getTriggerCounts() const { return m_triggerCounts; }
|
2015-07-21 19:38:36 +00:00
|
|
|
uint getTraceSize() const { return m_traceSize; }
|
2015-07-13 08:46:51 +00:00
|
|
|
|
2015-11-04 02:10:05 +00:00
|
|
|
static MsgConfigureScopeVis* create(uint triggerIndex,
|
|
|
|
int triggerChannel,
|
2018-02-22 02:04:42 +00:00
|
|
|
Real triggerLevel,
|
|
|
|
bool triggerPositiveEdge,
|
2015-07-23 04:52:12 +00:00
|
|
|
bool triggerBothEdges,
|
2015-07-23 02:58:27 +00:00
|
|
|
uint triggerPre,
|
2015-11-04 23:07:51 +00:00
|
|
|
uint triggerDelay,
|
|
|
|
uint triggerCounts,
|
2015-07-23 02:58:27 +00:00
|
|
|
uint traceSize)
|
2015-07-13 08:46:51 +00:00
|
|
|
{
|
2015-11-04 02:10:05 +00:00
|
|
|
return new MsgConfigureScopeVis(triggerIndex,
|
|
|
|
triggerChannel,
|
2015-07-23 04:52:12 +00:00
|
|
|
triggerLevel,
|
|
|
|
triggerPositiveEdge,
|
|
|
|
triggerBothEdges,
|
|
|
|
triggerPre,
|
|
|
|
triggerDelay,
|
2015-11-04 23:07:51 +00:00
|
|
|
triggerCounts,
|
2015-07-23 04:52:12 +00:00
|
|
|
traceSize);
|
2015-07-13 08:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-11-04 02:10:05 +00:00
|
|
|
uint m_triggerIndex;
|
2015-07-13 08:46:51 +00:00
|
|
|
int m_triggerChannel;
|
|
|
|
Real m_triggerLevel;
|
|
|
|
bool m_triggerPositiveEdge;
|
2015-07-23 04:52:12 +00:00
|
|
|
bool m_triggerBothEdges;
|
2015-07-21 20:18:17 +00:00
|
|
|
uint m_triggerPre;
|
2015-07-23 02:58:27 +00:00
|
|
|
uint m_triggerDelay;
|
2015-11-04 23:07:51 +00:00
|
|
|
uint m_triggerCounts;
|
2015-07-21 19:38:36 +00:00
|
|
|
uint m_traceSize;
|
2015-07-13 08:46:51 +00:00
|
|
|
|
2015-11-04 02:10:05 +00:00
|
|
|
MsgConfigureScopeVis(uint triggerIndex,
|
|
|
|
int triggerChannel,
|
2018-02-22 02:04:42 +00:00
|
|
|
Real triggerLevel,
|
|
|
|
bool triggerPositiveEdge,
|
2015-07-23 04:52:12 +00:00
|
|
|
bool triggerBothEdges,
|
2015-07-23 02:58:27 +00:00
|
|
|
uint triggerPre,
|
|
|
|
uint triggerDelay,
|
2015-11-04 23:07:51 +00:00
|
|
|
uint triggerCounts,
|
2015-07-23 02:58:27 +00:00
|
|
|
uint traceSize) :
|
2015-07-13 08:46:51 +00:00
|
|
|
Message(),
|
2015-11-04 02:10:05 +00:00
|
|
|
m_triggerIndex(triggerIndex),
|
2015-07-13 08:46:51 +00:00
|
|
|
m_triggerChannel(triggerChannel),
|
|
|
|
m_triggerLevel(triggerLevel),
|
2015-07-20 20:51:49 +00:00
|
|
|
m_triggerPositiveEdge(triggerPositiveEdge),
|
2015-07-23 04:52:12 +00:00
|
|
|
m_triggerBothEdges(triggerBothEdges),
|
2015-07-21 20:18:17 +00:00
|
|
|
m_triggerPre(triggerPre),
|
2015-07-23 02:58:27 +00:00
|
|
|
m_triggerDelay(triggerDelay),
|
2015-11-04 23:07:51 +00:00
|
|
|
m_triggerCounts(triggerCounts),
|
2015-07-21 19:38:36 +00:00
|
|
|
m_traceSize(traceSize)
|
2015-07-13 08:46:51 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2015-07-23 02:58:27 +00:00
|
|
|
/**
|
2015-11-04 02:25:41 +00:00
|
|
|
* TriggerState: (repeat at each successive non freerun trigger)
|
2018-02-22 02:04:42 +00:00
|
|
|
*
|
2015-07-23 02:58:27 +00:00
|
|
|
* send a Trigger condition +--------------------+
|
|
|
|
* dummy trace - Immediate m_triggerOneShot | |
|
|
|
|
* Config -------------> Untriggered ----------------------------------> Triggered ----------------> WaitForReset |
|
|
|
|
* ^ ^ | ^ | | ^ |
|
|
|
|
* | | | - Delayed Delay expired | | | | setOneShot(true)|
|
|
|
|
* | | +---------------------> Delay ----------------+ | | +-----------------+
|
|
|
|
* | | !m_triggerOneShot | |
|
|
|
|
* | +--------------------------------------------------+ setOneShot(false) |
|
|
|
|
* +-------------------------------------------------------------------------------+
|
|
|
|
*/
|
2014-05-18 15:52:39 +00:00
|
|
|
enum TriggerState {
|
2015-07-23 02:58:27 +00:00
|
|
|
Untriggered, //!< Search for trigger
|
|
|
|
Config, //!< New configuration has just been received
|
|
|
|
Triggered, //!< Trigger was kicked off
|
|
|
|
WaitForReset, //!< Wait for release from GUI
|
|
|
|
Delay //!< Trigger delay engaged
|
2014-05-18 15:52:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GLScope* m_glScope;
|
2018-01-22 13:07:24 +00:00
|
|
|
Real m_scalef; //!< Sample scale factor from [-1,+1] to integer sample size range
|
2015-07-20 20:51:49 +00:00
|
|
|
std::vector<Complex> m_trace; //!< Raw trace to be used by GLScope
|
2015-07-21 19:38:36 +00:00
|
|
|
boost::circular_buffer<Complex> m_traceback; //!< FIFO for samples prior to triggering point to support pre-trigger (when in triggered mode)
|
|
|
|
uint m_tracebackCount; //!< Count of samples stored into trace memory since triggering is active up to trace memory size
|
2014-05-18 15:52:39 +00:00
|
|
|
uint m_fill;
|
|
|
|
TriggerState m_triggerState;
|
2015-11-04 02:10:05 +00:00
|
|
|
uint m_triggerIndex; //!< current active trigger index
|
|
|
|
TriggerChannel m_triggerChannel[m_nbTriggers];
|
|
|
|
Real m_triggerLevel[m_nbTriggers];
|
|
|
|
bool m_triggerPositiveEdge[m_nbTriggers];
|
|
|
|
bool m_triggerBothEdges[m_nbTriggers];
|
2015-07-23 04:52:12 +00:00
|
|
|
bool m_prevTrigger;
|
2015-07-23 02:58:27 +00:00
|
|
|
uint m_triggerPre; //!< Pre-trigger delay in number of samples
|
2015-07-14 00:18:55 +00:00
|
|
|
bool m_triggerOneShot;
|
2015-07-13 22:04:34 +00:00
|
|
|
bool m_armed;
|
2015-11-04 02:10:05 +00:00
|
|
|
uint m_triggerDelay[m_nbTriggers]; //!< Trigger delay in number of trace sizes
|
2015-07-23 02:58:27 +00:00
|
|
|
uint m_triggerDelayCount; //!< trace sizes delay counter
|
2015-11-04 23:07:51 +00:00
|
|
|
uint m_triggerCounts[m_nbTriggers]; //!< Number of trigger events before the actual trigger is kicked off
|
|
|
|
uint m_triggerCount;
|
2014-05-18 15:52:39 +00:00
|
|
|
int m_sampleRate;
|
2015-07-14 23:19:39 +00:00
|
|
|
SampleVector::const_iterator m_triggerPoint;
|
2015-11-04 03:29:26 +00:00
|
|
|
Real m_prevArg;
|
|
|
|
bool m_firstArg;
|
2015-07-13 21:38:10 +00:00
|
|
|
|
|
|
|
bool triggerCondition(SampleVector::const_iterator& it);
|
2015-11-04 02:25:41 +00:00
|
|
|
bool nextTrigger(); //!< move to next trigger. Returns true if next trigger is active.
|
2014-05-18 15:52:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_SCOPEVIS_H
|