mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-23 18:52:28 -04:00
Fixed startup initialization sequence: interim state #1
This commit is contained in:
parent
88f9641877
commit
a7da0b76e2
@ -128,7 +128,9 @@ Done since the fork
|
|||||||
- Trigger line display for all trigger modes
|
- Trigger line display for all trigger modes
|
||||||
- Coarse and fine trigger level sliders
|
- Coarse and fine trigger level sliders
|
||||||
- Minimalist recording (no file choice)
|
- Minimalist recording (no file choice)
|
||||||
- File sample source plugin (recording reader)
|
- File sample source plugin (recording reader) not working
|
||||||
|
- Make the DSP engine global static
|
||||||
|
- Fixed startup initialization sequence. New initialization phase in DSP engine and new ready state
|
||||||
|
|
||||||
=====
|
=====
|
||||||
To Do
|
To Do
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2015 F4EXB //
|
||||||
|
// written by Edouard Griffiths //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef INCLUDE_DSPCOMMANDS_H
|
#ifndef INCLUDE_DSPCOMMANDS_H
|
||||||
#define INCLUDE_DSPCOMMANDS_H
|
#define INCLUDE_DSPCOMMANDS_H
|
||||||
|
|
||||||
@ -18,6 +35,10 @@ class SDRANGELOVE_API DSPExit : public Message {
|
|||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SDRANGELOVE_API DSPAcquisitionInit : public Message {
|
||||||
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
};
|
||||||
|
|
||||||
class SDRANGELOVE_API DSPAcquisitionStart : public Message {
|
class SDRANGELOVE_API DSPAcquisitionStart : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
};
|
};
|
||||||
@ -26,7 +47,7 @@ class SDRANGELOVE_API DSPAcquisitionStop : public Message {
|
|||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
};
|
};
|
||||||
|
|
||||||
class SDRANGELOVE_API DSPGetDeviceDescription : public Message {
|
class SDRANGELOVE_API DSPGetSourceDeviceDescription : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -84,11 +105,11 @@ private:
|
|||||||
SampleSink* m_sampleSink;
|
SampleSink* m_sampleSink;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SDRANGELOVE_API DSPAddAudioSource : public Message {
|
class SDRANGELOVE_API DSPAddAudioSink : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DSPAddAudioSource(AudioFifo* audioFifo) : Message(), m_audioFifo(audioFifo) { }
|
DSPAddAudioSink(AudioFifo* audioFifo) : Message(), m_audioFifo(audioFifo) { }
|
||||||
|
|
||||||
AudioFifo* getAudioFifo() const { return m_audioFifo; }
|
AudioFifo* getAudioFifo() const { return m_audioFifo; }
|
||||||
|
|
||||||
@ -96,11 +117,11 @@ private:
|
|||||||
AudioFifo* m_audioFifo;
|
AudioFifo* m_audioFifo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SDRANGELOVE_API DSPRemoveAudioSource : public Message {
|
class SDRANGELOVE_API DSPRemoveAudioSink : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DSPRemoveAudioSource(AudioFifo* audioFifo) : Message(), m_audioFifo(audioFifo) { }
|
DSPRemoveAudioSink(AudioFifo* audioFifo) : Message(), m_audioFifo(audioFifo) { }
|
||||||
|
|
||||||
AudioFifo* getAudioFifo() const { return m_audioFifo; }
|
AudioFifo* getAudioFifo() const { return m_audioFifo; }
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
// Copyright (C) 2015 F4EXB //
|
||||||
// written by Christian Daniel //
|
// written by Edouard Griffiths //
|
||||||
// //
|
// //
|
||||||
// This program is free software; you can redistribute it and/or modify //
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
// it under the terms of the GNU General Public License as published by //
|
// it under the terms of the GNU General Public License as published by //
|
||||||
@ -38,10 +38,11 @@ class SDRANGELOVE_API DSPEngine : public QThread {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum State {
|
enum State {
|
||||||
StNotStarted,
|
StNotStarted, //!< engine is before initialization
|
||||||
StIdle,
|
StIdle, //!< engine is idle
|
||||||
StRunning,
|
StReady, //!< engine is ready to run
|
||||||
StError
|
StRunning, //!< engine is running
|
||||||
|
StError //!< engine is in error
|
||||||
};
|
};
|
||||||
|
|
||||||
DSPEngine(QObject* parent = NULL);
|
DSPEngine(QObject* parent = NULL);
|
||||||
@ -49,33 +50,34 @@ public:
|
|||||||
|
|
||||||
static DSPEngine *instance();
|
static DSPEngine *instance();
|
||||||
|
|
||||||
MessageQueue* getMessageQueue() { return &m_messageQueue; }
|
MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; }
|
||||||
MessageQueue* getReportQueue() { return &m_reportQueue; }
|
MessageQueue* getOutputMessageQueue() { return &m_outputMessageQueue; }
|
||||||
|
|
||||||
void start();
|
void start(); //!< This thread start
|
||||||
void stop();
|
void stop(); //!< This thread stop
|
||||||
|
|
||||||
bool startAcquisition();
|
bool initAcquisition(); //!< Initialize acquisition sequence
|
||||||
void stopAcquistion();
|
bool startAcquisition(); //!< Start acquisition sequence
|
||||||
|
void stopAcquistion(); //!< Stop acquisition sequence
|
||||||
|
|
||||||
void setSource(SampleSource* source);
|
void setSource(SampleSource* source); //!< Set the unique sample source
|
||||||
|
|
||||||
void addSink(SampleSink* sink);
|
void addSink(SampleSink* sink); //!< Add a sample sink
|
||||||
void removeSink(SampleSink* sink);
|
void removeSink(SampleSink* sink); //!< Remove a sample sink
|
||||||
|
|
||||||
void addAudioSource(AudioFifo* audioFifo);
|
void addAudioSink(AudioFifo* audioFifo); //!< Add the audio sink
|
||||||
void removeAudioSource(AudioFifo* audioFifo);
|
void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
|
||||||
|
|
||||||
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection);
|
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure DSP corrections
|
||||||
|
|
||||||
State state() const { return m_state; }
|
State state() const { return m_state; } //!< Return DSP engine current state
|
||||||
|
|
||||||
QString errorMessage();
|
QString errorMessage(); //!< Return the current error message
|
||||||
QString deviceDescription();
|
QString sourceDeviceDescription(); //!< Return the source device description
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageQueue m_messageQueue;
|
MessageQueue m_inputMessageQueue; //<! Input message queue. Post here.
|
||||||
MessageQueue m_reportQueue;
|
MessageQueue m_outputMessageQueue; //<! Output message queue. Listen here.
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
|
|
||||||
@ -87,7 +89,7 @@ private:
|
|||||||
typedef std::list<SampleSink*> SampleSinks;
|
typedef std::list<SampleSink*> SampleSinks;
|
||||||
SampleSinks m_sampleSinks;
|
SampleSinks m_sampleSinks;
|
||||||
|
|
||||||
AudioOutput m_audioOutput;
|
AudioOutput m_audioSink;
|
||||||
|
|
||||||
uint m_sampleRate;
|
uint m_sampleRate;
|
||||||
quint64 m_centerFrequency;
|
quint64 m_centerFrequency;
|
||||||
@ -103,19 +105,19 @@ private:
|
|||||||
|
|
||||||
void dcOffset(SampleVector::iterator begin, SampleVector::iterator end);
|
void dcOffset(SampleVector::iterator begin, SampleVector::iterator end);
|
||||||
void imbalance(SampleVector::iterator begin, SampleVector::iterator end);
|
void imbalance(SampleVector::iterator begin, SampleVector::iterator end);
|
||||||
void work();
|
void work(); //!< transfer samples from source to sinks if in running state
|
||||||
|
|
||||||
State gotoIdle();
|
State gotoIdle(); //!< Go to the idle state
|
||||||
State gotoRunning();
|
State gotoInit(); //!< Go to the acquisition init state from idle
|
||||||
State gotoError(const QString& errorMsg);
|
State gotoRunning(); //!< Go to the running state from ready state
|
||||||
|
State gotoError(const QString& errorMsg); //!< Go to an error state
|
||||||
|
|
||||||
void handleSetSource(SampleSource* source);
|
void handleSetSource(SampleSource* source); //!< Manage source setting
|
||||||
void generateReport();
|
bool distributeMessage(Message* message); // FIXME: remove ?
|
||||||
bool distributeMessage(Message* message);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleData();
|
void handleData(); //!< Handle data when samples from source FIFO are ready to be processed
|
||||||
void handleMessages();
|
void handleInputMessages(); //!< Handle input message queue
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_DSPENGINE_H
|
#endif // INCLUDE_DSPENGINE_H
|
||||||
|
@ -15,7 +15,8 @@ public:
|
|||||||
virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) = 0;
|
virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) = 0;
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual bool handleMessage(Message* cmd) = 0;
|
virtual bool handleMessage(Message* cmd) = 0; //!< Handle message immediately or submit it to a queue
|
||||||
|
virtual bool executeMessage(Message* cmd); //!< Handle message immediately FIXME: shall we keep it or fix behaviour of ThreadedSampleSink?
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_SAMPLESINK_H
|
#endif // INCLUDE_SAMPLESINK_H
|
||||||
|
@ -23,6 +23,7 @@ public:
|
|||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* cmd);
|
bool handleMessage(Message* cmd);
|
||||||
|
virtual bool executeMessage(Message* cmd);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
Message* accept();
|
Message* accept();
|
||||||
|
|
||||||
int countPending();
|
int countPending();
|
||||||
|
void clear();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void messageEnqueued();
|
void messageEnqueued();
|
||||||
|
@ -29,6 +29,8 @@ AMDemod::AMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
|||||||
m_sampleSink(sampleSink),
|
m_sampleSink(sampleSink),
|
||||||
m_audioFifo(audioFifo)
|
m_audioFifo(audioFifo)
|
||||||
{
|
{
|
||||||
|
setObjectName("AMDemod");
|
||||||
|
|
||||||
m_config.m_inputSampleRate = 96000;
|
m_config.m_inputSampleRate = 96000;
|
||||||
m_config.m_inputFrequencyOffset = 0;
|
m_config.m_inputFrequencyOffset = 0;
|
||||||
m_config.m_rfBandwidth = 12500;
|
m_config.m_rfBandwidth = 12500;
|
||||||
|
@ -28,6 +28,8 @@ MESSAGE_CLASS_DEFINITION(LoRaDemod::MsgConfigureLoRaDemod, Message)
|
|||||||
LoRaDemod::LoRaDemod(SampleSink* sampleSink) :
|
LoRaDemod::LoRaDemod(SampleSink* sampleSink) :
|
||||||
m_sampleSink(sampleSink)
|
m_sampleSink(sampleSink)
|
||||||
{
|
{
|
||||||
|
setObjectName("LoRaDemod");
|
||||||
|
|
||||||
m_Bandwidth = 7813;
|
m_Bandwidth = 7813;
|
||||||
m_sampleRate = 96000;
|
m_sampleRate = 96000;
|
||||||
m_frequency = 0;
|
m_frequency = 0;
|
||||||
|
@ -36,6 +36,8 @@ NFMDemod::NFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
|||||||
m_sampleSink(sampleSink),
|
m_sampleSink(sampleSink),
|
||||||
m_audioFifo(audioFifo)
|
m_audioFifo(audioFifo)
|
||||||
{
|
{
|
||||||
|
setObjectName("NFMDemod");
|
||||||
|
|
||||||
m_config.m_inputSampleRate = 96000;
|
m_config.m_inputSampleRate = 96000;
|
||||||
m_config.m_inputFrequencyOffset = 0;
|
m_config.m_inputFrequencyOffset = 0;
|
||||||
m_config.m_rfBandwidth = 12500;
|
m_config.m_rfBandwidth = 12500;
|
||||||
|
@ -28,6 +28,8 @@ SSBDemod::SSBDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
|||||||
m_sampleSink(sampleSink),
|
m_sampleSink(sampleSink),
|
||||||
m_audioFifo(audioFifo)
|
m_audioFifo(audioFifo)
|
||||||
{
|
{
|
||||||
|
setObjectName("SSBDemod");
|
||||||
|
|
||||||
m_Bandwidth = 5000;
|
m_Bandwidth = 5000;
|
||||||
m_LowCutoff = 300;
|
m_LowCutoff = 300;
|
||||||
m_volume = 2.0;
|
m_volume = 2.0;
|
||||||
|
@ -27,6 +27,8 @@ MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcSpectrum, Message)
|
|||||||
|
|
||||||
TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* spectrum)
|
TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* spectrum)
|
||||||
{
|
{
|
||||||
|
setObjectName("TCPSrc");
|
||||||
|
|
||||||
m_inputSampleRate = 96000;
|
m_inputSampleRate = 96000;
|
||||||
m_sampleFormat = FormatSSB;
|
m_sampleFormat = FormatSSB;
|
||||||
m_outputSampleRate = 48000;
|
m_outputSampleRate = 48000;
|
||||||
|
@ -29,6 +29,8 @@ WFMDemod::WFMDemod(AudioFifo* audioFifo, SampleSink* sampleSink) :
|
|||||||
m_sampleSink(sampleSink),
|
m_sampleSink(sampleSink),
|
||||||
m_audioFifo(audioFifo)
|
m_audioFifo(audioFifo)
|
||||||
{
|
{
|
||||||
|
setObjectName("WFMDemod");
|
||||||
|
|
||||||
m_config.m_inputSampleRate = 384000;
|
m_config.m_inputSampleRate = 384000;
|
||||||
m_config.m_inputFrequencyOffset = 0;
|
m_config.m_inputFrequencyOffset = 0;
|
||||||
m_config.m_rfBandwidth = 180000;
|
m_config.m_rfBandwidth = 180000;
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
|
#include "dsp/dspengine.h"
|
||||||
|
#include "dsp/dspcommands.h"
|
||||||
#include "bladerfgui.h"
|
#include "bladerfgui.h"
|
||||||
#include "bladerfinput.h"
|
#include "bladerfinput.h"
|
||||||
#include "bladerfthread.h"
|
#include "bladerfthread.h"
|
||||||
@ -106,7 +108,7 @@ BladerfInput::BladerfInput(MessageQueue* msgQueueToGUI) :
|
|||||||
m_settings(),
|
m_settings(),
|
||||||
m_dev(NULL),
|
m_dev(NULL),
|
||||||
m_bladerfThread(NULL),
|
m_bladerfThread(NULL),
|
||||||
m_deviceDescription()
|
m_deviceDescription("BladeRF")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,6 @@ bool BladerfInput::startInput(int device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_bladerfThread->startWork();
|
m_bladerfThread->startWork();
|
||||||
m_deviceDescription = "BladeRF";
|
|
||||||
|
|
||||||
mutexLocker.unlock();
|
mutexLocker.unlock();
|
||||||
applySettings(m_generalSettings, m_settings, true);
|
applySettings(m_generalSettings, m_settings, true);
|
||||||
@ -215,13 +216,21 @@ quint64 BladerfInput::getCenterFrequency() const
|
|||||||
|
|
||||||
bool BladerfInput::handleMessage(Message* message)
|
bool BladerfInput::handleMessage(Message* message)
|
||||||
{
|
{
|
||||||
if(MsgConfigureBladerf::match(message)) {
|
if (MsgConfigureBladerf::match(message))
|
||||||
MsgConfigureBladerf* conf = (MsgConfigureBladerf*)message;
|
{
|
||||||
if(!applySettings(conf->getGeneralSettings(), conf->getSettings(), false))
|
qDebug() << "BladerfInput::handleMessage: MsgConfigureBladerf";
|
||||||
|
|
||||||
|
MsgConfigureBladerf* conf = (MsgConfigureBladerf*) message;
|
||||||
|
|
||||||
|
if(!applySettings(conf->getGeneralSettings(), conf->getSettings(), false)) {
|
||||||
qDebug("BladeRF config error");
|
qDebug("BladeRF config error");
|
||||||
|
}
|
||||||
|
|
||||||
message->completed();
|
message->completed();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,9 +239,14 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
|
||||||
if((m_settings.m_lnaGain != settings.m_lnaGain) || force) {
|
qDebug() << "BladerfInput::applySettings: m_dev: " << m_dev;
|
||||||
|
|
||||||
|
if ((m_settings.m_lnaGain != settings.m_lnaGain) || force)
|
||||||
|
{
|
||||||
m_settings.m_lnaGain = settings.m_lnaGain;
|
m_settings.m_lnaGain = settings.m_lnaGain;
|
||||||
if(m_dev != NULL) {
|
|
||||||
|
if (m_dev != NULL)
|
||||||
|
{
|
||||||
if(bladerf_set_lna_gain(m_dev, getLnaGain(m_settings.m_lnaGain)) != 0) {
|
if(bladerf_set_lna_gain(m_dev, getLnaGain(m_settings.m_lnaGain)) != 0) {
|
||||||
qDebug("bladerf_set_lna_gain() failed");
|
qDebug("bladerf_set_lna_gain() failed");
|
||||||
} else {
|
} else {
|
||||||
@ -241,9 +255,12 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_vga1 != settings.m_vga1) || force) {
|
if ((m_settings.m_vga1 != settings.m_vga1) || force)
|
||||||
|
{
|
||||||
m_settings.m_vga1 = settings.m_vga1;
|
m_settings.m_vga1 = settings.m_vga1;
|
||||||
if(m_dev != NULL) {
|
|
||||||
|
if (m_dev != NULL)
|
||||||
|
{
|
||||||
if(bladerf_set_rxvga1(m_dev, m_settings.m_vga1) != 0) {
|
if(bladerf_set_rxvga1(m_dev, m_settings.m_vga1) != 0) {
|
||||||
qDebug("bladerf_set_rxvga1() failed");
|
qDebug("bladerf_set_rxvga1() failed");
|
||||||
} else {
|
} else {
|
||||||
@ -252,9 +269,12 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_vga2 != settings.m_vga2) || force) {
|
if ((m_settings.m_vga2 != settings.m_vga2) || force)
|
||||||
|
{
|
||||||
m_settings.m_vga2 = settings.m_vga2;
|
m_settings.m_vga2 = settings.m_vga2;
|
||||||
if(m_dev != NULL) {
|
|
||||||
|
if(m_dev != NULL)
|
||||||
|
{
|
||||||
if(bladerf_set_rxvga2(m_dev, m_settings.m_vga2) != 0) {
|
if(bladerf_set_rxvga2(m_dev, m_settings.m_vga2) != 0) {
|
||||||
qDebug("bladerf_set_rxvga2() failed");
|
qDebug("bladerf_set_rxvga2() failed");
|
||||||
} else {
|
} else {
|
||||||
@ -263,16 +283,22 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_xb200 != settings.m_xb200) || force) {
|
if ((m_settings.m_xb200 != settings.m_xb200) || force)
|
||||||
|
{
|
||||||
m_settings.m_xb200 = settings.m_xb200;
|
m_settings.m_xb200 = settings.m_xb200;
|
||||||
if(m_dev != NULL) {
|
|
||||||
if (m_settings.m_xb200) {
|
if (m_dev != NULL)
|
||||||
|
{
|
||||||
|
if (m_settings.m_xb200)
|
||||||
|
{
|
||||||
if (bladerf_expansion_attach(m_dev, BLADERF_XB_200) != 0) {
|
if (bladerf_expansion_attach(m_dev, BLADERF_XB_200) != 0) {
|
||||||
qDebug("bladerf_expansion_attach(xb200) failed");
|
qDebug("bladerf_expansion_attach(xb200) failed");
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "BladerfInput: Attach XB200";
|
qDebug() << "BladerfInput: Attach XB200";
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (bladerf_expansion_attach(m_dev, BLADERF_XB_NONE) != 0) {
|
if (bladerf_expansion_attach(m_dev, BLADERF_XB_NONE) != 0) {
|
||||||
qDebug("bladerf_expansion_attach(none) failed");
|
qDebug("bladerf_expansion_attach(none) failed");
|
||||||
} else {
|
} else {
|
||||||
@ -282,9 +308,11 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_xb200Path != settings.m_xb200Path) || force) {
|
if ((m_settings.m_xb200Path != settings.m_xb200Path) || force)
|
||||||
|
{
|
||||||
m_settings.m_xb200Path = settings.m_xb200Path;
|
m_settings.m_xb200Path = settings.m_xb200Path;
|
||||||
if(m_dev != NULL) {
|
if (m_dev != NULL)
|
||||||
|
{
|
||||||
if(bladerf_xb200_set_path(m_dev, BLADERF_MODULE_RX, m_settings.m_xb200Path) != 0) {
|
if(bladerf_xb200_set_path(m_dev, BLADERF_MODULE_RX, m_settings.m_xb200Path) != 0) {
|
||||||
qDebug("bladerf_xb200_set_path(BLADERF_MODULE_RX) failed");
|
qDebug("bladerf_xb200_set_path(BLADERF_MODULE_RX) failed");
|
||||||
} else {
|
} else {
|
||||||
@ -293,9 +321,12 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_xb200Filter != settings.m_xb200Filter) || force) {
|
if ((m_settings.m_xb200Filter != settings.m_xb200Filter) || force)
|
||||||
|
{
|
||||||
m_settings.m_xb200Filter = settings.m_xb200Filter;
|
m_settings.m_xb200Filter = settings.m_xb200Filter;
|
||||||
if(m_dev != NULL) {
|
|
||||||
|
if(m_dev != NULL)
|
||||||
|
{
|
||||||
if(bladerf_xb200_set_filterbank(m_dev, BLADERF_MODULE_RX, m_settings.m_xb200Filter) != 0) {
|
if(bladerf_xb200_set_filterbank(m_dev, BLADERF_MODULE_RX, m_settings.m_xb200Filter) != 0) {
|
||||||
qDebug("bladerf_xb200_set_filterbank(BLADERF_MODULE_RX) failed");
|
qDebug("bladerf_xb200_set_filterbank(BLADERF_MODULE_RX) failed");
|
||||||
} else {
|
} else {
|
||||||
@ -304,23 +335,34 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_samplerate != settings.m_samplerate) || force) {
|
if ((m_settings.m_samplerate != settings.m_samplerate) || force)
|
||||||
if(m_dev != NULL) {
|
{
|
||||||
|
m_settings.m_samplerate = settings.m_samplerate;
|
||||||
|
|
||||||
|
if (m_dev != NULL)
|
||||||
|
{
|
||||||
unsigned int actualSamplerate;
|
unsigned int actualSamplerate;
|
||||||
if( bladerf_set_sample_rate(m_dev, BLADERF_MODULE_RX, settings.m_samplerate, &actualSamplerate) < 0)
|
|
||||||
qCritical("could not set sample rate: %d", settings.m_samplerate);
|
if (bladerf_set_sample_rate(m_dev, BLADERF_MODULE_RX, m_settings.m_samplerate, &actualSamplerate) < 0)
|
||||||
else {
|
{
|
||||||
|
qCritical("could not set sample rate: %d", m_settings.m_samplerate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
qDebug() << "bladerf_set_sample_rate(BLADERF_MODULE_RX) actual sample rate is " << actualSamplerate;
|
qDebug() << "bladerf_set_sample_rate(BLADERF_MODULE_RX) actual sample rate is " << actualSamplerate;
|
||||||
m_settings.m_samplerate = settings.m_samplerate;
|
m_bladerfThread->setSamplerate(m_settings.m_samplerate);
|
||||||
m_bladerfThread->setSamplerate(settings.m_samplerate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_bandwidth != settings.m_bandwidth) || force) {
|
if ((m_settings.m_bandwidth != settings.m_bandwidth) || force)
|
||||||
|
{
|
||||||
m_settings.m_bandwidth = settings.m_bandwidth;
|
m_settings.m_bandwidth = settings.m_bandwidth;
|
||||||
if(m_dev != NULL) {
|
|
||||||
|
if(m_dev != NULL)
|
||||||
|
{
|
||||||
unsigned int actualBandwidth;
|
unsigned int actualBandwidth;
|
||||||
|
|
||||||
if( bladerf_set_bandwidth(m_dev, BLADERF_MODULE_RX, m_settings.m_bandwidth, &actualBandwidth) < 0)
|
if( bladerf_set_bandwidth(m_dev, BLADERF_MODULE_RX, m_settings.m_bandwidth, &actualBandwidth) < 0)
|
||||||
qCritical("could not set sample rate: %d", m_settings.m_samplerate);
|
qCritical("could not set sample rate: %d", m_settings.m_samplerate);
|
||||||
else {
|
else {
|
||||||
@ -329,60 +371,72 @@ bool BladerfInput::applySettings(const GeneralSettings& generalSettings, const S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_log2Decim != settings.m_log2Decim) || force) {
|
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||||
|
{
|
||||||
m_settings.m_log2Decim = settings.m_log2Decim;
|
m_settings.m_log2Decim = settings.m_log2Decim;
|
||||||
if(m_dev != NULL) {
|
|
||||||
|
if(m_dev != NULL)
|
||||||
|
{
|
||||||
m_bladerfThread->setLog2Decimation(m_settings.m_log2Decim);
|
m_bladerfThread->setLog2Decimation(m_settings.m_log2Decim);
|
||||||
qDebug() << "BladerfInput: set decimation to " << (1<<settings.m_log2Decim);
|
qDebug() << "BladerfInput: set decimation to " << (1<<m_settings.m_log2Decim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_settings.m_fcPos != settings.m_fcPos) || force) {
|
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||||
|
{
|
||||||
m_settings.m_fcPos = settings.m_fcPos;
|
m_settings.m_fcPos = settings.m_fcPos;
|
||||||
if(m_dev != NULL) {
|
|
||||||
|
if(m_dev != NULL)
|
||||||
|
{
|
||||||
m_bladerfThread->setFcPos((int) m_settings.m_fcPos);
|
m_bladerfThread->setFcPos((int) m_settings.m_fcPos);
|
||||||
qDebug() << "BladerfInput: set fc pos (enum) to " << (int) m_settings.m_fcPos;
|
qDebug() << "BladerfInput: set fc pos (enum) to " << (int) m_settings.m_fcPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
||||||
if(m_dev != NULL) {
|
|
||||||
qint64 centerFrequency = m_generalSettings.m_centerFrequency;
|
|
||||||
qint64 f_img = centerFrequency;
|
|
||||||
qint64 f_cut = centerFrequency + m_settings.m_bandwidth/2;
|
|
||||||
|
|
||||||
if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == FC_POS_CENTER))
|
qint64 centerFrequency = m_generalSettings.m_centerFrequency;
|
||||||
|
qint64 f_img = centerFrequency;
|
||||||
|
qint64 f_cut = centerFrequency + m_settings.m_bandwidth/2;
|
||||||
|
|
||||||
|
if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == FC_POS_CENTER))
|
||||||
|
{
|
||||||
|
centerFrequency = m_generalSettings.m_centerFrequency;
|
||||||
|
f_img = centerFrequency;
|
||||||
|
f_cut = centerFrequency + m_settings.m_bandwidth/2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_settings.m_fcPos == FC_POS_INFRA)
|
||||||
{
|
{
|
||||||
centerFrequency = m_generalSettings.m_centerFrequency;
|
centerFrequency = m_generalSettings.m_centerFrequency + (m_settings.m_samplerate / 4);
|
||||||
f_img = centerFrequency;
|
f_img = centerFrequency + m_settings.m_samplerate/2;
|
||||||
f_cut = centerFrequency + m_settings.m_bandwidth/2;
|
f_cut = centerFrequency + m_settings.m_bandwidth/2;
|
||||||
}
|
}
|
||||||
else
|
else if (m_settings.m_fcPos == FC_POS_SUPRA)
|
||||||
{
|
{
|
||||||
if (m_settings.m_fcPos == FC_POS_INFRA) {
|
centerFrequency = m_generalSettings.m_centerFrequency - (m_settings.m_samplerate / 4);
|
||||||
centerFrequency = m_generalSettings.m_centerFrequency + (m_settings.m_samplerate / 4);
|
f_img = centerFrequency - m_settings.m_samplerate/2;
|
||||||
f_img = centerFrequency + m_settings.m_samplerate/2;
|
f_cut = centerFrequency - m_settings.m_bandwidth/2;
|
||||||
f_cut = centerFrequency + m_settings.m_bandwidth/2;
|
|
||||||
} else if (m_settings.m_fcPos == FC_POS_SUPRA) {
|
|
||||||
centerFrequency = m_generalSettings.m_centerFrequency - (m_settings.m_samplerate / 4);
|
|
||||||
f_img = centerFrequency - m_settings.m_samplerate/2;
|
|
||||||
f_cut = centerFrequency - m_settings.m_bandwidth/2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(bladerf_set_frequency( m_dev, BLADERF_MODULE_RX, centerFrequency ) != 0) {
|
if (m_dev != NULL)
|
||||||
|
{
|
||||||
|
if (bladerf_set_frequency( m_dev, BLADERF_MODULE_RX, centerFrequency ) != 0) {
|
||||||
qDebug("bladerf_set_frequency(%lld) failed", m_generalSettings.m_centerFrequency);
|
qDebug("bladerf_set_frequency(%lld) failed", m_generalSettings.m_centerFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "BladerfInput: center freq: " << m_generalSettings.m_centerFrequency << " Hz"
|
|
||||||
<< " RF center freq: " << centerFrequency << " Hz"
|
|
||||||
<< " sample rate / 2 : " << m_settings.m_samplerate/2 << "Hz"
|
|
||||||
<< " BW: " << m_settings.m_bandwidth << "Hz"
|
|
||||||
<< " img: " << f_img << "Hz"
|
|
||||||
<< " cut: " << f_cut << "Hz"
|
|
||||||
<< " img - cut: " << f_img - f_cut;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << " - center freq: " << m_generalSettings.m_centerFrequency << " Hz"
|
||||||
|
<< " RF center freq: " << centerFrequency << " Hz"
|
||||||
|
<< " RF sample rate: " << m_settings.m_samplerate << "Hz"
|
||||||
|
<< " Actual sample rate: " << m_settings.m_samplerate/(1<<m_settings.m_log2Decim) << "Hz"
|
||||||
|
<< " BW: " << m_settings.m_bandwidth << "Hz"
|
||||||
|
<< " img: " << f_img << "Hz"
|
||||||
|
<< " cut: " << f_cut << "Hz"
|
||||||
|
<< " img - cut: " << f_img - f_cut;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ Channelizer::Channelizer(SampleSink* sampleSink) :
|
|||||||
m_currentOutputSampleRate(0),
|
m_currentOutputSampleRate(0),
|
||||||
m_currentCenterFrequency(0)
|
m_currentCenterFrequency(0)
|
||||||
{
|
{
|
||||||
|
setObjectName("Channelizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
Channelizer::~Channelizer()
|
Channelizer::~Channelizer()
|
||||||
@ -62,6 +63,8 @@ void Channelizer::stop()
|
|||||||
|
|
||||||
bool Channelizer::handleMessage(Message* cmd)
|
bool Channelizer::handleMessage(Message* cmd)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Channelizer::handleMessage: " << cmd->getIdentifier();
|
||||||
|
|
||||||
if (DSPSignalNotification::match(cmd))
|
if (DSPSignalNotification::match(cmd))
|
||||||
{
|
{
|
||||||
DSPSignalNotification* signal = (DSPSignalNotification*)cmd;
|
DSPSignalNotification* signal = (DSPSignalNotification*)cmd;
|
||||||
|
@ -1,16 +1,34 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2015 F4EXB //
|
||||||
|
// written by Edouard Griffiths //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "dsp/dspcommands.h"
|
#include "dsp/dspcommands.h"
|
||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(DSPPing, Message)
|
MESSAGE_CLASS_DEFINITION(DSPPing, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPExit, Message)
|
MESSAGE_CLASS_DEFINITION(DSPExit, Message)
|
||||||
|
MESSAGE_CLASS_DEFINITION(DSPAcquisitionInit, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPAcquisitionStart, Message)
|
MESSAGE_CLASS_DEFINITION(DSPAcquisitionStart, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPAcquisitionStop, Message)
|
MESSAGE_CLASS_DEFINITION(DSPAcquisitionStop, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPGetDeviceDescription, Message)
|
MESSAGE_CLASS_DEFINITION(DSPGetSourceDeviceDescription, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPGetErrorMessage, Message)
|
MESSAGE_CLASS_DEFINITION(DSPGetErrorMessage, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPSetSource, Message)
|
MESSAGE_CLASS_DEFINITION(DSPSetSource, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPAddSink, Message)
|
MESSAGE_CLASS_DEFINITION(DSPAddSink, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPRemoveSink, Message)
|
MESSAGE_CLASS_DEFINITION(DSPRemoveSink, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPAddAudioSource, Message)
|
MESSAGE_CLASS_DEFINITION(DSPAddAudioSink, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPRemoveAudioSource, Message)
|
MESSAGE_CLASS_DEFINITION(DSPRemoveAudioSink, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPConfigureSpectrumVis, Message)
|
MESSAGE_CLASS_DEFINITION(DSPConfigureSpectrumVis, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPConfigureCorrection, Message)
|
MESSAGE_CLASS_DEFINITION(DSPConfigureCorrection, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(DSPEngineReport, Message)
|
MESSAGE_CLASS_DEFINITION(DSPEngineReport, Message)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
// Copyright (C) 2015 F4EXB //
|
||||||
// written by Christian Daniel //
|
// written by Edouard Griffiths //
|
||||||
// //
|
// //
|
||||||
// This program is free software; you can redistribute it and/or modify //
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
// it under the terms of the GNU General Public License as published by //
|
// it under the terms of the GNU General Public License as published by //
|
||||||
@ -26,8 +26,6 @@
|
|||||||
|
|
||||||
DSPEngine::DSPEngine(QObject* parent) :
|
DSPEngine::DSPEngine(QObject* parent) :
|
||||||
QThread(parent),
|
QThread(parent),
|
||||||
m_messageQueue(),
|
|
||||||
m_reportQueue(),
|
|
||||||
m_state(StNotStarted),
|
m_state(StNotStarted),
|
||||||
m_sampleSource(NULL),
|
m_sampleSource(NULL),
|
||||||
m_sampleSinks(),
|
m_sampleSinks(),
|
||||||
@ -55,97 +53,109 @@ DSPEngine *DSPEngine::instance()
|
|||||||
return dspEngine;
|
return dspEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DSPEngine::run()
|
||||||
|
{
|
||||||
|
qDebug() << "DSPEngine::run";
|
||||||
|
|
||||||
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||||
|
|
||||||
|
m_state = StIdle;
|
||||||
|
|
||||||
|
handleInputMessages();
|
||||||
|
exec();
|
||||||
|
}
|
||||||
|
|
||||||
void DSPEngine::start()
|
void DSPEngine::start()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPEngine::start";
|
qDebug() << "DSPEngine::start";
|
||||||
DSPPing cmd;
|
DSPPing cmd;
|
||||||
QThread::start();
|
QThread::start();
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::stop()
|
void DSPEngine::stop()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPEngine::stop";
|
qDebug() << "DSPEngine::stop";
|
||||||
DSPExit cmd;
|
DSPExit cmd;
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DSPEngine::initAcquisition()
|
||||||
|
{
|
||||||
|
DSPAcquisitionInit cmd;
|
||||||
|
|
||||||
|
return cmd.execute(&m_inputMessageQueue) == StReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DSPEngine::startAcquisition()
|
bool DSPEngine::startAcquisition()
|
||||||
{
|
{
|
||||||
DSPAcquisitionStart cmd;
|
DSPAcquisitionStart cmd;
|
||||||
return cmd.execute(&m_messageQueue) == StRunning;
|
|
||||||
|
return cmd.execute(&m_inputMessageQueue) == StRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::stopAcquistion()
|
void DSPEngine::stopAcquistion()
|
||||||
{
|
{
|
||||||
DSPAcquisitionStop cmd;
|
DSPAcquisitionStop cmd;
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
|
|
||||||
if(m_dcOffsetCorrection)
|
if(m_dcOffsetCorrection)
|
||||||
|
{
|
||||||
qDebug("DC offset:%f,%f", m_iOffset, m_qOffset);
|
qDebug("DC offset:%f,%f", m_iOffset, m_qOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::setSource(SampleSource* source)
|
void DSPEngine::setSource(SampleSource* source)
|
||||||
{
|
{
|
||||||
DSPSetSource cmd(source);
|
DSPSetSource cmd(source);
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::addSink(SampleSink* sink)
|
void DSPEngine::addSink(SampleSink* sink)
|
||||||
{
|
{
|
||||||
|
qDebug() << "DSPEngine::addSink: " << sink->objectName().toStdString().c_str();
|
||||||
DSPAddSink cmd(sink);
|
DSPAddSink cmd(sink);
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::removeSink(SampleSink* sink)
|
void DSPEngine::removeSink(SampleSink* sink)
|
||||||
{
|
{
|
||||||
DSPRemoveSink cmd(sink);
|
DSPRemoveSink cmd(sink);
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::addAudioSource(AudioFifo* audioFifo)
|
void DSPEngine::addAudioSink(AudioFifo* audioFifo)
|
||||||
{
|
{
|
||||||
DSPAddAudioSource cmd(audioFifo);
|
DSPAddAudioSink cmd(audioFifo);
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::removeAudioSource(AudioFifo* audioFifo)
|
void DSPEngine::removeAudioSink(AudioFifo* audioFifo)
|
||||||
{
|
{
|
||||||
DSPRemoveAudioSource cmd(audioFifo);
|
DSPRemoveAudioSink cmd(audioFifo);
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection)
|
void DSPEngine::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection)
|
||||||
{
|
{
|
||||||
Message* cmd = DSPConfigureCorrection::create(dcOffsetCorrection, iqImbalanceCorrection);
|
Message* cmd = DSPConfigureCorrection::create(dcOffsetCorrection, iqImbalanceCorrection);
|
||||||
cmd->submit(&m_messageQueue);
|
cmd->submit(&m_inputMessageQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DSPEngine::errorMessage()
|
QString DSPEngine::errorMessage()
|
||||||
{
|
{
|
||||||
DSPGetErrorMessage cmd;
|
DSPGetErrorMessage cmd;
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
return cmd.getErrorMessage();
|
return cmd.getErrorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DSPEngine::deviceDescription()
|
QString DSPEngine::sourceDeviceDescription()
|
||||||
{
|
{
|
||||||
DSPGetDeviceDescription cmd;
|
DSPGetSourceDeviceDescription cmd;
|
||||||
cmd.execute(&m_messageQueue);
|
cmd.execute(&m_inputMessageQueue);
|
||||||
return cmd.getDeviceDescription();
|
return cmd.getDeviceDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::run()
|
|
||||||
{
|
|
||||||
qDebug() << "DSPEngine::run";
|
|
||||||
|
|
||||||
connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
|
|
||||||
|
|
||||||
m_state = StIdle;
|
|
||||||
|
|
||||||
handleMessages();
|
|
||||||
exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSPEngine::dcOffset(SampleVector::iterator begin, SampleVector::iterator end)
|
void DSPEngine::dcOffset(SampleVector::iterator begin, SampleVector::iterator end)
|
||||||
{
|
{
|
||||||
double count;
|
double count;
|
||||||
@ -154,7 +164,8 @@ void DSPEngine::dcOffset(SampleVector::iterator begin, SampleVector::iterator en
|
|||||||
Sample corr((qint16)m_iOffset, (qint16)m_qOffset);
|
Sample corr((qint16)m_iOffset, (qint16)m_qOffset);
|
||||||
|
|
||||||
// sum and correct in one pass
|
// sum and correct in one pass
|
||||||
for(SampleVector::iterator it = begin; it < end; it++) {
|
for(SampleVector::iterator it = begin; it < end; it++)
|
||||||
|
{
|
||||||
io += it->real();
|
io += it->real();
|
||||||
qo += it->imag();
|
qo += it->imag();
|
||||||
*it -= corr;
|
*it -= corr;
|
||||||
@ -175,18 +186,24 @@ void DSPEngine::imbalance(SampleVector::iterator begin, SampleVector::iterator e
|
|||||||
|
|
||||||
// find value ranges for both I and Q
|
// find value ranges for both I and Q
|
||||||
// both intervals should be same same size (for a perfect circle)
|
// both intervals should be same same size (for a perfect circle)
|
||||||
for(SampleVector::iterator it = begin; it < end; it++) {
|
for (SampleVector::iterator it = begin; it < end; it++)
|
||||||
if(it != begin) {
|
{
|
||||||
if(it->real() < iMin)
|
if (it != begin)
|
||||||
|
{
|
||||||
|
if (it->real() < iMin) {
|
||||||
iMin = it->real();
|
iMin = it->real();
|
||||||
else if(it->real() > iMax)
|
} else if (it->real() > iMax) {
|
||||||
iMax = it->real();
|
iMax = it->real();
|
||||||
if(it->imag() < qMin)
|
}
|
||||||
qMin = it->imag();
|
|
||||||
else if(it->imag() > qMax)
|
|
||||||
qMax = it->imag();
|
|
||||||
|
|
||||||
} else {
|
if (it->imag() < qMin) {
|
||||||
|
qMin = it->imag();
|
||||||
|
} else if (it->imag() > qMax) {
|
||||||
|
qMax = it->imag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
iMin = it->real();
|
iMin = it->real();
|
||||||
iMax = it->real();
|
iMax = it->real();
|
||||||
qMin = it->imag();
|
qMin = it->imag();
|
||||||
@ -199,12 +216,14 @@ void DSPEngine::imbalance(SampleVector::iterator begin, SampleVector::iterator e
|
|||||||
m_qRange = (m_qRange * 15 + (qMax - qMin)) >> 4;
|
m_qRange = (m_qRange * 15 + (qMax - qMin)) >> 4;
|
||||||
|
|
||||||
// calculate imbalance as Q15.16
|
// calculate imbalance as Q15.16
|
||||||
if(m_qRange != 0)
|
if(m_qRange != 0) {
|
||||||
m_imbalance = ((uint)m_iRange << 16) / (uint)m_qRange;
|
m_imbalance = ((uint)m_iRange << 16) / (uint)m_qRange;
|
||||||
|
}
|
||||||
|
|
||||||
// correct imbalance and convert back to signed int 16
|
// correct imbalance and convert back to signed int 16
|
||||||
for(SampleVector::iterator it = begin; it < end; it++)
|
for(SampleVector::iterator it = begin; it < end; it++) {
|
||||||
it->m_imag = (it->m_imag * m_imbalance) >> 16;
|
it->m_imag = (it->m_imag * m_imbalance) >> 16;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::work()
|
void DSPEngine::work()
|
||||||
@ -213,7 +232,8 @@ void DSPEngine::work()
|
|||||||
size_t samplesDone = 0;
|
size_t samplesDone = 0;
|
||||||
bool positiveOnly = false;
|
bool positiveOnly = false;
|
||||||
|
|
||||||
while((sampleFifo->fill() > 0) && (m_messageQueue.countPending() == 0) && (samplesDone < m_sampleRate)) {
|
while ((sampleFifo->fill() > 0) && (m_inputMessageQueue.countPending() == 0) && (samplesDone < m_sampleRate))
|
||||||
|
{
|
||||||
SampleVector::iterator part1begin;
|
SampleVector::iterator part1begin;
|
||||||
SampleVector::iterator part1end;
|
SampleVector::iterator part1end;
|
||||||
SampleVector::iterator part2begin;
|
SampleVector::iterator part2begin;
|
||||||
@ -222,26 +242,39 @@ void DSPEngine::work()
|
|||||||
size_t count = sampleFifo->readBegin(sampleFifo->fill(), &part1begin, &part1end, &part2begin, &part2end);
|
size_t count = sampleFifo->readBegin(sampleFifo->fill(), &part1begin, &part1end, &part2begin, &part2end);
|
||||||
|
|
||||||
// first part of FIFO data
|
// first part of FIFO data
|
||||||
if(part1begin != part1end) {
|
if (part1begin != part1end)
|
||||||
|
{
|
||||||
// correct stuff
|
// correct stuff
|
||||||
if(m_dcOffsetCorrection)
|
if (m_dcOffsetCorrection) {
|
||||||
dcOffset(part1begin, part1end);
|
dcOffset(part1begin, part1end);
|
||||||
if(m_iqImbalanceCorrection)
|
}
|
||||||
|
|
||||||
|
if (m_iqImbalanceCorrection) {
|
||||||
imbalance(part1begin, part1end);
|
imbalance(part1begin, part1end);
|
||||||
|
}
|
||||||
|
|
||||||
// feed data to handlers
|
// feed data to handlers
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) {
|
||||||
(*it)->feed(part1begin, part1end, positiveOnly);
|
(*it)->feed(part1begin, part1end, positiveOnly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// second part of FIFO data (used when block wraps around)
|
// second part of FIFO data (used when block wraps around)
|
||||||
if(part2begin != part2end) {
|
if(part2begin != part2end)
|
||||||
|
{
|
||||||
// correct stuff
|
// correct stuff
|
||||||
if(m_dcOffsetCorrection)
|
if(m_dcOffsetCorrection) {
|
||||||
dcOffset(part2begin, part2end);
|
dcOffset(part2begin, part2end);
|
||||||
if(m_iqImbalanceCorrection)
|
}
|
||||||
|
|
||||||
|
if(m_iqImbalanceCorrection) {
|
||||||
imbalance(part2begin, part2end);
|
imbalance(part2begin, part2end);
|
||||||
|
}
|
||||||
|
|
||||||
// feed data to handlers
|
// feed data to handlers
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) {
|
||||||
(*it)->feed(part2begin, part2end, positiveOnly);
|
(*it)->feed(part2begin, part2end, positiveOnly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust FIFO pointers
|
// adjust FIFO pointers
|
||||||
@ -250,6 +283,10 @@ void DSPEngine::work()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// notStarted -> idle -> init -> running -+
|
||||||
|
// ^ |
|
||||||
|
// +-----------------------+
|
||||||
|
|
||||||
DSPEngine::State DSPEngine::gotoIdle()
|
DSPEngine::State DSPEngine::gotoIdle()
|
||||||
{
|
{
|
||||||
switch(m_state) {
|
switch(m_state) {
|
||||||
@ -260,24 +297,32 @@ DSPEngine::State DSPEngine::gotoIdle()
|
|||||||
case StError:
|
case StError:
|
||||||
return StIdle;
|
return StIdle;
|
||||||
|
|
||||||
|
case StReady:
|
||||||
case StRunning:
|
case StRunning:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_sampleSource == NULL)
|
if(m_sampleSource == 0)
|
||||||
|
{
|
||||||
return StIdle;
|
return StIdle;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop everything
|
||||||
|
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||||
|
{
|
||||||
(*it)->stop();
|
(*it)->stop();
|
||||||
|
}
|
||||||
|
|
||||||
m_sampleSource->stopInput();
|
m_sampleSource->stopInput();
|
||||||
m_deviceDescription.clear();
|
m_deviceDescription.clear();
|
||||||
m_audioOutput.stop();
|
m_audioSink.stop();
|
||||||
m_sampleRate = 0;
|
m_sampleRate = 0;
|
||||||
|
|
||||||
return StIdle;
|
return StIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
DSPEngine::State DSPEngine::gotoRunning()
|
DSPEngine::State DSPEngine::gotoInit()
|
||||||
{
|
{
|
||||||
switch(m_state) {
|
switch(m_state) {
|
||||||
case StNotStarted:
|
case StNotStarted:
|
||||||
@ -286,35 +331,89 @@ DSPEngine::State DSPEngine::gotoRunning()
|
|||||||
case StRunning:
|
case StRunning:
|
||||||
return StRunning;
|
return StRunning;
|
||||||
|
|
||||||
|
case StReady:
|
||||||
|
return StReady;
|
||||||
|
|
||||||
case StIdle:
|
case StIdle:
|
||||||
case StError:
|
case StError:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_sampleSource == 0)
|
||||||
|
{
|
||||||
|
return gotoError("No sample source configured");
|
||||||
|
}
|
||||||
|
|
||||||
|
// init: pass sample rate to all sample rate dependent sinks waiting for completion
|
||||||
|
|
||||||
|
m_deviceDescription = m_sampleSource->getDeviceDescription();
|
||||||
|
m_centerFrequency = m_sampleSource->getCenterFrequency();
|
||||||
|
m_sampleRate = m_sampleSource->getSampleRate();
|
||||||
|
qDebug() << "DSPEngine::gotoInit: " << m_deviceDescription.toStdString().c_str()
|
||||||
|
<< ": sampleRate: " << m_sampleRate
|
||||||
|
<< " centerFrequency: " << m_centerFrequency;
|
||||||
|
|
||||||
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||||
|
{
|
||||||
|
qDebug() << " - " << (*it)->objectName().toStdString().c_str();
|
||||||
|
DSPSignalNotification* notif = DSPSignalNotification::create(m_sampleRate, 0);
|
||||||
|
//notif->execute(&m_outputMessageQueue, *it); // wait for completion
|
||||||
|
(*it)->executeMessage(notif);
|
||||||
|
(*it)->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// pass sample rate to main window
|
||||||
|
|
||||||
|
Message* rep = DSPEngineReport::create(m_sampleRate, m_centerFrequency);
|
||||||
|
rep->submit(&m_outputMessageQueue);
|
||||||
|
|
||||||
|
return StReady;
|
||||||
|
}
|
||||||
|
|
||||||
|
DSPEngine::State DSPEngine::gotoRunning()
|
||||||
|
{
|
||||||
|
switch(m_state) {
|
||||||
|
case StNotStarted:
|
||||||
|
return StNotStarted;
|
||||||
|
|
||||||
|
case StIdle:
|
||||||
|
return StIdle;
|
||||||
|
|
||||||
|
case StRunning:
|
||||||
|
return StRunning;
|
||||||
|
|
||||||
|
case StReady:
|
||||||
|
case StError:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(m_sampleSource == NULL) {
|
if(m_sampleSource == NULL) {
|
||||||
return gotoError("No sample source configured");
|
return gotoError("No sample source configured");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "DSPEngine::gotoRunning: " << m_deviceDescription.toStdString().c_str() << " started";
|
||||||
|
|
||||||
m_iOffset = 0;
|
m_iOffset = 0;
|
||||||
m_qOffset = 0;
|
m_qOffset = 0;
|
||||||
m_iRange = 1 << 16;
|
m_iRange = 1 << 16;
|
||||||
m_qRange = 1 << 16;
|
m_qRange = 1 << 16;
|
||||||
|
|
||||||
if(!m_sampleSource->startInput(0)) {
|
// Start everything
|
||||||
|
|
||||||
|
if(!m_sampleSource->startInput(0))
|
||||||
|
{
|
||||||
return gotoError("Could not start sample source");
|
return gotoError("Could not start sample source");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_deviceDescription = m_sampleSource->getDeviceDescription();
|
m_audioSink.start(0, 48000);
|
||||||
qDebug() << "DSPEngine::gotoRunning: " << m_deviceDescription.toStdString().c_str() << " started";
|
|
||||||
|
|
||||||
m_audioOutput.start(0, 48000);
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||||
|
{
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) {
|
|
||||||
(*it)->start();
|
(*it)->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleRate = 0; // make sure, report is sent
|
m_sampleRate = 0; // make sure, report is sent
|
||||||
generateReport();
|
//generateReport();
|
||||||
|
|
||||||
return StRunning;
|
return StRunning;
|
||||||
}
|
}
|
||||||
@ -335,48 +434,62 @@ void DSPEngine::handleSetSource(SampleSource* source)
|
|||||||
m_sampleSource = source;
|
m_sampleSource = source;
|
||||||
if(m_sampleSource != NULL)
|
if(m_sampleSource != NULL)
|
||||||
connect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()), Qt::QueuedConnection);
|
connect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()), Qt::QueuedConnection);
|
||||||
generateReport();
|
//generateReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void DSPEngine::generateReport()
|
void DSPEngine::generateReport()
|
||||||
{
|
{
|
||||||
bool needReport = false;
|
bool needReport = false;
|
||||||
unsigned int sampleRate;
|
unsigned int sampleRate;
|
||||||
quint64 centerFrequency;
|
quint64 centerFrequency;
|
||||||
|
|
||||||
if(m_sampleSource != NULL) {
|
if (m_sampleSource != NULL)
|
||||||
|
{
|
||||||
sampleRate = m_sampleSource->getSampleRate();
|
sampleRate = m_sampleSource->getSampleRate();
|
||||||
centerFrequency = m_sampleSource->getCenterFrequency();
|
centerFrequency = m_sampleSource->getCenterFrequency();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sampleRate = 0;
|
sampleRate = 0;
|
||||||
centerFrequency = 0;
|
centerFrequency = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sampleRate != m_sampleRate) {
|
qDebug() << "DSPEngine::generateReport:"
|
||||||
|
<< " sampleRate: " << sampleRate
|
||||||
|
<< " centerFrequency: " << centerFrequency;
|
||||||
|
|
||||||
|
if (sampleRate != m_sampleRate)
|
||||||
|
{
|
||||||
m_sampleRate = sampleRate;
|
m_sampleRate = sampleRate;
|
||||||
needReport = true;
|
needReport = true;
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) {
|
|
||||||
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||||
|
{
|
||||||
DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0);
|
DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0);
|
||||||
signal->submit(&m_messageQueue, *it);
|
signal->submit(&m_reportQueue, *it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(centerFrequency != m_centerFrequency) {
|
|
||||||
|
if (centerFrequency != m_centerFrequency)
|
||||||
|
{
|
||||||
m_centerFrequency = centerFrequency;
|
m_centerFrequency = centerFrequency;
|
||||||
needReport = true;
|
needReport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needReport) {
|
if (needReport)
|
||||||
|
{
|
||||||
Message* rep = DSPEngineReport::create(m_sampleRate, m_centerFrequency);
|
Message* rep = DSPEngineReport::create(m_sampleRate, m_centerFrequency);
|
||||||
rep->submit(&m_reportQueue);
|
rep->submit(&m_reportQueue);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
bool DSPEngine::distributeMessage(Message* message)
|
bool DSPEngine::distributeMessage(Message* message)
|
||||||
{
|
{
|
||||||
if(m_sampleSource != NULL) {
|
if(m_sampleSource != NULL) {
|
||||||
if((message->getDestination() == NULL) || (message->getDestination() == m_sampleSource)) {
|
if((message->getDestination() == NULL) || (message->getDestination() == m_sampleSource)) {
|
||||||
if(m_sampleSource->handleMessage(message)) {
|
if(m_sampleSource->handleMessage(message)) {
|
||||||
generateReport();
|
//generateReport();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,11 +509,13 @@ void DSPEngine::handleData()
|
|||||||
work();
|
work();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::handleMessages()
|
void DSPEngine::handleInputMessages()
|
||||||
{
|
{
|
||||||
Message* message;
|
Message* message;
|
||||||
while((message = m_messageQueue.accept()) != NULL) {
|
|
||||||
qDebug("DSPEngine::handleMessages: Message: %s", message->getIdentifier());
|
while ((message = m_inputMessageQueue.accept()) != NULL)
|
||||||
|
{
|
||||||
|
qDebug("DSPEngine::handleInputMessages: Message: %s", message->getIdentifier());
|
||||||
|
|
||||||
if (DSPPing::match(message))
|
if (DSPPing::match(message))
|
||||||
{
|
{
|
||||||
@ -413,12 +528,22 @@ void DSPEngine::handleMessages()
|
|||||||
exit();
|
exit();
|
||||||
message->completed(m_state);
|
message->completed(m_state);
|
||||||
}
|
}
|
||||||
else if (DSPAcquisitionStart::match(message))
|
else if (DSPAcquisitionInit::match(message))
|
||||||
{
|
{
|
||||||
m_state = gotoIdle();
|
m_state = gotoIdle();
|
||||||
|
|
||||||
if(m_state == StIdle) {
|
if(m_state == StIdle) {
|
||||||
|
m_state = gotoInit(); // State goes ready if OK or stays idle
|
||||||
|
}
|
||||||
|
|
||||||
|
message->completed(m_state);
|
||||||
|
}
|
||||||
|
else if (DSPAcquisitionStart::match(message))
|
||||||
|
{
|
||||||
|
if(m_state == StReady) {
|
||||||
m_state = gotoRunning();
|
m_state = gotoRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
message->completed(m_state);
|
message->completed(m_state);
|
||||||
}
|
}
|
||||||
else if (DSPAcquisitionStop::match(message))
|
else if (DSPAcquisitionStop::match(message))
|
||||||
@ -426,9 +551,9 @@ void DSPEngine::handleMessages()
|
|||||||
m_state = gotoIdle();
|
m_state = gotoIdle();
|
||||||
message->completed(m_state);
|
message->completed(m_state);
|
||||||
}
|
}
|
||||||
else if (DSPGetDeviceDescription::match(message))
|
else if (DSPGetSourceDeviceDescription::match(message))
|
||||||
{
|
{
|
||||||
((DSPGetDeviceDescription*)message)->setDeviceDescription(m_deviceDescription);
|
((DSPGetSourceDeviceDescription*)message)->setDeviceDescription(m_deviceDescription);
|
||||||
message->completed();
|
message->completed();
|
||||||
}
|
}
|
||||||
else if (DSPGetErrorMessage::match(message))
|
else if (DSPGetErrorMessage::match(message))
|
||||||
@ -444,12 +569,13 @@ void DSPEngine::handleMessages()
|
|||||||
{
|
{
|
||||||
SampleSink* sink = ((DSPAddSink*)message)->getSampleSink();
|
SampleSink* sink = ((DSPAddSink*)message)->getSampleSink();
|
||||||
|
|
||||||
if(m_state == StRunning)
|
/*
|
||||||
|
if(m_state == StRunning) // FIXME: fix this mess once init phase is coded
|
||||||
{
|
{
|
||||||
DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0);
|
DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0);
|
||||||
signal->submit(&m_messageQueue, sink);
|
signal->submit(&m_outputMessageQueue, sink);
|
||||||
sink->start();
|
sink->start();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
m_sampleSinks.push_back(sink);
|
m_sampleSinks.push_back(sink);
|
||||||
message->completed();
|
message->completed();
|
||||||
@ -465,14 +591,14 @@ void DSPEngine::handleMessages()
|
|||||||
m_sampleSinks.remove(sink);
|
m_sampleSinks.remove(sink);
|
||||||
message->completed();
|
message->completed();
|
||||||
}
|
}
|
||||||
else if (DSPAddAudioSource::match(message))
|
else if (DSPAddAudioSink::match(message))
|
||||||
{
|
{
|
||||||
m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo());
|
m_audioSink.addFifo(((DSPAddAudioSink*)message)->getAudioFifo());
|
||||||
message->completed();
|
message->completed();
|
||||||
}
|
}
|
||||||
else if (DSPRemoveAudioSource::match(message))
|
else if (DSPRemoveAudioSink::match(message))
|
||||||
{
|
{
|
||||||
m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo());
|
m_audioSink.removeFifo(((DSPAddAudioSink*)message)->getAudioFifo());
|
||||||
message->completed();
|
message->completed();
|
||||||
}
|
}
|
||||||
else if (DSPConfigureCorrection::match(message))
|
else if (DSPConfigureCorrection::match(message))
|
||||||
@ -504,7 +630,8 @@ void DSPEngine::handleMessages()
|
|||||||
DSPSignalNotification *conf = (DSPSignalNotification*)message;
|
DSPSignalNotification *conf = (DSPSignalNotification*)message;
|
||||||
qDebug() << " (" << conf->getSampleRate() << "," << conf->getFrequencyOffset() << ")";
|
qDebug() << " (" << conf->getSampleRate() << "," << conf->getFrequencyOffset() << ")";
|
||||||
}
|
}
|
||||||
if(!distributeMessage(message)) {
|
if (!distributeMessage(message))
|
||||||
|
{
|
||||||
message->completed();
|
message->completed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ FileSink::FileSink() :
|
|||||||
m_recordStart(false),
|
m_recordStart(false),
|
||||||
m_byteCount(0)
|
m_byteCount(0)
|
||||||
{
|
{
|
||||||
|
setObjectName("FileSink");
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSink::~FileSink()
|
FileSink::~FileSink()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
NullSink::NullSink()
|
NullSink::NullSink()
|
||||||
{
|
{
|
||||||
|
setObjectName("NullSink");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NullSink::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
void NullSink::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
|
@ -8,6 +8,11 @@ SampleSink::~SampleSink()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SampleSink::executeMessage(Message *cmd)
|
||||||
|
{
|
||||||
|
return handleMessage(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#include "samplesink.h"
|
#include "samplesink.h"
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ ScopeVis::ScopeVis(GLScope* glScope) :
|
|||||||
m_armed(false),
|
m_armed(false),
|
||||||
m_sampleRate(0)
|
m_sampleRate(0)
|
||||||
{
|
{
|
||||||
|
setObjectName("ScopeVis");
|
||||||
m_trace.reserve(100*m_traceChunkSize);
|
m_trace.reserve(100*m_traceChunkSize);
|
||||||
m_trace.resize(20*m_traceChunkSize);
|
m_trace.resize(20*m_traceChunkSize);
|
||||||
m_traceback.resize(20*m_traceChunkSize);
|
m_traceback.resize(20*m_traceChunkSize);
|
||||||
|
@ -6,6 +6,7 @@ SpectrumScopeComboVis::SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis*
|
|||||||
m_spectrumVis(spectrumVis),
|
m_spectrumVis(spectrumVis),
|
||||||
m_scopeVis(scopeVis)
|
m_scopeVis(scopeVis)
|
||||||
{
|
{
|
||||||
|
setObjectName("SpectrumScopeComboVis");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrumScopeComboVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
void SpectrumScopeComboVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
|
@ -21,6 +21,7 @@ SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) :
|
|||||||
m_needMoreSamples(false),
|
m_needMoreSamples(false),
|
||||||
m_glSpectrum(glSpectrum)
|
m_glSpectrum(glSpectrum)
|
||||||
{
|
{
|
||||||
|
setObjectName("SpectrumVis");
|
||||||
handleConfigure(1024, 0, FFTWindow::BlackmanHarris);
|
handleConfigure(1024, 0, FFTWindow::BlackmanHarris);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QDebug>
|
||||||
#include "dsp/threadedsamplesink.h"
|
#include "dsp/threadedsamplesink.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
@ -6,6 +7,7 @@ ThreadedSampleSink::ThreadedSampleSink(SampleSink* sampleSink) :
|
|||||||
m_thread(new QThread),
|
m_thread(new QThread),
|
||||||
m_sampleSink(sampleSink)
|
m_sampleSink(sampleSink)
|
||||||
{
|
{
|
||||||
|
setObjectName("ThreadedSampleSink");
|
||||||
moveToThread(m_thread);
|
moveToThread(m_thread);
|
||||||
connect(m_thread, SIGNAL(started()), this, SLOT(threadStarted()));
|
connect(m_thread, SIGNAL(started()), this, SLOT(threadStarted()));
|
||||||
connect(m_thread, SIGNAL(finished()), this, SLOT(threadFinished()));
|
connect(m_thread, SIGNAL(finished()), this, SLOT(threadFinished()));
|
||||||
@ -47,11 +49,34 @@ void ThreadedSampleSink::stop()
|
|||||||
|
|
||||||
bool ThreadedSampleSink::handleMessage(Message* cmd)
|
bool ThreadedSampleSink::handleMessage(Message* cmd)
|
||||||
{
|
{
|
||||||
|
qDebug() << "ThreadedSampleSink::handleMessage: "
|
||||||
|
<< m_sampleSink->objectName().toStdString().c_str()
|
||||||
|
<< ": " << cmd->getIdentifier();
|
||||||
// called from other thread
|
// called from other thread
|
||||||
m_messageQueue.submit(cmd);
|
m_messageQueue.submit(cmd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ThreadedSampleSink::executeMessage(Message* cmd)
|
||||||
|
{
|
||||||
|
qDebug() << "ThreadedSampleSink::executeMessage: "
|
||||||
|
<< m_sampleSink->objectName().toStdString().c_str()
|
||||||
|
<< ": " << cmd->getIdentifier();
|
||||||
|
|
||||||
|
if (m_sampleSink != NULL)
|
||||||
|
{
|
||||||
|
if (!m_sampleSink->handleMessage(cmd)) {
|
||||||
|
cmd->completed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd->completed();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ThreadedSampleSink::handleData()
|
void ThreadedSampleSink::handleData()
|
||||||
{
|
{
|
||||||
bool positiveOnly = false;
|
bool positiveOnly = false;
|
||||||
|
@ -54,7 +54,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
m_sampleFileName(std::string("./test.sdriq")),
|
m_sampleFileName(std::string("./test.sdriq")),
|
||||||
m_pluginManager(new PluginManager(this, m_dspEngine))
|
m_pluginManager(new PluginManager(this, m_dspEngine))
|
||||||
{
|
{
|
||||||
connect(m_dspEngine->getReportQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
|
connect(m_dspEngine->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
|
||||||
m_dspEngine->start();
|
m_dspEngine->start();
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -108,7 +108,7 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
m_dspEngine->addSink(m_fileSink);
|
m_dspEngine->addSink(m_fileSink);
|
||||||
|
|
||||||
ui->glSpectrum->connectTimer(m_masterTimer);
|
ui->glSpectrum->connectTimer(m_masterTimer);
|
||||||
ui->glSpectrumGUI->setBuddies(m_dspEngine->getMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
ui->glSpectrumGUI->setBuddies(m_dspEngine->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ void MainWindow::handleDSPMessages()
|
|||||||
{
|
{
|
||||||
Message* message;
|
Message* message;
|
||||||
|
|
||||||
while ((message = m_dspEngine->getReportQueue()->accept()) != 0)
|
while ((message = m_dspEngine->getOutputMessageQueue()->accept()) != 0)
|
||||||
{
|
{
|
||||||
qDebug("Message: %s", message->getIdentifier());
|
qDebug("Message: %s", message->getIdentifier());
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ void MainWindow::handleDSPMessages()
|
|||||||
updateSampleRate();
|
updateSampleRate();
|
||||||
message->completed();
|
message->completed();
|
||||||
qDebug() << "MainWindow::handleMessages: m_fileSink->configure";
|
qDebug() << "MainWindow::handleMessages: m_fileSink->configure";
|
||||||
m_fileSink->configure(m_dspEngine->getMessageQueue(), m_sampleFileName, m_sampleRate, m_centerFrequency);
|
m_fileSink->configure(m_dspEngine->getInputMessageQueue(), m_sampleFileName, m_sampleRate, m_centerFrequency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,7 +379,7 @@ void MainWindow::updateStatus()
|
|||||||
m_engineIdle->setColor(Qt::gray);
|
m_engineIdle->setColor(Qt::gray);
|
||||||
m_engineRunning->setColor(Qt::green);
|
m_engineRunning->setColor(Qt::green);
|
||||||
m_engineError->setColor(Qt::gray);
|
m_engineError->setColor(Qt::gray);
|
||||||
statusBar()->showMessage(tr("Sampling from %1").arg(m_dspEngine->deviceDescription()));
|
statusBar()->showMessage(tr("Sampling from %1").arg(m_dspEngine->sourceDeviceDescription()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DSPEngine::StError:
|
case DSPEngine::StError:
|
||||||
@ -395,7 +395,10 @@ void MainWindow::updateStatus()
|
|||||||
|
|
||||||
void MainWindow::on_action_Start_triggered()
|
void MainWindow::on_action_Start_triggered()
|
||||||
{
|
{
|
||||||
m_dspEngine->startAcquisition();
|
if (m_dspEngine->initAcquisition())
|
||||||
|
{
|
||||||
|
m_dspEngine->startAcquisition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_action_Stop_triggered()
|
void MainWindow::on_action_Stop_triggered()
|
||||||
|
@ -72,17 +72,17 @@ void PluginAPI::removeSampleSink(SampleSink* sampleSink)
|
|||||||
|
|
||||||
MessageQueue* PluginAPI::getDSPEngineMessageQueue()
|
MessageQueue* PluginAPI::getDSPEngineMessageQueue()
|
||||||
{
|
{
|
||||||
return m_dspEngine->getMessageQueue();
|
return m_dspEngine->getInputMessageQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginAPI::addAudioSource(AudioFifo* audioFifo)
|
void PluginAPI::addAudioSource(AudioFifo* audioFifo)
|
||||||
{
|
{
|
||||||
m_dspEngine->addAudioSource(audioFifo);
|
m_dspEngine->addAudioSink(audioFifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginAPI::removeAudioSource(AudioFifo* audioFifo)
|
void PluginAPI::removeAudioSource(AudioFifo* audioFifo)
|
||||||
{
|
{
|
||||||
m_dspEngine->removeAudioSource(audioFifo);
|
m_dspEngine->removeAudioSink(audioFifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginAPI::registerSampleSource(const QString& sourceName, PluginInterface* plugin)
|
void PluginAPI::registerSampleSource(const QString& sourceName, PluginInterface* plugin)
|
||||||
|
@ -38,3 +38,8 @@ int MessageQueue::countPending()
|
|||||||
|
|
||||||
return m_queue.size();
|
return m_queue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageQueue::clear()
|
||||||
|
{
|
||||||
|
m_queue.clear();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user