| 
									
										
										
										
											2015-08-03 01:04:20 +02: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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-09 10:33:04 +02:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | #include <QTime>
 | 
					
						
							|  |  |  | #include <QDateTime>
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							| 
									
										
										
										
											2015-08-05 01:43:30 +02:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | #include <QMessageBox>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | #include "ui_filesourcegui.h"
 | 
					
						
							|  |  |  | #include "plugin/pluginapi.h"
 | 
					
						
							|  |  |  | #include "gui/colormapper.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  | #include "gui/glspectrum.h"
 | 
					
						
							| 
									
										
										
										
											2018-12-26 11:06:37 +01:00
										 |  |  | #include "gui/crightclickenabler.h"
 | 
					
						
							|  |  |  | #include "gui/basicdevicesettingsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | #include "dsp/dspengine.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  | #include "dsp/dspcommands.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | #include "mainwindow.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "filesourcegui.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | #include <device/devicesourceapi.h>
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  | #include "device/deviceuiset.h"
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:45:23 +01:00
										 |  |  | FileSourceGui::FileSourceGui(DeviceUISet *deviceUISet, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	QWidget(parent), | 
					
						
							|  |  |  | 	ui(new Ui::FileSourceGui), | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  | 	m_deviceUISet(deviceUISet), | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	m_settings(), | 
					
						
							| 
									
										
										
										
											2018-01-09 23:54:27 +01:00
										 |  |  | 	m_doApplySettings(true), | 
					
						
							|  |  |  | 	m_sampleSource(0), | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	m_acquisition(false), | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 	m_fileName("..."), | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	m_sampleRate(0), | 
					
						
							|  |  |  | 	m_centerFrequency(0), | 
					
						
							| 
									
										
										
										
											2016-02-25 02:30:50 +01:00
										 |  |  | 	m_recordLength(0), | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	m_startingTimeStamp(0), | 
					
						
							| 
									
										
										
										
											2015-08-06 01:43:35 +02:00
										 |  |  | 	m_samplesCount(0), | 
					
						
							| 
									
										
										
										
											2016-02-25 14:07:39 +01:00
										 |  |  | 	m_tickCount(0), | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 	m_enableNavTime(false), | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  | 	m_lastEngineState(DSPDeviceSourceEngine::StNotStarted) | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	ui->setupUi(this); | 
					
						
							| 
									
										
										
										
											2017-05-16 09:07:58 +02:00
										 |  |  | 	ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	ui->centerFrequency->setValueRange(7, 0, pow(10,7)); | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 	ui->fileNameText->setText(m_fileName); | 
					
						
							| 
									
										
										
										
											2018-10-09 18:52:39 +02:00
										 |  |  | 	ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:45:23 +01:00
										 |  |  | 	connect(&(m_deviceUISet->m_deviceSourceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick())); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 	connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | 
					
						
							|  |  |  | 	m_statusTimer.start(500); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-26 11:06:37 +01:00
										 |  |  |     CRightClickEnabler *startStopRightClickEnabler = new CRightClickEnabler(ui->startStop); | 
					
						
							|  |  |  |     connect(startStopRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | 	setAccelerationCombo(); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:52:40 +02:00
										 |  |  | 	displaySettings(); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-25 11:02:39 +01:00
										 |  |  | 	ui->navTimeSlider->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | 	ui->acceleration->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:45:23 +01:00
										 |  |  |     m_sampleSource = m_deviceUISet->m_deviceSourceAPI->getSampleSource(); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |     connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2018-05-25 19:28:57 +02:00
										 |  |  |     m_sampleSource->setMessageQueueToGUI(&m_inputMessageQueue); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | FileSourceGui::~FileSourceGui() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	delete this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::setName(const QString& name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	setObjectName(name); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString FileSourceGui::getName() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return objectName(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	m_settings.resetToDefaults(); | 
					
						
							|  |  |  | 	displaySettings(); | 
					
						
							|  |  |  | 	sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | qint64 FileSourceGui::getCenterFrequency() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	return m_centerFrequency; | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 03:35:14 +02:00
										 |  |  | void FileSourceGui::setCenterFrequency(qint64 centerFrequency) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	m_centerFrequency = centerFrequency; | 
					
						
							|  |  |  | 	displaySettings(); | 
					
						
							|  |  |  | 	sendSettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | QByteArray FileSourceGui::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return m_settings.serialize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool FileSourceGui::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if(m_settings.deserialize(data)) { | 
					
						
							|  |  |  | 		displaySettings(); | 
					
						
							|  |  |  | 		sendSettings(); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		resetToDefaults(); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  | void FileSourceGui::handleInputMessages() | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |     while ((message = m_inputMessageQueue.pop()) != 0) | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (DSPSignalNotification::match(*message)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             DSPSignalNotification* notif = (DSPSignalNotification*) message; | 
					
						
							|  |  |  |             m_deviceSampleRate = notif->getSampleRate(); | 
					
						
							|  |  |  |             m_deviceCenterFrequency = notif->getCenterFrequency(); | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |             qDebug("FileSourceGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  |             updateSampleRateAndFrequency(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (handleMessage(*message)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 delete message; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | bool FileSourceGui::handleMessage(const Message& message) | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-28 03:21:48 +01:00
										 |  |  |     if (FileSourceInput::MsgConfigureFileSource::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const FileSourceInput::MsgConfigureFileSource& cfg = (FileSourceInput::MsgConfigureFileSource&) message; | 
					
						
							|  |  |  |         m_settings = cfg.getSettings(); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (FileSourceInput::MsgReportFileSourceAcquisition::match(message)) | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 		m_acquisition = ((FileSourceInput::MsgReportFileSourceAcquisition&)message).getAcquisition(); | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 		updateWithAcquisition(); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-26 09:25:02 +02:00
										 |  |  | 	else if (FileSourceInput::MsgReportFileSourceStreamData::match(message)) | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 		m_sampleRate = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getSampleRate(); | 
					
						
							| 
									
										
										
										
											2018-01-25 23:52:36 +01:00
										 |  |  | 		m_sampleSize = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getSampleSize(); | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 		m_centerFrequency = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getCenterFrequency(); | 
					
						
							|  |  |  | 		m_startingTimeStamp = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getStartingTimeStamp(); | 
					
						
							| 
									
										
										
										
											2016-02-25 02:30:50 +01:00
										 |  |  | 		m_recordLength = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getRecordLength(); | 
					
						
							| 
									
										
										
										
											2015-08-06 01:43:35 +02:00
										 |  |  | 		updateWithStreamData(); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-26 09:25:02 +02:00
										 |  |  | 	else if (FileSourceInput::MsgReportFileSourceStreamTiming::match(message)) | 
					
						
							| 
									
										
										
										
											2015-08-06 01:14:44 +02:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 		m_samplesCount = ((FileSourceInput::MsgReportFileSourceStreamTiming&)message).getSamplesCount(); | 
					
						
							| 
									
										
										
										
											2015-08-06 01:14:44 +02:00
										 |  |  | 		updateWithStreamTime(); | 
					
						
							| 
									
										
										
										
											2015-08-06 01:43:35 +02:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2015-08-06 01:14:44 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  | 	else if (FileSourceInput::MsgStartStop::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  | 	    FileSourceInput::MsgStartStop& notif = (FileSourceInput::MsgStartStop&) message; | 
					
						
							|  |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         ui->startStop->setChecked(notif.getStartStop()); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-14 01:52:40 +02:00
										 |  |  | 	else if (FileSourceInput::MsgPlayPause::match(message)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 	    FileSourceInput::MsgPlayPause& notif = (FileSourceInput::MsgPlayPause&) message; | 
					
						
							|  |  |  | 	    bool checked = notif.getPlayPause(); | 
					
						
							|  |  |  | 	    ui->play->setChecked(checked); | 
					
						
							|  |  |  | 	    ui->navTimeSlider->setEnabled(!checked); | 
					
						
							|  |  |  | 	    ui->acceleration->setEnabled(!checked); | 
					
						
							|  |  |  | 	    m_enableNavTime = !checked; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	    return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-09 18:52:39 +02:00
										 |  |  | 	else if (FileSourceInput::MsgReportHeaderCRC::match(message)) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		FileSourceInput::MsgReportHeaderCRC& notif = (FileSourceInput::MsgReportHeaderCRC&) message; | 
					
						
							|  |  |  | 		if (notif.isOK()) { | 
					
						
							|  |  |  | 			ui->crcLabel->setStyleSheet("QLabel { background-color : green; }"); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			ui->crcLabel->setStyleSheet("QLabel { background-color : red; }"); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  | void FileSourceGui::updateSampleRateAndFrequency() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  |     m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRate); | 
					
						
							|  |  |  |     m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:48:08 +02:00
										 |  |  |     ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000)); | 
					
						
							| 
									
										
										
										
											2016-05-12 12:29:12 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | void FileSourceGui::displaySettings() | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  |     blockApplySettings(true); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:52:40 +02:00
										 |  |  |     ui->playLoop->setChecked(m_settings.m_loop); | 
					
						
							|  |  |  |     ui->acceleration->setCurrentIndex(FileSourceSettings::getAccelerationIndex(m_settings.m_accelerationFactor)); | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  |     blockApplySettings(false); | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::sendSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-14 01:52:40 +02:00
										 |  |  | void FileSourceGui::on_playLoop_toggled(bool checked) | 
					
						
							| 
									
										
										
										
											2016-02-25 11:06:23 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_loop = checked; | 
					
						
							| 
									
										
										
										
											2018-10-14 10:38:31 +02:00
										 |  |  |         FileSourceInput::MsgConfigureFileSource *message = FileSourceInput::MsgConfigureFileSource::create(m_settings, false); | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  |         m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-02-25 11:06:23 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | void FileSourceGui::on_startStop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-14 18:02:49 +01:00
										 |  |  |         FileSourceInput::MsgStartStop *message = FileSourceInput::MsgStartStop::create(checked); | 
					
						
							|  |  |  |         m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-30 00:45:23 +01:00
										 |  |  |     int state = m_deviceUISet->m_deviceSourceAPI->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; }"); | 
					
						
							| 
									
										
										
										
											2017-10-30 00:45:23 +01:00
										 |  |  |                 QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceSourceAPI->errorMessage()); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_lastEngineState = state; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | void FileSourceGui::on_play_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-08-06 01:14:44 +02:00
										 |  |  | 	FileSourceInput::MsgConfigureFileSourceWork* message = FileSourceInput::MsgConfigureFileSourceWork::create(checked); | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2016-02-25 14:07:39 +01:00
										 |  |  | 	ui->navTimeSlider->setEnabled(!checked); | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | 	ui->acceleration->setEnabled(!checked); | 
					
						
							| 
									
										
										
										
											2016-02-25 14:07:39 +01:00
										 |  |  | 	m_enableNavTime = !checked; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::on_navTimeSlider_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-14 02:38:24 +02:00
										 |  |  | 	if (m_enableNavTime && ((value >= 0) && (value <= 1000))) | 
					
						
							| 
									
										
										
										
											2016-02-25 14:07:39 +01:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		FileSourceInput::MsgConfigureFileSourceSeek* message = FileSourceInput::MsgConfigureFileSourceSeek::create(value); | 
					
						
							|  |  |  | 		m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  | void FileSourceGui::on_showFileDialog_clicked(bool checked) | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-13 08:51:14 +01:00
										 |  |  |     (void) checked; | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 	QString fileName = QFileDialog::getOpenFileName(this, | 
					
						
							| 
									
										
										
										
											2018-05-11 00:00:15 +02:00
										 |  |  | 	    tr("Open I/Q record file"), ".", tr("SDR I/Q Files (*.sdriq)"), 0, QFileDialog::DontUseNativeDialog); | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (fileName != "") | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 		m_fileName = fileName; | 
					
						
							|  |  |  | 		ui->fileNameText->setText(m_fileName); | 
					
						
							| 
									
										
										
										
											2018-10-09 18:52:39 +02:00
										 |  |  | 		ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 		configureFileName(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | void FileSourceGui::on_acceleration_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_accelerationFactor = FileSourceSettings::getAccelerationValue(index); | 
					
						
							| 
									
										
										
										
											2018-10-14 10:38:31 +02:00
										 |  |  |         FileSourceInput::MsgConfigureFileSource *message = FileSourceInput::MsgConfigureFileSource::create(m_settings, false); | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  |         m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | void FileSourceGui::configureFileName() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-08-09 11:11:28 +02:00
										 |  |  | 	qDebug() << "FileSourceGui::configureFileName: " << m_fileName.toStdString().c_str(); | 
					
						
							| 
									
										
										
										
											2015-08-06 00:10:46 +02:00
										 |  |  | 	FileSourceInput::MsgConfigureFileSourceName* message = FileSourceInput::MsgConfigureFileSourceName::create(m_fileName); | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::updateWithAcquisition() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ui->play->setEnabled(m_acquisition); | 
					
						
							|  |  |  | 	ui->play->setChecked(m_acquisition); | 
					
						
							|  |  |  | 	ui->showFileDialog->setEnabled(!m_acquisition); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::updateWithStreamData() | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	ui->centerFrequency->setValue(m_centerFrequency/1000); | 
					
						
							| 
									
										
										
										
											2016-10-07 18:16:17 +02:00
										 |  |  | 	ui->sampleRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000)); | 
					
						
							| 
									
										
										
										
											2018-01-25 23:52:36 +01:00
										 |  |  | 	ui->sampleSizeText->setText(tr("%1b").arg(m_sampleSize)); | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	ui->play->setEnabled(m_acquisition); | 
					
						
							| 
									
										
										
										
											2016-02-25 02:30:50 +01:00
										 |  |  | 	QTime recordLength(0, 0, 0, 0); | 
					
						
							|  |  |  | 	recordLength = recordLength.addSecs(m_recordLength); | 
					
						
							| 
									
										
										
										
											2018-05-11 11:00:08 +02:00
										 |  |  | 	QString s_time = recordLength.toString("HH:mm:ss"); | 
					
						
							| 
									
										
										
										
											2016-02-25 02:30:50 +01:00
										 |  |  | 	ui->recordLengthText->setText(s_time); | 
					
						
							| 
									
										
										
										
											2018-10-14 10:38:31 +02:00
										 |  |  | 	updateWithStreamTime(); | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | void FileSourceGui::updateWithStreamTime() | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-12 17:05:03 +02:00
										 |  |  |     qint64 t_sec = 0; | 
					
						
							|  |  |  |     qint64 t_msec = 0; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (m_sampleRate > 0){ | 
					
						
							|  |  |  | 		t_sec = m_samplesCount / m_sampleRate; | 
					
						
							| 
									
										
										
										
											2018-10-12 17:05:03 +02:00
										 |  |  |         t_msec = (m_samplesCount - (t_sec * m_sampleRate)) * 1000LL / m_sampleRate; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	QTime t(0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2015-08-06 01:14:44 +02:00
										 |  |  | 	t = t.addSecs(t_sec); | 
					
						
							|  |  |  | 	t = t.addMSecs(t_msec); | 
					
						
							| 
									
										
										
										
											2018-05-11 11:00:08 +02:00
										 |  |  | 	QString s_timems = t.toString("HH:mm:ss.zzz"); | 
					
						
							| 
									
										
										
										
											2016-02-25 11:02:39 +01:00
										 |  |  | 	ui->relTimeText->setText(s_timems); | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-12 17:05:03 +02:00
										 |  |  |     qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec); | 
					
						
							| 
									
										
										
										
											2018-10-12 17:05:03 +02:00
										 |  |  |     dt = dt.addSecs(t_sec); | 
					
						
							|  |  |  |     dt = dt.addMSecs(t_msec); | 
					
						
							| 
									
										
										
										
											2018-05-11 11:00:08 +02:00
										 |  |  | 	QString s_date = dt.toString("yyyy-MM-dd HH:mm:ss.zzz"); | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	ui->absTimeText->setText(s_date); | 
					
						
							| 
									
										
										
										
											2016-02-25 14:07:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (!m_enableNavTime) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		float posRatio = (float) t_sec / (float) m_recordLength; | 
					
						
							| 
									
										
										
										
											2018-10-14 02:38:24 +02:00
										 |  |  | 		ui->navTimeSlider->setValue((int) (posRatio * 1000.0)); | 
					
						
							| 
									
										
										
										
											2016-02-25 14:07:39 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-08-06 01:43:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::tick() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if ((++m_tickCount & 0xf) == 0) { | 
					
						
							|  |  |  | 		FileSourceInput::MsgConfigureFileSourceStreamTiming* message = FileSourceInput::MsgConfigureFileSourceStreamTiming::create(); | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 		m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							| 
									
										
										
										
											2015-08-06 01:43:35 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::setAccelerationCombo() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->acceleration->blockSignals(true); | 
					
						
							|  |  |  |     ui->acceleration->clear(); | 
					
						
							|  |  |  |     ui->acceleration->addItem(QString("1")); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-14 02:25:10 +02:00
										 |  |  |     for (unsigned int i = 0; i <= FileSourceSettings::m_accelerationMaxScale; i++) | 
					
						
							| 
									
										
										
										
											2018-10-14 01:16:39 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         QString s; | 
					
						
							|  |  |  |         int m = pow(10.0, i); | 
					
						
							|  |  |  |         int x = 2*m; | 
					
						
							|  |  |  |         setNumberStr(x, s); | 
					
						
							|  |  |  |         ui->acceleration->addItem(s); | 
					
						
							|  |  |  |         x = 5*m; | 
					
						
							|  |  |  |         setNumberStr(x, s); | 
					
						
							|  |  |  |         ui->acceleration->addItem(s); | 
					
						
							|  |  |  |         x = 10*m; | 
					
						
							|  |  |  |         setNumberStr(x, s); | 
					
						
							|  |  |  |         ui->acceleration->addItem(s); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->acceleration->blockSignals(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::setNumberStr(int n, QString& s) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (n < 1000) { | 
					
						
							|  |  |  |         s = tr("%1").arg(n); | 
					
						
							|  |  |  |     } else if (n < 100000) { | 
					
						
							|  |  |  |         s = tr("%1k").arg(n/1000); | 
					
						
							|  |  |  |     } else if (n < 1000000) { | 
					
						
							|  |  |  |         s = tr("%1e5").arg(n/100000); | 
					
						
							|  |  |  |     } else if (n < 1000000000) { | 
					
						
							|  |  |  |         s = tr("%1M").arg(n/1000000); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         s = tr("%1G").arg(n/1000000000); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-26 11:06:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::openDeviceSettingsDialog(const QPoint& p) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     BasicDeviceSettingsDialog dialog(this); | 
					
						
							|  |  |  |     dialog.setUseReverseAPI(m_settings.m_useReverseAPI); | 
					
						
							|  |  |  |     dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress); | 
					
						
							|  |  |  |     dialog.setReverseAPIPort(m_settings.m_reverseAPIPort); | 
					
						
							|  |  |  |     dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     dialog.move(p); | 
					
						
							|  |  |  |     dialog.exec(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_settings.m_useReverseAPI = dialog.useReverseAPI(); | 
					
						
							|  |  |  |     m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); | 
					
						
							|  |  |  |     m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); | 
					
						
							|  |  |  |     m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     sendSettings(); | 
					
						
							|  |  |  | } |