2016-06-19 03:56:49 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// //
|
|
|
|
// 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 <stdint.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QString>
|
|
|
|
|
2017-09-15 22:50:25 -04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <nn.h>
|
|
|
|
#include <pair.h>
|
|
|
|
#else
|
2016-06-19 03:56:49 -04:00
|
|
|
#include <nanomsg/nn.h>
|
|
|
|
#include <nanomsg/pair.h>
|
2017-09-15 22:50:25 -04:00
|
|
|
#endif
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-09 07:47:26 -04:00
|
|
|
#include "ui_sdrdaemonsourcegui.h"
|
2016-06-19 03:56:49 -04:00
|
|
|
#include "gui/colormapper.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
#include <device/devicesourceapi.h>
|
2017-10-29 19:02:28 -04:00
|
|
|
#include "device/deviceuiset.h"
|
2017-06-09 07:58:27 -04:00
|
|
|
#include "sdrdaemonsourcegui.h"
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-10-29 19:45:23 -04:00
|
|
|
SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
2016-06-19 03:56:49 -04:00
|
|
|
QWidget(parent),
|
2017-06-09 07:47:26 -04:00
|
|
|
ui(new Ui::SDRdaemonSourceGui),
|
2017-10-29 19:02:28 -04:00
|
|
|
m_deviceUISet(deviceUISet),
|
2017-12-25 20:18:30 -05:00
|
|
|
m_settings(),
|
|
|
|
m_sampleSource(0),
|
2016-06-19 03:56:49 -04:00
|
|
|
m_acquisition(false),
|
2017-12-25 20:18:30 -05:00
|
|
|
m_streamSampleRate(0),
|
|
|
|
m_streamCenterFrequency(0),
|
2016-10-03 12:29:05 -04:00
|
|
|
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
|
2016-07-24 05:09:11 -04:00
|
|
|
m_framesDecodingStatus(0),
|
2016-06-19 03:56:49 -04:00
|
|
|
m_bufferLengthInSecs(0.0),
|
|
|
|
m_bufferGauge(-50),
|
2016-07-24 05:09:11 -04:00
|
|
|
m_nbOriginalBlocks(128),
|
2017-05-25 14:13:34 -04:00
|
|
|
m_nbFECBlocks(0),
|
|
|
|
m_samplesCount(0),
|
|
|
|
m_tickCount(0),
|
|
|
|
m_addressEdited(false),
|
|
|
|
m_dataPortEdited(false),
|
2017-06-08 09:31:24 -04:00
|
|
|
m_countUnrecoverable(0),
|
|
|
|
m_countRecovered(0),
|
2017-06-07 20:06:36 -04:00
|
|
|
m_doApplySettings(true),
|
|
|
|
m_forceSettings(true),
|
2017-12-25 20:18:30 -05:00
|
|
|
m_txDelay(0.0)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2016-07-27 23:57:59 -04:00
|
|
|
m_paletteGreenText.setColor(QPalette::WindowText, Qt::green);
|
|
|
|
m_paletteWhiteText.setColor(QPalette::WindowText, Qt::white);
|
|
|
|
|
2016-06-19 03:56:49 -04:00
|
|
|
m_startingTimeStamp.tv_sec = 0;
|
|
|
|
m_startingTimeStamp.tv_usec = 0;
|
|
|
|
ui->setupUi(this);
|
2017-06-08 18:43:06 -04:00
|
|
|
|
2017-05-16 11:48:12 -04:00
|
|
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2017-06-08 19:03:56 -04:00
|
|
|
ui->centerFrequency->setValueRange(7, 0, 9999999U);
|
|
|
|
|
|
|
|
ui->freq->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->freq->setValueRange(7, 0, 9999999U);
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-08 18:43:06 -04:00
|
|
|
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
2017-06-08 19:03:56 -04:00
|
|
|
ui->sampleRate->setValueRange(7, 32000U, 9999999U);
|
2017-06-08 18:43:06 -04:00
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
displaySettings();
|
|
|
|
|
2016-06-19 03:56:49 -04:00
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
|
|
|
m_statusTimer.start(500);
|
2017-10-29 19:45:23 -04:00
|
|
|
connect(&(m_deviceUISet->m_deviceSourceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
2017-06-07 20:06:36 -04:00
|
|
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-10-29 19:45:23 -04:00
|
|
|
m_sampleSource = (SDRdaemonSourceInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
2017-06-07 20:06:36 -04:00
|
|
|
|
2017-06-08 09:31:24 -04:00
|
|
|
m_eventsTime.start();
|
|
|
|
displayEventCounts();
|
|
|
|
displayEventTimer();
|
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
m_forceSettings = true;
|
2017-06-07 20:06:36 -04:00
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
SDRdaemonSourceGui::~SDRdaemonSourceGui()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::blockApplySettings(bool block)
|
2017-06-07 20:06:36 -04:00
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::destroy()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::setName(const QString& name)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
QString SDRdaemonSourceGui::getName() const
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::resetToDefaults()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
2017-12-25 20:18:30 -05:00
|
|
|
m_forceSettings = true;
|
2017-06-07 20:06:36 -04:00
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
QByteArray SDRdaemonSourceGui::serialize() const
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
return m_settings.serialize();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
bool SDRdaemonSourceGui::deserialize(const QByteArray& data)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
qDebug("SDRdaemonSourceGui::deserialize");
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
if (m_settings.deserialize(data))
|
2017-06-07 20:06:36 -04:00
|
|
|
{
|
2017-06-08 17:35:52 -04:00
|
|
|
updateTxDelay();
|
2017-12-25 20:18:30 -05:00
|
|
|
displaySettings();
|
2017-06-07 20:06:36 -04:00
|
|
|
m_forceSettings = true;
|
|
|
|
sendSettings();
|
2017-12-25 20:18:30 -05:00
|
|
|
|
2017-06-07 20:06:36 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
qint64 SDRdaemonSourceGui::getCenterFrequency() const
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
return m_streamCenterFrequency;
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::setCenterFrequency(qint64 centerFrequency)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
m_settings.m_centerFrequency = centerFrequency;
|
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
bool SDRdaemonSourceGui::handleMessage(const Message& message)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-27 21:21:48 -05:00
|
|
|
if (SDRdaemonSourceInput::MsgConfigureSDRdaemonSource::match(message))
|
|
|
|
{
|
|
|
|
const SDRdaemonSourceInput::MsgConfigureSDRdaemonSource& cfg = (SDRdaemonSourceInput::MsgConfigureSDRdaemonSource&) message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (SDRdaemonSourceInput::MsgReportSDRdaemonAcquisition::match(message))
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-09 08:14:32 -04:00
|
|
|
m_acquisition = ((SDRdaemonSourceInput::MsgReportSDRdaemonAcquisition&)message).getAcquisition();
|
2016-06-19 03:56:49 -04:00
|
|
|
updateWithAcquisition();
|
|
|
|
return true;
|
|
|
|
}
|
2017-06-09 08:14:32 -04:00
|
|
|
else if (SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData::match(message))
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-09 08:14:32 -04:00
|
|
|
m_startingTimeStamp.tv_sec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).get_tv_sec();
|
|
|
|
m_startingTimeStamp.tv_usec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).get_tv_usec();
|
2017-06-08 17:35:52 -04:00
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
qDebug() << "SDRdaemonSourceGui::handleMessage: SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData: "
|
|
|
|
<< " : " << m_startingTimeStamp.tv_sec
|
|
|
|
<< " : " << m_startingTimeStamp.tv_usec;
|
|
|
|
|
|
|
|
updateWithStreamTime();
|
2017-06-08 17:35:52 -04:00
|
|
|
return true;
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
2017-06-09 08:14:32 -04:00
|
|
|
else if (SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming::match(message))
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-09 08:14:32 -04:00
|
|
|
m_startingTimeStamp.tv_sec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).get_tv_sec();
|
|
|
|
m_startingTimeStamp.tv_usec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).get_tv_usec();
|
|
|
|
m_framesDecodingStatus = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getFramesDecodingStatus();
|
|
|
|
m_allBlocksReceived = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).allBlocksReceived();
|
|
|
|
m_bufferLengthInSecs = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getBufferLengthInSecs();
|
|
|
|
m_bufferGauge = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getBufferGauge();
|
|
|
|
m_minNbBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getMinNbBlocks();
|
|
|
|
m_minNbOriginalBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getMinNbOriginalBlocks();
|
|
|
|
m_maxNbRecovery = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getMaxNbRecovery();
|
|
|
|
m_avgNbBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getAvgNbBlocks();
|
|
|
|
m_avgNbOriginalBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getAvgNbOriginalBlocks();
|
|
|
|
m_avgNbRecovery = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getAvgNbRecovery();
|
|
|
|
m_nbOriginalBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getNbOriginalBlocksPerFrame();
|
|
|
|
|
|
|
|
int nbFECBlocks = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming&)message).getNbFECBlocksPerFrame();
|
2017-06-08 17:35:52 -04:00
|
|
|
|
|
|
|
if (m_nbFECBlocks != nbFECBlocks)
|
|
|
|
{
|
|
|
|
m_nbFECBlocks = nbFECBlocks;
|
|
|
|
updateTxDelay();
|
|
|
|
}
|
2016-06-19 03:56:49 -04:00
|
|
|
|
|
|
|
updateWithStreamTime();
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-13 18:19:59 -05:00
|
|
|
else if (SDRdaemonSourceInput::MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
SDRdaemonSourceInput::MsgStartStop& notif = (SDRdaemonSourceInput::MsgStartStop&) message;
|
|
|
|
blockApplySettings(true);
|
|
|
|
ui->startStop->setChecked(notif.getStartStop());
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-06-19 03:56:49 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
void SDRdaemonSourceGui::handleInputMessages()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
while ((message = m_inputMessageQueue.pop()) != 0)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-09-16 20:02:41 -04:00
|
|
|
//qDebug("SDRdaemonGui::handleInputMessages: message: %s", message->getIdentifier());
|
2016-06-19 03:56:49 -04:00
|
|
|
|
|
|
|
if (DSPSignalNotification::match(*message))
|
|
|
|
{
|
|
|
|
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
2017-12-25 20:18:30 -05:00
|
|
|
|
|
|
|
if (notif->getSampleRate() != m_streamSampleRate)
|
|
|
|
{
|
|
|
|
m_streamSampleRate = notif->getSampleRate();
|
|
|
|
updateTxDelay();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_streamCenterFrequency = notif->getCenterFrequency();
|
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
qDebug("SDRdaemonGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
2017-12-25 20:18:30 -05:00
|
|
|
|
2016-06-19 03:56:49 -04:00
|
|
|
updateSampleRateAndFrequency();
|
2017-09-04 18:31:45 -04:00
|
|
|
DSPSignalNotification *fwd = new DSPSignalNotification(*notif);
|
|
|
|
m_sampleSource->getInputMessageQueue()->push(fwd);
|
2016-06-19 03:56:49 -04:00
|
|
|
|
|
|
|
delete message;
|
|
|
|
}
|
2017-09-16 19:23:54 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::updateSampleRateAndFrequency()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
m_deviceUISet->getSpectrum()->setSampleRate(m_streamSampleRate);
|
|
|
|
m_deviceUISet->getSpectrum()->setCenterFrequency(m_streamCenterFrequency);
|
|
|
|
ui->deviceRateText->setText(tr("%1k").arg((float)m_streamSampleRate / 1000));
|
|
|
|
blockApplySettings(true);
|
|
|
|
ui->centerFrequency->setValue(m_streamCenterFrequency / 1000);
|
|
|
|
ui->freq->setValue(m_streamCenterFrequency / 1000);
|
|
|
|
blockApplySettings(false);
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::updateTxDelay()
|
2017-06-08 17:35:52 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
if (m_streamSampleRate == 0) {
|
2017-06-09 21:10:30 -04:00
|
|
|
m_txDelay = 0.0; // 0 value will not set the Tx delay
|
|
|
|
} else {
|
2017-12-25 20:18:30 -05:00
|
|
|
m_txDelay = ((127*127*m_settings.m_txDelay) / m_streamSampleRate)/(128 + m_nbFECBlocks);
|
2017-06-09 21:10:30 -04:00
|
|
|
}
|
|
|
|
|
2017-06-08 17:35:52 -04:00
|
|
|
ui->txDelayText->setToolTip(tr("%1 us").arg(QString::number(m_txDelay*1e6, 'f', 0)));
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::displaySettings()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
blockApplySettings(true);
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
ui->centerFrequency->setValue(m_streamCenterFrequency / 1000);
|
|
|
|
ui->deviceRateText->setText(tr("%1k").arg(m_streamSampleRate / 1000.0));
|
|
|
|
|
|
|
|
ui->freq->setValue(m_streamCenterFrequency / 1000);
|
2017-06-07 20:06:36 -04:00
|
|
|
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
|
|
|
|
ui->fcPos->setCurrentIndex(m_settings.m_fcPos);
|
2017-06-08 18:43:06 -04:00
|
|
|
ui->sampleRate->setValue(m_settings.m_sampleRate);
|
2017-06-07 20:06:36 -04:00
|
|
|
ui->specificParms->setText(m_settings.m_specificParameters);
|
|
|
|
ui->specificParms->setCursorPosition(0);
|
2017-06-08 17:35:52 -04:00
|
|
|
ui->txDelayText->setText(tr("%1").arg(m_settings.m_txDelay*100));
|
2017-06-08 18:21:05 -04:00
|
|
|
ui->nbFECBlocks->setValue(m_settings.m_nbFECBlocks);
|
|
|
|
QString nstr = QString("%1").arg(m_settings.m_nbFECBlocks, 2, 10, QChar('0'));
|
|
|
|
ui->nbFECBlocksText->setText(nstr);
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-07 20:06:36 -04:00
|
|
|
QString s0 = QString::number(128 + m_settings.m_nbFECBlocks, 'f', 0);
|
2017-06-08 18:21:05 -04:00
|
|
|
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s0).arg(nstr));
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-07 20:06:36 -04:00
|
|
|
ui->address->setText(m_settings.m_address);
|
|
|
|
ui->dataPort->setText(tr("%1").arg(m_settings.m_dataPort));
|
|
|
|
ui->controlPort->setText(tr("%1").arg(m_settings.m_controlPort));
|
|
|
|
ui->specificParms->setText(m_settings.m_specificParameters);
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-07 20:06:36 -04:00
|
|
|
ui->dcOffset->setChecked(m_settings.m_dcBlock);
|
|
|
|
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
|
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
blockApplySettings(false);
|
2017-06-07 20:06:36 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::sendSettings()
|
2017-06-07 20:06:36 -04:00
|
|
|
{
|
|
|
|
if(!m_updateTimer.isActive())
|
|
|
|
m_updateTimer.start(100);
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_applyButton_clicked(bool checked __attribute__((unused)))
|
2017-06-07 20:06:36 -04:00
|
|
|
{
|
|
|
|
m_settings.m_address = ui->address->text();
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
bool send = false;
|
2017-06-07 20:06:36 -04:00
|
|
|
bool ctlOk;
|
|
|
|
int udpCtlPort = ui->controlPort->text().toInt(&ctlOk);
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-07 20:06:36 -04:00
|
|
|
if((ctlOk) && (udpCtlPort >= 1024) && (udpCtlPort < 65535))
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
m_settings.m_controlPort = udpCtlPort;
|
2017-12-25 20:18:30 -05:00
|
|
|
send = true;
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
2017-06-07 20:06:36 -04:00
|
|
|
|
|
|
|
bool dataOk;
|
|
|
|
int udpDataPort = ui->dataPort->text().toInt(&dataOk);
|
|
|
|
|
|
|
|
if((dataOk) && (udpDataPort >= 1024) && (udpDataPort < 65535))
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
m_settings.m_dataPort = udpDataPort;
|
2017-12-25 20:18:30 -05:00
|
|
|
send = true;
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
2017-06-07 20:06:36 -04:00
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
if (send) {
|
|
|
|
sendSettings();
|
|
|
|
}
|
2017-06-07 20:06:36 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_sendButton_clicked(bool checked __attribute__((unused)))
|
2017-06-07 20:06:36 -04:00
|
|
|
{
|
2017-06-08 17:35:52 -04:00
|
|
|
updateTxDelay();
|
2017-12-25 20:18:30 -05:00
|
|
|
m_forceSettings = true;
|
|
|
|
sendSettings();
|
2017-06-07 20:06:36 -04:00
|
|
|
ui->specificParms->setCursorPosition(0);
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_address_returnPressed()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
m_settings.m_address = ui->address->text();
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_dataPort_returnPressed()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
bool dataOk;
|
|
|
|
int udpDataPort = ui->dataPort->text().toInt(&dataOk);
|
|
|
|
|
|
|
|
if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.m_dataPort = udpDataPort;
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2017-06-07 20:06:36 -04:00
|
|
|
}
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_controlPort_returnPressed()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
bool ctlOk;
|
|
|
|
int udpCtlPort = ui->controlPort->text().toInt(&ctlOk);
|
|
|
|
|
|
|
|
if((!ctlOk) || (udpCtlPort < 1024) || (udpCtlPort > 65535))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.m_controlPort = udpCtlPort;
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2017-06-07 20:06:36 -04:00
|
|
|
}
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_dcOffset_toggled(bool checked)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
m_settings.m_dcBlock = checked;
|
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_iqImbalance_toggled(bool checked)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
m_settings.m_iqCorrection = checked;
|
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_freq_changed(quint64 value)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-08 19:03:56 -04:00
|
|
|
m_settings.m_centerFrequency = value * 1000;
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_sampleRate_changed(quint64 value)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-08 18:43:06 -04:00
|
|
|
m_settings.m_sampleRate = value;
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_specificParms_returnPressed()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
if ((ui->specificParms->text()).size() > 0) {
|
|
|
|
m_settings.m_specificParameters = ui->specificParms->text();
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2017-06-07 20:06:36 -04:00
|
|
|
}
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_decim_currentIndexChanged(int index __attribute__((unused)))
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
m_settings.m_log2Decim = ui->decim->currentIndex();
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_fcPos_currentIndexChanged(int index __attribute__((unused)))
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-07 20:06:36 -04:00
|
|
|
m_settings.m_fcPos = ui->fcPos->currentIndex();
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_txDelay_valueChanged(int value)
|
2017-06-08 17:35:52 -04:00
|
|
|
{
|
|
|
|
m_settings.m_txDelay = value / 100.0;
|
|
|
|
ui->txDelayText->setText(tr("%1").arg(value));
|
|
|
|
updateTxDelay();
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2017-06-08 17:35:52 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_nbFECBlocks_valueChanged(int value)
|
2017-06-08 18:21:05 -04:00
|
|
|
{
|
|
|
|
m_settings.m_nbFECBlocks = value;
|
|
|
|
QString nstr = QString("%1").arg(m_settings.m_nbFECBlocks, 2, 10, QChar('0'));
|
|
|
|
ui->nbFECBlocksText->setText(nstr);
|
2017-12-25 20:18:30 -05:00
|
|
|
sendSettings();
|
2017-06-08 18:21:05 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_startStop_toggled(bool checked)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-13 18:19:59 -05:00
|
|
|
if (m_doApplySettings)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-13 18:19:59 -05:00
|
|
|
SDRdaemonSourceInput::MsgStartStop *message = SDRdaemonSourceInput::MsgStartStop::create(checked);
|
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_record_toggled(bool checked)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-09-04 18:31:45 -04:00
|
|
|
if (checked) {
|
2016-06-19 03:56:49 -04:00
|
|
|
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
2017-09-04 18:31:45 -04:00
|
|
|
} else {
|
2016-06-19 03:56:49 -04:00
|
|
|
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
2017-09-04 18:31:45 -04:00
|
|
|
|
|
|
|
SDRdaemonSourceInput::MsgFileRecord* message = SDRdaemonSourceInput::MsgFileRecord::create(checked);
|
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::on_eventCountsReset_clicked(bool checked __attribute__((unused)))
|
2017-06-08 09:31:24 -04:00
|
|
|
{
|
|
|
|
m_countUnrecoverable = 0;
|
|
|
|
m_countRecovered = 0;
|
|
|
|
m_eventsTime.start();
|
|
|
|
displayEventCounts();
|
|
|
|
displayEventTimer();
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::displayEventCounts()
|
2017-06-08 09:31:24 -04:00
|
|
|
{
|
|
|
|
QString nstr = QString("%1").arg(m_countUnrecoverable, 3, 10, QChar('0'));
|
|
|
|
ui->eventUnrecText->setText(nstr);
|
|
|
|
nstr = QString("%1").arg(m_countRecovered, 3, 10, QChar('0'));
|
|
|
|
ui->eventRecText->setText(nstr);
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::displayEventTimer()
|
2017-06-08 09:31:24 -04:00
|
|
|
{
|
|
|
|
int elapsedTimeMillis = m_eventsTime.elapsed();
|
|
|
|
QTime recordLength(0, 0, 0, 0);
|
|
|
|
recordLength = recordLength.addSecs(elapsedTimeMillis/1000);
|
2018-05-11 05:00:08 -04:00
|
|
|
QString s_time = recordLength.toString("HH:mm:ss");
|
2017-06-08 09:31:24 -04:00
|
|
|
ui->eventCountsTimeText->setText(s_time);
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::updateWithAcquisition()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::updateWithStreamTime()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-08 09:31:24 -04:00
|
|
|
bool updateEventCounts = false;
|
2016-06-19 03:56:49 -04:00
|
|
|
quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL);
|
|
|
|
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
|
2018-05-11 05:00:08 -04:00
|
|
|
QString s_date = dt.toString("yyyy-MM-dd HH:mm:ss.zzz");
|
2016-06-19 03:56:49 -04:00
|
|
|
ui->absTimeText->setText(s_date);
|
|
|
|
|
2017-06-08 09:31:24 -04:00
|
|
|
if (m_framesDecodingStatus == 2)
|
|
|
|
{
|
2016-07-17 18:39:35 -04:00
|
|
|
ui->allFramesDecoded->setStyleSheet("QToolButton { background-color : green; }");
|
2017-06-08 09:31:24 -04:00
|
|
|
}
|
|
|
|
else if (m_framesDecodingStatus == 1)
|
|
|
|
{
|
|
|
|
if (m_countRecovered < 999) m_countRecovered++;
|
|
|
|
updateEventCounts = true;
|
2016-07-25 02:40:10 -04:00
|
|
|
ui->allFramesDecoded->setStyleSheet("QToolButton { background:rgb(56,56,56); }");
|
2017-06-08 09:31:24 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_countUnrecoverable < 999) m_countUnrecoverable++;
|
|
|
|
updateEventCounts = true;
|
2017-06-08 02:40:21 -04:00
|
|
|
ui->allFramesDecoded->setStyleSheet("QToolButton { background-color : red; }");
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2016-06-19 19:18:21 -04:00
|
|
|
QString s = QString::number(m_bufferLengthInSecs, 'f', 1);
|
2016-06-19 03:56:49 -04:00
|
|
|
ui->bufferLenSecsText->setText(tr("%1").arg(s));
|
|
|
|
|
2016-06-21 19:10:58 -04:00
|
|
|
s = QString::number(m_bufferGauge, 'f', 0);
|
2016-06-19 03:56:49 -04:00
|
|
|
ui->bufferRWBalanceText->setText(tr("%1").arg(s));
|
|
|
|
|
2016-06-21 19:10:58 -04:00
|
|
|
ui->bufferGaugeNegative->setValue((m_bufferGauge < 0 ? -m_bufferGauge : 0));
|
|
|
|
ui->bufferGaugePositive->setValue((m_bufferGauge < 0 ? 0 : m_bufferGauge));
|
2016-06-19 19:18:21 -04:00
|
|
|
|
2016-07-17 18:39:35 -04:00
|
|
|
s = QString::number(m_minNbBlocks, 'f', 0);
|
|
|
|
ui->minNbBlocksText->setText(tr("%1").arg(s));
|
2016-06-19 19:18:21 -04:00
|
|
|
|
2017-06-08 18:21:05 -04:00
|
|
|
s = QString("%1").arg(m_maxNbRecovery, 2, 10, QChar('0'));
|
2016-07-27 12:49:17 -04:00
|
|
|
ui->maxNbRecoveryText->setText(tr("%1").arg(s));
|
2016-06-19 19:18:21 -04:00
|
|
|
|
2016-07-24 05:09:11 -04:00
|
|
|
s = QString::number(m_nbOriginalBlocks + m_nbFECBlocks, 'f', 0);
|
2017-06-08 18:21:05 -04:00
|
|
|
QString s1 = QString("%1").arg(m_nbFECBlocks, 2, 10, QChar('0'));
|
2016-07-24 05:09:11 -04:00
|
|
|
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1));
|
2017-06-08 09:31:24 -04:00
|
|
|
|
|
|
|
if (updateEventCounts)
|
|
|
|
{
|
|
|
|
displayEventCounts();
|
|
|
|
}
|
|
|
|
|
|
|
|
displayEventTimer();
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::updateHardware()
|
2017-06-07 20:06:36 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
qDebug() << "SDRdaemonSinkGui::updateHardware";
|
|
|
|
SDRdaemonSourceInput::MsgConfigureSDRdaemonSource* message =
|
|
|
|
SDRdaemonSourceInput::MsgConfigureSDRdaemonSource::create(m_settings, m_forceSettings);
|
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
|
|
|
m_forceSettings = false;
|
|
|
|
m_updateTimer.stop();
|
|
|
|
}
|
2017-06-07 20:06:36 -04:00
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::updateStatus()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
if (m_sampleSource->isStreaming())
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
int state = m_deviceUISet->m_deviceSourceAPI->state();
|
|
|
|
|
|
|
|
if (m_lastEngineState != state)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-12-25 20:18:30 -05:00
|
|
|
switch(state)
|
|
|
|
{
|
|
|
|
case DSPDeviceSourceEngine::StNotStarted:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
break;
|
|
|
|
case DSPDeviceSourceEngine::StIdle:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
|
|
|
break;
|
|
|
|
case DSPDeviceSourceEngine::StRunning:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
break;
|
|
|
|
case DSPDeviceSourceEngine::StError:
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
|
|
|
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceSourceAPI->errorMessage());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastEngineState = state;
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
2017-12-25 20:18:30 -05:00
|
|
|
ui->startStop->setEnabled(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
ui->startStop->setChecked(false);
|
|
|
|
ui->startStop->setEnabled(false);
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
void SDRdaemonSourceGui::tick()
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
|
|
|
if ((++m_tickCount & 0xf) == 0) {
|
2017-06-09 08:14:32 -04:00
|
|
|
SDRdaemonSourceInput::MsgConfigureSDRdaemonStreamTiming* message = SDRdaemonSourceInput::MsgConfigureSDRdaemonStreamTiming::create();
|
2016-06-19 03:56:49 -04:00
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|