mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 09:18:54 -05:00
Removed SyncMessenger from DSPDeviceSourceEngine. Part of #2159
This commit is contained in:
parent
6b2573d955
commit
9fa1974ba3
@ -47,7 +47,6 @@ DSPDeviceSourceEngine::DSPDeviceSourceEngine(uint uid, QObject* parent) :
|
|||||||
m_imbalance(65536)
|
m_imbalance(65536)
|
||||||
{
|
{
|
||||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||||
connect(&m_syncMessenger, SIGNAL(messageSent()), this, SLOT(handleSynchronousMessages()), Qt::QueuedConnection);
|
|
||||||
|
|
||||||
moveToThread(this);
|
moveToThread(this);
|
||||||
}
|
}
|
||||||
@ -69,61 +68,55 @@ void DSPDeviceSourceEngine::setState(State state)
|
|||||||
|
|
||||||
void DSPDeviceSourceEngine::run()
|
void DSPDeviceSourceEngine::run()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::run";
|
qDebug("DSPDeviceSourceEngine::run");
|
||||||
setState(StIdle);
|
setState(StIdle);
|
||||||
exec();
|
exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::start()
|
void DSPDeviceSourceEngine::start()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::start";
|
qDebug("DSPDeviceSourceEngine::start");
|
||||||
QThread::start();
|
QThread::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::stop()
|
void DSPDeviceSourceEngine::stop()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::stop";
|
qDebug("DSPDeviceSourceEngine::stop");
|
||||||
gotoIdle();
|
gotoIdle();
|
||||||
setState(StNotStarted);
|
setState(StNotStarted);
|
||||||
QThread::exit();
|
QThread::exit();
|
||||||
// DSPExit cmd;
|
|
||||||
// m_syncMessenger.sendWait(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DSPDeviceSourceEngine::initAcquisition()
|
bool DSPDeviceSourceEngine::initAcquisition()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::initAcquisition";
|
qDebug("DSPDeviceSourceEngine::initAcquisition (dummy)");
|
||||||
DSPAcquisitionInit cmd;
|
return true;
|
||||||
|
|
||||||
return m_syncMessenger.sendWait(cmd) == StReady;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DSPDeviceSourceEngine::startAcquisition()
|
bool DSPDeviceSourceEngine::startAcquisition()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::startAcquisition";
|
qDebug("DSPDeviceSourceEngine::startAcquisition");
|
||||||
DSPAcquisitionStart cmd;
|
auto *cmd = new DSPAcquisitionStart();
|
||||||
|
getInputMessageQueue()->push(cmd);
|
||||||
return m_syncMessenger.sendWait(cmd) == StRunning;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::stopAcquistion()
|
void DSPDeviceSourceEngine::stopAcquistion()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::stopAcquistion";
|
qDebug("DSPDeviceSourceEngine::stopAcquistion");
|
||||||
DSPAcquisitionStop cmd;
|
auto *cmd = new DSPAcquisitionStop();
|
||||||
m_syncMessenger.storeMessage(cmd);
|
getInputMessageQueue()->push(cmd);
|
||||||
handleSynchronousMessages();
|
|
||||||
|
|
||||||
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 DSPDeviceSourceEngine::setSource(DeviceSampleSource* source)
|
void DSPDeviceSourceEngine::setSource(DeviceSampleSource* source)
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::setSource";
|
qDebug("DSPDeviceSourceEngine::setSource");
|
||||||
DSPSetSource cmd(source);
|
auto *cmd = new DSPSetSource(source);
|
||||||
m_syncMessenger.sendWait(cmd);
|
getInputMessageQueue()->push(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::setSourceSequence(int sequence)
|
void DSPDeviceSourceEngine::setSourceSequence(int sequence)
|
||||||
@ -135,38 +128,34 @@ void DSPDeviceSourceEngine::setSourceSequence(int sequence)
|
|||||||
void DSPDeviceSourceEngine::addSink(BasebandSampleSink* sink)
|
void DSPDeviceSourceEngine::addSink(BasebandSampleSink* sink)
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::addSink: " << sink->getSinkName().toStdString().c_str();
|
qDebug() << "DSPDeviceSourceEngine::addSink: " << sink->getSinkName().toStdString().c_str();
|
||||||
DSPAddBasebandSampleSink cmd(sink);
|
auto *cmd = new DSPAddBasebandSampleSink(sink);
|
||||||
m_syncMessenger.sendWait(cmd);
|
getInputMessageQueue()->push(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::removeSink(BasebandSampleSink* sink)
|
void DSPDeviceSourceEngine::removeSink(BasebandSampleSink* sink)
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::removeSink: " << sink->getSinkName().toStdString().c_str();
|
qDebug() << "DSPDeviceSourceEngine::removeSink: " << sink->getSinkName().toStdString().c_str();
|
||||||
DSPRemoveBasebandSampleSink cmd(sink);
|
auto *cmd = new DSPRemoveBasebandSampleSink(sink);
|
||||||
m_syncMessenger.sendWait(cmd);
|
getInputMessageQueue()->push(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection)
|
void DSPDeviceSourceEngine::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection)
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::configureCorrections";
|
qDebug("DSPDeviceSourceEngine::configureCorrections");
|
||||||
DSPConfigureCorrection* cmd = new DSPConfigureCorrection(dcOffsetCorrection, iqImbalanceCorrection);
|
auto *cmd = new DSPConfigureCorrection(dcOffsetCorrection, iqImbalanceCorrection);
|
||||||
m_inputMessageQueue.push(cmd);
|
getInputMessageQueue()->push(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DSPDeviceSourceEngine::errorMessage()
|
QString DSPDeviceSourceEngine::errorMessage() const
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::errorMessage";
|
qDebug("DSPDeviceSourceEngine::errorMessage");
|
||||||
DSPGetErrorMessage cmd;
|
return m_errorMessage;
|
||||||
m_syncMessenger.sendWait(cmd);
|
|
||||||
return cmd.getErrorMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DSPDeviceSourceEngine::sourceDeviceDescription()
|
QString DSPDeviceSourceEngine::sourceDeviceDescription() const
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::sourceDeviceDescription";
|
qDebug("DSPDeviceSourceEngine::sourceDeviceDescription");
|
||||||
DSPGetSourceDeviceDescription cmd;
|
return m_deviceDescription;
|
||||||
m_syncMessenger.sendWait(cmd);
|
|
||||||
return cmd.getDeviceDescription();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::iqCorrections(SampleVector::iterator begin, SampleVector::iterator end, bool imbalanceCorrection)
|
void DSPDeviceSourceEngine::iqCorrections(SampleVector::iterator begin, SampleVector::iterator end, bool imbalanceCorrection)
|
||||||
@ -217,8 +206,8 @@ void DSPDeviceSourceEngine::iqCorrections(SampleVector::iterator begin, SampleVe
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
// DC correction and conversion
|
// DC correction and conversion
|
||||||
float xi = (it->m_real - (int32_t) m_iBeta) / SDR_RX_SCALEF;
|
float xi = (float) (it->m_real - (int32_t) m_iBeta) / SDR_RX_SCALEF;
|
||||||
float xq = (it->m_imag - (int32_t) m_qBeta) / SDR_RX_SCALEF;
|
float xq = (float) (it->m_imag - (int32_t) m_qBeta) / SDR_RX_SCALEF;
|
||||||
|
|
||||||
// phase imbalance
|
// phase imbalance
|
||||||
m_avgII(xi*xi); // <I", I">
|
m_avgII(xi*xi); // <I", I">
|
||||||
@ -263,10 +252,10 @@ void DSPDeviceSourceEngine::dcOffset(SampleVector::iterator begin, SampleVector:
|
|||||||
// 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++)
|
||||||
{
|
{
|
||||||
m_iBeta(it->real());
|
m_iBeta(it->real());
|
||||||
m_qBeta(it->imag());
|
m_qBeta(it->imag());
|
||||||
it->m_real -= (int32_t) m_iBeta;
|
it->m_real -= (int32_t) m_iBeta;
|
||||||
it->m_imag -= (int32_t) m_qBeta;
|
it->m_imag -= (int32_t) m_qBeta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +365,7 @@ void DSPDeviceSourceEngine::work()
|
|||||||
|
|
||||||
DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoIdle()
|
DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoIdle()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::gotoIdle";
|
qDebug("DSPDeviceSourceEngine::gotoIdle");
|
||||||
|
|
||||||
switch(m_state) {
|
switch(m_state) {
|
||||||
case StNotStarted:
|
case StNotStarted:
|
||||||
@ -442,14 +431,14 @@ DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoInit()
|
|||||||
m_sampleRate = m_deviceSampleSource->getSampleRate();
|
m_sampleRate = m_deviceSampleSource->getSampleRate();
|
||||||
|
|
||||||
qDebug() << "DSPDeviceSourceEngine::gotoInit: "
|
qDebug() << "DSPDeviceSourceEngine::gotoInit: "
|
||||||
<< " m_deviceDescription: " << m_deviceDescription.toStdString().c_str()
|
<< " m_deviceDescription: " << m_deviceDescription.toStdString().c_str()
|
||||||
<< " sampleRate: " << m_sampleRate
|
<< " sampleRate: " << m_sampleRate
|
||||||
<< " centerFrequency: " << m_centerFrequency;
|
<< " centerFrequency: " << m_centerFrequency;
|
||||||
|
|
||||||
|
|
||||||
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it)
|
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it)
|
||||||
{
|
{
|
||||||
DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
auto *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
||||||
qDebug() << "DSPDeviceSourceEngine::gotoInit: initializing " << (*it)->getSinkName().toStdString().c_str();
|
qDebug() << "DSPDeviceSourceEngine::gotoInit: initializing " << (*it)->getSinkName().toStdString().c_str();
|
||||||
(*it)->pushMessage(notif);
|
(*it)->pushMessage(notif);
|
||||||
}
|
}
|
||||||
@ -457,7 +446,7 @@ DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoInit()
|
|||||||
// pass data to listeners
|
// pass data to listeners
|
||||||
if (m_deviceSampleSource->getMessageQueueToGUI())
|
if (m_deviceSampleSource->getMessageQueueToGUI())
|
||||||
{
|
{
|
||||||
DSPSignalNotification* rep = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
auto *rep = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
||||||
m_deviceSampleSource->getMessageQueueToGUI()->push(rep);
|
m_deviceSampleSource->getMessageQueueToGUI()->push(rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +455,7 @@ DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoInit()
|
|||||||
|
|
||||||
DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoRunning()
|
DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoRunning()
|
||||||
{
|
{
|
||||||
qDebug() << "DSPDeviceSourceEngine::gotoRunning";
|
qDebug("DSPDeviceSourceEngine::gotoRunning");
|
||||||
|
|
||||||
switch(m_state)
|
switch(m_state)
|
||||||
{
|
{
|
||||||
@ -521,11 +510,6 @@ void DSPDeviceSourceEngine::handleSetSource(DeviceSampleSource* source)
|
|||||||
{
|
{
|
||||||
gotoIdle();
|
gotoIdle();
|
||||||
|
|
||||||
// if(m_sampleSource != 0)
|
|
||||||
// {
|
|
||||||
// disconnect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()));
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_deviceSampleSource = source;
|
m_deviceSampleSource = source;
|
||||||
|
|
||||||
if (m_deviceSampleSource)
|
if (m_deviceSampleSource)
|
||||||
@ -547,55 +531,123 @@ void DSPDeviceSourceEngine::handleData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::handleSynchronousMessages()
|
bool DSPDeviceSourceEngine::handleMessage(const Message& message)
|
||||||
{
|
{
|
||||||
Message *message = m_syncMessenger.getMessage();
|
if (DSPConfigureCorrection::match(message))
|
||||||
qDebug() << "DSPDeviceSourceEngine::handleSynchronousMessages: " << message->getIdentifier();
|
{
|
||||||
|
auto& conf = (const DSPConfigureCorrection&) message;
|
||||||
|
m_iqImbalanceCorrection = conf.getIQImbalanceCorrection();
|
||||||
|
|
||||||
if (DSPAcquisitionInit::match(*message))
|
if (m_dcOffsetCorrection != conf.getDCOffsetCorrection())
|
||||||
|
{
|
||||||
|
m_dcOffsetCorrection = conf.getDCOffsetCorrection();
|
||||||
|
m_iOffset = 0;
|
||||||
|
m_qOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_iqImbalanceCorrection != conf.getIQImbalanceCorrection())
|
||||||
|
{
|
||||||
|
m_iqImbalanceCorrection = conf.getIQImbalanceCorrection();
|
||||||
|
m_iRange = 1 << 16;
|
||||||
|
m_qRange = 1 << 16;
|
||||||
|
m_imbalance = 65536;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_avgAmp.reset();
|
||||||
|
m_avgII.reset();
|
||||||
|
m_avgII2.reset();
|
||||||
|
m_avgIQ.reset();
|
||||||
|
m_avgPhi.reset();
|
||||||
|
m_avgQQ2.reset();
|
||||||
|
m_iBeta.reset();
|
||||||
|
m_qBeta.reset();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (DSPSignalNotification::match(message))
|
||||||
|
{
|
||||||
|
auto& notif = (const DSPSignalNotification&) message;
|
||||||
|
|
||||||
|
// update DSP values
|
||||||
|
|
||||||
|
m_sampleRate = notif.getSampleRate();
|
||||||
|
m_centerFrequency = notif.getCenterFrequency();
|
||||||
|
m_realElseComplex = notif.getRealElseComplex();
|
||||||
|
|
||||||
|
qDebug() << "DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification:"
|
||||||
|
<< " m_sampleRate: " << m_sampleRate
|
||||||
|
<< " m_centerFrequency: " << m_centerFrequency;
|
||||||
|
|
||||||
|
// forward source changes to channel sinks with immediate execution (no queuing)
|
||||||
|
|
||||||
|
for(BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++)
|
||||||
|
{
|
||||||
|
auto* rep = new DSPSignalNotification(notif); // make a copy
|
||||||
|
qDebug() << "DSPDeviceSourceEngine::handleInputMessages: forward message to " << (*it)->getSinkName().toStdString().c_str();
|
||||||
|
(*it)->pushMessage(rep);
|
||||||
|
}
|
||||||
|
|
||||||
|
// forward changes to source GUI input queue
|
||||||
|
if (m_deviceSampleSource)
|
||||||
|
{
|
||||||
|
MessageQueue *guiMessageQueue = m_deviceSampleSource->getMessageQueueToGUI();
|
||||||
|
qDebug("DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification: guiMessageQueue: %p", guiMessageQueue);
|
||||||
|
|
||||||
|
if (guiMessageQueue)
|
||||||
|
{
|
||||||
|
auto* rep = new DSPSignalNotification(notif); // make a copy for the source GUI
|
||||||
|
guiMessageQueue->push(rep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// was in handleSynchronousMessages:
|
||||||
|
else if (DSPAcquisitionInit::match(message))
|
||||||
|
{
|
||||||
|
return true; // discard
|
||||||
|
}
|
||||||
|
else if (DSPAcquisitionStart::match(message))
|
||||||
{
|
{
|
||||||
setState(gotoIdle());
|
setState(gotoIdle());
|
||||||
|
|
||||||
if(m_state == StIdle) {
|
if(m_state == StIdle) {
|
||||||
setState(gotoInit()); // State goes ready if init is performed
|
setState(gotoInit()); // State goes ready if init is performed
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (DSPAcquisitionStart::match(*message))
|
|
||||||
{
|
|
||||||
if(m_state == StReady) {
|
if(m_state == StReady) {
|
||||||
setState(gotoRunning());
|
setState(gotoRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (DSPAcquisitionStop::match(*message))
|
else if (DSPAcquisitionStop::match(message))
|
||||||
{
|
{
|
||||||
setState(gotoIdle());
|
setState(gotoIdle());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (DSPGetSourceDeviceDescription::match(*message))
|
else if (DSPSetSource::match(message))
|
||||||
|
{
|
||||||
|
auto cmd = (const DSPSetSource&) message;
|
||||||
|
handleSetSource(cmd.getSampleSource());
|
||||||
|
}
|
||||||
|
else if (DSPAddBasebandSampleSink::match(message))
|
||||||
{
|
{
|
||||||
((DSPGetSourceDeviceDescription*) message)->setDeviceDescription(m_deviceDescription);
|
auto cmd = (const DSPAddBasebandSampleSink&) message;
|
||||||
}
|
BasebandSampleSink* sink = cmd.getSampleSink();
|
||||||
else if (DSPGetErrorMessage::match(*message))
|
|
||||||
{
|
|
||||||
((DSPGetErrorMessage*) message)->setErrorMessage(m_errorMessage);
|
|
||||||
}
|
|
||||||
else if (DSPSetSource::match(*message)) {
|
|
||||||
handleSetSource(((DSPSetSource*) message)->getSampleSource());
|
|
||||||
}
|
|
||||||
else if (DSPAddBasebandSampleSink::match(*message))
|
|
||||||
{
|
|
||||||
BasebandSampleSink* sink = ((DSPAddBasebandSampleSink*) message)->getSampleSink();
|
|
||||||
m_basebandSampleSinks.push_back(sink);
|
m_basebandSampleSinks.push_back(sink);
|
||||||
// initialize sample rate and center frequency in the sink:
|
// initialize sample rate and center frequency in the sink:
|
||||||
DSPSignalNotification *msg = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
auto *msg = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
||||||
sink->pushMessage(msg);
|
sink->pushMessage(msg);
|
||||||
// start the sink:
|
// start the sink:
|
||||||
if(m_state == StRunning) {
|
if(m_state == StRunning) {
|
||||||
sink->start();
|
sink->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (DSPRemoveBasebandSampleSink::match(*message))
|
else if (DSPRemoveBasebandSampleSink::match(message))
|
||||||
{
|
{
|
||||||
BasebandSampleSink* sink = ((DSPRemoveBasebandSampleSink*) message)->getSampleSink();
|
auto cmd = (const DSPRemoveBasebandSampleSink&) message;
|
||||||
|
BasebandSampleSink* sink = cmd.getSampleSink();
|
||||||
|
|
||||||
if(m_state == StRunning) {
|
if(m_state == StRunning) {
|
||||||
sink->stop();
|
sink->stop();
|
||||||
@ -604,85 +656,19 @@ void DSPDeviceSourceEngine::handleSynchronousMessages()
|
|||||||
m_basebandSampleSinks.remove(sink);
|
m_basebandSampleSinks.remove(sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_syncMessenger.done(m_state);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSourceEngine::handleInputMessages()
|
void DSPDeviceSourceEngine::handleInputMessages()
|
||||||
{
|
{
|
||||||
Message* message;
|
Message* message;
|
||||||
|
|
||||||
while ((message = m_inputMessageQueue.pop()) != 0)
|
while ((message = m_inputMessageQueue.pop()) != nullptr)
|
||||||
{
|
{
|
||||||
qDebug("DSPDeviceSourceEngine::handleInputMessages: message: %s", message->getIdentifier());
|
qDebug("DSPDeviceSourceEngine::handleInputMessages: message: %s", message->getIdentifier());
|
||||||
|
|
||||||
if (DSPConfigureCorrection::match(*message))
|
if (handleMessage(*message)) {
|
||||||
{
|
delete message;
|
||||||
DSPConfigureCorrection* conf = (DSPConfigureCorrection*) message;
|
}
|
||||||
m_iqImbalanceCorrection = conf->getIQImbalanceCorrection();
|
|
||||||
|
|
||||||
if(m_dcOffsetCorrection != conf->getDCOffsetCorrection())
|
|
||||||
{
|
|
||||||
m_dcOffsetCorrection = conf->getDCOffsetCorrection();
|
|
||||||
m_iOffset = 0;
|
|
||||||
m_qOffset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_iqImbalanceCorrection != conf->getIQImbalanceCorrection())
|
|
||||||
{
|
|
||||||
m_iqImbalanceCorrection = conf->getIQImbalanceCorrection();
|
|
||||||
m_iRange = 1 << 16;
|
|
||||||
m_qRange = 1 << 16;
|
|
||||||
m_imbalance = 65536;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_avgAmp.reset();
|
|
||||||
m_avgII.reset();
|
|
||||||
m_avgII2.reset();
|
|
||||||
m_avgIQ.reset();
|
|
||||||
m_avgPhi.reset();
|
|
||||||
m_avgQQ2.reset();
|
|
||||||
m_iBeta.reset();
|
|
||||||
m_qBeta.reset();
|
|
||||||
|
|
||||||
delete message;
|
|
||||||
}
|
|
||||||
else if (DSPSignalNotification::match(*message))
|
|
||||||
{
|
|
||||||
DSPSignalNotification *notif = (DSPSignalNotification *) message;
|
|
||||||
|
|
||||||
// update DSP values
|
|
||||||
|
|
||||||
m_sampleRate = notif->getSampleRate();
|
|
||||||
m_centerFrequency = notif->getCenterFrequency();
|
|
||||||
m_realElseComplex = notif->getRealElseComplex();
|
|
||||||
|
|
||||||
qDebug() << "DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification:"
|
|
||||||
<< " m_sampleRate: " << m_sampleRate
|
|
||||||
<< " m_centerFrequency: " << m_centerFrequency;
|
|
||||||
|
|
||||||
// forward source changes to channel sinks with immediate execution (no queuing)
|
|
||||||
|
|
||||||
for(BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++)
|
|
||||||
{
|
|
||||||
DSPSignalNotification* rep = new DSPSignalNotification(*notif); // make a copy
|
|
||||||
qDebug() << "DSPDeviceSourceEngine::handleInputMessages: forward message to " << (*it)->getSinkName().toStdString().c_str();
|
|
||||||
(*it)->pushMessage(rep);
|
|
||||||
}
|
|
||||||
|
|
||||||
// forward changes to source GUI input queue
|
|
||||||
if (m_deviceSampleSource)
|
|
||||||
{
|
|
||||||
MessageQueue *guiMessageQueue = m_deviceSampleSource->getMessageQueueToGUI();
|
|
||||||
qDebug("DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification: guiMessageQueue: %p", guiMessageQueue);
|
|
||||||
|
|
||||||
if (guiMessageQueue)
|
|
||||||
{
|
|
||||||
DSPSignalNotification* rep = new DSPSignalNotification(*notif); // make a copy for the source GUI
|
|
||||||
guiMessageQueue->push(rep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete message;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
#include "dsp/dsptypes.h"
|
#include "dsp/dsptypes.h"
|
||||||
#include "util/messagequeue.h"
|
#include "util/messagequeue.h"
|
||||||
#include "util/syncmessenger.h"
|
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
#include "util/movingaverage.h"
|
#include "util/movingaverage.h"
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ public:
|
|||||||
StError //!< engine is in error
|
StError //!< engine is in error
|
||||||
};
|
};
|
||||||
|
|
||||||
DSPDeviceSourceEngine(uint uid, QObject* parent = NULL);
|
DSPDeviceSourceEngine(uint uid, QObject* parent = nullptr);
|
||||||
~DSPDeviceSourceEngine();
|
~DSPDeviceSourceEngine();
|
||||||
|
|
||||||
uint getUID() const { return m_uid; }
|
uint getUID() const { return m_uid; }
|
||||||
@ -72,14 +71,13 @@ public:
|
|||||||
|
|
||||||
State state() const { return m_state; } //!< Return DSP engine current state
|
State state() const { return m_state; } //!< Return DSP engine current state
|
||||||
|
|
||||||
QString errorMessage(); //!< Return the current error message
|
QString errorMessage() const; //!< Return the current error message
|
||||||
QString sourceDeviceDescription(); //!< Return the source device description
|
QString sourceDeviceDescription() const; //!< Return the source device description
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint m_uid; //!< unique ID
|
uint m_uid; //!< unique ID
|
||||||
|
|
||||||
MessageQueue m_inputMessageQueue; //<! Input message queue. Post here.
|
MessageQueue m_inputMessageQueue; //<! Input message queue. Post here.
|
||||||
SyncMessenger m_syncMessenger; //!< Used to process messages synchronously with the thread
|
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
|
|
||||||
@ -89,7 +87,7 @@ private:
|
|||||||
DeviceSampleSource* m_deviceSampleSource;
|
DeviceSampleSource* m_deviceSampleSource;
|
||||||
int m_sampleSourceSequence;
|
int m_sampleSourceSequence;
|
||||||
|
|
||||||
typedef std::list<BasebandSampleSink*> BasebandSampleSinks;
|
using BasebandSampleSinks = std::list<BasebandSampleSink *>;
|
||||||
BasebandSampleSinks m_basebandSampleSinks; //!< sample sinks within main thread (usually spectrum, file output)
|
BasebandSampleSinks m_basebandSampleSinks; //!< sample sinks within main thread (usually spectrum, file output)
|
||||||
|
|
||||||
uint m_sampleRate;
|
uint m_sampleRate;
|
||||||
@ -98,7 +96,8 @@ private:
|
|||||||
|
|
||||||
bool m_dcOffsetCorrection;
|
bool m_dcOffsetCorrection;
|
||||||
bool m_iqImbalanceCorrection;
|
bool m_iqImbalanceCorrection;
|
||||||
double m_iOffset, m_qOffset;
|
double m_iOffset;
|
||||||
|
double m_qOffset;
|
||||||
|
|
||||||
MovingAverageUtil<int32_t, int64_t, 1024> m_iBeta;
|
MovingAverageUtil<int32_t, int64_t, 1024> m_iBeta;
|
||||||
MovingAverageUtil<int32_t, int64_t, 1024> m_qBeta;
|
MovingAverageUtil<int32_t, int64_t, 1024> m_qBeta;
|
||||||
@ -140,11 +139,11 @@ private:
|
|||||||
void setState(State state);
|
void setState(State state);
|
||||||
|
|
||||||
void handleSetSource(DeviceSampleSource* source); //!< Manage source setting
|
void handleSetSource(DeviceSampleSource* source); //!< Manage source setting
|
||||||
|
bool handleMessage(const Message& cmd);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleData(); //!< Handle data when samples from source FIFO are ready to be processed
|
void handleData(); //!< Handle data when samples from source FIFO are ready to be processed
|
||||||
void handleInputMessages(); //!< Handle input message queue
|
void handleInputMessages(); //!< Handle input message queue
|
||||||
void handleSynchronousMessages(); //!< Handle synchronous messages with the thread
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stateChanged();
|
void stateChanged();
|
||||||
|
@ -63,10 +63,12 @@ DSPEngine *DSPEngine::instance()
|
|||||||
|
|
||||||
DSPDeviceSourceEngine *DSPEngine::addDeviceSourceEngine()
|
DSPDeviceSourceEngine *DSPEngine::addDeviceSourceEngine()
|
||||||
{
|
{
|
||||||
m_deviceSourceEngines.push_back(new DSPDeviceSourceEngine(m_deviceSourceEnginesUIDSequence));
|
auto *deviceSourceEngine = new DSPDeviceSourceEngine(m_deviceSourceEnginesUIDSequence);
|
||||||
|
// auto *deviceThread = new QThread(); TBD
|
||||||
m_deviceSourceEnginesUIDSequence++;
|
m_deviceSourceEnginesUIDSequence++;
|
||||||
m_deviceEngineReferences.push_back(DeviceEngineReference{0, m_deviceSourceEngines.back(), nullptr, nullptr});
|
m_deviceSourceEngines.push_back(deviceSourceEngine);
|
||||||
return m_deviceSourceEngines.back();
|
m_deviceEngineReferences.push_back(DeviceEngineReference{0, m_deviceSourceEngines.back(), nullptr, nullptr, nullptr});
|
||||||
|
return deviceSourceEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::removeLastDeviceSourceEngine()
|
void DSPEngine::removeLastDeviceSourceEngine()
|
||||||
@ -92,7 +94,7 @@ DSPDeviceSinkEngine *DSPEngine::addDeviceSinkEngine()
|
|||||||
{
|
{
|
||||||
m_deviceSinkEngines.push_back(new DSPDeviceSinkEngine(m_deviceSinkEnginesUIDSequence));
|
m_deviceSinkEngines.push_back(new DSPDeviceSinkEngine(m_deviceSinkEnginesUIDSequence));
|
||||||
m_deviceSinkEnginesUIDSequence++;
|
m_deviceSinkEnginesUIDSequence++;
|
||||||
m_deviceEngineReferences.push_back(DeviceEngineReference{1, nullptr, m_deviceSinkEngines.back(), nullptr});
|
m_deviceEngineReferences.push_back(DeviceEngineReference{1, nullptr, m_deviceSinkEngines.back(), nullptr, nullptr});
|
||||||
return m_deviceSinkEngines.back();
|
return m_deviceSinkEngines.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +121,7 @@ DSPDeviceMIMOEngine *DSPEngine::addDeviceMIMOEngine()
|
|||||||
{
|
{
|
||||||
m_deviceMIMOEngines.push_back(new DSPDeviceMIMOEngine(m_deviceMIMOEnginesUIDSequence));
|
m_deviceMIMOEngines.push_back(new DSPDeviceMIMOEngine(m_deviceMIMOEnginesUIDSequence));
|
||||||
m_deviceMIMOEnginesUIDSequence++;
|
m_deviceMIMOEnginesUIDSequence++;
|
||||||
m_deviceEngineReferences.push_back(DeviceEngineReference{2, nullptr, nullptr, m_deviceMIMOEngines.back()});
|
m_deviceEngineReferences.push_back(DeviceEngineReference{2, nullptr, nullptr, m_deviceMIMOEngines.back(), nullptr});
|
||||||
return m_deviceMIMOEngines.back();
|
return m_deviceMIMOEngines.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ class DSPDeviceSourceEngine;
|
|||||||
class DSPDeviceSinkEngine;
|
class DSPDeviceSinkEngine;
|
||||||
class DSPDeviceMIMOEngine;
|
class DSPDeviceMIMOEngine;
|
||||||
class FFTFactory;
|
class FFTFactory;
|
||||||
|
class QThread;
|
||||||
|
|
||||||
class SDRBASE_API DSPEngine : public QObject {
|
class SDRBASE_API DSPEngine : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -79,6 +80,7 @@ private:
|
|||||||
DSPDeviceSourceEngine *m_deviceSourceEngine;
|
DSPDeviceSourceEngine *m_deviceSourceEngine;
|
||||||
DSPDeviceSinkEngine *m_deviceSinkEngine;
|
DSPDeviceSinkEngine *m_deviceSinkEngine;
|
||||||
DSPDeviceMIMOEngine *m_deviceMIMOEngine;
|
DSPDeviceMIMOEngine *m_deviceMIMOEngine;
|
||||||
|
QThread *m_thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<DSPDeviceSourceEngine*> m_deviceSourceEngines;
|
QList<DSPDeviceSourceEngine*> m_deviceSourceEngines;
|
||||||
|
Loading…
Reference in New Issue
Block a user