1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-05 08:21:16 -05:00
sdrangel/include-gpl/dsp/scopevis.h

148 lines
5.2 KiB
C
Raw Normal View History

#ifndef INCLUDE_SCOPEVIS_H
#define INCLUDE_SCOPEVIS_H
2015-07-20 16:51:49 -04:00
#include <boost/circular_buffer.hpp>
#include "dsp/samplesink.h"
#include "util/export.h"
2015-07-13 04:46:51 -04:00
#include "util/message.h"
class GLScope;
class MessageQueue;
2015-08-29 19:26:51 -04:00
class SDRANGEL_API ScopeVis : public SampleSink {
public:
enum TriggerChannel {
TriggerFreeRun,
TriggerChannelI,
2015-07-13 04:46:51 -04:00
TriggerChannelQ,
TriggerMagLin,
TriggerMagDb,
TriggerPhase
};
2015-07-21 15:38:36 -04:00
static const uint m_traceChunkSize;
ScopeVis(GLScope* glScope = NULL);
2015-08-13 23:00:28 -04:00
virtual ~ScopeVis();
2015-07-22 22:58:27 -04:00
void configure(MessageQueue* msgQueue,
TriggerChannel triggerChannel,
Real triggerLevel,
bool triggerPositiveEdge,
2015-07-23 00:52:12 -04:00
bool triggerBothEdges,
2015-07-22 22:58:27 -04:00
uint triggerPre,
uint triggerDelay,
uint traceSize);
2015-07-13 20:18:55 -04:00
void setOneShot(bool oneShot);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
2015-08-13 23:00:28 -04:00
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& message);
2015-07-06 19:17:16 -04:00
void setSampleRate(int sampleRate);
int getSampleRate() const { return m_sampleRate; }
SampleVector::const_iterator getTriggerPoint() const { return m_triggerPoint; }
2015-07-06 19:17:16 -04:00
private:
2015-07-13 04:46:51 -04:00
class MsgConfigureScopeVis : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getTriggerChannel() const { return m_triggerChannel; }
Real getTriggerLevel() const { return m_triggerLevel; }
Real getTriggerPositiveEdge() const { return m_triggerPositiveEdge; }
2015-07-23 00:52:12 -04:00
Real getTriggerBothEdges() const { return m_triggerBothEdges; }
uint getTriggerPre() const { return m_triggerPre; }
2015-07-22 22:58:27 -04:00
uint getTriggerDelay() const { return m_triggerDelay; }
2015-07-21 15:38:36 -04:00
uint getTraceSize() const { return m_traceSize; }
2015-07-13 04:46:51 -04:00
2015-07-22 22:58:27 -04:00
static MsgConfigureScopeVis* create(int triggerChannel,
Real triggerLevel,
bool triggerPositiveEdge,
2015-07-23 00:52:12 -04:00
bool triggerBothEdges,
2015-07-22 22:58:27 -04:00
uint triggerPre,
uint triggerDelay,
uint traceSize)
2015-07-13 04:46:51 -04:00
{
2015-07-23 00:52:12 -04:00
return new MsgConfigureScopeVis(triggerChannel,
triggerLevel,
triggerPositiveEdge,
triggerBothEdges,
triggerPre,
triggerDelay,
traceSize);
2015-07-13 04:46:51 -04:00
}
private:
int m_triggerChannel;
Real m_triggerLevel;
bool m_triggerPositiveEdge;
2015-07-23 00:52:12 -04:00
bool m_triggerBothEdges;
uint m_triggerPre;
2015-07-22 22:58:27 -04:00
uint m_triggerDelay;
2015-07-21 15:38:36 -04:00
uint m_traceSize;
2015-07-13 04:46:51 -04:00
2015-07-22 22:58:27 -04:00
MsgConfigureScopeVis(int triggerChannel,
Real triggerLevel,
bool triggerPositiveEdge,
2015-07-23 00:52:12 -04:00
bool triggerBothEdges,
2015-07-22 22:58:27 -04:00
uint triggerPre,
uint triggerDelay,
uint traceSize) :
2015-07-13 04:46:51 -04:00
Message(),
m_triggerChannel(triggerChannel),
m_triggerLevel(triggerLevel),
2015-07-20 16:51:49 -04:00
m_triggerPositiveEdge(triggerPositiveEdge),
2015-07-23 00:52:12 -04:00
m_triggerBothEdges(triggerBothEdges),
m_triggerPre(triggerPre),
2015-07-22 22:58:27 -04:00
m_triggerDelay(triggerDelay),
2015-07-21 15:38:36 -04:00
m_traceSize(traceSize)
2015-07-13 04:46:51 -04:00
{ }
};
2015-07-22 22:58:27 -04:00
/**
* TriggerState:
*
* send a Trigger condition +--------------------+
* dummy trace - Immediate m_triggerOneShot | |
* Config -------------> Untriggered ----------------------------------> Triggered ----------------> WaitForReset |
* ^ ^ | ^ | | ^ |
* | | | - Delayed Delay expired | | | | setOneShot(true)|
* | | +---------------------> Delay ----------------+ | | +-----------------+
* | | !m_triggerOneShot | |
* | +--------------------------------------------------+ setOneShot(false) |
* +-------------------------------------------------------------------------------+
*/
enum TriggerState {
2015-07-22 22:58:27 -04: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
};
GLScope* m_glScope;
2015-07-20 16:51:49 -04:00
std::vector<Complex> m_trace; //!< Raw trace to be used by GLScope
2015-07-21 15:38:36 -04: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
uint m_fill;
TriggerState m_triggerState;
TriggerChannel m_triggerChannel;
2015-07-13 17:38:10 -04:00
Real m_triggerLevel;
2015-07-13 04:46:51 -04:00
bool m_triggerPositiveEdge;
2015-07-23 00:52:12 -04:00
bool m_triggerBothEdges;
bool m_prevTrigger;
2015-07-22 22:58:27 -04:00
uint m_triggerPre; //!< Pre-trigger delay in number of samples
2015-07-13 20:18:55 -04:00
bool m_triggerOneShot;
2015-07-13 18:04:34 -04:00
bool m_armed;
2015-07-22 22:58:27 -04:00
uint m_triggerDelay; //!< Trigger delay in number of trace sizes
uint m_triggerDelayCount; //!< trace sizes delay counter
int m_sampleRate;
SampleVector::const_iterator m_triggerPoint;
2015-07-13 17:38:10 -04:00
bool triggerCondition(SampleVector::const_iterator& it);
};
#endif // INCLUDE_SCOPEVIS_H