| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2015 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | #include <stdint.h>
 | 
					
						
							|  |  |  | #include <sstream>
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <cassert>
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | #include <QTime>
 | 
					
						
							|  |  |  | #include <QDateTime>
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							|  |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <nanomsg/nn.h>
 | 
					
						
							|  |  |  | #include <nanomsg/pair.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | #include "ui_sdrdaemongui.h"
 | 
					
						
							|  |  |  | #include "gui/colormapper.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  | #include "gui/glspectrum.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | #include "dsp/dspengine.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  | #include "dsp/dspcommands.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | #include "mainwindow.h"
 | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | #include "util/simpleserializer.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "sdrdaemongui.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <device/devicesourceapi.h>
 | 
					
						
							| 
									
										
										
										
											2016-10-02 10:30:58 +02:00
										 |  |  | #include <dsp/filerecord.h>
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | SDRdaemonGui::SDRdaemonGui(DeviceSourceAPI *deviceAPI, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	QWidget(parent), | 
					
						
							|  |  |  | 	ui(new Ui::SDRdaemonGui), | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:37 +02:00
										 |  |  | 	m_deviceAPI(deviceAPI), | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	m_sampleSource(NULL), | 
					
						
							|  |  |  | 	m_acquisition(false), | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 	m_lastEngineState((DSPDeviceSourceEngine::State)-1), | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	m_sampleRate(0), | 
					
						
							| 
									
										
										
										
											2016-02-22 15:03:16 +01:00
										 |  |  | 	m_sampleRateStream(0), | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	m_centerFrequency(0), | 
					
						
							| 
									
										
										
										
											2016-02-23 14:57:40 +01:00
										 |  |  | 	m_syncLocked(false), | 
					
						
							| 
									
										
										
										
											2016-02-23 19:27:47 +01:00
										 |  |  | 	m_frameSize(0), | 
					
						
							|  |  |  | 	m_lz4(false), | 
					
						
							|  |  |  | 	m_compressionRatio(1.0), | 
					
						
							|  |  |  | 	m_nbLz4DataCRCOK(0), | 
					
						
							|  |  |  | 	m_nbLz4SuccessfulDecodes(0), | 
					
						
							| 
									
										
										
										
											2016-03-20 14:40:40 +01:00
										 |  |  | 	m_bufferLengthInSecs(0.0), | 
					
						
							| 
									
										
										
										
											2016-03-17 15:41:48 +01:00
										 |  |  |     m_bufferGauge(-50), | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	m_samplesCount(0), | 
					
						
							| 
									
										
										
										
											2016-02-17 23:47:03 +01:00
										 |  |  | 	m_tickCount(0), | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 	m_address("127.0.0.1"), | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	m_dataPort(9090), | 
					
						
							|  |  |  | 	m_controlPort(9091), | 
					
						
							|  |  |  | 	m_addressEdited(false), | 
					
						
							|  |  |  | 	m_dataPortEdited(false), | 
					
						
							|  |  |  | 	m_initSendConfiguration(false), | 
					
						
							| 
									
										
										
										
											2016-02-17 23:47:03 +01:00
										 |  |  | 	m_dcBlock(false), | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 	m_iqCorrection(false), | 
					
						
							|  |  |  | 	m_autoFollowRate(false) | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-03-27 04:33:12 +02:00
										 |  |  | 	m_sender = nn_socket(AF_SP, NN_PAIR); | 
					
						
							|  |  |  | 	assert(m_sender != -1); | 
					
						
							|  |  |  | 	int millis = 500; | 
					
						
							| 
									
										
										
										
											2017-05-26 10:35:29 +02:00
										 |  |  |     int rc __attribute__((unused)) = nn_setsockopt (m_sender, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis)); | 
					
						
							| 
									
										
										
										
											2016-03-27 04:33:12 +02:00
										 |  |  |     assert (rc == 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-14 20:01:46 +01:00
										 |  |  | 	m_startingTimeStamp.tv_sec = 0; | 
					
						
							|  |  |  | 	m_startingTimeStamp.tv_usec = 0; | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	ui->setupUi(this); | 
					
						
							| 
									
										
										
										
											2017-05-16 18:27:36 +02:00
										 |  |  | 	ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	ui->centerFrequency->setValueRange(7, 0, pow(10,7)); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-23 01:50:17 +02:00
										 |  |  | 	//connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); does not exist in this class
 | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 	connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | 
					
						
							|  |  |  | 	m_statusTimer.start(500); | 
					
						
							| 
									
										
										
										
											2016-05-17 19:08:04 +02:00
										 |  |  | 	connect(&(deviceAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick())); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-17 19:08:04 +02:00
										 |  |  | 	m_sampleSource = new SDRdaemonInput(deviceAPI->getMainWindow()->getMasterTimer(), m_deviceAPI); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  | 	m_deviceAPI->setSource(m_sampleSource); | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	displaySettings(); | 
					
						
							| 
									
										
										
										
											2016-02-25 01:37:47 +01:00
										 |  |  | 	ui->applyButton->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	ui->sendButton->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     char recFileNameCStr[30]; | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |     sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID()); | 
					
						
							| 
									
										
										
										
											2016-10-02 10:30:58 +02:00
										 |  |  |     m_fileSink = new FileRecord(std::string(recFileNameCStr)); | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:37 +02:00
										 |  |  |     m_deviceAPI->addSink(m_fileSink); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |     connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SDRdaemonGui::~SDRdaemonGui() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |     m_deviceAPI->removeSink(m_fileSink); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  |     delete m_fileSink; | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRdaemonGui::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	delete this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRdaemonGui::setName(const QString& name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	setObjectName(name); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString SDRdaemonGui::getName() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return objectName(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRdaemonGui::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 	m_address = "127.0.0.1"; | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	m_remoteAddress = "127.0.0.1"; | 
					
						
							|  |  |  | 	m_dataPort = 9090; | 
					
						
							|  |  |  | 	m_controlPort = 9091; | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 	m_dcBlock = false; | 
					
						
							|  |  |  | 	m_iqCorrection = false; | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 	m_autoFollowRate = false; | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	displaySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray SDRdaemonGui::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 	bool ok; | 
					
						
							|  |  |  | 	SimpleSerializer s(1); | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 	s.writeString(1, ui->address->text()); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	uint32_t uintval = ui->dataPort->text().toInt(&ok); | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 	if((!ok) || (uintval < 1024) || (uintval > 65535)) { | 
					
						
							|  |  |  | 		uintval = 9090; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 	s.writeU32(2, uintval); | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 	s.writeBool(3, m_dcBlock); | 
					
						
							|  |  |  | 	s.writeBool(4, m_iqCorrection); | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 	s.writeBool(5, m_autoFollowRate); | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  |     s.writeBool(6, m_autoCorrBuffer); | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	uintval = ui->controlPort->text().toInt(&ok); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if((!ok) || (uintval < 1024) || (uintval > 65535)) { | 
					
						
							|  |  |  | 		uintval = 9091; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	s.writeU32(7, uintval); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	uint32_t confFrequency = ui->freq->text().toInt(&ok); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ok) { | 
					
						
							|  |  |  | 		s.writeU32(8, confFrequency); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	s.writeU32(9,  ui->decim->currentIndex()); | 
					
						
							|  |  |  | 	s.writeU32(10,  ui->fcPos->currentIndex()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	uint32_t sampleRate = ui->sampleRate->text().toInt(&ok); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ok) { | 
					
						
							|  |  |  | 		s.writeU32(11, sampleRate); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	s.writeString(12, ui->specificParms->text()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 	return s.final(); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool SDRdaemonGui::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 	SimpleDeserializer d(data); | 
					
						
							|  |  |  | 	QString address; | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	quint16 dataPort; | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 	bool dcBlock; | 
					
						
							|  |  |  | 	bool iqCorrection; | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 	bool autoFollowRate; | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  |     bool autoCorrBuffer; | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  |     uint32_t confFrequency; | 
					
						
							|  |  |  |     uint32_t confSampleRate; | 
					
						
							|  |  |  |     uint32_t confDecim; | 
					
						
							|  |  |  |     uint32_t confFcPos; | 
					
						
							|  |  |  |     QString confSpecificParms; | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 	if (!d.isValid()) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 		resetToDefaults(); | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 		displaySettings(); | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 	if (d.getVersion() == 1) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 		uint32_t uintval; | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 		d.readString(1, &address, "127.0.0.1"); | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 		d.readU32(2, &uintval, 9090); | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 		if ((uintval > 1024) && (uintval < 65536)) { | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 			dataPort = uintval; | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 			dataPort = 9090; | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 		d.readBool(3, &dcBlock, false); | 
					
						
							|  |  |  | 		d.readBool(4, &iqCorrection, false); | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 		d.readBool(5, &autoFollowRate, false); | 
					
						
							| 
									
										
										
										
											2016-03-18 18:37:32 +01:00
										 |  |  |         d.readBool(6, &autoCorrBuffer, false); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 		d.readU32(7, &uintval, 9091); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if ((uintval > 1024) && (uintval < 65536)) { | 
					
						
							|  |  |  | 			m_controlPort = uintval; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			m_controlPort = 9091; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 		d.readU32(8, &confFrequency, 435000); | 
					
						
							|  |  |  | 		d.readU32(9, &confDecim, 3); | 
					
						
							|  |  |  | 		d.readU32(10, &confFcPos, 2); | 
					
						
							|  |  |  | 		d.readU32(11, &confSampleRate, 1000); | 
					
						
							|  |  |  | 		d.readString(12, &confSpecificParms, ""); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if ((address != m_address) || (dataPort != m_dataPort)) | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			m_address = address; | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 			m_dataPort = dataPort; | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 			configureUDPLink(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if ((dcBlock != m_dcBlock) || (iqCorrection != m_iqCorrection)) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			m_dcBlock = dcBlock; | 
					
						
							|  |  |  | 			m_iqCorrection = iqCorrection; | 
					
						
							|  |  |  | 			configureAutoCorrections(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  |         if ((m_autoFollowRate != autoFollowRate) || (m_autoCorrBuffer != autoCorrBuffer)) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 			m_autoFollowRate = autoFollowRate; | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  |             m_autoCorrBuffer = autoCorrBuffer; | 
					
						
							|  |  |  |             configureAutoFollowPolicy(); | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 		displaySettings(); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 		displayConfigurationParameters(confFrequency, confDecim, confFcPos, confSampleRate, confSpecificParms); | 
					
						
							|  |  |  | 		m_initSendConfiguration = true; | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 		resetToDefaults(); | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 		displaySettings(); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 		QString defaultSpecificParameters(""); | 
					
						
							|  |  |  | 		displayConfigurationParameters(435000, 3, 2, 1000, defaultSpecificParameters); | 
					
						
							|  |  |  | 		m_initSendConfiguration = true; | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | qint64 SDRdaemonGui::getCenterFrequency() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return m_centerFrequency; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRdaemonGui::setCenterFrequency(qint64 centerFrequency) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	m_centerFrequency = centerFrequency; | 
					
						
							|  |  |  | 	displaySettings(); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool SDRdaemonGui::handleMessage(const Message& message) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (SDRdaemonInput::MsgReportSDRdaemonAcquisition::match(message)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		m_acquisition = ((SDRdaemonInput::MsgReportSDRdaemonAcquisition&)message).getAcquisition(); | 
					
						
							|  |  |  | 		updateWithAcquisition(); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (SDRdaemonInput::MsgReportSDRdaemonStreamData::match(message)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-02-22 15:03:16 +01:00
										 |  |  | 		m_sampleRateStream = ((SDRdaemonInput::MsgReportSDRdaemonStreamData&)message).getSampleRateStream(); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 		m_sampleRate = ((SDRdaemonInput::MsgReportSDRdaemonStreamData&)message).getSampleRate(); | 
					
						
							|  |  |  | 		m_centerFrequency = ((SDRdaemonInput::MsgReportSDRdaemonStreamData&)message).getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2016-02-14 20:01:46 +01:00
										 |  |  | 		m_startingTimeStamp.tv_sec = ((SDRdaemonInput::MsgReportSDRdaemonStreamData&)message).get_tv_sec(); | 
					
						
							|  |  |  | 		m_startingTimeStamp.tv_usec = ((SDRdaemonInput::MsgReportSDRdaemonStreamData&)message).get_tv_usec(); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 		updateWithStreamData(); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (SDRdaemonInput::MsgReportSDRdaemonStreamTiming::match(message)) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-02-17 02:22:05 +01:00
										 |  |  | 		m_startingTimeStamp.tv_sec = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).get_tv_sec(); | 
					
						
							|  |  |  | 		m_startingTimeStamp.tv_usec = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).get_tv_usec(); | 
					
						
							| 
									
										
										
										
											2016-02-23 14:57:40 +01:00
										 |  |  | 		m_syncLocked = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getSyncLock(); | 
					
						
							| 
									
										
										
										
											2016-02-23 18:09:20 +01:00
										 |  |  | 		m_frameSize = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getFrameSize(); | 
					
						
							| 
									
										
										
										
											2016-02-23 18:19:35 +01:00
										 |  |  | 		m_lz4 = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getLz4Compression(); | 
					
						
							| 
									
										
										
										
											2016-02-23 19:27:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (m_lz4) { | 
					
						
							|  |  |  | 			m_compressionRatio = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getLz4CompressionRatio(); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			m_compressionRatio = 1.0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		m_nbLz4DataCRCOK = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getLz4DataCRCOK(); | 
					
						
							|  |  |  | 		m_nbLz4SuccessfulDecodes = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getLz4SuccessfulDecodes(); | 
					
						
							| 
									
										
										
										
											2016-03-20 14:40:40 +01:00
										 |  |  | 		m_bufferLengthInSecs = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getBufferLengthInSecs(); | 
					
						
							| 
									
										
										
										
											2016-03-17 15:41:48 +01:00
										 |  |  |         m_bufferGauge = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getBufferGauge(); | 
					
						
							| 
									
										
										
										
											2016-02-23 19:27:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 		updateWithStreamTime(); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  | void SDRdaemonGui::handleDSPMessages() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |     while ((message = m_deviceAPI->getDeviceOutputMessageQueue()->pop()) != 0) | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         qDebug("SDRdaemonGui::handleDSPMessages: message: %s", message->getIdentifier()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (DSPSignalNotification::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DSPSignalNotification* notif = (DSPSignalNotification*) message; | 
					
						
							|  |  |  |             m_deviceSampleRate = notif->getSampleRate(); | 
					
						
							|  |  |  |             m_deviceCenterFrequency = notif->getCenterFrequency(); | 
					
						
							|  |  |  |             qDebug("SDRdaemonGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); | 
					
						
							|  |  |  |             updateSampleRateAndFrequency(); | 
					
						
							|  |  |  |             m_fileSink->handleMessage(*notif); // forward to file sink
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | void SDRdaemonGui::handleSourceMessages() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while ((message = m_sampleSource->getOutputMessageQueueToGUI()->pop()) != 0) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-02-17 23:47:03 +01:00
										 |  |  | 		//qDebug("SDRdaemonGui::handleSourceMessages: message: %s", message->getIdentifier());
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (handleMessage(*message)) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			delete message; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  | void SDRdaemonGui::updateSampleRateAndFrequency() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |     m_deviceAPI->getSpectrum()->setSampleRate(m_deviceSampleRate); | 
					
						
							|  |  |  |     m_deviceAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  |     ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | void SDRdaemonGui::displaySettings() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 	ui->address->setText(m_address); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	ui->dataPort->setText(QString::number(m_dataPort)); | 
					
						
							|  |  |  | 	ui->controlPort->setText(QString::number(m_controlPort)); | 
					
						
							| 
									
										
										
										
											2016-02-17 23:47:03 +01:00
										 |  |  | 	ui->dcOffset->setChecked(m_dcBlock); | 
					
						
							|  |  |  | 	ui->iqImbalance->setChecked(m_iqCorrection); | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 	ui->autoFollowRate->setChecked(m_autoFollowRate); | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  |     ui->autoCorrBuffer->setChecked(m_autoCorrBuffer); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | void SDRdaemonGui::displayConfigurationParameters(uint32_t freq, | 
					
						
							|  |  |  | 		uint32_t log2Decim, | 
					
						
							|  |  |  | 		uint32_t fcPos, | 
					
						
							|  |  |  | 		uint32_t sampleRate, | 
					
						
							|  |  |  | 		QString& specParms) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ui->freq->setText(QString::number(freq)); | 
					
						
							|  |  |  | 	ui->decim->setCurrentIndex(log2Decim); | 
					
						
							|  |  |  | 	ui->fcPos->setCurrentIndex(fcPos); | 
					
						
							|  |  |  | 	ui->sampleRate->setText(QString::number(sampleRate)); | 
					
						
							|  |  |  | 	ui->specificParms->setText(specParms); | 
					
						
							|  |  |  | 	ui->specificParms->setCursorPosition(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_applyButton_clicked(bool checked __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	bool dataOk, ctlOk; | 
					
						
							| 
									
										
										
										
											2016-02-23 23:16:05 +01:00
										 |  |  | 	QString udpAddress = ui->address->text(); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	int udpDataPort = ui->dataPort->text().toInt(&dataOk); | 
					
						
							|  |  |  | 	int tcpCtlPort = ui->controlPort->text().toInt(&ctlOk); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		udpDataPort = 9090; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-23 23:16:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	if((!ctlOk) || (tcpCtlPort < 1024) || (tcpCtlPort > 65535)) | 
					
						
							| 
									
										
										
										
											2016-02-23 23:16:05 +01:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 		tcpCtlPort = 9091; | 
					
						
							| 
									
										
										
										
											2016-02-23 23:16:05 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	m_address = udpAddress; | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	m_dataPort = udpDataPort; | 
					
						
							|  |  |  | 	m_controlPort = tcpCtlPort; | 
					
						
							| 
									
										
										
										
											2016-02-23 23:16:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	if (m_addressEdited || m_dataPortEdited) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		configureUDPLink(); | 
					
						
							|  |  |  | 		m_addressEdited = false; | 
					
						
							|  |  |  | 		m_dataPortEdited = false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-25 01:37:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ui->applyButton->setEnabled(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_sendButton_clicked(bool checked __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	sendConfiguration(); | 
					
						
							| 
									
										
										
										
											2016-03-27 04:33:12 +02:00
										 |  |  | 	ui->specificParms->setCursorPosition(0); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	ui->sendButton->setEnabled(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRdaemonGui::sendConfiguration() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QString remoteAddress; | 
					
						
							|  |  |  | 	((SDRdaemonInput *) m_sampleSource)->getRemoteAddress(remoteAddress); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (remoteAddress != m_remoteAddress) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		m_remoteAddress = remoteAddress; | 
					
						
							| 
									
										
										
										
											2016-03-27 04:33:12 +02:00
										 |  |  | 		std::ostringstream os; | 
					
						
							|  |  |  | 		os << "tcp://" << m_remoteAddress.toStdString() << ":" << m_controlPort; | 
					
						
							|  |  |  | 		std::string addrstrng = os.str(); | 
					
						
							|  |  |  | 	    int rc = nn_connect(m_sender, addrstrng.c_str()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	    if (rc < 0) { | 
					
						
							|  |  |  | 	    	QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port")); | 
					
						
							|  |  |  | 	    } else { | 
					
						
							|  |  |  | 	    	qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " successful"; | 
					
						
							|  |  |  | 	    } | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	std::ostringstream os; | 
					
						
							|  |  |  | 	bool ok; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	os << "decim=" << ui->decim->currentIndex() | 
					
						
							|  |  |  | 	   << ",fcpos=" << ui->fcPos->currentIndex(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	uint64_t freq = ui->freq->text().toInt(&ok); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ok) { | 
					
						
							|  |  |  | 		os << ",freq=" << freq*1000LL; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		QMessageBox::information(this, tr("Message"), tr("Invalid frequency")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	uint32_t srate = ui->sampleRate->text().toInt(&ok); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (ok) { | 
					
						
							|  |  |  | 		os << ",srate=" << srate*1000; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		QMessageBox::information(this,  tr("Message"), tr("invalid sample rate")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if ((ui->specificParms->text()).size() > 0) { | 
					
						
							|  |  |  | 		os << "," << ui->specificParms->text().toStdString(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-27 04:33:12 +02:00
										 |  |  |     int config_size = os.str().size(); | 
					
						
							|  |  |  |     int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (rc != config_size) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     	QMessageBox::information(this, tr("Message"), tr("Cannot send message to remote control port")); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     	qDebug() << "SDRdaemonGui::sendConfiguration:" | 
					
						
							|  |  |  |     		<< " remoteAddress: " << remoteAddress | 
					
						
							|  |  |  |     		<< " message: " << os.str().c_str(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_address_textEdited(const QString& arg1 __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-02-25 01:37:47 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->applyButton->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	m_addressEdited = true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_dataPort_textEdited(const QString& arg1 __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->applyButton->setEnabled(true); | 
					
						
							|  |  |  | 	m_dataPortEdited = true; | 
					
						
							| 
									
										
										
										
											2016-02-25 01:37:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_controlPort_textEdited(const QString& arg1 __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-02-25 01:37:47 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->applyButton->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-17 23:47:03 +01:00
										 |  |  | void SDRdaemonGui::on_dcOffset_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (m_dcBlock != checked) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		m_dcBlock = checked; | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 		configureAutoCorrections(); | 
					
						
							| 
									
										
										
										
											2016-02-17 23:47:03 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRdaemonGui::on_iqImbalance_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (m_iqCorrection != checked) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		m_iqCorrection = checked; | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 		configureAutoCorrections(); | 
					
						
							| 
									
										
										
										
											2016-02-17 23:47:03 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | void SDRdaemonGui::on_autoFollowRate_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (m_autoFollowRate != checked) { | 
					
						
							|  |  |  | 		m_autoFollowRate = checked; | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  |         configureAutoFollowPolicy(); | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  | void SDRdaemonGui::on_autoCorrBuffer_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_autoCorrBuffer != checked) { | 
					
						
							|  |  |  |         m_autoCorrBuffer = checked; | 
					
						
							|  |  |  |         configureAutoFollowPolicy(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_resetIndexes_clicked(bool checked __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     SDRdaemonInput::MsgConfigureSDRdaemonResetIndexes* message = SDRdaemonInput::MsgConfigureSDRdaemonResetIndexes::create(); | 
					
						
							|  |  |  |     m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_freq_textEdited(const QString& arg1 __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->sendButton->setEnabled(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_sampleRate_textEdited(const QString& arg1 __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->sendButton->setEnabled(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_specificParms_textEdited(const QString& arg1 __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->sendButton->setEnabled(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_decim_currentIndexChanged(int index __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->sendButton->setEnabled(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void SDRdaemonGui::on_fcPos_currentIndexChanged(int index __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->sendButton->setEnabled(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | void SDRdaemonGui::on_startStop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (checked) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |         if (m_deviceAPI->initAcquisition()) | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |             m_deviceAPI->startAcquisition(); | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  |             DSPEngine::instance()->startAudioOutput(); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |         m_deviceAPI->stopAcquisition(); | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  |         DSPEngine::instance()->stopAudioOutput(); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  | void SDRdaemonGui::on_record_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (checked) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->record->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							|  |  |  |         m_fileSink->startRecording(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |         m_fileSink->stopRecording(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | void SDRdaemonGui::configureUDPLink() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-23 23:16:05 +01:00
										 |  |  | 	qDebug() << "SDRdaemonGui::configureUDPLink: " << m_address.toStdString().c_str() | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 			<< " : " << m_dataPort; | 
					
						
							| 
									
										
										
										
											2016-02-01 08:24:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	SDRdaemonInput::MsgConfigureSDRdaemonUDPLink* message = SDRdaemonInput::MsgConfigureSDRdaemonUDPLink::create(m_address, m_dataPort); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 	m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | void SDRdaemonGui::configureAutoCorrections() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SDRdaemonInput::MsgConfigureSDRdaemonAutoCorr* message = SDRdaemonInput::MsgConfigureSDRdaemonAutoCorr::create(m_dcBlock, m_iqCorrection); | 
					
						
							|  |  |  | 	m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  | void SDRdaemonGui::configureAutoFollowPolicy() | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-03-18 14:03:34 +01:00
										 |  |  |     SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowPolicy* message = SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowPolicy::create(m_autoFollowRate, m_autoCorrBuffer); | 
					
						
							| 
									
										
										
										
											2016-03-11 05:25:25 +01:00
										 |  |  | 	m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | void SDRdaemonGui::updateWithAcquisition() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SDRdaemonGui::updateWithStreamData() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-20 10:10:11 +01:00
										 |  |  | 	ui->centerFrequency->setValue(m_centerFrequency / 1000); | 
					
						
							| 
									
										
										
										
											2016-02-23 21:22:27 +01:00
										 |  |  | 	QString s0 = QString::number(m_sampleRateStream/1000.0, 'f', 2); | 
					
						
							| 
									
										
										
										
											2016-02-22 15:03:16 +01:00
										 |  |  | 	ui->sampleRateStreamText->setText(tr("%1").arg(s0)); | 
					
						
							|  |  |  | 	QString s1 = QString::number(m_sampleRate/1000.0, 'f', 3); | 
					
						
							|  |  |  | 	ui->sampleRateText->setText(tr("%1").arg(s1)); | 
					
						
							|  |  |  | 	float skewPerCent = (float) ((m_sampleRate - m_sampleRateStream) * 100) / (float) m_sampleRateStream; | 
					
						
							|  |  |  | 	QString s2 = QString::number(skewPerCent, 'f', 2); | 
					
						
							|  |  |  | 	ui->skewRateText->setText(tr("%1").arg(s2)); | 
					
						
							|  |  |  | 	updateWithStreamTime(); | 
					
						
							| 
									
										
										
										
											2016-03-27 04:33:12 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-27 04:33:12 +02:00
										 |  |  | void SDRdaemonGui::updateWithStreamTime() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-03-26 21:40:54 +01:00
										 |  |  | 	if (m_initSendConfiguration) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		sendConfiguration(); | 
					
						
							|  |  |  | 		m_initSendConfiguration = false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-11 03:30:13 +01:00
										 |  |  |     quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL); | 
					
						
							|  |  |  |     QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec); | 
					
						
							|  |  |  |     QString s_date = dt.toString("yyyy-MM-dd  hh:mm:ss.zzz"); | 
					
						
							| 
									
										
										
										
											2016-02-14 20:01:46 +01:00
										 |  |  | 	ui->absTimeText->setText(s_date); | 
					
						
							| 
									
										
										
										
											2016-02-23 14:57:40 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (m_syncLocked) { | 
					
						
							|  |  |  | 		ui->streamLocked->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		ui->streamLocked->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-23 18:09:20 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	QString s = QString::number(m_frameSize / 1024.0, 'f', 0); | 
					
						
							|  |  |  | 	ui->frameSizeText->setText(tr("%1").arg(s)); | 
					
						
							| 
									
										
										
										
											2016-02-23 18:19:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (m_lz4) { | 
					
						
							|  |  |  | 		ui->lz4Compressed->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		ui->lz4Compressed->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-23 18:29:08 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	s = QString::number(m_compressionRatio, 'f', 2); | 
					
						
							|  |  |  | 	ui->compressionRatioText->setText(tr("%1").arg(s)); | 
					
						
							| 
									
										
										
										
											2016-02-23 19:27:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	s = QString::number(m_nbLz4DataCRCOK, 'f', 0); | 
					
						
							|  |  |  | 	ui->dataCRCOKText->setText(tr("%1").arg(s)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	s = QString::number(m_nbLz4SuccessfulDecodes, 'f', 0); | 
					
						
							|  |  |  | 	ui->lz4DecodesOKText->setText(tr("%1").arg(s)); | 
					
						
							| 
									
										
										
										
											2016-03-17 15:41:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-20 14:40:40 +01:00
										 |  |  | 	s = QString::number(m_bufferLengthInSecs, 'f', 1); | 
					
						
							|  |  |  | 	ui->bufferLenSecsText->setText(tr("%1").arg(s)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-19 05:10:02 +01:00
										 |  |  | 	s = QString::number((m_bufferGauge < 0 ? -50 - m_bufferGauge : 50 - m_bufferGauge), 'f', 0); | 
					
						
							| 
									
										
										
										
											2016-03-19 04:09:55 +01:00
										 |  |  | 	ui->bufferRWBalanceText->setText(tr("%1").arg(s)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-17 15:41:48 +01:00
										 |  |  |     ui->bufferGaugeNegative->setValue((m_bufferGauge < 0 ? 50 + m_bufferGauge : 0)); | 
					
						
							|  |  |  |     ui->bufferGaugePositive->setValue((m_bufferGauge < 0 ? 0 : 50 - m_bufferGauge)); | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | void SDRdaemonGui::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |     int state = m_deviceAPI->state(); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if(m_lastEngineState != state) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch(state) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  |             case DSPDeviceSourceEngine::StNotStarted: | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  |             case DSPDeviceSourceEngine::StIdle: | 
					
						
							| 
									
										
										
										
											2016-05-12 10:31:57 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  |             case DSPDeviceSourceEngine::StRunning: | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  |             case DSPDeviceSourceEngine::StError: | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							| 
									
										
										
										
											2016-05-16 02:14:36 +02:00
										 |  |  |                 QMessageBox::information(this, tr("Message"), m_deviceAPI->errorMessage()); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_lastEngineState = state; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-24 19:21:21 +01:00
										 |  |  | void SDRdaemonGui::tick() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if ((++m_tickCount & 0xf) == 0) { | 
					
						
							|  |  |  | 		SDRdaemonInput::MsgConfigureSDRdaemonStreamTiming* message = SDRdaemonInput::MsgConfigureSDRdaemonStreamTiming::create(); | 
					
						
							|  |  |  | 		m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-18 01:24:58 +01:00
										 |  |  | 
 |