2017-03-05 21:39:34 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDebug>
|
2017-03-11 21:51:22 -05:00
|
|
|
#include <QMessageBox>
|
2017-03-05 21:39:34 -05:00
|
|
|
|
2017-03-19 23:31:57 -04:00
|
|
|
#include <cmath>
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
#include "device/devicesinkapi.h"
|
|
|
|
#include "dsp/upchannelizer.h"
|
|
|
|
|
|
|
|
#include "dsp/threadedbasebandsamplesource.h"
|
|
|
|
#include "ui_atvmodgui.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
#include "gui/basicchannelsettingswidget.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "atvmodgui.h"
|
|
|
|
|
|
|
|
const QString ATVModGUI::m_channelID = "sdrangel.channeltx.modatv";
|
|
|
|
|
|
|
|
ATVModGUI* ATVModGUI::create(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI)
|
|
|
|
{
|
|
|
|
ATVModGUI* gui = new ATVModGUI(pluginAPI, deviceAPI);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::destroy()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ATVModGUI::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 ATVModGUI::getCenterFrequency() const {
|
|
|
|
return m_channelMarker.getCenterFrequency();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(centerFrequency);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
2017-03-09 13:07:45 -05:00
|
|
|
ui->rfBW->setValue(10);
|
2017-03-05 21:39:34 -05:00
|
|
|
ui->uniformLevel->setValue(35);
|
|
|
|
ui->standard->setCurrentIndex(0);
|
2017-03-20 23:29:28 -04:00
|
|
|
ui->nbLines->setCurrentIndex(0);
|
|
|
|
ui->fps->setCurrentIndex(1);
|
2017-03-05 21:39:34 -05:00
|
|
|
ui->inputSelect->setCurrentIndex(0);
|
|
|
|
ui->deltaFrequency->setValue(0);
|
2017-03-07 13:19:54 -05:00
|
|
|
ui->modulation->setCurrentIndex(0);
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray ATVModGUI::serialize() const
|
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
|
|
|
|
s.writeS32(1, m_channelMarker.getCenterFrequency());
|
|
|
|
s.writeS32(2, ui->rfBW->value());
|
|
|
|
s.writeS32(3, ui->uniformLevel->value());
|
|
|
|
s.writeS32(4, ui->standard->currentIndex());
|
|
|
|
s.writeS32(5, ui->inputSelect->currentIndex());
|
|
|
|
s.writeU32(6, m_channelMarker.getColor().rgb());
|
2017-03-16 05:44:31 -04:00
|
|
|
s.writeS32(7, ui->rfOppBW->value());
|
2017-03-07 13:19:54 -05:00
|
|
|
s.writeS32(8, ui->modulation->currentIndex());
|
2017-03-19 05:49:02 -04:00
|
|
|
s.writeBool(9, ui->invertVideo->isChecked());
|
2017-03-20 23:29:28 -04:00
|
|
|
s.writeS32(10, ui->nbLines->currentIndex());
|
|
|
|
s.writeS32(11, ui->fps->currentIndex());
|
2017-03-21 16:59:44 -04:00
|
|
|
s.writeS32(12, ui->rfScaling->value());
|
2017-03-21 18:29:42 -04:00
|
|
|
s.writeS32(13, ui->fmExcursion->value());
|
2017-04-09 11:57:30 -04:00
|
|
|
s.writeString(14, ui->overlayText->text());
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ATVModGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if(!d.isValid())
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(d.getVersion() == 1)
|
|
|
|
{
|
|
|
|
QByteArray bytetmp;
|
|
|
|
quint32 u32tmp;
|
|
|
|
qint32 tmp;
|
2017-03-19 05:49:02 -04:00
|
|
|
bool booltmp;
|
2017-04-09 11:57:30 -04:00
|
|
|
QString tmpString;
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
|
|
|
|
d.readS32(1, &tmp, 0);
|
|
|
|
m_channelMarker.setCenterFrequency(tmp);
|
|
|
|
d.readS32(2, &tmp, 4);
|
|
|
|
ui->rfBW->setValue(tmp);
|
|
|
|
d.readS32(3, &tmp, 100);
|
|
|
|
ui->uniformLevel->setValue(tmp);
|
|
|
|
d.readS32(4, &tmp, 0);
|
|
|
|
ui->standard->setCurrentIndex(tmp);
|
|
|
|
d.readS32(5, &tmp, 0);
|
|
|
|
ui->inputSelect->setCurrentIndex(tmp);
|
|
|
|
|
|
|
|
if(d.readU32(6, &u32tmp))
|
|
|
|
{
|
|
|
|
m_channelMarker.setColor(u32tmp);
|
|
|
|
}
|
|
|
|
|
2017-03-15 22:23:58 -04:00
|
|
|
d.readS32(7, &tmp, 10);
|
2017-03-16 05:44:31 -04:00
|
|
|
ui->rfOppBW->setValue(tmp);
|
2017-03-07 13:19:54 -05:00
|
|
|
d.readS32(8, &tmp, 0);
|
|
|
|
ui->modulation->setCurrentIndex(tmp);
|
2017-03-19 05:49:02 -04:00
|
|
|
d.readBool(9, &booltmp, false);
|
|
|
|
ui->invertVideo->setChecked(booltmp);
|
2017-03-20 23:29:28 -04:00
|
|
|
d.readS32(10, &tmp, 0);
|
|
|
|
ui->nbLines->setCurrentIndex(tmp);
|
|
|
|
d.readS32(11, &tmp, 0);
|
|
|
|
ui->fps->setCurrentIndex(tmp);
|
2017-03-21 16:59:44 -04:00
|
|
|
d.readS32(12, &tmp, 80);
|
|
|
|
ui->rfScaling->setValue(tmp);
|
2017-04-09 01:27:32 -04:00
|
|
|
d.readS32(13, &tmp, 250);
|
2017-03-21 18:29:42 -04:00
|
|
|
ui->fmExcursion->setValue(tmp);
|
2017-04-09 11:57:30 -04:00
|
|
|
d.readString(14, &tmpString, "");
|
|
|
|
ui->overlayText->setText(tmpString);
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
|
2017-04-09 11:57:30 -04:00
|
|
|
ATVMod::MsgConfigureOverlayText* message = ATVMod::MsgConfigureOverlayText::create(ui->overlayText->text());
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
applySettings();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ATVModGUI::handleMessage(const Message& message)
|
|
|
|
{
|
2017-03-09 17:17:14 -05:00
|
|
|
if (ATVMod::MsgReportVideoFileSourceStreamData::match(message))
|
|
|
|
{
|
|
|
|
m_videoFrameRate = ((ATVMod::MsgReportVideoFileSourceStreamData&)message).getFrameRate();
|
|
|
|
m_videoLength = ((ATVMod::MsgReportVideoFileSourceStreamData&)message).getVideoLength();
|
|
|
|
m_frameCount = 0;
|
|
|
|
updateWithStreamData();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (ATVMod::MsgReportVideoFileSourceStreamTiming::match(message))
|
|
|
|
{
|
|
|
|
m_frameCount = ((ATVMod::MsgReportVideoFileSourceStreamTiming&)message).getFrameCount();
|
|
|
|
updateWithStreamTime();
|
|
|
|
return true;
|
|
|
|
}
|
2017-03-10 13:06:51 -05:00
|
|
|
else if (ATVMod::MsgReportCameraData::match(message))
|
|
|
|
{
|
2017-03-11 00:57:22 -05:00
|
|
|
ATVMod::MsgReportCameraData& rpt = (ATVMod::MsgReportCameraData&) message;
|
|
|
|
ui->cameraDeviceNumber->setText(tr("#%1").arg(rpt.getdeviceNumber()));
|
|
|
|
ui->camerFPS->setText(tr("%1 FPS").arg(rpt.getFPS(), 0, 'f', 2));
|
|
|
|
ui->cameraImageSize->setText(tr("%1x%2").arg(rpt.getWidth()).arg(rpt.getHeight()));
|
2017-03-24 14:06:29 -04:00
|
|
|
ui->cameraManualFPSText->setText(tr("%1 FPS").arg(rpt.getFPSManual(), 0, 'f', 1));
|
|
|
|
ui->cameraManualFPSEnable->setChecked(rpt.getFPSManualEnable());
|
|
|
|
ui->cameraManualFPS->setValue((int) rpt.getFPSManual()*10.0f);
|
2017-03-11 21:51:22 -05:00
|
|
|
|
|
|
|
int status = rpt.getStatus();
|
|
|
|
|
|
|
|
if (status == 1) // camera FPS scan is startng
|
|
|
|
{
|
|
|
|
m_camBusyFPSMessageBox = new QMessageBox();
|
|
|
|
m_camBusyFPSMessageBox->setText("Computing camera FPS. Please wait…");
|
|
|
|
m_camBusyFPSMessageBox->setStandardButtons(0);
|
|
|
|
m_camBusyFPSMessageBox->show();
|
|
|
|
}
|
|
|
|
else if (status == 2) // camera FPS scan is finished
|
|
|
|
{
|
|
|
|
m_camBusyFPSMessageBox->close();
|
|
|
|
if (m_camBusyFPSMessageBox) delete m_camBusyFPSMessageBox;
|
|
|
|
m_camBusyFPSMessageBox = 0;
|
|
|
|
}
|
|
|
|
|
2017-03-10 13:06:51 -05:00
|
|
|
return true;
|
|
|
|
}
|
2017-03-19 22:35:27 -04:00
|
|
|
else if (ATVMod::MsgReportEffectiveSampleRate::match(message))
|
|
|
|
{
|
|
|
|
int sampleRate = ((ATVMod::MsgReportEffectiveSampleRate&)message).getSampleRate();
|
2017-03-22 06:48:39 -04:00
|
|
|
uint32_t nbPointsPerLine = ((ATVMod::MsgReportEffectiveSampleRate&)message).gatNbPointsPerLine();
|
2017-04-09 00:48:29 -04:00
|
|
|
ui->channelSampleRateText->setText(tr("%1k").arg(sampleRate/1000.0f, 0, 'f', 2));
|
2017-03-22 06:48:39 -04:00
|
|
|
ui->nbPointsPerLineText->setText(tr("%1p").arg(nbPointsPerLine));
|
2017-03-21 07:16:43 -04:00
|
|
|
setRFFiltersSlidersRange(sampleRate);
|
2017-03-19 22:35:27 -04:00
|
|
|
return true;
|
|
|
|
}
|
2017-03-09 17:17:14 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::viewChanged()
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-11 19:26:12 -05:00
|
|
|
void ATVModGUI::channelizerOutputSampleRateChanged()
|
2017-03-19 22:35:27 -04:00
|
|
|
{
|
2017-03-21 07:16:43 -04:00
|
|
|
//setRFFiltersSlidersRange(m_channelizer->getOutputSampleRate());
|
2017-03-19 22:35:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::setRFFiltersSlidersRange(int sampleRate)
|
2017-03-11 19:26:12 -05:00
|
|
|
{
|
2017-03-21 07:35:27 -04:00
|
|
|
int scaleFactor = (int) std::log10(sampleRate/2);
|
2017-03-19 23:31:57 -04:00
|
|
|
m_rfSliderDivisor = std::pow(10.0, scaleFactor-1);
|
|
|
|
|
2017-03-21 09:42:42 -04:00
|
|
|
if (sampleRate/m_rfSliderDivisor < 50) {
|
|
|
|
m_rfSliderDivisor /= 10;
|
|
|
|
}
|
|
|
|
|
2017-03-15 00:05:42 -04:00
|
|
|
if ((ui->modulation->currentIndex() == (int) ATVMod::ATVModulationLSB) ||
|
2017-03-15 21:45:51 -04:00
|
|
|
(ui->modulation->currentIndex() == (int) ATVMod::ATVModulationUSB) ||
|
|
|
|
(ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialLSB) ||
|
|
|
|
(ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialUSB))
|
2017-03-15 00:05:42 -04:00
|
|
|
{
|
2017-03-21 07:35:27 -04:00
|
|
|
ui->rfBW->setMaximum((sampleRate) / (2*m_rfSliderDivisor));
|
|
|
|
ui->rfOppBW->setMaximum((sampleRate) / (2*m_rfSliderDivisor));
|
2017-03-15 00:05:42 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-21 07:35:27 -04:00
|
|
|
ui->rfBW->setMaximum((sampleRate) / m_rfSliderDivisor);
|
|
|
|
ui->rfOppBW->setMaximum((sampleRate) / m_rfSliderDivisor);
|
2017-03-15 00:05:42 -04:00
|
|
|
}
|
2017-03-21 11:38:56 -04:00
|
|
|
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg((ui->rfBW->value()*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
|
|
|
ui->rfOppBWText->setText(QString("%1k").arg((ui->rfOppBW->value()*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
2017-03-11 19:26:12 -05:00
|
|
|
}
|
|
|
|
|
2017-03-20 22:56:01 -04:00
|
|
|
int ATVModGUI::getNbLines()
|
|
|
|
{
|
|
|
|
switch(ui->nbLines->currentIndex())
|
|
|
|
{
|
2017-04-08 00:54:24 -04:00
|
|
|
case 0:
|
|
|
|
return 640;
|
2017-03-20 22:56:01 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 525;
|
2017-03-20 22:56:01 -04:00
|
|
|
break;
|
2017-04-03 11:23:20 -04:00
|
|
|
case 3:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 480;
|
2017-04-03 11:23:20 -04:00
|
|
|
break;
|
|
|
|
case 4:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 405;
|
2017-04-03 11:23:20 -04:00
|
|
|
break;
|
|
|
|
case 5:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 360;
|
2017-04-03 11:23:20 -04:00
|
|
|
break;
|
|
|
|
case 6:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 343;
|
2017-04-03 11:23:20 -04:00
|
|
|
break;
|
2017-04-03 12:37:26 -04:00
|
|
|
case 7:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 240;
|
2017-04-03 12:37:26 -04:00
|
|
|
break;
|
|
|
|
case 8:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 180;
|
2017-04-06 02:28:30 -04:00
|
|
|
break;
|
|
|
|
case 9:
|
2017-04-08 00:54:24 -04:00
|
|
|
return 120;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
return 90;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
return 60;
|
|
|
|
break;
|
|
|
|
case 12:
|
2017-04-03 12:37:26 -04:00
|
|
|
return 32;
|
|
|
|
break;
|
2017-04-08 00:54:24 -04:00
|
|
|
case 1:
|
2017-03-20 22:56:01 -04:00
|
|
|
default:
|
|
|
|
return 625;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int ATVModGUI::getFPS()
|
|
|
|
{
|
|
|
|
switch(ui->fps->currentIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return 30;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return 20;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return 16;
|
|
|
|
break;
|
2017-04-03 11:23:20 -04:00
|
|
|
case 4:
|
|
|
|
return 12;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return 10;
|
|
|
|
break;
|
2017-04-04 23:01:01 -04:00
|
|
|
case 6:
|
|
|
|
return 8;
|
|
|
|
break;
|
2017-04-08 00:54:24 -04:00
|
|
|
case 7:
|
|
|
|
return 5;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
return 2;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
return 1;
|
|
|
|
break;
|
2017-03-20 22:56:01 -04:00
|
|
|
case 1:
|
|
|
|
default:
|
|
|
|
return 25;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
void ATVModGUI::handleSourceMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = m_atvMod->getOutputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:16:07 -04:00
|
|
|
void ATVModGUI::on_deltaFrequency_changed(qint64 value)
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
2017-05-17 18:16:07 -04:00
|
|
|
m_channelMarker.setCenterFrequency(value);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_modulation_currentIndexChanged(int index __attribute__((unused)))
|
2017-03-07 13:19:54 -05:00
|
|
|
{
|
2017-03-21 07:16:43 -04:00
|
|
|
setRFFiltersSlidersRange(m_atvMod->getEffectiveSampleRate());
|
|
|
|
setChannelMarkerBandwidth();
|
2017-03-07 13:19:54 -05:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-21 16:59:44 -04:00
|
|
|
void ATVModGUI::on_rfScaling_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->rfScalingText->setText(tr("%1").arg(value));
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-21 18:29:42 -04:00
|
|
|
void ATVModGUI::on_fmExcursion_valueChanged(int value)
|
|
|
|
{
|
2017-04-09 01:27:32 -04:00
|
|
|
ui->fmExcursionText->setText(tr("%1").arg(value / 10.0, 0, 'f', 1));
|
2017-03-21 18:29:42 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
void ATVModGUI::on_rfBW_valueChanged(int value)
|
|
|
|
{
|
2017-03-19 23:31:57 -04:00
|
|
|
ui->rfBWText->setText(QString("%1k").arg((value*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
2017-03-21 07:16:43 -04:00
|
|
|
setChannelMarkerBandwidth();
|
2017-03-05 21:39:34 -05:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-16 05:44:31 -04:00
|
|
|
void ATVModGUI::on_rfOppBW_valueChanged(int value)
|
|
|
|
{
|
2017-03-19 23:31:57 -04:00
|
|
|
ui->rfOppBWText->setText(QString("%1k").arg((value*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
2017-03-21 07:16:43 -04:00
|
|
|
setChannelMarkerBandwidth();
|
|
|
|
applySettings();
|
|
|
|
}
|
2017-03-16 05:44:31 -04:00
|
|
|
|
2017-03-21 07:16:43 -04:00
|
|
|
void ATVModGUI::setChannelMarkerBandwidth()
|
|
|
|
{
|
|
|
|
if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationLSB)
|
2017-03-16 05:44:31 -04:00
|
|
|
{
|
2017-03-21 07:16:43 -04:00
|
|
|
m_channelMarker.setBandwidth(-ui->rfBW->value()*m_rfSliderDivisor*2);
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::lsb);
|
|
|
|
}
|
|
|
|
else if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialLSB)
|
|
|
|
{
|
|
|
|
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
|
|
|
|
m_channelMarker.setOppositeBandwidth(ui->rfOppBW->value()*m_rfSliderDivisor);
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::vlsb);
|
|
|
|
}
|
|
|
|
else if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationUSB)
|
|
|
|
{
|
|
|
|
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor*2);
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
2017-03-16 05:44:31 -04:00
|
|
|
}
|
|
|
|
else if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialUSB)
|
|
|
|
{
|
2017-03-21 07:16:43 -04:00
|
|
|
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
|
|
|
|
m_channelMarker.setOppositeBandwidth(ui->rfOppBW->value()*m_rfSliderDivisor);
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::vusb);
|
2017-03-16 05:44:31 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-21 07:16:43 -04:00
|
|
|
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::dsb);
|
2017-03-16 05:44:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_nbLines_currentIndexChanged(int index __attribute__((unused)))
|
2017-03-20 22:56:01 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_fps_currentIndexChanged(int index __attribute__((unused)))
|
2017-03-20 22:56:01 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_standard_currentIndexChanged(int index __attribute__((unused)))
|
2017-03-12 16:41:01 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-05 21:39:34 -05:00
|
|
|
void ATVModGUI::on_uniformLevel_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->uniformLevelText->setText(QString("%1").arg(value));
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-19 05:49:02 -04:00
|
|
|
void ATVModGUI::on_invertVideo_clicked()
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_inputSelect_currentIndexChanged(int index __attribute__((unused)))
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_channelMute_toggled(bool checked __attribute__((unused)))
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_forceDecimator_toggled(bool checked __attribute__((unused)))
|
2017-03-22 08:10:42 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_imageFileDialog_clicked(bool checked __attribute__((unused)))
|
2017-03-07 19:35:18 -05:00
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this,
|
2017-03-12 19:03:54 -04:00
|
|
|
tr("Open image file"), ".", tr("Image Files (*.png *.jpg *.bmp *.gif *.tiff)"));
|
2017-03-07 19:35:18 -05:00
|
|
|
|
|
|
|
if (fileName != "")
|
|
|
|
{
|
|
|
|
m_imageFileName = fileName;
|
2017-03-08 20:09:31 -05:00
|
|
|
ui->imageFileText->setText(m_imageFileName);
|
2017-03-07 19:35:18 -05:00
|
|
|
configureImageFileName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_videoFileDialog_clicked(bool checked __attribute__((unused)))
|
2017-03-08 20:09:31 -05:00
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this,
|
2017-03-20 17:34:48 -04:00
|
|
|
tr("Open video file"), ".", tr("Video Files (*.avi *.mpg *.mp4 *.mov *.m4v *.mkv *.vob *.wmv)"));
|
2017-03-08 20:09:31 -05:00
|
|
|
|
|
|
|
if (fileName != "")
|
|
|
|
{
|
|
|
|
m_videoFileName = fileName;
|
|
|
|
ui->videoFileText->setText(m_videoFileName);
|
|
|
|
configureVideoFileName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_playLoop_toggled(bool checked __attribute__((unused)))
|
2017-03-09 18:30:15 -05:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-03-11 00:57:22 -05:00
|
|
|
void ATVModGUI::on_playVideo_toggled(bool checked)
|
2017-03-09 18:30:15 -05:00
|
|
|
{
|
|
|
|
ui->navTimeSlider->setEnabled(!checked);
|
|
|
|
m_enableNavTime = !checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::on_navTimeSlider_valueChanged(int value)
|
|
|
|
{
|
|
|
|
if (m_enableNavTime && ((value >= 0) && (value <= 100)))
|
|
|
|
{
|
|
|
|
ATVMod::MsgConfigureVideoFileSourceSeek* message = ATVMod::MsgConfigureVideoFileSourceSeek::create(value);
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_playCamera_toggled(bool checked __attribute__((unused)))
|
2017-03-11 02:21:26 -05:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::on_camSelect_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
ATVMod::MsgConfigureCameraIndex* message = ATVMod::MsgConfigureCameraIndex::create(index);
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
2017-03-09 18:30:15 -05:00
|
|
|
|
2017-03-24 14:06:29 -04:00
|
|
|
void ATVModGUI::on_cameraManualFPSEnable_toggled(bool checked)
|
|
|
|
{
|
|
|
|
ATVMod::MsgConfigureCameraData* message = ATVMod::MsgConfigureCameraData::create(
|
|
|
|
ui->camSelect->currentIndex(),
|
|
|
|
checked,
|
|
|
|
ui->cameraManualFPS->value() / 10.0f);
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::on_cameraManualFPS_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->cameraManualFPSText->setText(tr("%1 FPS").arg(value / 10.0f, 0, 'f', 1));
|
|
|
|
ATVMod::MsgConfigureCameraData* message = ATVMod::MsgConfigureCameraData::create(
|
|
|
|
ui->camSelect->currentIndex(),
|
|
|
|
ui->cameraManualFPSEnable->isChecked(),
|
|
|
|
value / 10.0f);
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
2017-03-12 10:10:59 -04:00
|
|
|
void ATVModGUI::on_overlayTextShow_toggled(bool checked)
|
|
|
|
{
|
|
|
|
ATVMod::MsgConfigureShowOverlayText* message = ATVMod::MsgConfigureShowOverlayText::create(checked);
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::on_overlayText_textEdited(const QString& arg1 __attribute__((unused)))
|
2017-03-12 10:10:59 -04:00
|
|
|
{
|
|
|
|
ATVMod::MsgConfigureOverlayText* message = ATVMod::MsgConfigureOverlayText::create(ui->overlayText->text());
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
2017-03-07 19:35:18 -05:00
|
|
|
void ATVModGUI::configureImageFileName()
|
|
|
|
{
|
|
|
|
qDebug() << "ATVModGUI::configureImageFileName: " << m_imageFileName.toStdString().c_str();
|
|
|
|
ATVMod::MsgConfigureImageFileName* message = ATVMod::MsgConfigureImageFileName::create(m_imageFileName);
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
2017-03-08 20:09:31 -05:00
|
|
|
void ATVModGUI::configureVideoFileName()
|
|
|
|
{
|
|
|
|
qDebug() << "ATVModGUI::configureVideoFileName: " << m_videoFileName.toStdString().c_str();
|
|
|
|
ATVMod::MsgConfigureVideoFileName* message = ATVMod::MsgConfigureVideoFileName::create(m_videoFileName);
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void ATVModGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused)))
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::onMenuDoubleClicked()
|
|
|
|
{
|
|
|
|
if(!m_basicSettingsShown) {
|
|
|
|
m_basicSettingsShown = true;
|
|
|
|
BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this);
|
|
|
|
bcsw->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ATVModGUI::ATVModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* parent) :
|
|
|
|
RollupWidget(parent),
|
|
|
|
ui(new Ui::ATVModGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_deviceAPI(deviceAPI),
|
|
|
|
m_channelMarker(this),
|
|
|
|
m_basicSettingsShown(false),
|
|
|
|
m_doApplySettings(true),
|
|
|
|
m_channelPowerDbAvg(20,0),
|
2017-03-09 17:17:14 -05:00
|
|
|
m_videoLength(0),
|
|
|
|
m_videoFrameRate(48000),
|
|
|
|
m_frameCount(0),
|
2017-03-05 21:39:34 -05:00
|
|
|
m_tickCount(0),
|
2017-03-11 21:51:22 -05:00
|
|
|
m_enableNavTime(false),
|
2017-03-19 23:31:57 -04:00
|
|
|
m_camBusyFPSMessageBox(0),
|
|
|
|
m_rfSliderDivisor(100000)
|
2017-03-05 21:39:34 -05:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
|
|
|
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
|
|
|
|
|
|
|
m_atvMod = new ATVMod();
|
|
|
|
m_channelizer = new UpChannelizer(m_atvMod);
|
|
|
|
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
|
|
|
|
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
|
2017-03-11 19:26:12 -05:00
|
|
|
connect(m_channelizer, SIGNAL(outputSampleRateChanged()), this, SLOT(channelizerOutputSampleRateChanged()));
|
2017-03-05 21:39:34 -05:00
|
|
|
m_deviceAPI->addThreadedSource(m_threadedChannelizer);
|
|
|
|
|
|
|
|
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
|
|
|
|
2017-05-17 18:16:07 -04:00
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
//m_channelMarker = new ChannelMarker(this);
|
|
|
|
m_channelMarker.setColor(Qt::white);
|
|
|
|
m_channelMarker.setBandwidth(5000);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
|
|
|
m_channelMarker.setVisible(true);
|
|
|
|
|
|
|
|
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
|
|
|
|
|
|
|
|
m_deviceAPI->registerChannelInstance(m_channelID, this);
|
|
|
|
m_deviceAPI->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceAPI->addRollupWidget(this);
|
|
|
|
|
|
|
|
resetToDefaults();
|
|
|
|
|
|
|
|
connect(m_atvMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
|
|
|
connect(m_atvMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
|
2017-03-10 08:28:04 -05:00
|
|
|
|
|
|
|
std::vector<int> cameraNumbers;
|
|
|
|
m_atvMod->getCameraNumbers(cameraNumbers);
|
|
|
|
|
|
|
|
for (std::vector<int>::iterator it = cameraNumbers.begin(); it != cameraNumbers.end(); ++it) {
|
|
|
|
ui->camSelect->addItem(tr("%1").arg(*it));
|
|
|
|
}
|
2017-03-21 18:29:42 -04:00
|
|
|
|
|
|
|
QChar delta = QChar(0x94, 0x03);
|
|
|
|
ui->fmExcursionLabel->setText(delta);
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ATVModGUI::~ATVModGUI()
|
|
|
|
{
|
|
|
|
m_deviceAPI->removeChannelInstance(this);
|
|
|
|
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
|
|
|
|
delete m_threadedChannelizer;
|
|
|
|
delete m_channelizer;
|
|
|
|
delete m_atvMod;
|
|
|
|
//delete m_channelMarker;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::applySettings()
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
setTitleColor(m_channelMarker.getColor());
|
|
|
|
|
|
|
|
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
|
|
|
m_channelizer->getOutputSampleRate(),
|
|
|
|
m_channelMarker.getCenterFrequency());
|
|
|
|
|
2017-05-17 18:16:07 -04:00
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
2017-03-05 21:39:34 -05:00
|
|
|
|
|
|
|
m_atvMod->configure(m_atvMod->getInputMessageQueue(),
|
2017-03-19 23:31:57 -04:00
|
|
|
ui->rfBW->value() * m_rfSliderDivisor * 1.0f,
|
|
|
|
ui->rfOppBW->value() * m_rfSliderDivisor * 1.0f,
|
2017-03-05 21:39:34 -05:00
|
|
|
(ATVMod::ATVStd) ui->standard->currentIndex(),
|
2017-03-20 22:56:01 -04:00
|
|
|
getNbLines(),
|
|
|
|
getFPS(),
|
2017-03-05 21:39:34 -05:00
|
|
|
(ATVMod::ATVModInput) ui->inputSelect->currentIndex(),
|
|
|
|
ui->uniformLevel->value() / 100.0f,
|
2017-03-07 13:19:54 -05:00
|
|
|
(ATVMod::ATVModulation) ui->modulation->currentIndex(),
|
2017-03-09 18:30:15 -05:00
|
|
|
ui->playLoop->isChecked(),
|
2017-03-11 00:57:22 -05:00
|
|
|
ui->playVideo->isChecked(),
|
2017-03-11 02:21:26 -05:00
|
|
|
ui->playCamera->isChecked(),
|
2017-03-19 05:49:02 -04:00
|
|
|
ui->channelMute->isChecked(),
|
2017-03-21 16:59:44 -04:00
|
|
|
ui->invertVideo->isChecked(),
|
2017-03-21 18:29:42 -04:00
|
|
|
ui->rfScaling->value() * 327.68f,
|
2017-04-09 01:27:32 -04:00
|
|
|
ui->fmExcursion->value() / 1000.0f, // percentage of full bandwidth. Value in pro milli
|
2017-03-22 08:10:42 -04:00
|
|
|
ui->forceDecimator->isChecked());
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::leaveEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(false);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::enterEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(true);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::tick()
|
|
|
|
{
|
2017-05-16 17:39:49 -04:00
|
|
|
double powDb = CalcDb::dbPower(m_atvMod->getMagSq());
|
2017-03-05 21:39:34 -05:00
|
|
|
m_channelPowerDbAvg.feed(powDb);
|
2017-05-25 19:19:36 -04:00
|
|
|
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.average(), 0, 'f', 1));
|
2017-03-09 17:17:14 -05:00
|
|
|
|
|
|
|
if (((++m_tickCount & 0xf) == 0) && (ui->inputSelect->currentIndex() == (int) ATVMod::ATVModInputVideo))
|
|
|
|
{
|
|
|
|
ATVMod::MsgConfigureVideoFileSourceStreamTiming* message = ATVMod::MsgConfigureVideoFileSourceStreamTiming::create();
|
|
|
|
m_atvMod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::updateWithStreamData()
|
|
|
|
{
|
|
|
|
QTime recordLength(0, 0, 0, 0);
|
|
|
|
recordLength = recordLength.addSecs(m_videoLength / m_videoFrameRate);
|
|
|
|
QString s_time = recordLength.toString("hh:mm:ss");
|
|
|
|
ui->recordLengthText->setText(s_time);
|
|
|
|
updateWithStreamTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVModGUI::updateWithStreamTime()
|
|
|
|
{
|
|
|
|
int t_sec = 0;
|
|
|
|
int t_msec = 0;
|
|
|
|
|
|
|
|
if (m_videoFrameRate > 0.0f)
|
|
|
|
{
|
|
|
|
float secs = m_frameCount / m_videoFrameRate;
|
|
|
|
t_sec = (int) secs;
|
|
|
|
t_msec = (int) ((secs - t_sec) * 1000.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
QTime t(0, 0, 0, 0);
|
|
|
|
t = t.addSecs(t_sec);
|
|
|
|
t = t.addMSecs(t_msec);
|
|
|
|
QString s_timems = t.toString("hh:mm:ss.zzz");
|
|
|
|
QString s_time = t.toString("hh:mm:ss");
|
|
|
|
ui->relTimeText->setText(s_timems);
|
|
|
|
|
|
|
|
if (!m_enableNavTime)
|
|
|
|
{
|
|
|
|
float posRatio = (t_sec * m_videoFrameRate) / m_videoLength;
|
|
|
|
ui->navTimeSlider->setValue((int) (posRatio * 100.0));
|
|
|
|
}
|
2017-03-05 21:39:34 -05:00
|
|
|
}
|
2017-03-09 17:17:14 -05:00
|
|
|
|