mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 13:51:47 -05:00
Merge pull request #798 from srcejon/file_input_filename_handling
File Input source filename settings
This commit is contained in:
commit
07b621b2c5
@ -54,7 +54,6 @@ FileInput::FileInput(DeviceAPI *deviceAPI) :
|
|||||||
m_settings(),
|
m_settings(),
|
||||||
m_fileInputWorker(nullptr),
|
m_fileInputWorker(nullptr),
|
||||||
m_deviceDescription(),
|
m_deviceDescription(),
|
||||||
m_fileName("..."),
|
|
||||||
m_sampleRate(48000),
|
m_sampleRate(48000),
|
||||||
m_sampleSize(0),
|
m_sampleSize(0),
|
||||||
m_centerFrequency(435000000),
|
m_centerFrequency(435000000),
|
||||||
@ -94,9 +93,9 @@ void FileInput::openFileStream()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
m_ifstream.open(m_fileName.toStdWString().c_str(), std::ios::binary | std::ios::ate);
|
m_ifstream.open(m_settings.m_fileName.toStdWString().c_str(), std::ios::binary | std::ios::ate);
|
||||||
#else
|
#else
|
||||||
m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
|
m_ifstream.open(m_settings.m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
|
||||||
#endif
|
#endif
|
||||||
quint64 fileSize = m_ifstream.tellg();
|
quint64 fileSize = m_ifstream.tellg();
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ void FileInput::openFileStream()
|
|||||||
m_recordLengthMuSec = 0;
|
m_recordLengthMuSec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "FileInput::openFileStream: " << m_fileName.toStdString().c_str()
|
qDebug() << "FileInput::openFileStream: " << m_settings.m_fileName.toStdString().c_str()
|
||||||
<< " fileSize: " << fileSize << " bytes"
|
<< " fileSize: " << fileSize << " bytes"
|
||||||
<< " length: " << m_recordLengthMuSec << " microseconds"
|
<< " length: " << m_recordLengthMuSec << " microseconds"
|
||||||
<< " sample rate: " << m_sampleRate << " S/s"
|
<< " sample rate: " << m_sampleRate << " S/s"
|
||||||
@ -329,7 +328,7 @@ bool FileInput::handleMessage(const Message& message)
|
|||||||
else if (MsgConfigureFileSourceName::match(message))
|
else if (MsgConfigureFileSourceName::match(message))
|
||||||
{
|
{
|
||||||
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) message;
|
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) message;
|
||||||
m_fileName = conf.getFileName();
|
m_settings.m_fileName = conf.getFileName();
|
||||||
openFileStream();
|
openFileStream();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -463,6 +462,11 @@ bool FileInput::applySettings(const FileInputSettings& settings, bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
|
||||||
|
// Open the file if there isn't a GUI which will open it
|
||||||
|
if ((m_guiMessageQueue == nullptr) && reverseAPIKeys.contains("fileName") && !m_settings.m_fileName.isEmpty())
|
||||||
|
openFileStream();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +620,7 @@ void FileInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
|||||||
recordLength = recordLength.addMSecs(m_recordLengthMuSec / 1000UL);
|
recordLength = recordLength.addMSecs(m_recordLengthMuSec / 1000UL);
|
||||||
response.getFileInputReport()->setDurationTime(new QString(recordLength.toString("HH:mm:ss.zzz")));
|
response.getFileInputReport()->setDurationTime(new QString(recordLength.toString("HH:mm:ss.zzz")));
|
||||||
|
|
||||||
response.getFileInputReport()->setFileName(new QString(m_fileName));
|
response.getFileInputReport()->setFileName(new QString(m_settings.m_fileName));
|
||||||
response.getFileInputReport()->setSampleRate(m_sampleRate);
|
response.getFileInputReport()->setSampleRate(m_sampleRate);
|
||||||
response.getFileInputReport()->setSampleSize(m_sampleSize);
|
response.getFileInputReport()->setSampleSize(m_sampleSize);
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,6 @@ public:
|
|||||||
FileInputWorker* m_fileInputWorker;
|
FileInputWorker* m_fileInputWorker;
|
||||||
QThread m_fileInputWorkerThread;
|
QThread m_fileInputWorkerThread;
|
||||||
QString m_deviceDescription;
|
QString m_deviceDescription;
|
||||||
QString m_fileName;
|
|
||||||
int m_sampleRate;
|
int m_sampleRate;
|
||||||
quint32 m_sampleSize;
|
quint32 m_sampleSize;
|
||||||
quint64 m_centerFrequency;
|
quint64 m_centerFrequency;
|
||||||
|
@ -46,7 +46,6 @@ FileInputGUI::FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
|
|||||||
m_doApplySettings(true),
|
m_doApplySettings(true),
|
||||||
m_sampleSource(0),
|
m_sampleSource(0),
|
||||||
m_acquisition(false),
|
m_acquisition(false),
|
||||||
m_fileName("..."),
|
|
||||||
m_sampleRate(0),
|
m_sampleRate(0),
|
||||||
m_centerFrequency(0),
|
m_centerFrequency(0),
|
||||||
m_recordLengthMuSec(0),
|
m_recordLengthMuSec(0),
|
||||||
@ -59,7 +58,6 @@ FileInputGUI::FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||||
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
|
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
|
||||||
ui->fileNameText->setText(m_fileName);
|
|
||||||
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
||||||
|
|
||||||
connect(&(m_deviceUISet->m_deviceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
connect(&(m_deviceUISet->m_deviceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
||||||
@ -221,6 +219,12 @@ void FileInputGUI::displaySettings()
|
|||||||
blockApplySettings(true);
|
blockApplySettings(true);
|
||||||
ui->playLoop->setChecked(m_settings.m_loop);
|
ui->playLoop->setChecked(m_settings.m_loop);
|
||||||
ui->acceleration->setCurrentIndex(FileInputSettings::getAccelerationIndex(m_settings.m_accelerationFactor));
|
ui->acceleration->setCurrentIndex(FileInputSettings::getAccelerationIndex(m_settings.m_accelerationFactor));
|
||||||
|
if (!m_settings.m_fileName.isEmpty() && (m_settings.m_fileName != ui->fileNameText->text()))
|
||||||
|
{
|
||||||
|
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
||||||
|
configureFileName();
|
||||||
|
}
|
||||||
|
ui->fileNameText->setText(m_settings.m_fileName);
|
||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,8 +306,8 @@ void FileInputGUI::on_showFileDialog_clicked(bool checked)
|
|||||||
|
|
||||||
if (fileName != "")
|
if (fileName != "")
|
||||||
{
|
{
|
||||||
m_fileName = fileName;
|
m_settings.m_fileName = fileName;
|
||||||
ui->fileNameText->setText(m_fileName);
|
ui->fileNameText->setText(m_settings.m_fileName);
|
||||||
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
||||||
configureFileName();
|
configureFileName();
|
||||||
}
|
}
|
||||||
@ -321,8 +325,8 @@ void FileInputGUI::on_acceleration_currentIndexChanged(int index)
|
|||||||
|
|
||||||
void FileInputGUI::configureFileName()
|
void FileInputGUI::configureFileName()
|
||||||
{
|
{
|
||||||
qDebug() << "FileInputGUI::configureFileName: " << m_fileName.toStdString().c_str();
|
qDebug() << "FileInputGUI::configureFileName: " << m_settings.m_fileName.toStdString().c_str();
|
||||||
FileInput::MsgConfigureFileSourceName* message = FileInput::MsgConfigureFileSourceName::create(m_fileName);
|
FileInput::MsgConfigureFileSourceName* message = FileInput::MsgConfigureFileSourceName::create(m_settings.m_fileName);
|
||||||
m_sampleSource->getInputMessageQueue()->push(message);
|
m_sampleSource->getInputMessageQueue()->push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ private:
|
|||||||
std::vector<int> m_gains;
|
std::vector<int> m_gains;
|
||||||
DeviceSampleSource* m_sampleSource;
|
DeviceSampleSource* m_sampleSource;
|
||||||
bool m_acquisition;
|
bool m_acquisition;
|
||||||
QString m_fileName;
|
|
||||||
int m_sampleRate;
|
int m_sampleRate;
|
||||||
quint32 m_sampleSize;
|
quint32 m_sampleSize;
|
||||||
quint64 m_centerFrequency;
|
quint64 m_centerFrequency;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
|
|
||||||
#include "fileinputsettings.h"
|
#include "fileinputsettings.h"
|
||||||
@ -28,7 +29,7 @@ FileInputSettings::FileInputSettings()
|
|||||||
|
|
||||||
void FileInputSettings::resetToDefaults()
|
void FileInputSettings::resetToDefaults()
|
||||||
{
|
{
|
||||||
m_fileName = "./test.sdriq";
|
m_fileName = "";
|
||||||
m_accelerationFactor = 1;
|
m_accelerationFactor = 1;
|
||||||
m_loop = true;
|
m_loop = true;
|
||||||
m_useReverseAPI = false;
|
m_useReverseAPI = false;
|
||||||
@ -64,7 +65,7 @@ bool FileInputSettings::deserialize(const QByteArray& data)
|
|||||||
{
|
{
|
||||||
uint32_t uintval;
|
uint32_t uintval;
|
||||||
|
|
||||||
d.readString(1, &m_fileName, "./test.sdriq");
|
d.readString(1, &m_fileName, "");
|
||||||
d.readU32(2, &m_accelerationFactor, 1);
|
d.readU32(2, &m_accelerationFactor, 1);
|
||||||
d.readBool(3, &m_loop, true);
|
d.readBool(3, &m_loop, true);
|
||||||
d.readBool(4, &m_useReverseAPI, false);
|
d.readBool(4, &m_useReverseAPI, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user