| 
									
										
										
										
											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"
 | 
					
						
							| 
									
										
										
										
											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>
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | FileSourceGui::FileSourceGui(DeviceSourceAPI *deviceAPI, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	QWidget(parent), | 
					
						
							|  |  |  | 	ui(new Ui::FileSourceGui), | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:37 +02:00
										 |  |  | 	m_deviceAPI(deviceAPI), | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	m_settings(), | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	m_sampleSource(NULL), | 
					
						
							|  |  |  | 	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), | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 	m_lastEngineState((DSPDeviceSourceEngine::State)-1) | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-17 19:26:23 +02:00
										 |  |  | 	connect(&(m_deviceAPI->getMainWindow()->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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 	displaySettings(); | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-25 11:02:39 +01:00
										 |  |  | 	ui->navTimeSlider->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2016-02-25 11:06:23 +01:00
										 |  |  | 	ui->playLoop->setChecked(true); // FIXME: always play in a loop
 | 
					
						
							|  |  |  | 	ui->playLoop->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2015-08-03 01:04:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-16 10:45:08 +02:00
										 |  |  |     m_sampleSource = m_deviceAPI->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); | 
					
						
							| 
									
										
										
										
											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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  |         qDebug("FileSourceGui::handleInputMessages: message: %s", message->getIdentifier()); | 
					
						
							| 
									
										
										
										
											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
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-08-26 09:25:02 +02:00
										 |  |  | 	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(); | 
					
						
							|  |  |  | 		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
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											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() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											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-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
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::sendSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void FileSourceGui::on_playLoop_toggled(bool checked __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2016-02-25 11:06:23 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	// TODO: do something about it!
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-11 23:35:16 +02:00
										 |  |  | void FileSourceGui::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
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::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; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 	m_enableNavTime = !checked; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void FileSourceGui::on_navTimeSlider_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (m_enableNavTime && ((value >= 0) && (value <= 100))) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		int t_sec = (m_recordLength * value) / 100; | 
					
						
							|  |  |  | 		QTime t(0, 0, 0, 0); | 
					
						
							|  |  |  | 		t = t.addSecs(t_sec); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		FileSourceInput::MsgConfigureFileSourceSeek* message = FileSourceInput::MsgConfigureFileSourceSeek::create(value); | 
					
						
							|  |  |  | 		m_sampleSource->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  | void FileSourceGui::on_showFileDialog_clicked(bool checked __attribute__((unused))) | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	QString fileName = QFileDialog::getOpenFileName(this, | 
					
						
							|  |  |  | 	    tr("Open I/Q record file"), ".", tr("SDR I/Q Files (*.sdriq)")); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 		configureFileName(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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)); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 	QString s_time = recordLength.toString("hh:mm:ss"); | 
					
						
							|  |  |  | 	ui->recordLengthText->setText(s_time); | 
					
						
							| 
									
										
										
										
											2015-08-05 03:25:06 +02:00
										 |  |  | 	updateWithStreamTime(); // TODO: remove when time data is implemented
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | { | 
					
						
							|  |  |  | 	int t_sec = 0; | 
					
						
							|  |  |  | 	int t_msec = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (m_sampleRate > 0){ | 
					
						
							|  |  |  | 		t_msec = ((m_samplesCount * 1000) / m_sampleRate) % 1000; | 
					
						
							|  |  |  | 		t_sec = m_samplesCount / m_sampleRate; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	QTime t(0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2015-08-06 01:14:44 +02:00
										 |  |  | 	t = t.addSecs(t_sec); | 
					
						
							|  |  |  | 	t = t.addMSecs(t_msec); | 
					
						
							| 
									
										
										
										
											2016-02-25 11:02:39 +01:00
										 |  |  | 	QString s_timems = t.toString("hh:mm:ss.zzz"); | 
					
						
							|  |  |  | 	QString s_time = t.toString("hh:mm:ss"); | 
					
						
							|  |  |  | 	ui->relTimeText->setText(s_timems); | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-11 03:30:13 +01:00
										 |  |  |     quint64 startingTimeStampMsec = (quint64) m_startingTimeStamp * 1000LL; | 
					
						
							| 
									
										
										
										
											2015-08-04 04:17:24 +02:00
										 |  |  | 	QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec); | 
					
						
							| 
									
										
										
										
											2016-03-11 03:30:13 +01:00
										 |  |  |     dt = dt.addSecs((quint64) t_sec); | 
					
						
							|  |  |  |     dt = dt.addMSecs((quint64) t_msec); | 
					
						
							| 
									
										
										
										
											2016-02-25 01:44:48 +01: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; | 
					
						
							|  |  |  | 		ui->navTimeSlider->setValue((int) (posRatio * 100.0)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 	} | 
					
						
							|  |  |  | } |