mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 08:04:49 -05:00
Allow filename to be restored from settings.
Allow filename to be set via API.
This commit is contained in:
parent
2389f0d55c
commit
bf9d5501b0
@ -54,7 +54,6 @@ FileInput::FileInput(DeviceAPI *deviceAPI) :
|
||||
m_settings(),
|
||||
m_fileInputWorker(nullptr),
|
||||
m_deviceDescription(),
|
||||
m_fileName("..."),
|
||||
m_sampleRate(48000),
|
||||
m_sampleSize(0),
|
||||
m_centerFrequency(435000000),
|
||||
@ -94,9 +93,9 @@ void FileInput::openFileStream()
|
||||
}
|
||||
|
||||
#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
|
||||
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
|
||||
quint64 fileSize = m_ifstream.tellg();
|
||||
|
||||
@ -133,7 +132,7 @@ void FileInput::openFileStream()
|
||||
m_recordLengthMuSec = 0;
|
||||
}
|
||||
|
||||
qDebug() << "FileInput::openFileStream: " << m_fileName.toStdString().c_str()
|
||||
qDebug() << "FileInput::openFileStream: " << m_settings.m_fileName.toStdString().c_str()
|
||||
<< " fileSize: " << fileSize << " bytes"
|
||||
<< " length: " << m_recordLengthMuSec << " microseconds"
|
||||
<< " sample rate: " << m_sampleRate << " S/s"
|
||||
@ -329,7 +328,7 @@ bool FileInput::handleMessage(const Message& message)
|
||||
else if (MsgConfigureFileSourceName::match(message))
|
||||
{
|
||||
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) message;
|
||||
m_fileName = conf.getFileName();
|
||||
m_settings.m_fileName = conf.getFileName();
|
||||
openFileStream();
|
||||
return true;
|
||||
}
|
||||
@ -463,6 +462,11 @@ bool FileInput::applySettings(const FileInputSettings& settings, bool force)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -616,7 +620,7 @@ void FileInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
||||
recordLength = recordLength.addMSecs(m_recordLengthMuSec / 1000UL);
|
||||
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()->setSampleSize(m_sampleSize);
|
||||
}
|
||||
|
@ -336,7 +336,6 @@ public:
|
||||
FileInputWorker* m_fileInputWorker;
|
||||
QThread m_fileInputWorkerThread;
|
||||
QString m_deviceDescription;
|
||||
QString m_fileName;
|
||||
int m_sampleRate;
|
||||
quint32 m_sampleSize;
|
||||
quint64 m_centerFrequency;
|
||||
|
@ -46,7 +46,6 @@ FileInputGUI::FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
m_doApplySettings(true),
|
||||
m_sampleSource(0),
|
||||
m_acquisition(false),
|
||||
m_fileName("..."),
|
||||
m_sampleRate(0),
|
||||
m_centerFrequency(0),
|
||||
m_recordLengthMuSec(0),
|
||||
@ -59,7 +58,6 @@ FileInputGUI::FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
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()));
|
||||
@ -221,6 +219,12 @@ void FileInputGUI::displaySettings()
|
||||
blockApplySettings(true);
|
||||
ui->playLoop->setChecked(m_settings.m_loop);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -302,8 +306,8 @@ void FileInputGUI::on_showFileDialog_clicked(bool checked)
|
||||
|
||||
if (fileName != "")
|
||||
{
|
||||
m_fileName = fileName;
|
||||
ui->fileNameText->setText(m_fileName);
|
||||
m_settings.m_fileName = fileName;
|
||||
ui->fileNameText->setText(m_settings.m_fileName);
|
||||
ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
||||
configureFileName();
|
||||
}
|
||||
@ -321,8 +325,8 @@ void FileInputGUI::on_acceleration_currentIndexChanged(int index)
|
||||
|
||||
void FileInputGUI::configureFileName()
|
||||
{
|
||||
qDebug() << "FileInputGUI::configureFileName: " << m_fileName.toStdString().c_str();
|
||||
FileInput::MsgConfigureFileSourceName* message = FileInput::MsgConfigureFileSourceName::create(m_fileName);
|
||||
qDebug() << "FileInputGUI::configureFileName: " << m_settings.m_fileName.toStdString().c_str();
|
||||
FileInput::MsgConfigureFileSourceName* message = FileInput::MsgConfigureFileSourceName::create(m_settings.m_fileName);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,6 @@ private:
|
||||
std::vector<int> m_gains;
|
||||
DeviceSampleSource* m_sampleSource;
|
||||
bool m_acquisition;
|
||||
QString m_fileName;
|
||||
int m_sampleRate;
|
||||
quint32 m_sampleSize;
|
||||
quint64 m_centerFrequency;
|
||||
|
@ -15,6 +15,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QDebug>
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
#include "fileinputsettings.h"
|
||||
@ -28,7 +29,7 @@ FileInputSettings::FileInputSettings()
|
||||
|
||||
void FileInputSettings::resetToDefaults()
|
||||
{
|
||||
m_fileName = "./test.sdriq";
|
||||
m_fileName = "";
|
||||
m_accelerationFactor = 1;
|
||||
m_loop = true;
|
||||
m_useReverseAPI = false;
|
||||
@ -64,7 +65,7 @@ bool FileInputSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
uint32_t uintval;
|
||||
|
||||
d.readString(1, &m_fileName, "./test.sdriq");
|
||||
d.readString(1, &m_fileName, "");
|
||||
d.readU32(2, &m_accelerationFactor, 1);
|
||||
d.readBool(3, &m_loop, true);
|
||||
d.readBool(4, &m_useReverseAPI, false);
|
||||
|
Loading…
Reference in New Issue
Block a user