mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-02 22:14:45 -04:00
TestMOSync: spectrum display
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "gui/glspectrum.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/spectrumvis.h"
|
||||
#include "mainwindow.h"
|
||||
#include "device/deviceapi.h"
|
||||
#include "device/deviceuiset.h"
|
||||
@@ -49,6 +50,7 @@ TestMOSyncGui::TestMOSyncGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
m_lastEngineState(DeviceAPI::StNotStarted)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_sampleMIMO = (TestMOSync*) m_deviceUISet->m_deviceAPI->getSampleMIMO();
|
||||
|
||||
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
|
||||
@@ -56,6 +58,13 @@ TestMOSyncGui::TestMOSyncGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
||||
ui->sampleRate->setValueRange(7, 32000U, 9000000U);
|
||||
|
||||
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
|
||||
m_sampleMIMO->setSpectrumSink(m_spectrumVis);
|
||||
ui->glSpectrum->setCenterFrequency(m_settings.m_centerFrequency);
|
||||
ui->glSpectrum->setSampleRate(m_settings.m_sampleRate*(1<<m_settings.m_log2Interp));
|
||||
ui->glSpectrum->connectTimer(MainWindow::getInstance()->getMasterTimer());
|
||||
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
||||
|
||||
connect(&(m_deviceUISet->m_deviceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
@@ -63,9 +72,12 @@ TestMOSyncGui::TestMOSyncGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
|
||||
displaySettings();
|
||||
|
||||
m_sampleMIMO = (TestMOSync*) m_deviceUISet->m_deviceAPI->getSampleMIMO();
|
||||
m_sampleMIMO->setMessageQueueToGUI(&m_inputMessageQueue);
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||
|
||||
m_deviceUISet->m_spectrum->setDisplayedStream(false, 0);
|
||||
m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(false, 0);
|
||||
m_deviceUISet->setSpectrumScalingFactor(SDR_TX_SCALEF);
|
||||
}
|
||||
|
||||
TestMOSyncGui::~TestMOSyncGui()
|
||||
@@ -114,12 +126,15 @@ QByteArray TestMOSyncGui::serialize() const
|
||||
|
||||
bool TestMOSyncGui::deserialize(const QByteArray& data)
|
||||
{
|
||||
if(m_settings.deserialize(data)) {
|
||||
if (m_settings.deserialize(data))
|
||||
{
|
||||
displaySettings();
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
@@ -127,7 +142,28 @@ bool TestMOSyncGui::deserialize(const QByteArray& data)
|
||||
|
||||
bool TestMOSyncGui::handleMessage(const Message& message)
|
||||
{
|
||||
if (TestMOSync::MsgConfigureTestMOSync::match(message))
|
||||
if (DSPMIMOSignalNotification::match(message))
|
||||
{
|
||||
const DSPMIMOSignalNotification& cfg = (DSPMIMOSignalNotification&) message;
|
||||
int istream = cfg.getIndex();
|
||||
bool sourceOrSink = cfg.getSourceOrSink();
|
||||
qDebug("TestMOSyncGui::handleMessage: DSPMIMOSignalNotification: %s:%d SampleRate:%d, CenterFrequency:%llu",
|
||||
sourceOrSink ? "Rx" : "Tx",
|
||||
istream,
|
||||
cfg.getSampleRate(),
|
||||
cfg.getCenterFrequency()
|
||||
);
|
||||
|
||||
if (!sourceOrSink)
|
||||
{
|
||||
m_sampleRate = cfg.getSampleRate();
|
||||
m_deviceCenterFrequency = cfg.getCenterFrequency();
|
||||
updateSampleRateAndFrequency();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (TestMOSync::MsgConfigureTestMOSync::match(message))
|
||||
{
|
||||
qDebug("TestMOSyncGui::handleMessage: message: MsgConfigureTestMOSync");
|
||||
const TestMOSync::MsgConfigureTestMOSync& cfg = (TestMOSync::MsgConfigureTestMOSync&) message;
|
||||
@@ -158,24 +194,9 @@ void TestMOSyncGui::handleInputMessages()
|
||||
|
||||
while ((message = m_inputMessageQueue.pop()) != 0)
|
||||
{
|
||||
|
||||
if (DSPSignalNotification::match(*message))
|
||||
{
|
||||
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
||||
qDebug("TestMOSyncGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
m_sampleRate = notif->getSampleRate();
|
||||
m_deviceCenterFrequency = notif->getCenterFrequency();
|
||||
updateSampleRateAndFrequency();
|
||||
|
||||
if (handleMessage(*message)) {
|
||||
delete message;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (handleMessage(*message))
|
||||
{
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,20 +222,23 @@ void TestMOSyncGui::sendSettings()
|
||||
|
||||
void TestMOSyncGui::updateHardware()
|
||||
{
|
||||
qDebug() << "TestMOSyncGui::updateHardware";
|
||||
TestMOSync::MsgConfigureTestMOSync* message = TestMOSync::MsgConfigureTestMOSync::create(m_settings, m_forceSettings);
|
||||
m_sampleMIMO->getInputMessageQueue()->push(message);
|
||||
m_forceSettings = false;
|
||||
m_updateTimer.stop();
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
qDebug() << "TestMOSyncGui::updateHardware";
|
||||
TestMOSync::MsgConfigureTestMOSync* message = TestMOSync::MsgConfigureTestMOSync::create(m_settings, m_forceSettings);
|
||||
m_sampleMIMO->getInputMessageQueue()->push(message);
|
||||
m_forceSettings = false;
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void TestMOSyncGui::updateStatus()
|
||||
{
|
||||
int state = m_deviceUISet->m_deviceAPI->state();
|
||||
int state = m_deviceUISet->m_deviceAPI->state(1);
|
||||
|
||||
if(m_lastEngineState != state)
|
||||
if (m_lastEngineState != state)
|
||||
{
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case DeviceAPI::StNotStarted:
|
||||
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
@@ -240,12 +264,14 @@ void TestMOSyncGui::updateStatus()
|
||||
void TestMOSyncGui::on_centerFrequency_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_centerFrequency = value * 1000;
|
||||
ui->glSpectrum->setCenterFrequency(m_settings.m_centerFrequency);
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void TestMOSyncGui::on_sampleRate_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_sampleRate = value;
|
||||
ui->glSpectrum->setSampleRate(m_settings.m_sampleRate*(1<<m_settings.m_log2Interp));
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@@ -256,6 +282,7 @@ void TestMOSyncGui::on_interp_currentIndexChanged(int index)
|
||||
}
|
||||
|
||||
m_settings.m_log2Interp = index;
|
||||
ui->glSpectrum->setSampleRate(m_settings.m_sampleRate*(1<<m_settings.m_log2Interp));
|
||||
updateSampleRateAndFrequency();
|
||||
sendSettings();
|
||||
}
|
||||
@@ -269,6 +296,13 @@ void TestMOSyncGui::on_startStop_toggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void TestMOSyncGui::on_spectrumIndex_currentIndexChanged(int index)
|
||||
{
|
||||
m_deviceUISet->m_spectrum->setDisplayedStream(false, index);
|
||||
m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(false, index);
|
||||
m_sampleMIMO->setFeedSpectrumIndex(index);
|
||||
}
|
||||
|
||||
void TestMOSyncGui::tick()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user