1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Interferometer: list local input devices and make update settings atomic

This commit is contained in:
f4exb 2024-05-12 03:52:19 +02:00
parent dae5a9174b
commit 40d7fece02
7 changed files with 363 additions and 67 deletions

View File

@ -28,6 +28,9 @@
#include "device/deviceapi.h" #include "device/deviceapi.h"
#include "dsp/hbfilterchainconverter.h" #include "dsp/hbfilterchainconverter.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/dspdevicesourceengine.h"
#include "dsp/devicesamplesource.h"
#include "device/deviceset.h"
#include "maincore.h" #include "maincore.h"
#include "interferometerbaseband.h" #include "interferometerbaseband.h"
@ -35,6 +38,7 @@
MESSAGE_CLASS_DEFINITION(Interferometer::MsgConfigureInterferometer, Message) MESSAGE_CLASS_DEFINITION(Interferometer::MsgConfigureInterferometer, Message)
MESSAGE_CLASS_DEFINITION(Interferometer::MsgBasebandNotification, Message) MESSAGE_CLASS_DEFINITION(Interferometer::MsgBasebandNotification, Message)
MESSAGE_CLASS_DEFINITION(Interferometer::MsgReportDevices, Message)
const char* const Interferometer::m_channelIdURI = "sdrangel.channel.interferometer"; const char* const Interferometer::m_channelIdURI = "sdrangel.channel.interferometer";
const char* const Interferometer::m_channelId = "Interferometer"; const char* const Interferometer::m_channelId = "Interferometer";
@ -63,6 +67,20 @@ Interferometer::Interferometer(DeviceAPI *deviceAPI) :
this, this,
&Interferometer::networkManagerFinished &Interferometer::networkManagerFinished
); );
// Update device list when devices are added or removed
QObject::connect(
MainCore::instance(),
&MainCore::deviceSetAdded,
this,
&Interferometer::updateDeviceSetList
);
QObject::connect(
MainCore::instance(),
&MainCore::deviceSetRemoved,
this,
&Interferometer::updateDeviceSetList
);
updateDeviceSetList();
startSinks(); startSinks();
} }
@ -155,62 +173,30 @@ void Interferometer::pull(SampleVector::iterator& begin, unsigned int nbSamples,
(void) sourceIndex; (void) sourceIndex;
} }
void Interferometer::applySettings(const InterferometerSettings& settings, bool force) void Interferometer::applySettings(const InterferometerSettings& settings, const QList<QString>& settingsKeys, bool force)
{ {
qDebug() << "Interferometer::applySettings: " qDebug() << "LocalSink::applySettings:" << settings.getDebugString(settingsKeys, force) << "force: " << force;
<< "m_correlationType: " << settings.m_correlationType
<< "m_filterChainHash: " << settings.m_filterChainHash
<< "m_log2Decim: " << settings.m_log2Decim
<< "m_phase: " << settings.m_phase
<< "m_gain: " << settings.m_gain / 10.0
<< "m_useReverseAPI: " << settings.m_useReverseAPI
<< "m_reverseAPIAddress: " << settings.m_reverseAPIAddress
<< "m_reverseAPIPort: " << settings.m_reverseAPIPort
<< "m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
<< "m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
<< "m_title: " << settings.m_title;
QList<QString> reverseAPIKeys; if (m_running && (settingsKeys.contains("log2Decim")
|| settingsKeys.contains("filterChainHash") || force))
if ((m_settings.m_correlationType != settings.m_correlationType) || force) {
reverseAPIKeys.append("correlationType");
}
if ((m_settings.m_filterChainHash != settings.m_filterChainHash) || force) {
reverseAPIKeys.append("filterChainHash");
}
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) {
reverseAPIKeys.append("log2Decim");
}
if ((m_settings.m_phase != settings.m_phase) || force) {
reverseAPIKeys.append("phase");
}
if ((m_settings.m_phase != settings.m_gain) || force) {
reverseAPIKeys.append("gain");
}
if ((m_settings.m_title != settings.m_title) || force) {
reverseAPIKeys.append("title");
}
if (m_running && ((m_settings.m_log2Decim != settings.m_log2Decim)
|| (m_settings.m_filterChainHash != settings.m_filterChainHash) || force))
{ {
InterferometerBaseband::MsgConfigureChannelizer *msg = InterferometerBaseband::MsgConfigureChannelizer::create( InterferometerBaseband::MsgConfigureChannelizer *msg = InterferometerBaseband::MsgConfigureChannelizer::create(
settings.m_log2Decim, settings.m_filterChainHash); settings.m_log2Decim, settings.m_filterChainHash);
m_basebandSink->getInputMessageQueue()->push(msg); m_basebandSink->getInputMessageQueue()->push(msg);
} }
if (m_running && ((m_settings.m_correlationType != settings.m_correlationType) || force)) if (m_running && ((settingsKeys.contains("correlationType")) || force))
{ {
InterferometerBaseband::MsgConfigureCorrelation *msg = InterferometerBaseband::MsgConfigureCorrelation::create( InterferometerBaseband::MsgConfigureCorrelation *msg = InterferometerBaseband::MsgConfigureCorrelation::create(
settings.m_correlationType); settings.m_correlationType);
m_basebandSink->getInputMessageQueue()->push(msg); m_basebandSink->getInputMessageQueue()->push(msg);
} }
if (m_running && ((m_settings.m_phase != settings.m_phase) || force)) { if (m_running && ((settingsKeys.contains("phase")) || force)) {
m_basebandSink->setPhase(settings.m_phase); m_basebandSink->setPhase(settings.m_phase);
} }
if (m_running && ((m_settings.m_gain != settings.m_gain) || force)) { if (m_running && ((settingsKeys.contains("gain")) || force)) {
m_basebandSink->setGain(settings.m_gain); m_basebandSink->setGain(settings.m_gain);
} }
@ -218,10 +204,24 @@ void Interferometer::applySettings(const InterferometerSettings& settings, bool
MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes); MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes);
if (pipes.size() > 0) { if (pipes.size() > 0) {
sendChannelSettings(pipes, reverseAPIKeys, settings, force); sendChannelSettings(pipes, settingsKeys, settings, force);
} }
m_settings = settings; if (settings.m_useReverseAPI)
{
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
settingsKeys.contains("reverseAPIAddress") ||
settingsKeys.contains("reverseAPIPort") ||
settingsKeys.contains("reverseAPIFeatureSetIndex") ||
settingsKeys.contains("reverseAPIFeatureIndex");
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
}
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
} }
void Interferometer::handleInputMessages() void Interferometer::handleInputMessages()
@ -243,7 +243,7 @@ bool Interferometer::handleMessage(const Message& cmd)
{ {
MsgConfigureInterferometer& cfg = (MsgConfigureInterferometer&) cmd; MsgConfigureInterferometer& cfg = (MsgConfigureInterferometer&) cmd;
qDebug() << "Interferometer::handleMessage: MsgConfigureInterferometer"; qDebug() << "Interferometer::handleMessage: MsgConfigureInterferometer";
applySettings(cfg.getSettings(), cfg.getForce()); applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
return true; return true;
} }
else if (DSPMIMOSignalNotification::match(cmd)) else if (DSPMIMOSignalNotification::match(cmd))
@ -298,14 +298,14 @@ bool Interferometer::deserialize(const QByteArray& data)
(void) data; (void) data;
if (m_settings.deserialize(data)) if (m_settings.deserialize(data))
{ {
MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(m_settings, true); MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
return true; return true;
} }
else else
{ {
m_settings.resetToDefaults(); m_settings.resetToDefaults();
MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(m_settings, true); MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
return false; return false;
} }
@ -338,6 +338,70 @@ void Interferometer::applyChannelSettings(uint32_t log2Decim, uint32_t filterCha
m_basebandSink->getInputMessageQueue()->push(msg); m_basebandSink->getInputMessageQueue()->push(msg);
} }
void Interferometer::updateDeviceSetList()
{
MainCore *mainCore = MainCore::instance();
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
m_localInputDeviceIndexes.clear();
unsigned int deviceIndex = 0;
for (; it != deviceSets.end(); ++it, deviceIndex++)
{
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
if (deviceSourceEngine)
{
DeviceSampleSource *deviceSource = deviceSourceEngine->getSource();
if (deviceSource->getDeviceDescription() == "LocalInput") {
m_localInputDeviceIndexes.append(deviceIndex);
}
}
}
if (m_guiMessageQueue)
{
MsgReportDevices *msg = MsgReportDevices::create();
msg->getDeviceSetIndexes() = m_localInputDeviceIndexes;
m_guiMessageQueue->push(msg);
}
InterferometerSettings settings = m_settings;
int newIndexInList;
if (it != deviceSets.begin())
{
if (m_settings.m_localDeviceIndex < 0) {
newIndexInList = 0;
} else if (m_settings.m_localDeviceIndex >= m_localInputDeviceIndexes.size()) {
newIndexInList = m_localInputDeviceIndexes.size() - 1;
} else {
newIndexInList = m_settings.m_localDeviceIndex;
}
}
else
{
newIndexInList = -1;
}
if (newIndexInList < 0) {
settings.m_localDeviceIndex = -1; // means no device
} else {
settings.m_localDeviceIndex = m_localInputDeviceIndexes[newIndexInList];
}
qDebug("LocalSink::updateDeviceSetLists: new device index: %d device: %d", newIndexInList, settings.m_localDeviceIndex);
applySettings(settings, QList<QString>{"localDeviceIndex"});
if (m_guiMessageQueue)
{
MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(m_settings, QList<QString>{"localDeviceIndex"}, false);
m_guiMessageQueue->push(msg);
}
}
int Interferometer::webapiSettingsGet( int Interferometer::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage) QString& errorMessage)
@ -368,12 +432,12 @@ int Interferometer::webapiSettingsPutPatch(
InterferometerSettings settings = m_settings; InterferometerSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response); webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(settings, force); MsgConfigureInterferometer *msg = MsgConfigureInterferometer::create(settings, channelSettingsKeys, force);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
if (getMessageQueueToGUI()) // forward to GUI if any if (getMessageQueueToGUI()) // forward to GUI if any
{ {
MsgConfigureInterferometer *msgToGUI = MsgConfigureInterferometer::create(settings, force); MsgConfigureInterferometer *msgToGUI = MsgConfigureInterferometer::create(settings, channelSettingsKeys, force);
getMessageQueueToGUI()->push(msgToGUI); getMessageQueueToGUI()->push(msgToGUI);
} }
@ -521,7 +585,7 @@ void Interferometer::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings
} }
} }
void Interferometer::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const InterferometerSettings& settings, bool force) void Interferometer::webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const InterferometerSettings& settings, bool force)
{ {
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force); webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
@ -548,7 +612,7 @@ void Interferometer::webapiReverseSendSettings(QList<QString>& channelSettingsKe
void Interferometer::sendChannelSettings( void Interferometer::sendChannelSettings(
const QList<ObjectPipe*>& pipes, const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
const InterferometerSettings& settings, const InterferometerSettings& settings,
bool force) bool force)
{ {
@ -572,7 +636,7 @@ void Interferometer::sendChannelSettings(
} }
void Interferometer::webapiFormatChannelSettings( void Interferometer::webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings, SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const InterferometerSettings& settings, const InterferometerSettings& settings,
bool force bool force
@ -606,18 +670,18 @@ void Interferometer::webapiFormatChannelSettings(
swgInterferometerSettings->setFilterChainHash(settings.m_filterChainHash); swgInterferometerSettings->setFilterChainHash(settings.m_filterChainHash);
} }
if (settings.m_spectrumGUI) if (settings.m_spectrumGUI && (channelSettingsKeys.contains("spectrumConfig") || force))
{ {
if (channelSettingsKeys.contains("spectrumConfig") || force) { SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
settings.m_spectrumGUI->formatTo(swgInterferometerSettings->getSpectrumConfig()); settings.m_spectrumGUI->formatTo(swgGLSpectrum);
} swgInterferometerSettings->setSpectrumConfig(swgGLSpectrum);
} }
if (settings.m_scopeGUI) if (settings.m_scopeGUI && (channelSettingsKeys.contains("scopeConfig") || force))
{ {
if (channelSettingsKeys.contains("scopeConfig") || force) { SWGSDRangel::SWGGLScope *swgGLScope = new SWGSDRangel::SWGGLScope();
settings.m_scopeGUI->formatTo(swgInterferometerSettings->getScopeConfig()); settings.m_scopeGUI->formatTo(swgGLScope);
} swgInterferometerSettings->setScopeConfig(swgGLScope);
} }
if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force)) if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))

View File

@ -45,20 +45,23 @@ public:
public: public:
const InterferometerSettings& getSettings() const { return m_settings; } const InterferometerSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; } bool getForce() const { return m_force; }
static MsgConfigureInterferometer* create(const InterferometerSettings& settings, bool force) static MsgConfigureInterferometer* create(const InterferometerSettings& settings, const QList<QString>& settingsKeys, bool force)
{ {
return new MsgConfigureInterferometer(settings, force); return new MsgConfigureInterferometer(settings, settingsKeys, force);
} }
private: private:
InterferometerSettings m_settings; InterferometerSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force; bool m_force;
MsgConfigureInterferometer(const InterferometerSettings& settings, bool force) : MsgConfigureInterferometer(const InterferometerSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(), Message(),
m_settings(settings), m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force) m_force(force)
{ } { }
}; };
@ -86,6 +89,24 @@ public:
qint64 m_centerFrequency; qint64 m_centerFrequency;
}; };
class MsgReportDevices : public Message {
MESSAGE_CLASS_DECLARATION
public:
QList<int>& getDeviceSetIndexes() { return m_deviceSetIndexes; }
static MsgReportDevices* create() {
return new MsgReportDevices();
}
private:
QList<int> m_deviceSetIndexes;
MsgReportDevices() :
Message()
{ }
};
Interferometer(DeviceAPI *deviceAPI); Interferometer(DeviceAPI *deviceAPI);
virtual ~Interferometer(); virtual ~Interferometer();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
@ -128,6 +149,7 @@ public:
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
ScopeVis *getScopeVis() { return &m_scopeSink; } ScopeVis *getScopeVis() { return &m_scopeSink; }
void applyChannelSettings(uint32_t log2Decim, uint32_t filterChainHash); void applyChannelSettings(uint32_t log2Decim, uint32_t filterChainHash);
const QList<int>& getDeviceSetList() { return m_localInputDeviceIndexes; }
virtual int webapiSettingsGet( virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
@ -174,19 +196,22 @@ private:
uint32_t m_deviceSampleRate; uint32_t m_deviceSampleRate;
int m_count0, m_count1; int m_count0, m_count1;
QList<int> m_localInputDeviceIndexes;
virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
void applySettings(const InterferometerSettings& settings, bool force = false); void applySettings(const InterferometerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
static void validateFilterChainHash(InterferometerSettings& settings); static void validateFilterChainHash(InterferometerSettings& settings);
void calculateFrequencyOffset(); void calculateFrequencyOffset();
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const InterferometerSettings& settings, bool force); void updateDeviceSetList();
void webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const InterferometerSettings& settings, bool force);
void sendChannelSettings( void sendChannelSettings(
const QList<ObjectPipe*>& pipes, const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
const InterferometerSettings& settings, const InterferometerSettings& settings,
bool force bool force
); );
void webapiFormatChannelSettings( void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys, const QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings, SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const InterferometerSettings& settings, const InterferometerSettings& settings,
bool force bool force

View File

@ -86,14 +86,26 @@ bool InterferometerGUI::handleMessage(const Message& message)
} }
else if (Interferometer::MsgConfigureInterferometer::match(message)) else if (Interferometer::MsgConfigureInterferometer::match(message))
{ {
const Interferometer::MsgConfigureInterferometer& notif = (const Interferometer::MsgConfigureInterferometer&) message; const Interferometer::MsgConfigureInterferometer& cfg = (const Interferometer::MsgConfigureInterferometer&) message;
m_settings = notif.getSettings();
if (cfg.getForce()) {
m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}
ui->scopeGUI->updateSettings(); ui->scopeGUI->updateSettings();
ui->spectrumGUI->updateSettings(); ui->spectrumGUI->updateSettings();
m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker)); m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker));
displaySettings(); displaySettings();
return true; return true;
} }
else if (Interferometer::MsgReportDevices::match(message))
{
Interferometer::MsgReportDevices& report = (Interferometer::MsgReportDevices&) message;
updateDeviceSetList(report.getDeviceSetIndexes());
return true;
}
else else
{ {
return false; return false;
@ -165,6 +177,7 @@ InterferometerGUI::InterferometerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUI
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
updateDeviceSetList(m_interferometer->getDeviceSetList());
displaySettings(); displaySettings();
makeUIConnections(); makeUIConnections();
displayRateAndShift(); displayRateAndShift();
@ -188,9 +201,11 @@ void InterferometerGUI::applySettings(bool force)
{ {
setTitleColor(m_channelMarker.getColor()); setTitleColor(m_channelMarker.getColor());
Interferometer::MsgConfigureInterferometer* message = Interferometer::MsgConfigureInterferometer::create(m_settings, force); Interferometer::MsgConfigureInterferometer* message = Interferometer::MsgConfigureInterferometer::create(m_settings, m_settingsKeys, force);
m_interferometer->getInputMessageQueue()->push(message); m_interferometer->getInputMessageQueue()->push(message);
} }
m_settingsKeys.clear();
} }
void InterferometerGUI::displaySettings() void InterferometerGUI::displaySettings()
@ -294,27 +309,53 @@ void InterferometerGUI::onMenuDialogCalled(const QPoint &p)
setTitle(m_channelMarker.getTitle()); setTitle(m_channelMarker.getTitle());
setTitleColor(m_settings.m_rgbColor); setTitleColor(m_settings.m_rgbColor);
m_settingsKeys.append("title");
m_settingsKeys.append("rgbColor");
m_settingsKeys.append("useReverseAPI");
m_settingsKeys.append("reverseAPIAddress");
m_settingsKeys.append("reverseAPIPort");
m_settingsKeys.append("reverseAPIFeatureSetIndex");
m_settingsKeys.append("reverseAPIFeatureIndex");
applySettings(); applySettings();
} }
resetContextMenuType(); resetContextMenuType();
} }
void InterferometerGUI::updateDeviceSetList(const QList<int>& deviceSetIndexes)
{
QList<int>::const_iterator it = deviceSetIndexes.begin();
ui->localDevice->blockSignals(true);
ui->localDevice->clear();
for (; it != deviceSetIndexes.end(); ++it) {
ui->localDevice->addItem(QString("R%1").arg(*it), *it);
}
ui->localDevice->blockSignals(false);
}
void InterferometerGUI::on_decimationFactor_currentIndexChanged(int index) void InterferometerGUI::on_decimationFactor_currentIndexChanged(int index)
{ {
m_settings.m_log2Decim = index; m_settings.m_log2Decim = index;
m_settingsKeys.append("log2Decim");
applyDecimation(); applyDecimation();
} }
void InterferometerGUI::on_position_valueChanged(int value) void InterferometerGUI::on_position_valueChanged(int value)
{ {
m_settings.m_filterChainHash = value; m_settings.m_filterChainHash = value;
m_settingsKeys.append("filterChainHash");
applyPosition(); applyPosition();
} }
void InterferometerGUI::on_phaseCorrection_valueChanged(int value) void InterferometerGUI::on_phaseCorrection_valueChanged(int value)
{ {
m_settings.m_phase = value; m_settings.m_phase = value;
m_settingsKeys.append("phase");
ui->phaseCorrectionText->setText(tr("%1").arg(value)); ui->phaseCorrectionText->setText(tr("%1").arg(value));
applySettings(); applySettings();
} }
@ -322,6 +363,7 @@ void InterferometerGUI::on_phaseCorrection_valueChanged(int value)
void InterferometerGUI::on_gain_valueChanged(int value) void InterferometerGUI::on_gain_valueChanged(int value)
{ {
m_settings.m_gain = value; m_settings.m_gain = value;
m_settingsKeys.append("gain");
ui->gainText->setText(QString("%1").arg(m_settings.m_gain / 10.0, 0, 'f', 1)); ui->gainText->setText(QString("%1").arg(m_settings.m_gain / 10.0, 0, 'f', 1));
applySettings(); applySettings();
} }
@ -341,6 +383,7 @@ void InterferometerGUI::on_gainLabel_clicked()
void InterferometerGUI::on_correlationType_currentIndexChanged(int index) void InterferometerGUI::on_correlationType_currentIndexChanged(int index)
{ {
m_settings.m_correlationType = (InterferometerSettings::CorrelationType) index; m_settings.m_correlationType = (InterferometerSettings::CorrelationType) index;
m_settingsKeys.append("correlationType");
applySettings(); applySettings();
} }
@ -355,6 +398,7 @@ void InterferometerGUI::applyDecimation()
ui->position->setMaximum(maxHash-1); ui->position->setMaximum(maxHash-1);
ui->position->setValue(m_settings.m_filterChainHash); ui->position->setValue(m_settings.m_filterChainHash);
m_settings.m_filterChainHash = ui->position->value(); m_settings.m_filterChainHash = ui->position->value();
m_settingsKeys.append("filterChainHash");
applyPosition(); applyPosition();
} }

View File

@ -70,6 +70,7 @@ private:
ChannelMarker m_channelMarker; ChannelMarker m_channelMarker;
RollupState m_rollupState; RollupState m_rollupState;
InterferometerSettings m_settings; InterferometerSettings m_settings;
QList<QString> m_settingsKeys;
int m_sampleRate; int m_sampleRate;
qint64 m_centerFrequency; qint64 m_centerFrequency;
double m_shiftFrequencyFactor; //!< Channel frequency shift factor double m_shiftFrequencyFactor; //!< Channel frequency shift factor
@ -93,6 +94,7 @@ private:
bool handleMessage(const Message& message); bool handleMessage(const Message& message);
void makeUIConnections(); void makeUIConnections();
void updateAbsoluteCenterFrequency(); void updateAbsoluteCenterFrequency();
void updateDeviceSetList(const QList<int>& deviceSetIndexes);
void leaveEvent(QEvent*); void leaveEvent(QEvent*);
void enterEvent(EnterEventType*); void enterEvent(EnterEventType*);

View File

@ -416,6 +416,60 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="localDeviceLabel">
<property name="text">
<string>Device</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="localDevice">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Local input device deviceset index</string>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="localDevicePlay">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Start/Stop sending IQ to local input device</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/play.png</normaloff>
<normalon>:/pause.png</normalon>:/play.png</iconset>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -588,6 +642,11 @@
<header>gui/glscopegui.h</header> <header>gui/glscopegui.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget> <customwidget>
<class>ClickableLabel</class> <class>ClickableLabel</class>
<extends>QLabel</extends> <extends>QLabel</extends>

View File

@ -41,6 +41,7 @@ void InterferometerSettings::resetToDefaults()
m_filterChainHash = 0; m_filterChainHash = 0;
m_phase = 0; m_phase = 0;
m_gain = 0; m_gain = 0;
m_localDeviceIndex = -1;
m_reverseAPIAddress = "127.0.0.1"; m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888; m_reverseAPIPort = 8888;
m_reverseAPIDeviceIndex = 0; m_reverseAPIDeviceIndex = 0;
@ -68,6 +69,7 @@ QByteArray InterferometerSettings::serialize() const
s.writeBlob(14, m_geometryBytes); s.writeBlob(14, m_geometryBytes);
s.writeBool(15, m_hidden); s.writeBool(15, m_hidden);
s.writeS32(16, m_gain); s.writeS32(16, m_gain);
s.writeS32(17, m_localDeviceIndex);
if (m_spectrumGUI) { if (m_spectrumGUI) {
s.writeBlob(20, m_spectrumGUI->serialize()); s.writeBlob(20, m_spectrumGUI->serialize());
@ -128,6 +130,7 @@ bool InterferometerSettings::deserialize(const QByteArray& data)
d.readBlob(14, &m_geometryBytes); d.readBlob(14, &m_geometryBytes);
d.readBool(15, &m_hidden, false); d.readBool(15, &m_hidden, false);
d.readS32(16, &m_gain, 0); d.readS32(16, &m_gain, 0);
d.readS32(17, &m_localDeviceIndex, -1);
if (m_spectrumGUI) if (m_spectrumGUI)
{ {
@ -161,3 +164,99 @@ bool InterferometerSettings::deserialize(const QByteArray& data)
return false; return false;
} }
} }
void InterferometerSettings::applySettings(const QStringList& settingsKeys, const InterferometerSettings& settings)
{
if (settingsKeys.contains("correlationType")) {
m_correlationType = settings.m_correlationType;
}
if (settingsKeys.contains("rgbColor")) {
m_rgbColor = settings.m_rgbColor;
}
if (settingsKeys.contains("title")) {
m_title = settings.m_title;
}
if (settingsKeys.contains("log2Decim")) {
m_log2Decim = settings.m_log2Decim;
}
if (settingsKeys.contains("filterChainHash")) {
m_filterChainHash = settings.m_filterChainHash;
}
if (settingsKeys.contains("phase")) {
m_phase = settings.m_phase;
}
if (settingsKeys.contains("gain")) {
m_gain = settings.m_gain;
}
if (settingsKeys.contains("localDeviceIndex")) {
m_localDeviceIndex = settings.m_localDeviceIndex;
}
if (settingsKeys.contains("reverseAPIAddress")) {
m_reverseAPIAddress = settings.m_reverseAPIAddress;
}
if (settingsKeys.contains("reverseAPIPort")) {
m_reverseAPIPort = settings.m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex")) {
m_reverseAPIDeviceIndex = settings.m_reverseAPIDeviceIndex;
}
if (settingsKeys.contains("reverseAPIChannelIndex")) {
m_reverseAPIChannelIndex = settings.m_reverseAPIChannelIndex;
}
if (settingsKeys.contains("workspaceIndex")) {
m_workspaceIndex = settings.m_workspaceIndex;
}
if (settingsKeys.contains("hidden")) {
m_hidden = settings.m_hidden;
}
}
QString InterferometerSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("correlationType")) {
ostr << " m_correlationType: " << m_correlationType;
}
if (settingsKeys.contains("rgbColor")) {
ostr << " m_rgbColor: " << m_rgbColor;
}
if (settingsKeys.contains("title")) {
ostr << " m_title: " << m_title.toStdString();
}
if (settingsKeys.contains("log2Decim")) {
ostr << " m_log2Decim: " << m_log2Decim;
}
if (settingsKeys.contains("filterChainHash")) {
ostr << " m_filterChainHash: " << m_filterChainHash;
}
if (settingsKeys.contains("phase")) {
ostr << " m_phase: " << m_phase;
}
if (settingsKeys.contains("gain")) {
ostr << " m_gain: " << m_gain;
}
if (settingsKeys.contains("localDeviceIndex")) {
ostr << " m_localDeviceIndex: " << m_localDeviceIndex;
}
if (settingsKeys.contains("reverseAPIAddress")) {
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
}
if (settingsKeys.contains("reverseAPIPort")) {
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex")) {
ostr << " m_reverseAPIDeviceIndex: " << m_reverseAPIDeviceIndex;
}
if (settingsKeys.contains("reverseAPIChannelIndex")) {
ostr << " m_reverseAPIChannelIndex: " << m_reverseAPIChannelIndex;
}
if (settingsKeys.contains("workspaceIndex")) {
ostr << " m_workspaceIndex: " << m_workspaceIndex;
}
if (settingsKeys.contains("hidden")) {
ostr << " m_hidden: " << m_hidden;
}
return QString(ostr.str().c_str());
}

View File

@ -47,6 +47,7 @@ struct InterferometerSettings
uint32_t m_filterChainHash; uint32_t m_filterChainHash;
int m_phase; int m_phase;
int m_gain; int m_gain;
int m_localDeviceIndex;
bool m_useReverseAPI; bool m_useReverseAPI;
QString m_reverseAPIAddress; QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort; uint16_t m_reverseAPIPort;
@ -69,6 +70,8 @@ struct InterferometerSettings
void setScopeGUI(Serializable *scopeGUI) { m_scopeGUI = scopeGUI; } void setScopeGUI(Serializable *scopeGUI) { m_scopeGUI = scopeGUI; }
QByteArray serialize() const; QByteArray serialize() const;
bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data);
void applySettings(const QStringList& settingsKeys, const InterferometerSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
}; };
#endif // INCLUDE_INTERFEROMETERSETTINGS_H #endif // INCLUDE_INTERFEROMETERSETTINGS_H