1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Small sequence of calls re-org in Main Window. Better debug messages

This commit is contained in:
f4exb 2015-08-10 00:09:10 +02:00
parent af8602a4d9
commit 058fcdc4e1
5 changed files with 101 additions and 35 deletions

View File

@ -27,7 +27,7 @@ BladerfThread::BladerfThread(struct bladerf* dev, SampleFifo* sampleFifo, QObjec
m_dev(dev),
m_convertBuffer(BLADERF_BLOCKSIZE),
m_sampleFifo(sampleFifo),
m_samplerate(3072000),
m_samplerate(10),
m_log2Decim(0),
m_fcPos(0)
{

View File

@ -6,10 +6,10 @@
Channelizer::Channelizer(SampleSink* sampleSink) :
m_sampleSink(sampleSink),
m_inputSampleRate(100000),
m_requestedOutputSampleRate(100000),
m_inputSampleRate(10),
m_requestedOutputSampleRate(10),
m_requestedCenterFrequency(0),
m_currentOutputSampleRate(100000),
m_currentOutputSampleRate(0),
m_currentCenterFrequency(0)
{
}
@ -62,34 +62,50 @@ void Channelizer::stop()
bool Channelizer::handleMessage(Message* cmd)
{
if(DSPSignalNotification::match(cmd)) {
if (DSPSignalNotification::match(cmd))
{
DSPSignalNotification* signal = (DSPSignalNotification*)cmd;
m_inputSampleRate = signal->getSampleRate();
qDebug() << "Channelizer::handleMessage: DSPSignalNotification: m_inputSampleRate: " << m_inputSampleRate;
applyConfiguration();
cmd->completed();
if(m_sampleSink != NULL) {
if(m_sampleSink != NULL)
{
signal = DSPSignalNotification::create(m_currentOutputSampleRate, m_currentCenterFrequency);
if(!m_sampleSink->handleMessage(signal))
if(!m_sampleSink->handleMessage(signal)) {
signal->completed();
}
}
emit inputSampleRateChanged();
return true;
} else if(DSPConfigureChannelizer::match(cmd)) {
}
else if (DSPConfigureChannelizer::match(cmd))
{
DSPConfigureChannelizer* chan = (DSPConfigureChannelizer*)cmd;
m_requestedOutputSampleRate = chan->getSampleRate();
m_requestedCenterFrequency = chan->getCenterFrequency();
qDebug() << "Channelizer::handleMessage: DSPConfigureChannelizer:"
<< " m_requestedOutputSampleRate: " << m_requestedOutputSampleRate
<< " m_requestedCenterFrequency: " << m_requestedCenterFrequency;
applyConfiguration();
cmd->completed();
if(m_sampleSink != NULL) {
if(m_sampleSink != NULL)
{
DSPSignalNotification* signal = DSPSignalNotification::create(m_currentOutputSampleRate, m_currentCenterFrequency);
if(!m_sampleSink->handleMessage(signal))
if(!m_sampleSink->handleMessage(signal)) {
signal->completed();
}
}
return true;
} else {
if(m_sampleSink != NULL)
}
else
{
if(m_sampleSink != NULL) {
return m_sampleSink->handleMessage(cmd);
else return false;
} else {
return false;
}
}
}

View File

@ -16,6 +16,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <QDebug>
#include "dsp/dspengine.h"
#include "dsp/channelizer.h"
#include "dsp/samplefifo.h"
@ -25,6 +26,8 @@
DSPEngine::DSPEngine(QObject* parent) :
QThread(parent),
m_messageQueue(),
m_reportQueue(),
m_state(StNotStarted),
m_sampleSource(NULL),
m_sampleSinks(),
@ -54,6 +57,7 @@ DSPEngine *DSPEngine::instance()
void DSPEngine::start()
{
qDebug() << "DSPEngine::start";
DSPPing cmd;
QThread::start();
cmd.execute(&m_messageQueue);
@ -61,6 +65,7 @@ void DSPEngine::start()
void DSPEngine::stop()
{
qDebug() << "DSPEngine::stop";
DSPExit cmd;
cmd.execute(&m_messageQueue);
}
@ -131,6 +136,8 @@ QString DSPEngine::deviceDescription()
void DSPEngine::run()
{
qDebug() << "DSPEngine::run";
connect(&m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
m_state = StIdle;
@ -386,71 +393,113 @@ void DSPEngine::handleMessages()
{
Message* message;
while((message = m_messageQueue.accept()) != NULL) {
qDebug("Message: %s", message->getIdentifier());
qDebug("DSPEngine::handleMessages: Message: %s", message->getIdentifier());
if(DSPPing::match(message)) {
if (DSPPing::match(message))
{
message->completed(m_state);
} else if(DSPExit::match(message)) {
}
else if (DSPExit::match(message))
{
gotoIdle();
m_state = StNotStarted;
exit();
message->completed(m_state);
} else if(DSPAcquisitionStart::match(message)) {
}
else if (DSPAcquisitionStart::match(message))
{
m_state = gotoIdle();
if(m_state == StIdle)
if(m_state == StIdle) {
m_state = gotoRunning();
}
message->completed(m_state);
} else if(DSPAcquisitionStop::match(message)) {
}
else if (DSPAcquisitionStop::match(message))
{
m_state = gotoIdle();
message->completed(m_state);
} else if(DSPGetDeviceDescription::match(message)) {
}
else if (DSPGetDeviceDescription::match(message))
{
((DSPGetDeviceDescription*)message)->setDeviceDescription(m_deviceDescription);
message->completed();
} else if(DSPGetErrorMessage::match(message)) {
}
else if (DSPGetErrorMessage::match(message))
{
((DSPGetErrorMessage*)message)->setErrorMessage(m_errorMessage);
message->completed();
} else if(DSPSetSource::match(message)) {
}
else if (DSPSetSource::match(message)) {
handleSetSource(((DSPSetSource*)message)->getSampleSource());
message->completed();
} else if(DSPAddSink::match(message)) {
}
else if (DSPAddSink::match(message))
{
SampleSink* sink = ((DSPAddSink*)message)->getSampleSink();
if(m_state == StRunning) {
if(m_state == StRunning)
{
DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0);
signal->submit(&m_messageQueue, sink);
sink->start();
}
m_sampleSinks.push_back(sink);
message->completed();
} else if(DSPRemoveSink::match(message)) {
}
else if (DSPRemoveSink::match(message))
{
SampleSink* sink = ((DSPAddSink*)message)->getSampleSink();
if(m_state == StRunning)
if(m_state == StRunning) {
sink->stop();
}
m_sampleSinks.remove(sink);
message->completed();
} else if(DSPAddAudioSource::match(message)) {
}
else if (DSPAddAudioSource::match(message))
{
m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo());
message->completed();
} else if(DSPRemoveAudioSource::match(message)) {
}
else if (DSPRemoveAudioSource::match(message))
{
m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo());
message->completed();
} else if(DSPConfigureCorrection::match(message)) {
}
else if (DSPConfigureCorrection::match(message))
{
DSPConfigureCorrection* conf = (DSPConfigureCorrection*)message;
m_iqImbalanceCorrection = conf->getIQImbalanceCorrection();
if(m_dcOffsetCorrection != conf->getDCOffsetCorrection()) {
if(m_dcOffsetCorrection != conf->getDCOffsetCorrection())
{
m_dcOffsetCorrection = conf->getDCOffsetCorrection();
m_iOffset = 0;
m_qOffset = 0;
}
if(m_iqImbalanceCorrection != conf->getIQImbalanceCorrection()) {
if(m_iqImbalanceCorrection != conf->getIQImbalanceCorrection())
{
m_iqImbalanceCorrection = conf->getIQImbalanceCorrection();
m_iRange = 1 << 16;
m_qRange = 1 << 16;
m_imbalance = 65536;
}
message->completed();
} else {
if(!distributeMessage(message))
}
else
{
if (DSPSignalNotification::match(message))
{
DSPSignalNotification *conf = (DSPSignalNotification*)message;
qDebug() << " (" << conf->getSampleRate() << "," << conf->getFrequencyOffset() << ")";
}
if(!distributeMessage(message)) {
message->completed();
}
}
}
}

View File

@ -85,7 +85,7 @@ void ThreadedSampleSink::handleMessages()
{
Message* message;
while((message = m_messageQueue.accept()) != NULL) {
qDebug("CMD: %s", message->getIdentifier());
qDebug("ThreadedSampleSink::handleMessages: %s", message->getIdentifier());
if(m_sampleSink != NULL) {
if(!m_sampleSink->handleMessage(message))
message->completed();

View File

@ -54,6 +54,7 @@ MainWindow::MainWindow(QWidget* parent) :
m_sampleFileName(std::string("./test.sdriq")),
m_pluginManager(new PluginManager(this, m_dspEngine))
{
connect(m_dspEngine->getReportQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
m_dspEngine->start();
ui->setupUi(this);
@ -85,7 +86,7 @@ MainWindow::MainWindow(QWidget* parent) :
ui->menu_Window->addAction(ui->channelDock->toggleViewAction());
connect(m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
connect(m_dspEngine->getReportQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
//connect(m_dspEngine->getReportQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);