mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-04 06:54:39 -04:00
Full renaming of FileSource device to FileInput
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
project(fileinput)
|
||||
|
||||
set(fileinput_SOURCES
|
||||
fileinput.cpp
|
||||
fileinputplugin.cpp
|
||||
fileinputthread.cpp
|
||||
fileinputsettings.cpp
|
||||
)
|
||||
|
||||
set(fileinput_HEADERS
|
||||
fileinput.h
|
||||
fileinputplugin.h
|
||||
fileinputthread.h
|
||||
fileinputsettings.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
||||
)
|
||||
|
||||
if(NOT SERVER_MODE)
|
||||
set(fileinput_SOURCES
|
||||
${fileinput_SOURCES}
|
||||
fileinputgui.cpp
|
||||
fileinputgui.ui
|
||||
)
|
||||
set(fileinput_HEADERS
|
||||
${fileinput_HEADERS}
|
||||
fileinputgui.h
|
||||
)
|
||||
set(TARGET_NAME inputfileinput)
|
||||
set(TARGET_LIB "Qt5::Widgets")
|
||||
set(TARGET_LIB_GUI "sdrgui")
|
||||
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
|
||||
else()
|
||||
set(TARGET_NAME inputfileinputsrv)
|
||||
set(TARGET_LIB "")
|
||||
set(TARGET_LIB_GUI "")
|
||||
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
|
||||
endif()
|
||||
|
||||
add_library(${TARGET_NAME} SHARED
|
||||
${fileinput_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(${TARGET_NAME}
|
||||
Qt5::Core
|
||||
${TARGET_LIB}
|
||||
sdrbase
|
||||
${TARGET_LIB_GUI}
|
||||
swagger
|
||||
)
|
||||
|
||||
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
|
||||
@@ -0,0 +1,680 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QNetworkReply>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGFileInputSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
#include "SWGDeviceReport.h"
|
||||
|
||||
#include "util/simpleserializer.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/dspdevicesourceengine.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/filerecord.h"
|
||||
#include "device/deviceapi.h"
|
||||
|
||||
#include "fileinput.h"
|
||||
#include "fileinputthread.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileInput, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileSourceName, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileInputWork, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileSourceSeek, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileInputStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgStartStop, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgPlayPause, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportFileSourceAcquisition, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportFileInputStreamData, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportFileInputStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportHeaderCRC, Message)
|
||||
|
||||
FileInput::FileInput(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_settings(),
|
||||
m_fileInputThread(nullptr),
|
||||
m_deviceDescription(),
|
||||
m_fileName("..."),
|
||||
m_sampleRate(0),
|
||||
m_sampleSize(0),
|
||||
m_centerFrequency(0),
|
||||
m_recordLength(0),
|
||||
m_startingTimeStamp(0)
|
||||
{
|
||||
m_deviceAPI->setNbSourceStreams(1);
|
||||
qDebug("FileInput::FileInput: device source engine: %p", m_deviceAPI->getDeviceSourceEngine());
|
||||
qDebug("FileInput::FileInput: device source engine message queue: %p", m_deviceAPI->getDeviceEngineInputMessageQueue());
|
||||
qDebug("FileInput::FileInput: device source: %p", m_deviceAPI->getDeviceSourceEngine()->getSource());
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
m_masterTimer.setTimerType(Qt::PreciseTimer);
|
||||
m_masterTimer.start(50);
|
||||
}
|
||||
|
||||
FileInput::~FileInput()
|
||||
{
|
||||
m_masterTimer.stop();
|
||||
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
delete m_networkManager;
|
||||
|
||||
stop();
|
||||
}
|
||||
|
||||
void FileInput::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void FileInput::openFileStream()
|
||||
{
|
||||
//stopInput();
|
||||
|
||||
if (m_ifstream.is_open()) {
|
||||
m_ifstream.close();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
m_ifstream.open(m_fileName.toStdWString().c_str(), std::ios::binary | std::ios::ate);
|
||||
#else
|
||||
m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
|
||||
#endif
|
||||
quint64 fileSize = m_ifstream.tellg();
|
||||
|
||||
if (fileSize > sizeof(FileRecord::Header))
|
||||
{
|
||||
FileRecord::Header header;
|
||||
m_ifstream.seekg(0,std::ios_base::beg);
|
||||
bool crcOK = FileRecord::readHeader(m_ifstream, header);
|
||||
m_sampleRate = header.sampleRate;
|
||||
m_centerFrequency = header.centerFrequency;
|
||||
m_startingTimeStamp = header.startTimeStamp;
|
||||
m_sampleSize = header.sampleSize;
|
||||
QString crcHex = QString("%1").arg(header.crc32 , 0, 16);
|
||||
|
||||
if (crcOK)
|
||||
{
|
||||
qDebug("FileInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
|
||||
m_recordLength = (fileSize - sizeof(FileRecord::Header)) / ((m_sampleSize == 24 ? 8 : 4) * m_sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical("FileInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
|
||||
m_recordLength = 0;
|
||||
}
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
MsgReportHeaderCRC *report = MsgReportHeaderCRC::create(crcOK);
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_recordLength = 0;
|
||||
}
|
||||
|
||||
qDebug() << "FileInput::openFileStream: " << m_fileName.toStdString().c_str()
|
||||
<< " fileSize: " << fileSize << " bytes"
|
||||
<< " length: " << m_recordLength << " seconds"
|
||||
<< " sample rate: " << m_sampleRate << " S/s"
|
||||
<< " center frequency: " << m_centerFrequency << " Hz"
|
||||
<< " sample size: " << m_sampleSize << " bits";
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
MsgReportFileInputStreamData *report = MsgReportFileInputStreamData::create(m_sampleRate,
|
||||
m_sampleSize,
|
||||
m_centerFrequency,
|
||||
m_startingTimeStamp,
|
||||
m_recordLength); // file stream data
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
|
||||
if (m_recordLength == 0) {
|
||||
m_ifstream.close();
|
||||
}
|
||||
}
|
||||
|
||||
void FileInput::seekFileStream(int seekMillis)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if ((m_ifstream.is_open()) && m_fileInputThread && !m_fileInputThread->isRunning())
|
||||
{
|
||||
quint64 seekPoint = ((m_recordLength * seekMillis) / 1000) * m_sampleRate;
|
||||
m_fileInputThread->setSamplesCount(seekPoint);
|
||||
seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileSink::Header)
|
||||
m_ifstream.clear();
|
||||
m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInput::init()
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_settings.m_sampleRate, m_settings.m_centerFrequency);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
}
|
||||
|
||||
bool FileInput::start()
|
||||
{
|
||||
if (!m_ifstream.is_open())
|
||||
{
|
||||
qWarning("FileInput::start: file not open. not starting");
|
||||
return false;
|
||||
}
|
||||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
qDebug() << "FileInput::start";
|
||||
|
||||
if (m_ifstream.tellg() != (std::streampos)0) {
|
||||
m_ifstream.clear();
|
||||
m_ifstream.seekg(sizeof(FileRecord::Header), std::ios::beg);
|
||||
}
|
||||
|
||||
if(!m_sampleFifo.setSize(m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample))) {
|
||||
qCritical("Could not allocate SampleFifo");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_fileInputThread = new FileInputThread(&m_ifstream, &m_sampleFifo, m_masterTimer, &m_inputMessageQueue);
|
||||
m_fileInputThread->setSampleRateAndSize(m_settings.m_accelerationFactor * m_sampleRate, m_sampleSize); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
m_fileInputThread->startWork();
|
||||
m_deviceDescription = "FileInput";
|
||||
|
||||
mutexLocker.unlock();
|
||||
qDebug("FileInput::startInput: started");
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(true); // acquisition on
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileInput::stop()
|
||||
{
|
||||
qDebug() << "FileInput::stop";
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (m_fileInputThread)
|
||||
{
|
||||
m_fileInputThread->stopWork();
|
||||
delete m_fileInputThread;
|
||||
m_fileInputThread = nullptr;
|
||||
}
|
||||
|
||||
m_deviceDescription.clear();
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(false); // acquisition off
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray FileInput::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
}
|
||||
|
||||
bool FileInput::deserialize(const QByteArray& data)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
if (!m_settings.deserialize(data))
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
success = false;
|
||||
}
|
||||
|
||||
MsgConfigureFileInput* message = MsgConfigureFileInput::create(m_settings, true);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgConfigureFileInput* messageToGUI = MsgConfigureFileInput::create(m_settings, true);
|
||||
getMessageQueueToGUI()->push(messageToGUI);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
const QString& FileInput::getDeviceDescription() const
|
||||
{
|
||||
return m_deviceDescription;
|
||||
}
|
||||
|
||||
int FileInput::getSampleRate() const
|
||||
{
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
||||
quint64 FileInput::getCenterFrequency() const
|
||||
{
|
||||
return m_centerFrequency;
|
||||
}
|
||||
|
||||
void FileInput::setCenterFrequency(qint64 centerFrequency)
|
||||
{
|
||||
FileInputSettings settings = m_settings;
|
||||
settings.m_centerFrequency = centerFrequency;
|
||||
|
||||
MsgConfigureFileInput* message = MsgConfigureFileInput::create(m_settings, false);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgConfigureFileInput* messageToGUI = MsgConfigureFileInput::create(m_settings, false);
|
||||
getMessageQueueToGUI()->push(messageToGUI);
|
||||
}
|
||||
}
|
||||
|
||||
quint64 FileInput::getStartingTimeStamp() const
|
||||
{
|
||||
return m_startingTimeStamp;
|
||||
}
|
||||
|
||||
bool FileInput::handleMessage(const Message& message)
|
||||
{
|
||||
if (MsgConfigureFileInput::match(message))
|
||||
{
|
||||
MsgConfigureFileInput& conf = (MsgConfigureFileInput&) message;
|
||||
FileInputSettings settings = conf.getSettings();
|
||||
applySettings(settings);
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceName::match(message))
|
||||
{
|
||||
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) message;
|
||||
m_fileName = conf.getFileName();
|
||||
openFileStream();
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileInputWork::match(message))
|
||||
{
|
||||
MsgConfigureFileInputWork& conf = (MsgConfigureFileInputWork&) message;
|
||||
bool working = conf.isWorking();
|
||||
|
||||
if (m_fileInputThread != 0)
|
||||
{
|
||||
if (working) {
|
||||
m_fileInputThread->startWork();
|
||||
} else {
|
||||
m_fileInputThread->stopWork();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceSeek::match(message))
|
||||
{
|
||||
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) message;
|
||||
int seekMillis = conf.getMillis();
|
||||
seekFileStream(seekMillis);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileInputStreamTiming::match(message))
|
||||
{
|
||||
MsgReportFileInputStreamTiming *report;
|
||||
|
||||
if (m_fileInputThread != 0)
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
report = MsgReportFileInputStreamTiming::create(m_fileInputThread->getSamplesCount());
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgStartStop::match(message))
|
||||
{
|
||||
MsgStartStop& cmd = (MsgStartStop&) message;
|
||||
qDebug() << "FileInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
||||
|
||||
if (cmd.getStartStop())
|
||||
{
|
||||
if (m_deviceAPI->initDeviceEngine())
|
||||
{
|
||||
m_deviceAPI->startDeviceEngine();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_deviceAPI->stopDeviceEngine();
|
||||
}
|
||||
|
||||
if (m_settings.m_useReverseAPI) {
|
||||
webapiReverseSendStartStop(cmd.getStartStop());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (FileInputThread::MsgReportEOF::match(message))
|
||||
{
|
||||
qDebug() << "FileInput::handleMessage: MsgReportEOF";
|
||||
m_fileInputThread->stopWork();
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportFileInputStreamTiming *report = MsgReportFileInputStreamTiming::create(m_fileInputThread->getSamplesCount());
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
|
||||
if (m_settings.m_loop)
|
||||
{
|
||||
seekFileStream(0);
|
||||
m_fileInputThread->startWork();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgPlayPause *report = MsgPlayPause::create(false);
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool FileInput::applySettings(const FileInputSettings& settings, bool force)
|
||||
{
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
|
||||
m_centerFrequency = settings.m_centerFrequency;
|
||||
}
|
||||
|
||||
if ((m_settings.m_accelerationFactor != settings.m_accelerationFactor) || force)
|
||||
{
|
||||
reverseAPIKeys.append("accelerationFactor");
|
||||
|
||||
if (m_fileInputThread)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
if (!m_sampleFifo.setSize(m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample))) {
|
||||
qCritical("FileInput::applySettings: could not reallocate sample FIFO size to %lu",
|
||||
m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample));
|
||||
}
|
||||
m_fileInputThread->setSampleRateAndSize(settings.m_accelerationFactor * m_sampleRate, m_sampleSize); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_loop != settings.m_loop)) {
|
||||
reverseAPIKeys.append("loop");
|
||||
}
|
||||
if ((m_settings.m_fileName != settings.m_fileName)) {
|
||||
reverseAPIKeys.append("fileName");
|
||||
}
|
||||
|
||||
if (settings.m_useReverseAPI)
|
||||
{
|
||||
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
||||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
||||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
||||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex);
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
return true;
|
||||
}
|
||||
|
||||
int FileInput::webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setFileInputSettings(new SWGSDRangel::SWGFileInputSettings());
|
||||
response.getFileInputSettings()->init();
|
||||
webapiFormatDeviceSettings(response, m_settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileInput::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
FileInputSettings settings = m_settings;
|
||||
|
||||
if (deviceSettingsKeys.contains("fileName")) {
|
||||
settings.m_fileName = *response.getFileInputSettings()->getFileName();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("accelerationFactor")) {
|
||||
settings.m_accelerationFactor = response.getFileInputSettings()->getAccelerationFactor();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("loop")) {
|
||||
settings.m_loop = response.getFileInputSettings()->getLoop() != 0;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
||||
settings.m_useReverseAPI = response.getFileInputSettings()->getUseReverseApi() != 0;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
|
||||
settings.m_reverseAPIAddress = *response.getFileInputSettings()->getReverseApiAddress();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
||||
settings.m_reverseAPIPort = response.getFileInputSettings()->getReverseApiPort();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
||||
settings.m_reverseAPIDeviceIndex = response.getFileInputSettings()->getReverseApiDeviceIndex();
|
||||
}
|
||||
|
||||
MsgConfigureFileInput *msg = MsgConfigureFileInput::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureFileInput *msgToGUI = MsgConfigureFileInput::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatDeviceSettings(response, settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileInput::webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileInput::webapiRun(
|
||||
bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
||||
MsgStartStop *message = MsgStartStop::create(run);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (getMessageQueueToGUI()) // forward to GUI if any
|
||||
{
|
||||
MsgStartStop *msgToGUI = MsgStartStop::create(run);
|
||||
getMessageQueueToGUI()->push(msgToGUI);
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileInput::webapiReportGet(
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setFileInputReport(new SWGSDRangel::SWGFileInputReport());
|
||||
response.getFileInputReport()->init();
|
||||
webapiFormatDeviceReport(response);
|
||||
return 200;
|
||||
}
|
||||
|
||||
void FileInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FileInputSettings& settings)
|
||||
{
|
||||
response.getFileInputSettings()->setFileName(new QString(settings.m_fileName));
|
||||
response.getFileInputSettings()->setAccelerationFactor(settings.m_accelerationFactor);
|
||||
response.getFileInputSettings()->setLoop(settings.m_loop ? 1 : 0);
|
||||
|
||||
response.getFileInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
||||
|
||||
if (response.getFileInputSettings()->getReverseApiAddress()) {
|
||||
*response.getFileInputSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
||||
} else {
|
||||
response.getFileInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
||||
}
|
||||
|
||||
response.getFileInputSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
||||
response.getFileInputSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
||||
}
|
||||
|
||||
void FileInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
||||
{
|
||||
qint64 t_sec = 0;
|
||||
qint64 t_msec = 0;
|
||||
quint64 samplesCount = 0;
|
||||
|
||||
if (m_fileInputThread) {
|
||||
samplesCount = m_fileInputThread->getSamplesCount();
|
||||
}
|
||||
|
||||
if (m_sampleRate > 0)
|
||||
{
|
||||
t_sec = samplesCount / m_sampleRate;
|
||||
t_msec = (samplesCount - (t_sec * m_sampleRate)) * 1000 / m_sampleRate;
|
||||
}
|
||||
|
||||
QTime t(0, 0, 0, 0);
|
||||
t = t.addSecs(t_sec);
|
||||
t = t.addMSecs(t_msec);
|
||||
response.getFileInputReport()->setElapsedTime(new QString(t.toString("HH:mm:ss.zzz")));
|
||||
|
||||
qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL;
|
||||
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
|
||||
dt = dt.addSecs(t_sec);
|
||||
dt = dt.addMSecs(t_msec);
|
||||
response.getFileInputReport()->setAbsoluteTime(new QString(dt.toString("yyyy-MM-dd HH:mm:ss.zzz")));
|
||||
|
||||
QTime recordLength(0, 0, 0, 0);
|
||||
recordLength = recordLength.addSecs(m_recordLength);
|
||||
response.getFileInputReport()->setDurationTime(new QString(recordLength.toString("HH:mm:ss")));
|
||||
|
||||
response.getFileInputReport()->setFileName(new QString(m_fileName));
|
||||
response.getFileInputReport()->setSampleRate(m_sampleRate);
|
||||
response.getFileInputReport()->setSampleSize(m_sampleSize);
|
||||
}
|
||||
|
||||
void FileInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FileInputSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("FileInput"));
|
||||
swgDeviceSettings->setFileInputSettings(new SWGSDRangel::SWGFileInputSettings());
|
||||
SWGSDRangel::SWGFileInputSettings *swgFileInputSettings = swgDeviceSettings->getFileInputSettings();
|
||||
|
||||
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
||||
|
||||
if (deviceSettingsKeys.contains("accelerationFactor") || force) {
|
||||
swgFileInputSettings->setAccelerationFactor(settings.m_accelerationFactor);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("loop") || force) {
|
||||
swgFileInputSettings->setLoop(settings.m_loop);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("fileName") || force) {
|
||||
swgFileInputSettings->setFileName(new QString(settings.m_fileName));
|
||||
}
|
||||
|
||||
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
|
||||
.arg(settings.m_reverseAPIAddress)
|
||||
.arg(settings.m_reverseAPIPort)
|
||||
.arg(settings.m_reverseAPIDeviceIndex);
|
||||
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer=new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
|
||||
// Always use PATCH to avoid passing reverse API settings
|
||||
m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
||||
|
||||
delete swgDeviceSettings;
|
||||
}
|
||||
|
||||
void FileInput::webapiReverseSendStartStop(bool start)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("FileInput"));
|
||||
|
||||
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
|
||||
.arg(m_settings.m_reverseAPIAddress)
|
||||
.arg(m_settings.m_reverseAPIPort)
|
||||
.arg(m_settings.m_reverseAPIDeviceIndex);
|
||||
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer=new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
|
||||
if (start) {
|
||||
m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
|
||||
} else {
|
||||
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
|
||||
}
|
||||
|
||||
delete swgDeviceSettings;
|
||||
}
|
||||
|
||||
void FileInput::networkManagerFinished(QNetworkReply *reply)
|
||||
{
|
||||
QNetworkReply::NetworkError replyError = reply->error();
|
||||
|
||||
if (replyError)
|
||||
{
|
||||
qWarning() << "FileInput::networkManagerFinished:"
|
||||
<< " error(" << (int) replyError
|
||||
<< "): " << replyError
|
||||
<< ": " << reply->errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
QString answer = reply->readAll();
|
||||
answer.chop(1); // remove last \n
|
||||
qDebug("FileInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILEINPUT_H
|
||||
#define INCLUDE_FILEINPUT_H
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QTimer>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include "dsp/devicesamplesource.h"
|
||||
#include "fileinputsettings.h"
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class FileInputThread;
|
||||
class DeviceAPI;
|
||||
|
||||
class FileInput : public DeviceSampleSource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MsgConfigureFileInput : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const FileInputSettings& getSettings() const { return m_settings; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureFileInput* create(const FileInputSettings& settings, bool force)
|
||||
{
|
||||
return new MsgConfigureFileInput(settings, force);
|
||||
}
|
||||
|
||||
private:
|
||||
FileInputSettings m_settings;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureFileInput(const FileInputSettings& settings, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureFileSourceName : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const QString& getFileName() const { return m_fileName; }
|
||||
|
||||
static MsgConfigureFileSourceName* create(const QString& fileName)
|
||||
{
|
||||
return new MsgConfigureFileSourceName(fileName);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
|
||||
MsgConfigureFileSourceName(const QString& fileName) :
|
||||
Message(),
|
||||
m_fileName(fileName)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureFileInputWork : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool isWorking() const { return m_working; }
|
||||
|
||||
static MsgConfigureFileInputWork* create(bool working)
|
||||
{
|
||||
return new MsgConfigureFileInputWork(working);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_working;
|
||||
|
||||
MsgConfigureFileInputWork(bool working) :
|
||||
Message(),
|
||||
m_working(working)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureFileInputStreamTiming : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
|
||||
static MsgConfigureFileInputStreamTiming* create()
|
||||
{
|
||||
return new MsgConfigureFileInputStreamTiming();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
MsgConfigureFileInputStreamTiming() :
|
||||
Message()
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureFileSourceSeek : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
int getMillis() const { return m_seekMillis; }
|
||||
|
||||
static MsgConfigureFileSourceSeek* create(int seekMillis)
|
||||
{
|
||||
return new MsgConfigureFileSourceSeek(seekMillis);
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_seekMillis; //!< millis of seek position from the beginning 0..1000
|
||||
|
||||
MsgConfigureFileSourceSeek(int seekMillis) :
|
||||
Message(),
|
||||
m_seekMillis(seekMillis)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportFileSourceAcquisition : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool getAcquisition() const { return m_acquisition; }
|
||||
|
||||
static MsgReportFileSourceAcquisition* create(bool acquisition)
|
||||
{
|
||||
return new MsgReportFileSourceAcquisition(acquisition);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_acquisition;
|
||||
|
||||
MsgReportFileSourceAcquisition(bool acquisition) :
|
||||
Message(),
|
||||
m_acquisition(acquisition)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgStartStop : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool getStartStop() const { return m_startStop; }
|
||||
|
||||
static MsgStartStop* create(bool startStop) {
|
||||
return new MsgStartStop(startStop);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_startStop;
|
||||
|
||||
MsgStartStop(bool startStop) :
|
||||
Message(),
|
||||
m_startStop(startStop)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgPlayPause : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool getPlayPause() const { return m_playPause; }
|
||||
|
||||
static MsgPlayPause* create(bool playPause) {
|
||||
return new MsgPlayPause(playPause);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_playPause;
|
||||
|
||||
MsgPlayPause(bool playPause) :
|
||||
Message(),
|
||||
m_playPause(playPause)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportFileInputStreamData : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
int getSampleRate() const { return m_sampleRate; }
|
||||
quint32 getSampleSize() const { return m_sampleSize; }
|
||||
quint64 getCenterFrequency() const { return m_centerFrequency; }
|
||||
quint64 getStartingTimeStamp() const { return m_startingTimeStamp; }
|
||||
quint64 getRecordLength() const { return m_recordLength; }
|
||||
|
||||
static MsgReportFileInputStreamData* create(int sampleRate,
|
||||
quint32 sampleSize,
|
||||
quint64 centerFrequency,
|
||||
quint64 startingTimeStamp,
|
||||
quint64 recordLength)
|
||||
{
|
||||
return new MsgReportFileInputStreamData(sampleRate, sampleSize, centerFrequency, startingTimeStamp, recordLength);
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_sampleRate;
|
||||
quint32 m_sampleSize;
|
||||
quint64 m_centerFrequency;
|
||||
quint64 m_startingTimeStamp;
|
||||
quint64 m_recordLength;
|
||||
|
||||
MsgReportFileInputStreamData(int sampleRate,
|
||||
quint32 sampleSize,
|
||||
quint64 centerFrequency,
|
||||
quint64 startingTimeStamp,
|
||||
quint64 recordLength) :
|
||||
Message(),
|
||||
m_sampleRate(sampleRate),
|
||||
m_sampleSize(sampleSize),
|
||||
m_centerFrequency(centerFrequency),
|
||||
m_startingTimeStamp(startingTimeStamp),
|
||||
m_recordLength(recordLength)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportFileInputStreamTiming : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
quint64 getSamplesCount() const { return m_samplesCount; }
|
||||
|
||||
static MsgReportFileInputStreamTiming* create(quint64 samplesCount)
|
||||
{
|
||||
return new MsgReportFileInputStreamTiming(samplesCount);
|
||||
}
|
||||
|
||||
protected:
|
||||
quint64 m_samplesCount;
|
||||
|
||||
MsgReportFileInputStreamTiming(quint64 samplesCount) :
|
||||
Message(),
|
||||
m_samplesCount(samplesCount)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportHeaderCRC : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool isOK() const { return m_ok; }
|
||||
|
||||
static MsgReportHeaderCRC* create(bool ok) {
|
||||
return new MsgReportHeaderCRC(ok);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
|
||||
MsgReportHeaderCRC(bool ok) :
|
||||
Message(),
|
||||
m_ok(ok)
|
||||
{ }
|
||||
};
|
||||
|
||||
FileInput(DeviceAPI *deviceAPI);
|
||||
virtual ~FileInput();
|
||||
virtual void destroy();
|
||||
|
||||
virtual void init();
|
||||
virtual bool start();
|
||||
virtual void stop();
|
||||
|
||||
virtual QByteArray serialize() const;
|
||||
virtual bool deserialize(const QByteArray& data);
|
||||
|
||||
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
||||
virtual const QString& getDeviceDescription() const;
|
||||
virtual int getSampleRate() const;
|
||||
virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
|
||||
virtual quint64 getCenterFrequency() const;
|
||||
virtual void setCenterFrequency(qint64 centerFrequency);
|
||||
quint64 getStartingTimeStamp() const;
|
||||
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiRun(
|
||||
bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiReportGet(
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage);
|
||||
|
||||
private:
|
||||
DeviceAPI *m_deviceAPI;
|
||||
QMutex m_mutex;
|
||||
FileInputSettings m_settings;
|
||||
std::ifstream m_ifstream;
|
||||
FileInputThread* m_fileInputThread;
|
||||
QString m_deviceDescription;
|
||||
QString m_fileName;
|
||||
int m_sampleRate;
|
||||
quint32 m_sampleSize;
|
||||
quint64 m_centerFrequency;
|
||||
quint64 m_recordLength; //!< record length in seconds computed from file size
|
||||
quint64 m_startingTimeStamp;
|
||||
QTimer m_masterTimer;
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
|
||||
void openFileStream();
|
||||
void seekFileStream(int seekMillis);
|
||||
bool applySettings(const FileInputSettings& settings, bool force = false);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FileInputSettings& settings);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FileInputSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FILESOURCEINPUT_H
|
||||
@@ -0,0 +1,465 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 <QDebug>
|
||||
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "ui_fileinputgui.h"
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "gui/colormapper.h"
|
||||
#include "gui/glspectrum.h"
|
||||
#include "gui/crightclickenabler.h"
|
||||
#include "gui/basicdevicesettingsdialog.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "fileinputgui.h"
|
||||
#include "device/deviceapi.h"
|
||||
#include "device/deviceuiset.h"
|
||||
|
||||
FileInputGUI::FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FileInputGUI),
|
||||
m_deviceUISet(deviceUISet),
|
||||
m_settings(),
|
||||
m_doApplySettings(true),
|
||||
m_sampleSource(0),
|
||||
m_acquisition(false),
|
||||
m_fileName("..."),
|
||||
m_sampleRate(0),
|
||||
m_centerFrequency(0),
|
||||
m_recordLength(0),
|
||||
m_startingTimeStamp(0),
|
||||
m_samplesCount(0),
|
||||
m_tickCount(0),
|
||||
m_enableNavTime(false),
|
||||
m_lastEngineState(DeviceAPI::StNotStarted)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
|
||||
ui->fileNameText->setText(m_fileName);
|
||||
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
||||
|
||||
connect(&(m_deviceUISet->m_deviceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
m_statusTimer.start(500);
|
||||
|
||||
CRightClickEnabler *startStopRightClickEnabler = new CRightClickEnabler(ui->startStop);
|
||||
connect(startStopRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
|
||||
|
||||
setAccelerationCombo();
|
||||
displaySettings();
|
||||
|
||||
ui->navTimeSlider->setEnabled(false);
|
||||
ui->acceleration->setEnabled(false);
|
||||
|
||||
m_sampleSource = m_deviceUISet->m_deviceAPI->getSampleSource();
|
||||
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||
m_sampleSource->setMessageQueueToGUI(&m_inputMessageQueue);
|
||||
}
|
||||
|
||||
FileInputGUI::~FileInputGUI()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FileInputGUI::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void FileInputGUI::setName(const QString& name)
|
||||
{
|
||||
setObjectName(name);
|
||||
}
|
||||
|
||||
QString FileInputGUI::getName() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void FileInputGUI::resetToDefaults()
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
qint64 FileInputGUI::getCenterFrequency() const
|
||||
{
|
||||
return m_centerFrequency;
|
||||
}
|
||||
|
||||
void FileInputGUI::setCenterFrequency(qint64 centerFrequency)
|
||||
{
|
||||
m_centerFrequency = centerFrequency;
|
||||
displaySettings();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
QByteArray FileInputGUI::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
}
|
||||
|
||||
bool FileInputGUI::deserialize(const QByteArray& data)
|
||||
{
|
||||
if(m_settings.deserialize(data)) {
|
||||
displaySettings();
|
||||
sendSettings();
|
||||
return true;
|
||||
} else {
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::handleInputMessages()
|
||||
{
|
||||
Message* message;
|
||||
|
||||
while ((message = m_inputMessageQueue.pop()) != 0)
|
||||
{
|
||||
if (DSPSignalNotification::match(*message))
|
||||
{
|
||||
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
||||
m_deviceSampleRate = notif->getSampleRate();
|
||||
m_deviceCenterFrequency = notif->getCenterFrequency();
|
||||
qDebug("FileInputGUI::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
updateSampleRateAndFrequency();
|
||||
|
||||
delete message;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (handleMessage(*message))
|
||||
{
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FileInputGUI::handleMessage(const Message& message)
|
||||
{
|
||||
if (FileInput::MsgConfigureFileInput::match(message))
|
||||
{
|
||||
const FileInput::MsgConfigureFileInput& cfg = (FileInput::MsgConfigureFileInput&) message;
|
||||
m_settings = cfg.getSettings();
|
||||
displaySettings();
|
||||
return true;
|
||||
}
|
||||
else if (FileInput::MsgReportFileSourceAcquisition::match(message))
|
||||
{
|
||||
m_acquisition = ((FileInput::MsgReportFileSourceAcquisition&)message).getAcquisition();
|
||||
updateWithAcquisition();
|
||||
return true;
|
||||
}
|
||||
else if (FileInput::MsgReportFileInputStreamData::match(message))
|
||||
{
|
||||
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();
|
||||
updateWithStreamData();
|
||||
return true;
|
||||
}
|
||||
else if (FileInput::MsgReportFileInputStreamTiming::match(message))
|
||||
{
|
||||
m_samplesCount = ((FileInput::MsgReportFileInputStreamTiming&)message).getSamplesCount();
|
||||
updateWithStreamTime();
|
||||
return true;
|
||||
}
|
||||
else if (FileInput::MsgStartStop::match(message))
|
||||
{
|
||||
FileInput::MsgStartStop& notif = (FileInput::MsgStartStop&) message;
|
||||
blockApplySettings(true);
|
||||
ui->startStop->setChecked(notif.getStartStop());
|
||||
blockApplySettings(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (FileInput::MsgPlayPause::match(message))
|
||||
{
|
||||
FileInput::MsgPlayPause& notif = (FileInput::MsgPlayPause&) message;
|
||||
bool checked = notif.getPlayPause();
|
||||
ui->play->setChecked(checked);
|
||||
ui->navTimeSlider->setEnabled(!checked);
|
||||
ui->acceleration->setEnabled(!checked);
|
||||
m_enableNavTime = !checked;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (FileInput::MsgReportHeaderCRC::match(message))
|
||||
{
|
||||
FileInput::MsgReportHeaderCRC& notif = (FileInput::MsgReportHeaderCRC&) message;
|
||||
if (notif.isOK()) {
|
||||
ui->crcLabel->setStyleSheet("QLabel { background-color : green; }");
|
||||
} else {
|
||||
ui->crcLabel->setStyleSheet("QLabel { background-color : red; }");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::updateSampleRateAndFrequency()
|
||||
{
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRate);
|
||||
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
||||
ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000));
|
||||
}
|
||||
|
||||
void FileInputGUI::displaySettings()
|
||||
{
|
||||
blockApplySettings(true);
|
||||
ui->playLoop->setChecked(m_settings.m_loop);
|
||||
ui->acceleration->setCurrentIndex(FileInputSettings::getAccelerationIndex(m_settings.m_accelerationFactor));
|
||||
blockApplySettings(false);
|
||||
}
|
||||
|
||||
void FileInputGUI::sendSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void FileInputGUI::on_playLoop_toggled(bool checked)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
m_settings.m_loop = checked;
|
||||
FileInput::MsgConfigureFileInput *message = FileInput::MsgConfigureFileInput::create(m_settings, false);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::on_startStop_toggled(bool checked)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
FileInput::MsgStartStop *message = FileInput::MsgStartStop::create(checked);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::updateStatus()
|
||||
{
|
||||
int state = m_deviceUISet->m_deviceAPI->state();
|
||||
|
||||
if(m_lastEngineState != state)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case DeviceAPI::StNotStarted:
|
||||
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
break;
|
||||
case DeviceAPI::StIdle:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
break;
|
||||
case DeviceAPI::StRunning:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
||||
break;
|
||||
case DeviceAPI::StError:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
||||
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_lastEngineState = state;
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::on_play_toggled(bool checked)
|
||||
{
|
||||
FileInput::MsgConfigureFileInputWork* message = FileInput::MsgConfigureFileInputWork::create(checked);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
ui->navTimeSlider->setEnabled(!checked);
|
||||
ui->acceleration->setEnabled(!checked);
|
||||
m_enableNavTime = !checked;
|
||||
}
|
||||
|
||||
void FileInputGUI::on_navTimeSlider_valueChanged(int value)
|
||||
{
|
||||
if (m_enableNavTime && ((value >= 0) && (value <= 1000)))
|
||||
{
|
||||
FileInput::MsgConfigureFileSourceSeek* message = FileInput::MsgConfigureFileSourceSeek::create(value);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::on_showFileDialog_clicked(bool checked)
|
||||
{
|
||||
(void) checked;
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open I/Q record file"), ".", tr("SDR I/Q Files (*.sdriq)"), 0, QFileDialog::DontUseNativeDialog);
|
||||
|
||||
if (fileName != "")
|
||||
{
|
||||
m_fileName = fileName;
|
||||
ui->fileNameText->setText(m_fileName);
|
||||
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
||||
configureFileName();
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::on_acceleration_currentIndexChanged(int index)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
m_settings.m_accelerationFactor = FileInputSettings::getAccelerationValue(index);
|
||||
FileInput::MsgConfigureFileInput *message = FileInput::MsgConfigureFileInput::create(m_settings, false);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::configureFileName()
|
||||
{
|
||||
qDebug() << "FileInputGUI::configureFileName: " << m_fileName.toStdString().c_str();
|
||||
FileInput::MsgConfigureFileSourceName* message = FileInput::MsgConfigureFileSourceName::create(m_fileName);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void FileInputGUI::updateWithAcquisition()
|
||||
{
|
||||
ui->play->setEnabled(m_acquisition);
|
||||
ui->play->setChecked(m_acquisition);
|
||||
ui->showFileDialog->setEnabled(!m_acquisition);
|
||||
}
|
||||
|
||||
void FileInputGUI::updateWithStreamData()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_centerFrequency/1000);
|
||||
ui->sampleRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000));
|
||||
ui->sampleSizeText->setText(tr("%1b").arg(m_sampleSize));
|
||||
ui->play->setEnabled(m_acquisition);
|
||||
QTime recordLength(0, 0, 0, 0);
|
||||
recordLength = recordLength.addSecs(m_recordLength);
|
||||
QString s_time = recordLength.toString("HH:mm:ss");
|
||||
ui->recordLengthText->setText(s_time);
|
||||
updateWithStreamTime();
|
||||
}
|
||||
|
||||
void FileInputGUI::updateWithStreamTime()
|
||||
{
|
||||
qint64 t_sec = 0;
|
||||
qint64 t_msec = 0;
|
||||
|
||||
if (m_sampleRate > 0){
|
||||
t_sec = m_samplesCount / m_sampleRate;
|
||||
t_msec = (m_samplesCount - (t_sec * m_sampleRate)) * 1000LL / m_sampleRate;
|
||||
}
|
||||
|
||||
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");
|
||||
ui->relTimeText->setText(s_timems);
|
||||
|
||||
qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL;
|
||||
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
|
||||
dt = dt.addSecs(t_sec);
|
||||
dt = dt.addMSecs(t_msec);
|
||||
QString s_date = dt.toString("yyyy-MM-dd HH:mm:ss.zzz");
|
||||
ui->absTimeText->setText(s_date);
|
||||
|
||||
if (!m_enableNavTime)
|
||||
{
|
||||
float posRatio = (float) t_sec / (float) m_recordLength;
|
||||
ui->navTimeSlider->setValue((int) (posRatio * 1000.0));
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::tick()
|
||||
{
|
||||
if ((++m_tickCount & 0xf) == 0) {
|
||||
FileInput::MsgConfigureFileInputStreamTiming* message = FileInput::MsgConfigureFileInputStreamTiming::create();
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::setAccelerationCombo()
|
||||
{
|
||||
ui->acceleration->blockSignals(true);
|
||||
ui->acceleration->clear();
|
||||
ui->acceleration->addItem(QString("1"));
|
||||
|
||||
for (unsigned int i = 0; i <= FileInputSettings::m_accelerationMaxScale; i++)
|
||||
{
|
||||
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 FileInputGUI::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);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputGUI::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();
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILEINPUTGUI_H
|
||||
#define INCLUDE_FILEINPUTGUI_H
|
||||
|
||||
#include <plugin/plugininstancegui.h>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
#include "fileinputsettings.h"
|
||||
#include "fileinput.h"
|
||||
|
||||
class DeviceUISet;
|
||||
|
||||
namespace Ui {
|
||||
class FileInputGUI;
|
||||
}
|
||||
|
||||
class FileInputGUI : public QWidget, public PluginInstanceGUI {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent = 0);
|
||||
virtual ~FileInputGUI();
|
||||
virtual void destroy();
|
||||
|
||||
void setName(const QString& name);
|
||||
QString getName() const;
|
||||
|
||||
void resetToDefaults();
|
||||
virtual qint64 getCenterFrequency() const;
|
||||
virtual void setCenterFrequency(qint64 centerFrequency);
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
private:
|
||||
Ui::FileInputGUI* ui;
|
||||
|
||||
DeviceUISet* m_deviceUISet;
|
||||
FileInputSettings m_settings;
|
||||
bool m_doApplySettings;
|
||||
QTimer m_statusTimer;
|
||||
std::vector<int> m_gains;
|
||||
DeviceSampleSource* m_sampleSource;
|
||||
bool m_acquisition;
|
||||
QString m_fileName;
|
||||
int m_sampleRate;
|
||||
quint32 m_sampleSize;
|
||||
quint64 m_centerFrequency;
|
||||
quint64 m_recordLength;
|
||||
quint64 m_startingTimeStamp;
|
||||
quint64 m_samplesCount;
|
||||
std::size_t m_tickCount;
|
||||
bool m_enableNavTime;
|
||||
int m_deviceSampleRate;
|
||||
quint64 m_deviceCenterFrequency; //!< Center frequency in device
|
||||
int m_lastEngineState;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
void blockApplySettings(bool block) { m_doApplySettings = !block; }
|
||||
void displaySettings();
|
||||
void displayTime();
|
||||
void sendSettings();
|
||||
void updateSampleRateAndFrequency();
|
||||
void configureFileName();
|
||||
void updateWithAcquisition();
|
||||
void updateWithStreamData();
|
||||
void updateWithStreamTime();
|
||||
void setAccelerationCombo();
|
||||
void setNumberStr(int n, QString& s);
|
||||
|
||||
private slots:
|
||||
void handleInputMessages();
|
||||
void on_startStop_toggled(bool checked);
|
||||
void on_playLoop_toggled(bool checked);
|
||||
void on_play_toggled(bool checked);
|
||||
void on_navTimeSlider_valueChanged(int value);
|
||||
void on_showFileDialog_clicked(bool checked);
|
||||
void on_acceleration_currentIndexChanged(int index);
|
||||
void updateStatus();
|
||||
void tick();
|
||||
void openDeviceSettingsDialog(const QPoint& p);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FILEINPUTGUI_H
|
||||
@@ -0,0 +1,624 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FileInputGUI</class>
|
||||
<widget class="QWidget" name="FileInputGUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>190</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>246</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Liberation Sans</family>
|
||||
<pointsize>9</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FileInput</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_freq">
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="deviceUILayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="deviceButtonsLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="startStop">
|
||||
<property name="toolTip">
|
||||
<string>start/stop acquisition</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrgui/resources/res.qrc">
|
||||
<normaloff>:/play.png</normaloff>
|
||||
<normalon>:/stop.png</normalon>:/play.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="deviceRateLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="deviceRateText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>I/Q sample rate kS/s</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00000k</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="freqLeftSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ValueDial" name="centerFrequency" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Liberation Mono</family>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Record center frequency in kHz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="freqUnits">
|
||||
<property name="text">
|
||||
<string> kHz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="freqRightlSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_freq">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="fileSelectionLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="showFileDialog">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrgui/resources/res.qrc">
|
||||
<normaloff>:/preset-load.png</normaloff>:/preset-load.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="fileNameText">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>File currently opened</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_file">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="rateTimeLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="sampleRateText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Record sample rate (kS/s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00000k</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="sampleSizeText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Record sample size (bits)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00b</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="crcLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>CRC status: Green: OK Red: KO Grey: undefined</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CRC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="absTimeLine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="absTimeText">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Record absolute time</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2015-01-01 00:00:00.000</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_rate">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="playControllLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="playLoop">
|
||||
<property name="toolTip">
|
||||
<string>Play in a loop</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrgui/resources/res.qrc">
|
||||
<normaloff>:/playloop.png</normaloff>:/playloop.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="play">
|
||||
<property name="toolTip">
|
||||
<string>Stopped / Play / Pause</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrgui/resources/res.qrc">
|
||||
<normaloff>:/play.png</normaloff>
|
||||
<normalon>:/pause.png</normalon>
|
||||
<disabledoff>:/stop.png</disabledoff>
|
||||
<disabledon>:/stop.png</disabledon>
|
||||
<activeoff>:/play.png</activeoff>
|
||||
<activeon>:/pause.png</activeon>
|
||||
<selectedoff>:/play.png</selectedoff>
|
||||
<selectedon>:/pause.png</selectedon>:/play.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="acceleration">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Acceleration factor</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>20</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>50</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>100</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>200</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>500</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1k</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="linePlay1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="relTimeText">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Record time from start</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00:00:00.000</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="linePlay2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="recordLengthText">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Total record time</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00:00:00</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_nav">
|
||||
<item>
|
||||
<widget class="QSlider" name="navTimeSlider">
|
||||
<property name="toolTip">
|
||||
<string>Time navigator</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="padLayout">
|
||||
<item>
|
||||
<spacer name="verticaPadlSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ValueDial</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/valuedial.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ButtonSwitch</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>gui/buttonswitch.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../sdrgui/resources/res.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,117 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 <QtPlugin>
|
||||
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
#include "fileinput.h"
|
||||
#else
|
||||
#include "fileinputgui.h"
|
||||
#endif
|
||||
#include "fileinputplugin.h"
|
||||
|
||||
const PluginDescriptor FileInputPlugin::m_pluginDescriptor = {
|
||||
QString("File input"),
|
||||
QString("4.11.0"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
QString("https://github.com/f4exb/sdrangel")
|
||||
};
|
||||
|
||||
const QString FileInputPlugin::m_hardwareID = "FileInput";
|
||||
const QString FileInputPlugin::m_deviceTypeID = FILEINPUT_DEVICE_TYPE_ID;
|
||||
|
||||
FileInputPlugin::FileInputPlugin(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const PluginDescriptor& FileInputPlugin::getPluginDescriptor() const
|
||||
{
|
||||
return m_pluginDescriptor;
|
||||
}
|
||||
|
||||
void FileInputPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
{
|
||||
pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
||||
}
|
||||
|
||||
PluginInterface::SamplingDevices FileInputPlugin::enumSampleSources()
|
||||
{
|
||||
SamplingDevices result;
|
||||
|
||||
result.append(SamplingDevice(
|
||||
"FileInput",
|
||||
m_hardwareID,
|
||||
m_deviceTypeID,
|
||||
QString::null,
|
||||
0,
|
||||
PluginInterface::SamplingDevice::BuiltInDevice,
|
||||
PluginInterface::SamplingDevice::StreamSingleRx,
|
||||
1,
|
||||
0));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
PluginInstanceGUI* FileInputPlugin::createSampleSourcePluginInstanceGUI(
|
||||
const QString& sourceId,
|
||||
QWidget **widget,
|
||||
DeviceUISet *deviceUISet)
|
||||
{
|
||||
(void) sourceId;
|
||||
(void) widget;
|
||||
(void) deviceUISet;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
PluginInstanceGUI* FileInputPlugin::createSampleSourcePluginInstanceGUI(
|
||||
const QString& sourceId,
|
||||
QWidget **widget,
|
||||
DeviceUISet *deviceUISet)
|
||||
{
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
FileInputGUI* gui = new FileInputGUI(deviceUISet);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DeviceSampleSource *FileInputPlugin::createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if (sourceId == m_deviceTypeID)
|
||||
{
|
||||
FileInput* input = new FileInput(deviceAPI);
|
||||
return input;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILEINPUTPLUGIN_H
|
||||
#define INCLUDE_FILEINPUTPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include "plugin/plugininterface.h"
|
||||
|
||||
#define FILEINPUT_DEVICE_TYPE_ID "sdrangel.samplesource.fileinput"
|
||||
|
||||
class PluginAPI;
|
||||
|
||||
class FileInputPlugin : public QObject, public PluginInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
Q_PLUGIN_METADATA(IID FILEINPUT_DEVICE_TYPE_ID)
|
||||
|
||||
public:
|
||||
explicit FileInputPlugin(QObject* parent = nullptr);
|
||||
|
||||
const PluginDescriptor& getPluginDescriptor() const;
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SamplingDevices enumSampleSources();
|
||||
virtual PluginInstanceGUI* createSampleSourcePluginInstanceGUI(
|
||||
const QString& sourceId,
|
||||
QWidget **widget,
|
||||
DeviceUISet *deviceUISet);
|
||||
virtual DeviceSampleSource* createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI);
|
||||
|
||||
static const QString m_hardwareID;
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
private:
|
||||
static const PluginDescriptor m_pluginDescriptor;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FILESOURCEPLUGIN_H
|
||||
@@ -0,0 +1,150 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 "util/simpleserializer.h"
|
||||
|
||||
#include "fileinputsettings.h"
|
||||
|
||||
const unsigned int FileInputSettings::m_accelerationMaxScale = 2;
|
||||
|
||||
FileInputSettings::FileInputSettings()
|
||||
{
|
||||
resetToDefaults();
|
||||
}
|
||||
|
||||
void FileInputSettings::resetToDefaults()
|
||||
{
|
||||
m_centerFrequency = 435000000;
|
||||
m_sampleRate = 48000;
|
||||
m_fileName = "./test.sdriq";
|
||||
m_accelerationFactor = 1;
|
||||
m_loop = true;
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
m_reverseAPIPort = 8888;
|
||||
m_reverseAPIDeviceIndex = 0;
|
||||
}
|
||||
|
||||
QByteArray FileInputSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
s.writeString(1, m_fileName);
|
||||
s.writeU32(2, m_accelerationFactor);
|
||||
s.writeBool(3, m_loop);
|
||||
s.writeBool(4, m_useReverseAPI);
|
||||
s.writeString(5, m_reverseAPIAddress);
|
||||
s.writeU32(6, m_reverseAPIPort);
|
||||
s.writeU32(7, m_reverseAPIDeviceIndex);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool FileInputSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
if(!d.isValid()) {
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d.getVersion() == 1)
|
||||
{
|
||||
uint32_t uintval;
|
||||
|
||||
d.readString(1, &m_fileName, "./test.sdriq");
|
||||
d.readU32(2, &m_accelerationFactor, 1);
|
||||
d.readBool(3, &m_loop, true);
|
||||
d.readBool(4, &m_useReverseAPI, false);
|
||||
d.readString(5, &m_reverseAPIAddress, "127.0.0.1");
|
||||
d.readU32(6, &uintval, 0);
|
||||
|
||||
if ((uintval > 1023) && (uintval < 65535)) {
|
||||
m_reverseAPIPort = uintval;
|
||||
} else {
|
||||
m_reverseAPIPort = 8888;
|
||||
}
|
||||
|
||||
d.readU32(7, &uintval, 0);
|
||||
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int FileInputSettings::getAccelerationIndex(int accelerationValue)
|
||||
{
|
||||
if (accelerationValue <= 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int v = accelerationValue;
|
||||
int j = 0;
|
||||
|
||||
for (int i = 0; i <= accelerationValue; i++)
|
||||
{
|
||||
if (v < 20)
|
||||
{
|
||||
if (v < 2) {
|
||||
j = 0;
|
||||
} else if (v < 5) {
|
||||
j = 1;
|
||||
} else if (v < 10) {
|
||||
j = 2;
|
||||
} else {
|
||||
j = 3;
|
||||
}
|
||||
|
||||
return 3*i + j;
|
||||
}
|
||||
|
||||
v /= 10;
|
||||
}
|
||||
|
||||
return 3*m_accelerationMaxScale + 3;
|
||||
}
|
||||
|
||||
int FileInputSettings::getAccelerationValue(int accelerationIndex)
|
||||
{
|
||||
if (accelerationIndex <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int v = accelerationIndex - 1;
|
||||
int m = pow(10.0, v/3 > m_accelerationMaxScale ? m_accelerationMaxScale : v/3);
|
||||
int x = 1;
|
||||
|
||||
if (v % 3 == 0) {
|
||||
x = 2;
|
||||
} else if (v % 3 == 1) {
|
||||
x = 5;
|
||||
} else if (v % 3 == 2) {
|
||||
x = 10;
|
||||
}
|
||||
|
||||
return x * m;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_SAMPLESOURCE_FILEINPUT_FILEINPUTSETTINGS_H_
|
||||
#define PLUGINS_SAMPLESOURCE_FILEINPUT_FILEINPUTSETTINGS_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
struct FileInputSettings {
|
||||
quint64 m_centerFrequency;
|
||||
qint32 m_sampleRate;
|
||||
QString m_fileName;
|
||||
quint32 m_accelerationFactor;
|
||||
bool m_loop;
|
||||
bool m_useReverseAPI;
|
||||
QString m_reverseAPIAddress;
|
||||
uint16_t m_reverseAPIPort;
|
||||
uint16_t m_reverseAPIDeviceIndex;
|
||||
|
||||
static const unsigned int m_accelerationMaxScale; //!< Max power of 10 multiplier to 2,5,10 base ex: 2 -> 2,5,10,20,50,100,200,500,1000
|
||||
|
||||
FileInputSettings();
|
||||
~FileInputSettings() {}
|
||||
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
static int getAccelerationIndex(int averaging);
|
||||
static int getAccelerationValue(int averagingIndex);
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_FILEINPUT_FILEINPUTSETTINGS_H_ */
|
||||
@@ -0,0 +1,250 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <QDebug>
|
||||
|
||||
#include "dsp/filerecord.h"
|
||||
#include "fileinputthread.h"
|
||||
#include "dsp/samplesinkfifo.h"
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(FileInputThread::MsgReportEOF, Message)
|
||||
|
||||
FileInputThread::FileInputThread(std::ifstream *samplesStream,
|
||||
SampleSinkFifo* sampleFifo,
|
||||
const QTimer& timer,
|
||||
MessageQueue *fileInputMessageQueue,
|
||||
QObject* parent) :
|
||||
QThread(parent),
|
||||
m_running(false),
|
||||
m_ifstream(samplesStream),
|
||||
m_fileBuf(0),
|
||||
m_convertBuf(0),
|
||||
m_bufsize(0),
|
||||
m_chunksize(0),
|
||||
m_sampleFifo(sampleFifo),
|
||||
m_samplesCount(0),
|
||||
m_timer(timer),
|
||||
m_fileInputMessageQueue(fileInputMessageQueue),
|
||||
m_samplerate(0),
|
||||
m_samplesize(0),
|
||||
m_samplebytes(0),
|
||||
m_throttlems(FILESOURCE_THROTTLE_MS),
|
||||
m_throttleToggle(false)
|
||||
{
|
||||
assert(m_ifstream != 0);
|
||||
}
|
||||
|
||||
FileInputThread::~FileInputThread()
|
||||
{
|
||||
if (m_running) {
|
||||
stopWork();
|
||||
}
|
||||
|
||||
if (m_fileBuf != 0) {
|
||||
free(m_fileBuf);
|
||||
}
|
||||
|
||||
if (m_convertBuf != 0) {
|
||||
free(m_convertBuf);
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputThread::startWork()
|
||||
{
|
||||
qDebug() << "FileInputThread::startWork: ";
|
||||
|
||||
if (m_ifstream->is_open())
|
||||
{
|
||||
qDebug() << "FileInputThread::startWork: file stream open, starting...";
|
||||
m_startWaitMutex.lock();
|
||||
m_elapsedTimer.start();
|
||||
start();
|
||||
while(!m_running)
|
||||
m_startWaiter.wait(&m_startWaitMutex, 100);
|
||||
m_startWaitMutex.unlock();
|
||||
connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "FileInputThread::startWork: file stream closed, not starting.";
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputThread::stopWork()
|
||||
{
|
||||
qDebug() << "FileInputThread::stopWork";
|
||||
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
m_running = false;
|
||||
wait();
|
||||
}
|
||||
|
||||
void FileInputThread::setSampleRateAndSize(int samplerate, quint32 samplesize)
|
||||
{
|
||||
qDebug() << "FileInputThread::setSampleRateAndSize:"
|
||||
<< " new rate:" << samplerate
|
||||
<< " new size:" << samplesize
|
||||
<< " old rate:" << m_samplerate
|
||||
<< " old size:" << m_samplesize;
|
||||
|
||||
if ((samplerate != m_samplerate) || (samplesize != m_samplesize))
|
||||
{
|
||||
if (m_running) {
|
||||
stopWork();
|
||||
}
|
||||
|
||||
m_samplerate = samplerate;
|
||||
m_samplesize = samplesize;
|
||||
m_samplebytes = m_samplesize > 16 ? sizeof(int32_t) : sizeof(int16_t);
|
||||
m_chunksize = (m_samplerate * 2 * m_samplebytes * m_throttlems) / 1000;
|
||||
|
||||
setBuffers(m_chunksize);
|
||||
}
|
||||
|
||||
//m_samplerate = samplerate;
|
||||
}
|
||||
|
||||
void FileInputThread::setBuffers(std::size_t chunksize)
|
||||
{
|
||||
if (chunksize > m_bufsize)
|
||||
{
|
||||
m_bufsize = chunksize;
|
||||
int nbSamples = m_bufsize/(2 * m_samplebytes);
|
||||
|
||||
if (m_fileBuf == 0)
|
||||
{
|
||||
qDebug() << "FileInputThread::setBuffers: Allocate file buffer";
|
||||
m_fileBuf = (quint8*) malloc(m_bufsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "FileInputThread::setBuffers: Re-allocate file buffer";
|
||||
quint8 *buf = m_fileBuf;
|
||||
m_fileBuf = (quint8*) realloc((void*) m_fileBuf, m_bufsize);
|
||||
if (!m_fileBuf) free(buf);
|
||||
}
|
||||
|
||||
if (m_convertBuf == 0)
|
||||
{
|
||||
qDebug() << "FileInputThread::setBuffers: Allocate conversion buffer";
|
||||
m_convertBuf = (quint8*) malloc(nbSamples*sizeof(Sample));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "FileInputThread::setBuffers: Re-allocate conversion buffer";
|
||||
quint8 *buf = m_convertBuf;
|
||||
m_convertBuf = (quint8*) realloc((void*) m_convertBuf, nbSamples*sizeof(Sample));
|
||||
if (!m_convertBuf) free(buf);
|
||||
}
|
||||
|
||||
qDebug() << "FileInputThread::setBuffers: size: " << m_bufsize
|
||||
<< " #samples: " << nbSamples;
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputThread::run()
|
||||
{
|
||||
m_running = true;
|
||||
m_startWaiter.wakeAll();
|
||||
|
||||
while(m_running) // actual work is in the tick() function
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
void FileInputThread::tick()
|
||||
{
|
||||
if (m_running)
|
||||
{
|
||||
qint64 throttlems = m_elapsedTimer.restart();
|
||||
|
||||
if (throttlems != m_throttlems)
|
||||
{
|
||||
m_throttlems = throttlems;
|
||||
m_chunksize = 2 * m_samplebytes * ((m_samplerate * (m_throttlems+(m_throttleToggle ? 1 : 0))) / 1000);
|
||||
m_throttleToggle = !m_throttleToggle;
|
||||
setBuffers(m_chunksize);
|
||||
}
|
||||
|
||||
// read samples directly feeding the SampleFifo (no callback)
|
||||
m_ifstream->read(reinterpret_cast<char*>(m_fileBuf), m_chunksize);
|
||||
|
||||
if (m_ifstream->eof())
|
||||
{
|
||||
writeToSampleFifo(m_fileBuf, (qint32) m_ifstream->gcount());
|
||||
MsgReportEOF *message = MsgReportEOF::create();
|
||||
m_fileInputMessageQueue->push(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeToSampleFifo(m_fileBuf, (qint32) m_chunksize);
|
||||
m_samplesCount += m_chunksize / (2 * m_samplebytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FileInputThread::writeToSampleFifo(const quint8* buf, qint32 nbBytes)
|
||||
{
|
||||
if (m_samplesize == 16)
|
||||
{
|
||||
if (SDR_RX_SAMP_SZ == 16)
|
||||
{
|
||||
m_sampleFifo->write(buf, nbBytes);
|
||||
}
|
||||
else if (SDR_RX_SAMP_SZ == 24)
|
||||
{
|
||||
FixReal *convertBuf = (FixReal *) m_convertBuf;
|
||||
const int16_t *fileBuf = (int16_t *) buf;
|
||||
int nbSamples = nbBytes / (2 * m_samplebytes);
|
||||
|
||||
for (int is = 0; is < nbSamples; is++)
|
||||
{
|
||||
convertBuf[2*is] = fileBuf[2*is] << 8;
|
||||
convertBuf[2*is+1] = fileBuf[2*is+1] << 8;
|
||||
}
|
||||
|
||||
m_sampleFifo->write((quint8*) convertBuf, nbSamples*sizeof(Sample));
|
||||
}
|
||||
}
|
||||
else if (m_samplesize == 24)
|
||||
{
|
||||
if (SDR_RX_SAMP_SZ == 24)
|
||||
{
|
||||
m_sampleFifo->write(buf, nbBytes);
|
||||
}
|
||||
else if (SDR_RX_SAMP_SZ == 16)
|
||||
{
|
||||
FixReal *convertBuf = (FixReal *) m_convertBuf;
|
||||
const int32_t *fileBuf = (int32_t *) buf;
|
||||
int nbSamples = nbBytes / (2 * m_samplebytes);
|
||||
|
||||
for (int is = 0; is < nbSamples; is++)
|
||||
{
|
||||
convertBuf[2*is] = fileBuf[2*is] >> 8;
|
||||
convertBuf[2*is+1] = fileBuf[2*is+1] >> 8;
|
||||
}
|
||||
|
||||
m_sampleFifo->write((quint8*) convertBuf, nbSamples*sizeof(Sample));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILEINPUTTHREAD_H
|
||||
#define INCLUDE_FILEINPUTTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "dsp/inthalfbandfilter.h"
|
||||
#include "util/message.h"
|
||||
|
||||
#define FILESOURCE_THROTTLE_MS 50
|
||||
|
||||
class SampleSinkFifo;
|
||||
class MessageQueue;
|
||||
|
||||
class FileInputThread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
class MsgReportEOF : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
static MsgReportEOF* create() {
|
||||
return new MsgReportEOF();
|
||||
}
|
||||
|
||||
private:
|
||||
MsgReportEOF() :
|
||||
Message()
|
||||
{ }
|
||||
};
|
||||
|
||||
FileInputThread(std::ifstream *samplesStream,
|
||||
SampleSinkFifo* sampleFifo,
|
||||
const QTimer& timer,
|
||||
MessageQueue *fileInputMessageQueue,
|
||||
QObject* parent = NULL);
|
||||
~FileInputThread();
|
||||
|
||||
void startWork();
|
||||
void stopWork();
|
||||
void setSampleRateAndSize(int samplerate, quint32 samplesize);
|
||||
void setBuffers(std::size_t chunksize);
|
||||
bool isRunning() const { return m_running; }
|
||||
quint64 getSamplesCount() const { return m_samplesCount; }
|
||||
void setSamplesCount(quint64 samplesCount) { m_samplesCount = samplesCount; }
|
||||
|
||||
private:
|
||||
QMutex m_startWaitMutex;
|
||||
QWaitCondition m_startWaiter;
|
||||
volatile bool m_running;
|
||||
|
||||
std::ifstream* m_ifstream;
|
||||
quint8 *m_fileBuf;
|
||||
quint8 *m_convertBuf;
|
||||
std::size_t m_bufsize;
|
||||
qint64 m_chunksize;
|
||||
SampleSinkFifo* m_sampleFifo;
|
||||
quint64 m_samplesCount;
|
||||
const QTimer& m_timer;
|
||||
MessageQueue *m_fileInputMessageQueue;
|
||||
|
||||
int m_samplerate; //!< File I/Q stream original sample rate
|
||||
quint64 m_samplesize; //!< File effective sample size in bits (I or Q). Ex: 16, 24.
|
||||
quint64 m_samplebytes; //!< Number of bytes used to store a I or Q sample. Ex: 2. 4.
|
||||
qint64 m_throttlems;
|
||||
QElapsedTimer m_elapsedTimer;
|
||||
bool m_throttleToggle;
|
||||
|
||||
void run();
|
||||
//void decimate1(SampleVector::iterator* it, const qint16* buf, qint32 len);
|
||||
void writeToSampleFifo(const quint8* buf, qint32 nbBytes);
|
||||
|
||||
private slots:
|
||||
void tick();
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FILEINPUTTHREAD_H
|
||||
@@ -0,0 +1,113 @@
|
||||
<h1>File input plugin</h1>
|
||||
|
||||
<h2>Introduction</h2>
|
||||
|
||||
This plugin reads a file of I/Q samples that have been previously saved with the file record button of other sampling source devices. The file starts with a 32 byte header of all unsigned integer of various sizes containing meta data:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Displ.</th>
|
||||
<th>Bytes</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0</td>
|
||||
<td>4</td>
|
||||
<td>Sample rate in S/s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>8</td>
|
||||
<td>Center frequency in Hz</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>12</td>
|
||||
<td>8</td>
|
||||
<td>Unix epoch (timestamp) of start</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>20</td>
|
||||
<td>4</td>
|
||||
<td>Sample size (16 or 24 bits)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24</td>
|
||||
<td>4</td>
|
||||
<td>Filler with zeroes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>28</td>
|
||||
<td>4</td>
|
||||
<td>CRC32 of the previous 28 bytes</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
The header takes an integer number of 16 (4 bytes) or 24 (8 bytes) bits samples. To calculate CRC it is assumed that bytes are in little endian order.
|
||||
|
||||
<h2>Interface</h2>
|
||||
|
||||

|
||||
|
||||
<h3>1: Start/Stop</h3>
|
||||
|
||||
Device start / stop button.
|
||||
|
||||
- Blue triangle icon: ready to be started
|
||||
- Green square icon: currently running and can be stopped
|
||||
- Magenta (or pink) square icon: an error occurred. The file may not be found or this can be a header CRC error or the file is too small (less than the header length). You may stop and choose another file.
|
||||
|
||||
<h3>2: Stream sample rate</h3>
|
||||
|
||||
Baseband I/Q sample rate in kS/s. This is the sample rate present in the header.
|
||||
|
||||
<h3>3: Frequency</h3>
|
||||
|
||||
This is the center frequency of reception in kHz when the record was taken and written in the header.
|
||||
|
||||
<h3>4: Open file</h3>
|
||||
|
||||
Opens a file dialog to select the input file. It expects a default extension of `.sdriq`. This button is disabled when the stream is running. You need to pause (button 11) to make it active and thus be able to select another file.
|
||||
|
||||
<h3>5: File path</h3>
|
||||
|
||||
Absolute path of the file being read
|
||||
|
||||
<h3>6: File recorded sample rate</h3>
|
||||
|
||||
Sample rate of the record in kS/s as written in the header. The reading process is based on this sample rate.
|
||||
|
||||
<h3>7: Sample size</h3>
|
||||
|
||||
This is the sample size in bits as written in the header. The reading process is based on this sample size.
|
||||
|
||||
<h3>8: CRC indicator</h3>
|
||||
|
||||
Indicates if the header block CRC check has succeeded (green) or failed (red) or undetermined yet (grey). If the header is corrupted you may try to reconstruct a valid header using the `rescuesdriq` utility in the folder with the same name. See the [readme](../../../rescuesdriq/readme.md) for details.
|
||||
|
||||
<h3>9: Current timestamp</h3>
|
||||
|
||||
This is the timestamp of the current pointer in the file based on the start time, number of samples read and sample rate.
|
||||
|
||||
<h3>10: Loop</h3>
|
||||
|
||||
Use this button to read in a loop or read only once
|
||||
|
||||
<h3>11: Play/pause</h3>
|
||||
|
||||
This is the play/pause button
|
||||
|
||||
<h3>12: Playback acceleration</h3>
|
||||
|
||||
Use this combo to select play back acceleration to values of 1 (no acceleration), 2, 5, 10, 20, 50, 100, 200, 500, 1k (1000) times. This is useful on long recordings used in conjunction with the spectrum "Max" averaging mode in order to see the waterfall over a long period. Thus the waterfall will be filled much faster.
|
||||
|
||||
☞ Note that this control is enabled only in paused mode.
|
||||
|
||||
⚠ The result when using channel plugins with acceleration is unpredictable. Use this tool to locate your signal of interest then play at normal speed to get proper demodulation or decoding.
|
||||
|
||||
<h3>13: Relative timestamp and record length</h3>
|
||||
|
||||
Left is the relative timestamp of the current pointer from the start of the record. Right is the total record time.
|
||||
|
||||
<h3>14: Current pointer gauge</h3>
|
||||
|
||||
This represents the position of the current pointer position in the complete recording. It can be used it paused mode to position the current pointer by moving the slider.
|
||||
Reference in New Issue
Block a user