34 m_state(StNotStarted),
35 m_deviceSampleSource(nullptr),
36 m_sampleSourceSequence(0),
37 m_basebandSampleSinks(),
40 m_dcOffsetCorrection(false),
41 m_iqImbalanceCorrection(false),
62 qDebug() <<
"DSPDeviceSourceEngine::run";
69 qDebug() <<
"DSPDeviceSourceEngine::start";
75 qDebug() <<
"DSPDeviceSourceEngine::stop";
85 qDebug() <<
"DSPDeviceSourceEngine::initAcquisition";
93 qDebug() <<
"DSPDeviceSourceEngine::startAcquisition";
101 qDebug() <<
"DSPDeviceSourceEngine::stopAcquistion";
114 qDebug() <<
"DSPDeviceSourceEngine::setSource";
121 qDebug(
"DSPDeviceSourceEngine::setSourceSequence: seq: %d", sequence);
127 qDebug() <<
"DSPDeviceSourceEngine::addSink: " << sink->objectName().toStdString().c_str();
134 qDebug() <<
"DSPDeviceSourceEngine::removeSink: " << sink->objectName().toStdString().c_str();
141 qDebug() <<
"DSPDeviceSourceEngine::addThreadedSink: " << sink->objectName().toStdString().c_str();
148 qDebug() <<
"DSPDeviceSourceEngine::removeThreadedSink: " << sink->objectName().toStdString().c_str();
155 qDebug() <<
"DSPDeviceSourceEngine::configureCorrections";
162 qDebug() <<
"DSPDeviceSourceEngine::errorMessage";
170 qDebug() <<
"DSPDeviceSourceEngine::sourceDeviceDescription";
178 for(SampleVector::iterator it = begin; it < end; it++)
183 if (imbalanceCorrection)
219 it->m_real = yi >> 5;
220 it->m_imag = zq >> 5;
268 for(SampleVector::iterator it = begin; it < end; it++)
286 for (SampleVector::iterator it = begin; it < end; it++)
290 if (it->real() < iMin) {
292 }
else if (it->real() > iMax) {
296 if (it->imag() < qMin) {
298 }
else if (it->imag() > qMax) {
321 for(SampleVector::iterator it = begin; it < end; it++) {
329 std::size_t samplesDone = 0;
330 bool positiveOnly =
false;
334 SampleVector::iterator part1begin;
335 SampleVector::iterator part1end;
336 SampleVector::iterator part2begin;
337 SampleVector::iterator part2end;
339 std::size_t count = sampleFifo->
readBegin(sampleFifo->
fill(), &part1begin, &part1end, &part2begin, &part2end);
342 if (part1begin != part1end)
363 (*it)->feed(part1begin, part1end, positiveOnly);
369 (*it)->feed(part1begin, part1end, positiveOnly);
374 if(part2begin != part2end)
395 (*it)->feed(part2begin, part2end, positiveOnly);
401 (*it)->feed(part2begin, part2end, positiveOnly);
407 samplesDone += count;
417 qDebug() <<
"DSPDeviceSourceEngine::gotoIdle";
475 return gotoError(
"No sample source configured");
489 qDebug() <<
"DSPDeviceSourceEngine::gotoInit: " 498 qDebug() <<
"DSPDeviceSourceEngine::gotoInit: initializing " << (*it)->objectName().toStdString().c_str();
499 (*it)->handleMessage(notif);
504 qDebug() <<
"DSPDeviceSourceEngine::gotoInit: initializing ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() <<
")";
505 (*it)->handleSinkMessage(notif);
520 qDebug() <<
"DSPDeviceSourceEngine::gotoRunning";
539 return gotoError(
"DSPDeviceSourceEngine::gotoRunning: No sample source configured");
542 qDebug() <<
"DSPDeviceSourceEngine::gotoRunning: " <<
m_deviceDescription.toStdString().c_str() <<
" started";
548 return gotoError(
"Could not start sample source");
553 qDebug() <<
"DSPDeviceSourceEngine::gotoRunning: starting " << (*it)->objectName().toStdString().c_str();
559 qDebug() <<
"DSPDeviceSourceEngine::gotoRunning: starting ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() <<
")";
570 qDebug() <<
"DSPDeviceSourceEngine::gotoError: " <<
errorMessage;
591 qDebug(
"DSPDeviceSourceEngine::handleSetSource: set %s", qPrintable(source->
getDeviceDescription()));
596 qDebug(
"DSPDeviceSourceEngine::handleSetSource: set none");
611 qDebug() <<
"DSPDeviceSourceEngine::handleSynchronousMessages: " << message->
getIdentifier();
673 threadedSink->
start();
679 threadedSink->
stop();
692 qDebug(
"DSPDeviceSourceEngine::handleInputMessages: message: %s", message->
getIdentifier());
734 qDebug() <<
"DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification:" 742 qDebug() <<
"DSPDeviceSourceEngine::handleInputMessages: forward message to " << (*it)->objectName().toStdString().c_str();
743 (*it)->handleMessage(*message);
748 qDebug() <<
"DSPDeviceSourceEngine::handleSourceMessages: forward message to ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() <<
")";
749 (*it)->handleSinkMessage(*message);
755 qDebug(
"DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification: guiMessageQueue: %p", guiMessageQueue);
757 if (guiMessageQueue) {
759 guiMessageQueue->
push(rep);
void handleSetSource(DeviceSampleSource *source)
Manage source setting.
Message * pop()
Pop message from queue.
State gotoInit()
Go to the acquisition init state from idle.
MovingAverageUtil< float, double, 128 > m_avgIQ
const QString & getErrorMessage() const
SampleSinkFifo * getSampleFifo()
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MovingAverageUtil< double, double, 128 > m_avgAmp
int size()
Returns queue size.
engine is before initialization
QString errorMessage()
Return the current error message.
BasebandSampleSinks m_basebandSampleSinks
sample sinks within main thread (usually spectrum, file output)
bool handleSinkMessage(const Message &cmd)
Send message to sink synchronously.
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection)
Configure DSP corrections.
void start()
this thread start()
void handleSynchronousMessages()
Handle synchronous messages with the thread.
int m_sampleSourceSequence
void removeSink(BasebandSampleSink *sink)
Remove a sample sink.
void stop()
This thread stop.
void storeMessage(Message &message)
DeviceSampleSource * m_deviceSampleSource
DSPDeviceSourceEngine(uint uid, QObject *parent=NULL)
MovingAverageUtil< float, double, 128 > m_avgQQ2
MovingAverageUtil< float, double, 128 > m_avgII2
uint readCommit(uint count)
void work()
transfer samples from source to sinks if in running state
MessageQueue * getMessageQueueToGUI()
MovingAverageUtil< double, double, 128 > m_avgPhi
void handleData()
Handle data when samples from source FIFO are ready to be processed.
qint64 getCenterFrequency() const
virtual int getSampleRate() const =0
Sample rate exposed by the source.
virtual const QString & getDeviceDescription() const =0
void setSourceSequence(int sequence)
Set the sample source sequence in type.
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
void setSource(DeviceSampleSource *source)
Set the sample source type.
bool initAcquisition()
Initialize acquisition sequence.
bool m_iqImbalanceCorrection
void stopAcquistion()
Stop acquisition sequence.
QString m_deviceDescription
static bool match(const Message *message)
MovingAverageUtil< int32_t, int64_t, 1024 > m_iBeta
State gotoRunning()
Go to the running state from ready state.
bool m_dcOffsetCorrection
void addSink(BasebandSampleSink *sink)
Add a sample sink.
Fixed< IntType, IntBits > sqrt(Fixed< IntType, IntBits > const &x)
MessageQueue m_inputMessageQueue
void dcOffset(SampleVector::iterator begin, SampleVector::iterator end)
State gotoError(const QString &errorMsg)
Go to an error state.
IntType as_internal() const
Message * getMessage() const
void imbalance(SampleVector::iterator begin, SampleVector::iterator end)
void removeThreadedSink(ThreadedBasebandSampleSink *sink)
Remove a sample sink that runs on its own thread.
QString sourceDeviceDescription()
Return the source device description.
void done(int result=0)
Processing of the message is complete.
void iqCorrections(SampleVector::iterator begin, SampleVector::iterator end, bool imbalanceCorrection)
const QString & getDeviceDescription() const
void start()
This thread start.
void stop()
this thread exit() and wait()
int getSampleRate() const
bool startAcquisition()
Start acquisition sequence.
virtual const char * getIdentifier() const
ThreadedBasebandSampleSinks m_threadedBasebandSampleSinks
sample sinks on their own threads (usually channels)
void addThreadedSink(ThreadedBasebandSampleSink *sink)
Add a sample sink that will run on its own thread.
int sendWait(Message &message, unsigned long msPollTime=100)
Send message and waits for its process completion.
void handleInputMessages()
Handle input message queue.
State gotoIdle()
Go to the idle state.
MovingAverageUtil< float, double, 128 > m_avgII
virtual quint64 getCenterFrequency() const =0
Center frequency exposed by the source.
uint readBegin(uint count, SampleVector::iterator *part1Begin, SampleVector::iterator *part1End, SampleVector::iterator *part2Begin, SampleVector::iterator *part2End)
quint64 m_centerFrequency
SyncMessenger m_syncMessenger
Used to process messages synchronously with the thread.
MovingAverageUtil< int32_t, int64_t, 1024 > m_qBeta