sdrangel/include-gpl/dsp/scopevis.h

98 wiersze
3.0 KiB
C
Czysty Zwykły widok Historia

#ifndef INCLUDE_SCOPEVIS_H
#define INCLUDE_SCOPEVIS_H
2015-07-20 20:51:49 +00:00
#include <boost/circular_buffer.hpp>
#include "dsp/samplesink.h"
#include "util/export.h"
2015-07-13 08:46:51 +00:00
#include "util/message.h"
class GLScope;
class MessageQueue;
class SDRANGELOVE_API ScopeVis : public SampleSink {
public:
enum TriggerChannel {
TriggerFreeRun,
TriggerChannelI,
2015-07-13 08:46:51 +00:00
TriggerChannelQ,
TriggerMagLin,
TriggerMagDb,
TriggerPhase
};
2015-07-21 19:38:36 +00:00
static const uint m_traceChunkSize;
ScopeVis(GLScope* glScope = NULL);
void configure(MessageQueue* msgQueue, TriggerChannel triggerChannel, Real triggerLevel, bool triggerPositiveEdge, uint triggerPre, uint traceSize);
2015-07-14 00:18:55 +00:00
void setOneShot(bool oneShot);
2014-06-15 08:32:25 +00:00
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
void start();
void stop();
bool handleMessageKeep(Message* message);
bool handleMessage(Message* message);
2015-07-06 23:17:16 +00:00
void setSampleRate(int sampleRate);
int getSampleRate() const { return m_sampleRate; }
SampleVector::const_iterator getTriggerPoint() const { return m_triggerPoint; }
2015-07-06 23:17:16 +00:00
private:
2015-07-13 08:46:51 +00: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; }
uint getTriggerPre() const { return m_triggerPre; }
2015-07-21 19:38:36 +00:00
uint getTraceSize() const { return m_traceSize; }
2015-07-13 08:46:51 +00:00
static MsgConfigureScopeVis* create(int triggerChannel, Real triggerLevel, bool triggerPositiveEdge, uint triggerPre, uint traceSize)
2015-07-13 08:46:51 +00:00
{
return new MsgConfigureScopeVis(triggerChannel, triggerLevel, triggerPositiveEdge, triggerPre, traceSize);
2015-07-13 08:46:51 +00:00
}
private:
int m_triggerChannel;
Real m_triggerLevel;
bool m_triggerPositiveEdge;
uint m_triggerPre;
2015-07-21 19:38:36 +00:00
uint m_traceSize;
2015-07-13 08:46:51 +00:00
MsgConfigureScopeVis(int triggerChannel, Real triggerLevel, bool triggerPositiveEdge, uint triggerPre, uint traceSize) :
2015-07-13 08:46:51 +00:00
Message(),
m_triggerChannel(triggerChannel),
m_triggerLevel(triggerLevel),
2015-07-20 20:51:49 +00:00
m_triggerPositiveEdge(triggerPositiveEdge),
m_triggerPre(triggerPre),
2015-07-21 19:38:36 +00:00
m_traceSize(traceSize)
2015-07-13 08:46:51 +00:00
{ }
};
enum TriggerState {
Untriggered,
Triggered,
WaitForReset
};
GLScope* m_glScope;
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
uint m_fill;
TriggerState m_triggerState;
TriggerChannel m_triggerChannel;
2015-07-13 21:38:10 +00:00
Real m_triggerLevel;
2015-07-13 08:46:51 +00:00
bool m_triggerPositiveEdge;
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;
int m_sampleRate;
SampleVector::const_iterator m_triggerPoint;
2015-07-13 21:38:10 +00:00
bool triggerCondition(SampleVector::const_iterator& it);
};
#endif // INCLUDE_SCOPEVIS_H