23 #include <QMessageBox> 39 #include "ui_testmigui.h" 45 m_deviceUISet(deviceUISet),
47 m_doApplySettings(true),
48 m_forceSettings(true),
49 m_sampleMIMO(nullptr),
51 m_lastEngineState(
DeviceAPI::StNotStarted)
53 qDebug(
"TestMIGui::TestMIGui");
62 ui->spectrumSource->addItem(
"0");
63 ui->spectrumSource->addItem(
"1");
65 ui->centerFrequency->setValueRange(7, 0, 9999999);
67 ui->sampleRate->setValueRange(7, 48000, 9999999);
69 ui->frequencyShift->setValueRange(
false, 7, -9999999, 9999999);
70 ui->frequencyShiftLabel->setText(QString(
"%1").
arg(QChar(0x94, 0x03)));
82 connect(startStopRightClickEnabler, SIGNAL(rightClick(
const QPoint &)),
this, SLOT(
openDeviceSettingsDialog(
const QPoint &)));
153 if (
ui->streamLock->isChecked())
158 ui->spectrumSource->blockSignals(
true);
159 ui->spectrumSource->setCurrentIndex(index);
160 ui->spectrumSource->blockSignals(
false);
176 if (
ui->streamLock->isChecked())
178 ui->streamIndex->blockSignals(
true);
179 ui->streamIndex->setCurrentIndex(index);
180 ui->streamIndex->blockSignals(
false);
189 if (checked && (
ui->streamIndex->currentIndex() !=
ui->spectrumSource->currentIndex())) {
190 ui->spectrumSource->setCurrentIndex(
ui->streamIndex->currentIndex());
218 if ((index < 0) || (index > 6)) {
228 if ((index < 0) || (index > 2)) {
246 if ((index < 0) || (index > 2)) {
308 ui->dcBiasText->setText(QString(tr(
"%1 %").
arg(value)));
315 ui->iBiasText->setText(QString(tr(
"%1 %").
arg(value)));
322 ui->qBiasText->setText(QString(tr(
"%1 %").
arg(value)));
329 ui->phaseImbalanceText->setText(QString(tr(
"%1 %").
arg(value)));
337 ui->record->setStyleSheet(
"QToolButton { background-color : red; }");
339 ui->record->setStyleSheet(
"QToolButton { background:rgb(79,79,79); }");
348 int amplitudeInt =
ui->amplitudeCoarse->value() * 100 +
ui->amplitudeFine->value();
351 switch (
ui->sampleSize->currentIndex())
354 power = (double) amplitudeInt*amplitudeInt / (
double) (1<<14);
357 power = (double) amplitudeInt*amplitudeInt / (
double) (1<<22);
361 power = (double) amplitudeInt*amplitudeInt / (
double) (1<<30);
365 ui->amplitudeBits->setText(QString(tr(
"%1 b").
arg(amplitudeInt)));
367 ui->power->setText(QString(tr(
"%1 dB").
arg(QString::number(powerDb,
'f', 1))));
372 switch (
ui->sampleSize->currentIndex())
375 ui->amplitudeCoarse->setMaximum(1);
378 ui->amplitudeCoarse->setMaximum(20);
382 ui->amplitudeCoarse->setMaximum(327);
389 switch (
ui->sampleSize->currentIndex())
392 if (
ui->amplitudeCoarse->value() == 1) {
393 ui->amplitudeFine->setMaximum(27);
395 ui->amplitudeFine->setMaximum(99);
399 if (
ui->amplitudeCoarse->value() == 20) {
400 ui->amplitudeFine->setMaximum(47);
402 ui->amplitudeFine->setMaximum(99);
407 if (
ui->amplitudeCoarse->value() == 327) {
408 ui->amplitudeFine->setMaximum(67);
410 ui->amplitudeFine->setMaximum(99);
418 qint64 sampleRate =
ui->sampleRate->getValueNew();
419 ui->frequencyShift->setValueRange(
false, 7, -sampleRate, sampleRate);
426 ui->record->setStyleSheet(
"QToolButton { background-color : red; }");
428 ui->record->setStyleSheet(
"QToolButton { background:rgb(79,79,79); }");
435 ui->sampleSize->blockSignals(
true);
447 ui->amplitudeCoarse->setValue(amplitudeBits/100);
449 ui->amplitudeFine->setValue(amplitudeBits%100);
452 ui->dcBias->setValue((
int) dcBiasPercent);
453 ui->dcBiasText->setText(QString(tr(
"%1 %").
arg(dcBiasPercent)));
455 ui->iBias->setValue((
int) iBiasPercent);
456 ui->iBiasText->setText(QString(tr(
"%1 %").
arg(iBiasPercent)));
458 ui->qBias->setValue((
int) qBiasPercent);
459 ui->qBiasText->setText(QString(tr(
"%1 %").
arg(qBiasPercent)));
460 int phaseImbalancePercent = roundf(
m_settings.
m_streams[m_streamIndex].m_phaseImbalance * 100.0f);
461 ui->phaseImbalance->setValue((
int) phaseImbalancePercent);
462 ui->phaseImbalanceText->setText(QString(tr(
"%1 %").
arg(phaseImbalancePercent)));
464 ui->sampleSize->blockSignals(
false);
467 ui->modulationFrequencyText->setText(QString(
"%1").
arg(
m_settings.
m_streams[m_streamIndex].m_modulationTone / 100.0, 0,
'f', 2));
471 ui->fmDeviationText->setText(QString(
"%1").
arg(
m_settings.
m_streams[m_streamIndex].m_fmDeviation / 10.0, 0,
'f', 1));
502 ui->startStop->setStyleSheet(
"QToolButton { background:rgb(79,79,79); }");
505 ui->startStop->setStyleSheet(
"QToolButton { background-color : blue; }");
508 ui->startStop->setStyleSheet(
"QToolButton { background-color : green; }");
511 ui->startStop->setStyleSheet(
"QToolButton { background-color : red; }");
526 qDebug(
"TestMIGui::handleMessage: MsgConfigureTestSource");
534 qDebug(
"TestMIGui::handleMessage: MsgStartStop");
562 qDebug(
"TestMIGui::handleInputMessages: DSPMIMOSignalNotification: %s stream: %d SampleRate:%d, CenterFrequency:%llu",
563 sourceOrSink ?
"source" :
"sink",
void on_fmDeviation_valueChanged(int value)
void on_phaseImbalance_valueChanged(int value)
int m_spectrumStreamIndex
Index of the stream displayed on main spectrum.
QString m_reverseAPIAddress
Message * pop()
Pop message from queue.
const QString & getReverseAPIAddress() const
void openDeviceSettingsDialog(const QPoint &p)
qint64 getCenterFrequency() const
void updateAmpFineLimit()
QByteArray serialize() const
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void setSampleRate(qint32 sampleRate)
uint16_t m_reverseAPIPort
static double dbPower(double magsq, double floor=1e-12)
void on_centerFrequency_changed(quint64 value)
MessageQueue * getInputMessageQueue()
void on_amModulation_valueChanged(int value)
void on_streamLock_toggled(bool checked)
void setUseReverseAPI(bool useReverseAPI)
void updateAmpCoarseLimit()
void on_qBias_valueChanged(int value)
void handleInputMessages()
int m_streamIndex
Current stream index being dealt with.
void on_spectrumSource_currentIndexChanged(int index)
void on_modulationFrequency_valueChanged(int value)
static MsgFileRecord * create(bool startStop, int streamIndex)
void setName(const QString &name)
void setSpectrumSinkInput(bool sourceElseSink=true, unsigned int index=0)
Used in the MIMO case to select which stream is used as input to main spectrum.
void setDisplayedStream(bool sourceOrSink, int streamIndex)
uint16_t getReverseAPIDeviceIndex() const
void on_frequencyShift_changed(qint64 value)
void on_sampleRate_changed(quint64 value)
QString errorMessage()
Last error message from the device engine.
int getSampleRate() const
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
void on_amplitudeFine_valueChanged(int value)
GLSpectrum * getSpectrum()
Direct spectrum getter.
bool getSourceOrSink() const
void on_decimation_currentIndexChanged(int index)
engine is before initialization
EngineState state() const
Return the state of the device engine corresponding to the stream type.
std::vector< int > m_deviceSampleRates
TestMIGui(DeviceUISet *deviceUISet, QWidget *parent=0)
uint16_t getReverseAPIPort() const
void updateSampleRateAndFrequency()
DeviceSampleMIMO * m_sampleMIMO
static MsgStartStop * create(bool startStop)
virtual qint64 getCenterFrequency() const
void blockApplySettings(bool block)
void on_iBias_valueChanged(int value)
uint16_t m_reverseAPIDeviceIndex
static bool match(const Message *message)
std::vector< TestMIStreamSettings > m_streams
void updateFrequencyShiftLimit()
bool deserialize(const QByteArray &data)
bool getStartStop() const
virtual void setCenterFrequency(qint64 centerFrequency)
DeviceUISet * m_deviceUISet
TestMISettings m_settings
void on_sampleSize_currentIndexChanged(int index)
void on_fcPos_currentIndexChanged(int index)
MessageQueue m_inputMessageQueue
void on_modulation_currentIndexChanged(int index)
void on_dcBias_valueChanged(int value)
virtual void setMessageQueueToGUI(MessageQueue *queue)=0
void setCenterFrequency(qint64 frequency)
void setReverseAPIAddress(const QString &address)
void updateFileRecordStatus()
virtual bool handleMessage(const Message &message)
void setReverseAPIDeviceIndex(uint16_t deviceIndex)
bool deserialize(const QByteArray &data)
void on_startStop_toggled(bool checked)
QByteArray serialize() const
void on_streamIndex_currentIndexChanged(int index)
void setReverseAPIPort(uint16_t port)
void on_autoCorr_currentIndexChanged(int index)
std::vector< quint64 > m_deviceCenterFrequencies
Center frequency in device.
bool useReverseAPI() const
unsigned int getIndex() const
DeviceSampleMIMO * getSampleMIMO()
Return pointer to the device sample MIMO or nullptr.
void on_record_toggled(bool checked)
void on_amplitudeCoarse_valueChanged(int value)