2019-05-18 00:30:37 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2019-05-28 02:56:36 -04:00
|
|
|
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
2019-05-18 00:30:37 -04:00
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// 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 <QDebug>
|
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QString>
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "device/deviceapi.h"
|
|
|
|
#include "device/deviceuiset.h"
|
|
|
|
#include "gui/colormapper.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "gui/crightclickenabler.h"
|
|
|
|
#include "gui/basicdevicesettingsdialog.h"
|
|
|
|
#include "dsp/dspengine.h"
|
2019-05-19 04:23:18 -04:00
|
|
|
#include "dsp/dspdevicemimoengine.h"
|
2019-05-18 00:30:37 -04:00
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include "ui_testmigui.h"
|
|
|
|
#include "testmigui.h"
|
|
|
|
|
|
|
|
TestMIGui::TestMIGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::TestMIGui),
|
|
|
|
m_deviceUISet(deviceUISet),
|
|
|
|
m_settings(),
|
|
|
|
m_doApplySettings(true),
|
|
|
|
m_forceSettings(true),
|
|
|
|
m_sampleMIMO(nullptr),
|
|
|
|
m_tickCount(0),
|
|
|
|
m_lastEngineState(DeviceAPI::StNotStarted)
|
|
|
|
{
|
|
|
|
qDebug("TestMIGui::TestMIGui");
|
|
|
|
m_sampleMIMO = m_deviceUISet->m_deviceAPI->getSampleMIMO();
|
2019-05-25 20:14:35 -04:00
|
|
|
m_streamIndex = 0;
|
2019-05-28 06:09:08 -04:00
|
|
|
m_deviceCenterFrequencies.push_back(m_settings.m_streams[0].m_centerFrequency);
|
|
|
|
m_deviceCenterFrequencies.push_back(m_settings.m_streams[1].m_centerFrequency);
|
|
|
|
m_deviceSampleRates.push_back(m_settings.m_streams[0].m_sampleRate / (1<<m_settings.m_streams[0].m_log2Decim));
|
|
|
|
m_deviceSampleRates.push_back(m_settings.m_streams[1].m_sampleRate / (1<<m_settings.m_streams[1].m_log2Decim));
|
2019-05-18 00:30:37 -04:00
|
|
|
|
|
|
|
ui->setupUi(this);
|
2019-05-28 06:09:08 -04:00
|
|
|
ui->spectrumSource->addItem("0");
|
|
|
|
ui->spectrumSource->addItem("1");
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->centerFrequency->setValueRange(7, 0, 9999999);
|
|
|
|
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
|
|
|
ui->sampleRate->setValueRange(7, 48000, 9999999);
|
|
|
|
ui->frequencyShift->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->frequencyShift->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
ui->frequencyShiftLabel->setText(QString("%1").arg(QChar(0x94, 0x03)));
|
|
|
|
|
|
|
|
displaySettings();
|
|
|
|
|
|
|
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
|
|
|
m_statusTimer.start(500);
|
|
|
|
|
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
|
|
|
m_sampleMIMO->setMessageQueueToGUI(&m_inputMessageQueue);
|
|
|
|
|
|
|
|
CRightClickEnabler *startStopRightClickEnabler = new CRightClickEnabler(ui->startStop);
|
|
|
|
connect(startStopRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
|
|
|
|
}
|
|
|
|
|
|
|
|
TestMIGui::~TestMIGui()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString TestMIGui::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 TestMIGui::getCenterFrequency() const
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
return m_settings.m_streams[m_streamIndex].m_centerFrequency;
|
2019-05-18 00:30:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_centerFrequency = centerFrequency;
|
2019-05-18 00:30:37 -04:00
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray TestMIGui::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TestMIGui::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data)) {
|
|
|
|
displaySettings();
|
|
|
|
m_forceSettings = true;
|
|
|
|
sendSettings();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_startStop_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
TestMI::MsgStartStop *message = TestMI::MsgStartStop::create(checked);
|
|
|
|
m_sampleMIMO->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
void TestMIGui::on_streamIndex_currentIndexChanged(int index)
|
|
|
|
{
|
2019-05-29 17:53:33 -04:00
|
|
|
if (ui->streamLock->isChecked())
|
|
|
|
{
|
|
|
|
m_spectrumStreamIndex = index;
|
2019-05-30 12:38:10 -04:00
|
|
|
m_deviceUISet->m_spectrum->setDisplayedStream(true, index);
|
2019-05-29 17:53:33 -04:00
|
|
|
m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex);
|
|
|
|
ui->spectrumSource->blockSignals(true);
|
|
|
|
ui->spectrumSource->setCurrentIndex(index);
|
|
|
|
ui->spectrumSource->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
m_streamIndex = index;
|
2019-05-28 02:56:36 -04:00
|
|
|
updateFileRecordStatus();
|
2019-05-28 06:09:08 -04:00
|
|
|
updateSampleRateAndFrequency();
|
2019-05-25 20:14:35 -04:00
|
|
|
displaySettings();
|
|
|
|
}
|
|
|
|
|
2019-05-28 06:09:08 -04:00
|
|
|
void TestMIGui::on_spectrumSource_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_spectrumStreamIndex = index;
|
2019-05-30 12:38:10 -04:00
|
|
|
m_deviceUISet->m_spectrum->setDisplayedStream(true, index);
|
2019-05-28 06:09:08 -04:00
|
|
|
m_deviceUISet->m_deviceAPI->setSpectrumSinkInput(true, m_spectrumStreamIndex);
|
|
|
|
updateSampleRateAndFrequency();
|
2019-05-29 17:53:33 -04:00
|
|
|
|
|
|
|
if (ui->streamLock->isChecked())
|
|
|
|
{
|
|
|
|
ui->streamIndex->blockSignals(true);
|
|
|
|
ui->streamIndex->setCurrentIndex(index);
|
|
|
|
ui->streamIndex->blockSignals(false);
|
|
|
|
m_streamIndex = index;
|
|
|
|
updateFileRecordStatus();
|
|
|
|
displaySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_streamLock_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (checked && (ui->streamIndex->currentIndex() != ui->spectrumSource->currentIndex())) {
|
|
|
|
ui->spectrumSource->setCurrentIndex(ui->streamIndex->currentIndex());
|
|
|
|
}
|
2019-05-28 06:09:08 -04:00
|
|
|
}
|
|
|
|
|
2019-05-18 00:30:37 -04:00
|
|
|
void TestMIGui::on_centerFrequency_changed(quint64 value)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_centerFrequency = value * 1000;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_autoCorr_currentIndexChanged(int index)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
if ((index < 0) || (index > TestMIStreamSettings::AutoCorrLast)) {
|
2019-05-18 00:30:37 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_autoCorrOptions = (TestMIStreamSettings::AutoCorrOptions) index;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_frequencyShift_changed(qint64 value)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_frequencyShift = value;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_decimation_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index > 6)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_log2Decim = index;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_fcPos_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index > 2)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_fcPos = (TestMIStreamSettings::fcPos_t) index;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_sampleRate_changed(quint64 value)
|
|
|
|
{
|
|
|
|
updateFrequencyShiftLimit();
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_frequencyShift = ui->frequencyShift->getValueNew();
|
|
|
|
m_settings.m_streams[m_streamIndex].m_sampleRate = value;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_sampleSize_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index > 2)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateAmpCoarseLimit();
|
|
|
|
updateAmpFineLimit();
|
|
|
|
displayAmplitude();
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value();
|
|
|
|
m_settings.m_streams[m_streamIndex].m_sampleSizeIndex = index;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_amplitudeCoarse_valueChanged(int value)
|
|
|
|
{
|
|
|
|
(void) value;
|
|
|
|
updateAmpFineLimit();
|
|
|
|
displayAmplitude();
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value();
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_amplitudeFine_valueChanged(int value)
|
|
|
|
{
|
|
|
|
(void) value;
|
|
|
|
displayAmplitude();
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_amplitudeBits = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value();
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_modulation_currentIndexChanged(int index)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
if ((index < 0) || (index > TestMIStreamSettings::ModulationLast)) {
|
2019-05-18 00:30:37 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_modulation = (TestMIStreamSettings::Modulation) index;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_modulationFrequency_valueChanged(int value)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_modulationTone = value;
|
|
|
|
ui->modulationFrequencyText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_modulationTone / 100.0, 0, 'f', 2));
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_amModulation_valueChanged(int value)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_amModulation = value;
|
|
|
|
ui->amModulationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_amModulation));
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_fmDeviation_valueChanged(int value)
|
|
|
|
{
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_fmDeviation = value;
|
|
|
|
ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_fmDeviation / 10.0, 0, 'f', 1));
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_dcBias_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->dcBiasText->setText(QString(tr("%1 %").arg(value)));
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_dcFactor = value / 100.0f;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_iBias_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->iBiasText->setText(QString(tr("%1 %").arg(value)));
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_iFactor = value / 100.0f;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_qBias_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->qBiasText->setText(QString(tr("%1 %").arg(value)));
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_qFactor = value / 100.0f;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_phaseImbalance_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->phaseImbalanceText->setText(QString(tr("%1 %").arg(value)));
|
2019-05-25 20:14:35 -04:00
|
|
|
m_settings.m_streams[m_streamIndex].m_phaseImbalance = value / 100.0f;
|
2019-05-18 00:30:37 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::on_record_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (checked) {
|
|
|
|
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
|
|
|
} else {
|
|
|
|
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
|
2019-05-28 02:56:36 -04:00
|
|
|
TestMI::MsgFileRecord* message = TestMI::MsgFileRecord::create(checked, m_streamIndex);
|
2019-05-18 00:30:37 -04:00
|
|
|
m_sampleMIMO->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::displayAmplitude()
|
|
|
|
{
|
|
|
|
int amplitudeInt = ui->amplitudeCoarse->value() * 100 + ui->amplitudeFine->value();
|
|
|
|
double power;
|
|
|
|
|
|
|
|
switch (ui->sampleSize->currentIndex())
|
|
|
|
{
|
|
|
|
case 0: // 8 bits: 128
|
|
|
|
power = (double) amplitudeInt*amplitudeInt / (double) (1<<14);
|
|
|
|
break;
|
|
|
|
case 1: // 12 bits 2048
|
|
|
|
power = (double) amplitudeInt*amplitudeInt / (double) (1<<22);
|
|
|
|
break;
|
|
|
|
case 2: // 16 bits 32768
|
|
|
|
default:
|
|
|
|
power = (double) amplitudeInt*amplitudeInt / (double) (1<<30);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->amplitudeBits->setText(QString(tr("%1 b").arg(amplitudeInt)));
|
|
|
|
double powerDb = CalcDb::dbPower(power);
|
|
|
|
ui->power->setText(QString(tr("%1 dB").arg(QString::number(powerDb, 'f', 1))));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::updateAmpCoarseLimit()
|
|
|
|
{
|
|
|
|
switch (ui->sampleSize->currentIndex())
|
|
|
|
{
|
|
|
|
case 0: // 8 bits: 128
|
|
|
|
ui->amplitudeCoarse->setMaximum(1);
|
|
|
|
break;
|
|
|
|
case 1: // 12 bits 2048
|
|
|
|
ui->amplitudeCoarse->setMaximum(20);
|
|
|
|
break;
|
|
|
|
case 2: // 16 bits 32768
|
|
|
|
default:
|
|
|
|
ui->amplitudeCoarse->setMaximum(327);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::updateAmpFineLimit()
|
|
|
|
{
|
|
|
|
switch (ui->sampleSize->currentIndex())
|
|
|
|
{
|
|
|
|
case 0: // 8 bits: 128
|
|
|
|
if (ui->amplitudeCoarse->value() == 1) {
|
|
|
|
ui->amplitudeFine->setMaximum(27);
|
|
|
|
} else {
|
|
|
|
ui->amplitudeFine->setMaximum(99);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: // 12 bits 2048
|
|
|
|
if (ui->amplitudeCoarse->value() == 20) {
|
|
|
|
ui->amplitudeFine->setMaximum(47);
|
|
|
|
} else {
|
|
|
|
ui->amplitudeFine->setMaximum(99);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: // 16 bits 32768
|
|
|
|
default:
|
|
|
|
if (ui->amplitudeCoarse->value() == 327) {
|
|
|
|
ui->amplitudeFine->setMaximum(67);
|
|
|
|
} else {
|
|
|
|
ui->amplitudeFine->setMaximum(99);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::updateFrequencyShiftLimit()
|
|
|
|
{
|
2019-05-28 10:31:44 -04:00
|
|
|
qint64 sampleRate = ui->sampleRate->getValueNew();
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->frequencyShift->setValueRange(false, 7, -sampleRate, sampleRate);
|
2019-05-29 16:09:19 -04:00
|
|
|
ui->frequencyShift->setValue(m_settings.m_streams[m_streamIndex].m_frequencyShift);
|
2019-05-18 00:30:37 -04:00
|
|
|
}
|
|
|
|
|
2019-05-28 02:56:36 -04:00
|
|
|
void TestMIGui::updateFileRecordStatus()
|
|
|
|
{
|
|
|
|
if (((TestMI*) m_sampleMIMO)->isRecording(m_streamIndex)) {
|
|
|
|
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
|
|
|
} else {
|
|
|
|
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-18 00:30:37 -04:00
|
|
|
void TestMIGui::displaySettings()
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
ui->sampleSize->blockSignals(true);
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
ui->streamIndex->setCurrentIndex(m_streamIndex);
|
|
|
|
ui->centerFrequency->setValue(m_settings.m_streams[m_streamIndex].m_centerFrequency / 1000);
|
|
|
|
ui->decimation->setCurrentIndex(m_settings.m_streams[m_streamIndex].m_log2Decim);
|
|
|
|
ui->fcPos->setCurrentIndex((int) m_settings.m_streams[m_streamIndex].m_fcPos);
|
|
|
|
ui->sampleRate->setValue(m_settings.m_streams[m_streamIndex].m_sampleRate);
|
2019-05-18 00:30:37 -04:00
|
|
|
updateFrequencyShiftLimit();
|
2019-05-25 20:14:35 -04:00
|
|
|
ui->frequencyShift->setValue(m_settings.m_streams[m_streamIndex].m_frequencyShift);
|
|
|
|
ui->sampleSize->setCurrentIndex(m_settings.m_streams[m_streamIndex].m_sampleSizeIndex);
|
2019-05-18 00:30:37 -04:00
|
|
|
updateAmpCoarseLimit();
|
2019-05-25 20:14:35 -04:00
|
|
|
int amplitudeBits = m_settings.m_streams[m_streamIndex].m_amplitudeBits;
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->amplitudeCoarse->setValue(amplitudeBits/100);
|
|
|
|
updateAmpFineLimit();
|
|
|
|
ui->amplitudeFine->setValue(amplitudeBits%100);
|
|
|
|
displayAmplitude();
|
2019-05-25 20:14:35 -04:00
|
|
|
int dcBiasPercent = roundf(m_settings.m_streams[m_streamIndex].m_dcFactor * 100.0f);
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->dcBias->setValue((int) dcBiasPercent);
|
|
|
|
ui->dcBiasText->setText(QString(tr("%1 %").arg(dcBiasPercent)));
|
2019-05-25 20:14:35 -04:00
|
|
|
int iBiasPercent = roundf(m_settings.m_streams[m_streamIndex].m_iFactor * 100.0f);
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->iBias->setValue((int) iBiasPercent);
|
|
|
|
ui->iBiasText->setText(QString(tr("%1 %").arg(iBiasPercent)));
|
2019-05-25 20:14:35 -04:00
|
|
|
int qBiasPercent = roundf(m_settings.m_streams[m_streamIndex].m_qFactor * 100.0f);
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->qBias->setValue((int) qBiasPercent);
|
|
|
|
ui->qBiasText->setText(QString(tr("%1 %").arg(qBiasPercent)));
|
2019-05-25 20:14:35 -04:00
|
|
|
int phaseImbalancePercent = roundf(m_settings.m_streams[m_streamIndex].m_phaseImbalance * 100.0f);
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->phaseImbalance->setValue((int) phaseImbalancePercent);
|
|
|
|
ui->phaseImbalanceText->setText(QString(tr("%1 %").arg(phaseImbalancePercent)));
|
2019-05-25 20:14:35 -04:00
|
|
|
ui->autoCorr->setCurrentIndex(m_settings.m_streams[m_streamIndex].m_autoCorrOptions);
|
2019-05-18 00:30:37 -04:00
|
|
|
ui->sampleSize->blockSignals(false);
|
2019-05-25 20:14:35 -04:00
|
|
|
ui->modulation->setCurrentIndex((int) m_settings.m_streams[m_streamIndex].m_modulation);
|
|
|
|
ui->modulationFrequency->setValue(m_settings.m_streams[m_streamIndex].m_modulationTone);
|
|
|
|
ui->modulationFrequencyText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_modulationTone / 100.0, 0, 'f', 2));
|
|
|
|
ui->amModulation->setValue(m_settings.m_streams[m_streamIndex].m_amModulation);
|
|
|
|
ui->amModulationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_amModulation));
|
|
|
|
ui->fmDeviation->setValue(m_settings.m_streams[m_streamIndex].m_fmDeviation);
|
|
|
|
ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_streams[m_streamIndex].m_fmDeviation / 10.0, 0, 'f', 1));
|
2019-05-18 00:30:37 -04:00
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::sendSettings()
|
|
|
|
{
|
|
|
|
if(!m_updateTimer.isActive()) {
|
|
|
|
m_updateTimer.start(100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::updateHardware()
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
TestMI::MsgConfigureTestSource* message = TestMI::MsgConfigureTestSource::create(m_settings, m_forceSettings);
|
|
|
|
m_sampleMIMO->getInputMessageQueue()->push(message);
|
|
|
|
m_forceSettings = false;
|
|
|
|
m_updateTimer.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::updateStatus()
|
|
|
|
{
|
|
|
|
int state = m_deviceUISet->m_deviceAPI->state();
|
|
|
|
|
|
|
|
if(m_lastEngineState != state)
|
|
|
|
{
|
|
|
|
switch(state)
|
|
|
|
{
|
|
|
|
case DeviceAPI::StNotStarted:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
break;
|
|
|
|
case DeviceAPI::StIdle:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
|
|
|
break;
|
|
|
|
case DeviceAPI::StRunning:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
break;
|
|
|
|
case DeviceAPI::StError:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
|
|
|
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastEngineState = state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TestMIGui::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (TestMI::MsgConfigureTestSource::match(message))
|
|
|
|
{
|
|
|
|
qDebug("TestMIGui::handleMessage: MsgConfigureTestSource");
|
|
|
|
const TestMI::MsgConfigureTestSource& cfg = (TestMI::MsgConfigureTestSource&) message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
displaySettings();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (TestMI::MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
qDebug("TestMIGui::handleMessage: MsgStartStop");
|
|
|
|
TestMI::MsgStartStop& notif = (TestMI::MsgStartStop&) message;
|
|
|
|
blockApplySettings(true);
|
|
|
|
ui->startStop->setChecked(notif.getStartStop());
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = m_inputMessageQueue.pop()) != 0)
|
|
|
|
{
|
2019-05-19 04:23:18 -04:00
|
|
|
if (DSPDeviceMIMOEngine::SignalNotification::match(*message))
|
2019-05-18 00:30:37 -04:00
|
|
|
{
|
2019-05-19 04:23:18 -04:00
|
|
|
DSPDeviceMIMOEngine::SignalNotification* notif = (DSPDeviceMIMOEngine::SignalNotification*) message;
|
2019-05-28 06:09:08 -04:00
|
|
|
int istream = notif->getIndex();
|
|
|
|
bool sourceOrSink = notif->getSourceOrSink();
|
|
|
|
m_deviceSampleRates[istream] = notif->getSampleRate();
|
|
|
|
m_deviceCenterFrequencies[istream] = notif->getCenterFrequency();
|
2019-05-19 04:23:18 -04:00
|
|
|
// Do not consider multiple sources at this time
|
2019-05-28 06:09:08 -04:00
|
|
|
qDebug("TestMIGui::handleInputMessages: DSPDeviceMIMOEngine::SignalNotification: %s stream: %d SampleRate:%d, CenterFrequency:%llu",
|
|
|
|
sourceOrSink ? "source" : "sink",
|
|
|
|
istream,
|
2019-05-18 00:30:37 -04:00
|
|
|
notif->getSampleRate(),
|
|
|
|
notif->getCenterFrequency());
|
|
|
|
updateSampleRateAndFrequency();
|
|
|
|
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::updateSampleRateAndFrequency()
|
|
|
|
{
|
2019-05-28 06:09:08 -04:00
|
|
|
m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRates[m_spectrumStreamIndex]);
|
|
|
|
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequencies[m_spectrumStreamIndex]);
|
|
|
|
ui->deviceRateText->setText(tr("%1k").arg((float) m_deviceSampleRates[m_streamIndex] / 1000));
|
2019-05-18 00:30:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestMIGui::openDeviceSettingsDialog(const QPoint& p)
|
|
|
|
{
|
|
|
|
BasicDeviceSettingsDialog dialog(this);
|
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
|
|
|
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
|
|
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
|
|
|
|
|
|
|
sendSettings();
|
|
|
|
}
|