mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
FileSource: fixed various issues with settings with GUI and REST API. Fixes issue #481
This commit is contained in:
parent
865f8691e4
commit
afc17ca12b
@ -38,7 +38,6 @@
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(FileSource::MsgSampleRateNotification, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSource::MsgConfigureFileSource, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSource::MsgConfigureFileSourceName, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSource::MsgConfigureFileSourceWork, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSource::MsgConfigureFileSourceStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSource::MsgConfigureFileSourceSeek, Message)
|
||||
@ -134,15 +133,6 @@ bool FileSource::handleMessage(const Message& cmd)
|
||||
applySettings(cfg.getSettings(), cfg.getForce());
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceName::match(cmd))
|
||||
{
|
||||
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) cmd;
|
||||
qDebug() << "FileSource::handleMessage: MsgConfigureFileSourceName:" << conf.getFileName();
|
||||
FileSourceBaseband::MsgConfigureFileSourceName *msg = FileSourceBaseband::MsgConfigureFileSourceName::create(conf.getFileName());
|
||||
m_basebandSource->getInputMessageQueue()->push(msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceWork::match(cmd))
|
||||
{
|
||||
MsgConfigureFileSourceWork& conf = (MsgConfigureFileSourceWork&) cmd;
|
||||
@ -218,17 +208,31 @@ void FileSource::applySettings(const FileSourceSettings& settings, bool force)
|
||||
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
if ((m_settings.m_fileName != settings.m_fileName) || force)
|
||||
{
|
||||
reverseAPIKeys.append("fileName");
|
||||
FileSourceBaseband::MsgConfigureFileSourceName *msg = FileSourceBaseband::MsgConfigureFileSourceName::create(settings.m_fileName);
|
||||
m_basebandSource->getInputMessageQueue()->push(msg);
|
||||
}
|
||||
|
||||
if ((m_settings.m_loop != settings.m_loop) || force) {
|
||||
reverseAPIKeys.append("loop");
|
||||
}
|
||||
if ((m_settings.m_fileName != settings.m_fileName) || force) {
|
||||
reverseAPIKeys.append("fileName");
|
||||
if ((m_settings.m_log2Interp != settings.m_log2Interp) || force) {
|
||||
reverseAPIKeys.append("log2Interp");
|
||||
}
|
||||
if ((m_settings.m_gainDB != settings.m_gainDB) || force)
|
||||
{
|
||||
m_linearGain = CalcDb::powerFromdB(settings.m_gainDB);
|
||||
if ((m_settings.m_filterChainHash != settings.m_filterChainHash) || force) {
|
||||
reverseAPIKeys.append("filterChainHash");
|
||||
}
|
||||
if ((m_settings.m_gainDB != settings.m_gainDB) || force) {
|
||||
reverseAPIKeys.append("gainDB");
|
||||
}
|
||||
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
|
||||
reverseAPIKeys.append("rgbColor");
|
||||
}
|
||||
if ((m_settings.m_title != settings.m_title) || force) {
|
||||
reverseAPIKeys.append("title");
|
||||
}
|
||||
|
||||
if (m_settings.m_streamIndex != settings.m_streamIndex)
|
||||
{
|
||||
@ -317,6 +321,12 @@ void FileSource::webapiUpdateChannelSettings(
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response)
|
||||
{
|
||||
if (channelSettingsKeys.contains("fileName")) {
|
||||
settings.m_fileName = *response.getFileSourceSettings()->getFileName();
|
||||
}
|
||||
if (channelSettingsKeys.contains("loop")) {
|
||||
settings.m_loop = response.getFileSourceSettings()->getLoop() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("log2Interp")) {
|
||||
settings.m_log2Interp = response.getFileSourceSettings()->getLog2Interp();
|
||||
}
|
||||
@ -327,15 +337,15 @@ void FileSource::webapiUpdateChannelSettings(
|
||||
validateFilterChainHash(settings);
|
||||
}
|
||||
|
||||
if (channelSettingsKeys.contains("gainDB")) {
|
||||
settings.m_gainDB = response.getFileSourceSettings()->getGainDb();
|
||||
}
|
||||
if (channelSettingsKeys.contains("rgbColor")) {
|
||||
settings.m_rgbColor = response.getFileSourceSettings()->getRgbColor();
|
||||
}
|
||||
if (channelSettingsKeys.contains("title")) {
|
||||
settings.m_title = *response.getFileSourceSettings()->getTitle();
|
||||
}
|
||||
if (channelSettingsKeys.contains("gainDB")) {
|
||||
settings.m_gainDB = response.getFileSourceSettings()->getGainDb();
|
||||
}
|
||||
if (channelSettingsKeys.contains("streamIndex")) {
|
||||
settings.m_streamIndex = response.getFileSourceSettings()->getStreamIndex();
|
||||
}
|
||||
@ -369,6 +379,13 @@ int FileSource::webapiReportGet(
|
||||
|
||||
void FileSource::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const FileSourceSettings& settings)
|
||||
{
|
||||
if (response.getFileSourceSettings()->getFileName()) {
|
||||
*response.getFileSourceSettings()->getFileName() = settings.m_fileName;
|
||||
} else {
|
||||
response.getFileSourceSettings()->setFileName(new QString(settings.m_fileName));
|
||||
}
|
||||
|
||||
response.getFileSourceSettings()->setLoop(settings.m_loop ? 1 : 0);
|
||||
response.getFileSourceSettings()->setLog2Interp(settings.m_log2Interp);
|
||||
response.getFileSourceSettings()->setFilterChainHash(settings.m_filterChainHash);
|
||||
response.getFileSourceSettings()->setGainDb(settings.m_gainDB);
|
||||
|
@ -88,26 +88,6 @@ public:
|
||||
int m_sampleRate;
|
||||
};
|
||||
|
||||
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 MsgConfigureFileSourceWork : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
|
@ -100,6 +100,7 @@ bool FileSourceGUI::handleMessage(const Message& message)
|
||||
{
|
||||
const FileSource::MsgConfigureFileSource& cfg = (FileSource::MsgConfigureFileSource&) message;
|
||||
m_settings = cfg.getSettings();
|
||||
m_fileName = m_settings.m_fileName;
|
||||
blockApplySettings(true);
|
||||
displaySettings();
|
||||
blockApplySettings(false);
|
||||
@ -183,6 +184,7 @@ FileSourceGUI::FileSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas
|
||||
m_fileSource = (FileSource*) channelTx;
|
||||
m_fileSource->setMessageQueueToGUI(getInputMessageQueue());
|
||||
m_fileSource->propagateMessageQueueToGUI();
|
||||
m_fileName = m_settings.m_fileName;
|
||||
|
||||
connect(&(m_deviceUISet->m_deviceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
||||
|
||||
@ -236,8 +238,8 @@ void FileSourceGUI::applySettings(bool force)
|
||||
void FileSourceGUI::configureFileName()
|
||||
{
|
||||
qDebug() << "FileSourceGui::configureFileName: " << m_fileName.toStdString().c_str();
|
||||
FileSource::MsgConfigureFileSourceName* message = FileSource::MsgConfigureFileSourceName::create(m_fileName);
|
||||
m_fileSource->getInputMessageQueue()->push(message);
|
||||
m_settings.m_fileName = m_fileName;
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void FileSourceGUI::updateWithAcquisition()
|
||||
@ -304,6 +306,7 @@ void FileSourceGUI::displaySettings()
|
||||
displayStreamIndex();
|
||||
|
||||
blockApplySettings(true);
|
||||
ui->fileNameText->setText(m_fileName);
|
||||
ui->gain->setValue(m_settings.m_gainDB);
|
||||
ui->gainText->setText(tr("%1 dB").arg(m_settings.m_gainDB));
|
||||
ui->interpolationFactor->setCurrentIndex(m_settings.m_log2Interp);
|
||||
|
@ -279,5 +279,10 @@ void FileSourceSource::applySettings(const FileSourceSettings& settings, bool fo
|
||||
<< "m_filterChainHash:" << settings.m_filterChainHash
|
||||
<< " force: " << force;
|
||||
|
||||
|
||||
if ((m_settings.m_gainDB != settings.m_gainDB) || force) {
|
||||
m_linearGain = CalcDb::powerFromdB(settings.m_gainDB/2.0); // Divide by two for power gain to voltage gain conversion
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user