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