35 m_state(StNotStarted),
36 m_deviceSampleSink(nullptr),
37 m_sampleSinkSequence(0),
38 m_basebandSampleSources(),
39 m_spectrumSink(nullptr),
42 m_multipleSourcesDivisionFactor(1)
58 qDebug() <<
"DSPDeviceSinkEngine::run";
65 qDebug() <<
"DSPDeviceSinkEngine::start";
71 qDebug() <<
"DSPDeviceSinkEngine::stop";
81 qDebug() <<
"DSPDeviceSinkEngine::initGeneration";
89 qDebug() <<
"DSPDeviceSinkEngine::startGeneration";
97 qDebug() <<
"DSPDeviceSinkEngine::stopGeneration";
105 qDebug() <<
"DSPDeviceSinkEngine::setSink";
112 qDebug(
"DSPDeviceSinkEngine::setSinkSequence: seq: %d", sequence);
118 qDebug() <<
"DSPDeviceSinkEngine::addThreadedSource: " << source->objectName().toStdString().c_str();
125 qDebug() <<
"DSPDeviceSinkEngine::removeThreadedSource: " << source->objectName().toStdString().c_str();
132 qDebug() <<
"DSPDeviceSinkEngine::addSpectrumSink: " << spectrumSink->objectName().toStdString().c_str();
139 qDebug() <<
"DSPDeviceSinkEngine::removeSpectrumSink: " << spectrumSink->objectName().toStdString().c_str();
146 qDebug() <<
"DSPDeviceSinkEngine::errorMessage";
154 qDebug() <<
"DSPDeviceSinkEngine::sinkDeviceDescription";
167 SampleVector::iterator writeBegin;
170 SampleVector::iterator writeAt = writeBegin;
171 std::vector<SampleVector::iterator> sampleSourceIterators;
175 sampleSourceIterators.push_back(SampleVector::iterator());
176 (*it)->getSampleSourceFifo().readAdvance(sampleSourceIterators.back(), nbWriteSamples);
177 sampleSourceIterators.back() -= nbWriteSamples;
182 sampleSourceIterators.push_back(SampleVector::iterator());
183 (*it)->getSampleSourceFifo().readAdvance(sampleSourceIterators.back(), nbWriteSamples);
184 sampleSourceIterators.back() -= nbWriteSamples;
187 for (
int is = 0; is < nbWriteSamples; is++)
190 for (std::vector<SampleVector::iterator>::iterator it = sampleSourceIterators.begin(); it != sampleSourceIterators.end(); ++it)
196 if (it == sampleSourceIterators.begin()) {
214 qDebug() <<
"DSPDeviceSinkEngine::gotoIdle";
238 qDebug() <<
"DSPDeviceSinkEngine::gotoIdle: stopping " << (*it)->objectName().toStdString().c_str();
244 qDebug() <<
"DSPDeviceSinkEngine::gotoIdle: stopping ThreadedSampleSource(" << (*it)->getSampleSourceObjectName().toStdString().c_str() <<
")";
280 return gotoError(
"DSPDeviceSinkEngine::gotoInit: No sample source configured");
289 qDebug() <<
"DSPDeviceSinkEngine::gotoInit: " 298 qDebug() <<
"DSPDeviceSinkEngine::gotoInit: initializing " << (*it)->objectName().toStdString().c_str();
299 (*it)->handleMessage(notif);
304 qDebug() <<
"DSPDeviceSinkEngine::gotoInit: initializing ThreadedSampleSource(" << (*it)->getSampleSourceObjectName().toStdString().c_str() <<
")";
305 (*it)->handleSourceMessage(notif);
324 qDebug() <<
"DSPDeviceSinkEngine::gotoRunning";
343 return gotoError(
"DSPDeviceSinkEngine::gotoRunning: No sample source configured");
346 qDebug() <<
"DSPDeviceSinkEngine::gotoRunning: " <<
m_deviceDescription.toStdString().c_str() <<
" started";
352 return gotoError(
"DSPDeviceSinkEngine::gotoRunning: Could not start sample sink");
357 qDebug() <<
"DSPDeviceSinkEngine::gotoRunning: starting " << (*it)->objectName().toStdString().c_str();
363 qDebug() <<
"DSPDeviceSinkEngine::gotoRunning: starting ThreadedSampleSource(" << (*it)->getSampleSourceObjectName().toStdString().c_str() <<
")";
380 qDebug() <<
"DSPDeviceSinkEngine::gotoError";
397 qDebug(
"DSPDeviceSinkEngine::handleSetSource: set none");
412 qDebug() <<
"DSPDeviceSinkEngine::handleSynchronousMessages: " << message->
getIdentifier();
452 spectrumSink->
stop();
491 threadedSource->
start();
498 threadedSource->
stop();
514 qDebug(
"DSPDeviceSinkEngine::handleInputMessages: message: %s", message->
getIdentifier());
525 qDebug() <<
"DSPDeviceSinkEngine::handleInputMessages: DSPSignalNotification:" 533 qDebug() <<
"DSPDeviceSinkEngine::handleInputMessages: forward message to " << (*it)->objectName().toStdString().c_str();
534 (*it)->handleMessage(*message);
539 qDebug() <<
"DSPDeviceSinkEngine::handleSourceMessages: forward message to ThreadedSampleSource(" << (*it)->getSampleSourceObjectName().toStdString().c_str() <<
")";
540 (*it)->handleSourceMessage(*message);
546 qDebug(
"DSPDeviceSinkEngine::handleInputMessages: DSPSignalNotification: guiMessageQueue: %p", guiMessageQueue);
551 guiMessageQueue->
push(rep);
564 SampleVector::iterator readUntil;
577 qDebug(
"DSPDeviceSinkEngine::checkNumberOfBasebandSources: single channel mode");
578 disconnect(sampleFifo, SIGNAL(dataWrite(
int)),
this, SLOT(
handleData(
int)));
595 (*it)->setDeviceSampleSourceFifo(0);
601 (*it)->setDeviceSampleSourceFifo(0);
605 if (nbSources == 0) {
607 }
else if (nbSources < 3) {
614 connect(sampleFifo, SIGNAL(dataWrite(
int)),
this, SLOT(
handleData(
int)), Qt::QueuedConnection);
617 qDebug(
"DSPDeviceSinkEngine::checkNumberOfBasebandSources: handle %d channel(s)", nbSources);
void setSink(DeviceSampleSink *sink)
Set the sample sink type.
Message * pop()
Pop message from queue.
engine is before initialization
const QString & getErrorMessage() const
void push(Message *message, bool emitSignal=true)
Push message onto queue.
int size()
Returns queue size.
State gotoRunning()
Go to the running state from ready state.
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
void handleSynchronousMessages()
Handle synchronous messages with the thread.
DeviceSampleSink * m_deviceSampleSink
void removeSpectrumSink(BasebandSampleSink *spectrumSink)
Add a spectrum vis baseband sample sink.
void storeMessage(Message &message)
BasebandSampleSink * m_spectrumSink
void start()
This thread start.
virtual void feed(const SampleVector::const_iterator &begin, const SampleVector::const_iterator &end, bool positiveOnly)=0
bool initGeneration()
Initialize generation sequence.
void bumpIndex(SampleVector::iterator &writeAt)
copy current item to second buffer and bump write index - write phase 2
void stopGeneration()
Stop generation sequence.
qint64 getCenterFrequency() const
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
BasebandSampleSources m_basebandSampleSources
baseband sample sources within main thread (usually file input)
void removeThreadedSource(ThreadedBasebandSampleSource *source)
Remove a baseband sample source that runs on its own thread.
void handleForwardToSpectrumSink(int nbSamples)
SyncMessenger m_syncMessenger
Used to process messages synchronously with the thread.
virtual quint64 getCenterFrequency() const =0
Center frequency exposed by the sink.
void handleSetSink(DeviceSampleSink *sink)
Manage sink setting.
void addThreadedSource(ThreadedBasebandSampleSource *source)
Add a baseband sample source that will run on its own thread.
void handleData(int nbSamples)
Handle data when samples have to be written to the sample FIFO.
SampleSourceFifo * getSampleFifo()
const QString & getDeviceDescription() const
MessageQueue m_inputMessageQueue
void stop()
this thread exit() and wait()
static bool match(const Message *message)
State gotoIdle()
Go to the idle state.
void work(int nbWriteSamples)
transfer samples from beseband sources to sink if in running state
QString errorMessage()
Return the current error message.
quint64 m_centerFrequency
uint32_t m_multipleSourcesDivisionFactor
State gotoInit()
Go to the acquisition init state from idle.
void handleInputMessages()
Handle input message queue.
QString m_deviceDescription
Message * getMessage() const
void addSpectrumSink(BasebandSampleSink *spectrumSink)
Add a spectrum vis baseband sample sink.
DSPDeviceSinkEngine(uint32_t uid, QObject *parent=NULL)
void done(int result=0)
Processing of the message is complete.
void checkNumberOfBasebandSources()
int getSampleRate() const
QString sinkDeviceDescription()
Return the sink device description.
State gotoError(const QString &errorMsg)
Go to an error state.
virtual const char * getIdentifier() const
void setSinkSequence(int sequence)
Set the sample sink sequence in type.
virtual int getSampleRate() const =0
Sample rate exposed by the sink.
int sendWait(Message &message, unsigned long msPollTime=100)
Send message and waits for its process completion.
void start()
this thread start()
MessageQueue * getMessageQueueToGUI()
ThreadedBasebandSampleSources m_threadedBasebandSampleSources
baseband sample sources on their own threads (usually channels)
void getWriteIterator(SampleVector::iterator &writeAt)
get iterator to current item for update - write phase 1
virtual const QString & getDeviceDescription() const =0
void getReadIterator(SampleVector::iterator &readUntil)
get iterator past the last sample of a read advance operation (i.e. current read iterator) ...
bool startGeneration()
Start generation sequence.
bool handleSourceMessage(const Message &cmd)
Send message to source synchronously.
void stop()
This thread stop.