1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Reverse API: AM demod changes (1)

This commit is contained in:
f4exb 2018-12-14 08:51:01 +01:00
parent e7f123390f
commit 31123dacce
8 changed files with 141 additions and 2 deletions

View File

@ -427,8 +427,11 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
<< " m_audioDeviceName: " << settings.m_audioDeviceName << " m_audioDeviceName: " << settings.m_audioDeviceName
<< " m_pll: " << settings.m_pll << " m_pll: " << settings.m_pll
<< " m_syncAMOperation: " << (int) settings.m_syncAMOperation << " m_syncAMOperation: " << (int) settings.m_syncAMOperation
<< " m_useReverseAPI" << settings.m_useReverseAPI
<< " force: " << force; << " force: " << force;
QList<QString> reverseAPIKeys;
if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) ||
(m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force) (m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force)
{ {
@ -439,11 +442,19 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
m_bandpass.create(301, m_audioSampleRate, 300.0, settings.m_rfBandwidth / 2.0f); m_bandpass.create(301, m_audioSampleRate, 300.0, settings.m_rfBandwidth / 2.0f);
DSBFilter->create_dsb_filter((2.0f * settings.m_rfBandwidth) / (float) m_audioSampleRate); DSBFilter->create_dsb_filter((2.0f * settings.m_rfBandwidth) / (float) m_audioSampleRate);
m_settingsMutex.unlock(); m_settingsMutex.unlock();
if ((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}
if ((m_settings.m_bandpassEnable != settings.m_bandpassEnable) || force) {
reverseAPIKeys.append("bandpassEnable");
}
} }
if ((m_settings.m_squelch != settings.m_squelch) || force) if ((m_settings.m_squelch != settings.m_squelch) || force)
{ {
m_squelchLevel = CalcDb::powerFromdB(settings.m_squelch); m_squelchLevel = CalcDb::powerFromdB(settings.m_squelch);
reverseAPIKeys.append("squelchLevel");
} }
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
@ -457,6 +468,8 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
if (m_audioSampleRate != audioSampleRate) { if (m_audioSampleRate != audioSampleRate) {
applyAudioSampleRate(audioSampleRate); applyAudioSampleRate(audioSampleRate);
} }
reverseAPIKeys.append("audioDeviceName");
} }
if ((m_settings.m_pll != settings.m_pll) || force) if ((m_settings.m_pll != settings.m_pll) || force)
@ -470,13 +483,21 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
{ {
m_volumeAGC.resizeNew(m_audioSampleRate/10, 0.003); m_volumeAGC.resizeNew(m_audioSampleRate/10, 0.003);
} }
reverseAPIKeys.append("pll");
} }
if ((m_settings.m_syncAMOperation != settings.m_syncAMOperation) || force) { if ((m_settings.m_syncAMOperation != settings.m_syncAMOperation) || force)
{
m_syncAMBuffIndex = 0; m_syncAMBuffIndex = 0;
reverseAPIKeys.append("syncAMOperation");
} }
m_settings = settings; m_settings = settings;
if (m_settings.m_useReverseAPI) {
webapiReverseSendSettings(reverseAPIKeys, m_settings, force);
}
} }
QByteArray AMDemod::serialize() const QByteArray AMDemod::serialize() const
@ -634,3 +655,11 @@ void AMDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
response.getAmDemodReport()->setChannelSampleRate(m_inputSampleRate); response.getAmDemodReport()->setChannelSampleRate(m_inputSampleRate);
} }
void AMDemod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, AMDemodSettings& settings, bool force)
{
(void) channelSettingsKeys;
(void) settings;
(void) force;
// TODO
}

View File

@ -211,6 +211,7 @@ private:
void applyAudioSampleRate(int sampleRate); void applyAudioSampleRate(int sampleRate);
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const AMDemodSettings& settings); void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const AMDemodSettings& settings);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, AMDemodSettings& settings, bool force);
void processOneSample(Complex &ci); void processOneSample(Complex &ci);
}; };

View File

@ -209,6 +209,8 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p)
dialog.setUseReverseAPI(m_settings.m_useReverseAPI); dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress); dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort); dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex);
dialog.move(p); dialog.move(p);
dialog.exec(); dialog.exec();
@ -218,6 +220,8 @@ void AMDemodGUI::onMenuDialogCalled(const QPoint &p)
m_settings.m_useReverseAPI = dialog.useReverseAPI(); m_settings.m_useReverseAPI = dialog.useReverseAPI();
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex();
setWindowTitle(m_settings.m_title); setWindowTitle(m_settings.m_title);
setTitleColor(m_settings.m_rgbColor); setTitleColor(m_settings.m_rgbColor);

View File

@ -43,6 +43,8 @@ void AMDemodSettings::resetToDefaults()
m_useReverseAPI = false; m_useReverseAPI = false;
m_reverseAPIAddress = "127.0.0.1"; m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888; m_reverseAPIPort = 8888;
m_reverseAPIDeviceIndex = 0;
m_reverseAPIChannelIndex = 0;
} }
QByteArray AMDemodSettings::serialize() const QByteArray AMDemodSettings::serialize() const
@ -66,6 +68,8 @@ QByteArray AMDemodSettings::serialize() const
s.writeBool(14, m_useReverseAPI); s.writeBool(14, m_useReverseAPI);
s.writeString(15, m_reverseAPIAddress); s.writeString(15, m_reverseAPIAddress);
s.writeU32(16, m_reverseAPIPort); s.writeU32(16, m_reverseAPIPort);
s.writeU32(17, m_reverseAPIDeviceIndex);
s.writeU32(18, m_reverseAPIChannelIndex);
return s.final(); return s.final();
} }
@ -117,6 +121,11 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
m_reverseAPIPort = 8888; m_reverseAPIPort = 8888;
} }
d.readU32(17, &utmp, 0);
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
d.readU32(18, &utmp, 0);
m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
return true; return true;
} }
else else

View File

@ -45,6 +45,8 @@ struct AMDemodSettings
bool m_useReverseAPI; bool m_useReverseAPI;
QString m_reverseAPIAddress; QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort; uint16_t m_reverseAPIPort;
uint16_t m_reverseAPIDeviceIndex;
uint16_t m_reverseAPIChannelIndex;
AMDemodSettings(); AMDemodSettings();
void resetToDefaults(); void resetToDefaults();

View File

@ -49,6 +49,18 @@ void BasicChannelSettingsDialog::setReverseAPIPort(uint16_t port)
ui->reverseAPIPort->setText(tr("%1").arg(m_reverseAPIPort)); ui->reverseAPIPort->setText(tr("%1").arg(m_reverseAPIPort));
} }
void BasicChannelSettingsDialog::setReverseAPIDeviceIndex(uint16_t deviceIndex)
{
m_reverseAPIDeviceIndex = deviceIndex > 99 ? 99 : deviceIndex;
ui->reverseAPIDeviceIndex->setText(tr("%1").arg(m_reverseAPIDeviceIndex));
}
void BasicChannelSettingsDialog::setReverseAPIChannelIndex(uint16_t channelIndex)
{
m_reverseAPIChannelIndex = channelIndex > 99 ? 99 : channelIndex;
ui->reverseAPIDeviceIndex->setText(tr("%1").arg(m_reverseAPIChannelIndex));
}
void BasicChannelSettingsDialog::paintColor() void BasicChannelSettingsDialog::paintColor()
{ {
QPixmap pm(24, 24); QPixmap pm(24, 24);

View File

@ -22,9 +22,13 @@ public:
bool useReverseAPI() const { return m_useReverseAPI; } bool useReverseAPI() const { return m_useReverseAPI; }
const QString& getReverseAPIAddress() const { return m_reverseAPIAddress; } const QString& getReverseAPIAddress() const { return m_reverseAPIAddress; }
uint16_t getReverseAPIPort() const { return m_reverseAPIPort; } uint16_t getReverseAPIPort() const { return m_reverseAPIPort; }
uint16_t getReverseAPIDeviceIndex() const { return m_reverseAPIDeviceIndex; }
uint16_t getReverseAPIChannelIndex() const { return m_reverseAPIChannelIndex; }
void setUseReverseAPI(bool useReverseAPI); void setUseReverseAPI(bool useReverseAPI);
void setReverseAPIAddress(const QString& address); void setReverseAPIAddress(const QString& address);
void setReverseAPIPort(uint16_t port); void setReverseAPIPort(uint16_t port);
void setReverseAPIDeviceIndex(uint16_t deviceIndex);
void setReverseAPIChannelIndex(uint16_t channelIndex);
private slots: private slots:
void on_colorBtn_clicked(); void on_colorBtn_clicked();
@ -40,6 +44,8 @@ private:
bool m_useReverseAPI; bool m_useReverseAPI;
QString m_reverseAPIAddress; QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort; uint16_t m_reverseAPIPort;
uint16_t m_reverseAPIDeviceIndex;
uint16_t m_reverseAPIChannelIndex;
bool m_hasChanged; bool m_hasChanged;
void paintColor(); void paintColor();

View File

@ -152,9 +152,15 @@
</item> </item>
<item> <item>
<widget class="QLineEdit" name="reverseAPIPort"> <widget class="QLineEdit" name="reverseAPIPort">
<property name="minimumSize">
<size>
<width>45</width>
<height>0</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>50</width> <width>45</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -169,6 +175,76 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="reverseAPIDeviceLabel">
<property name="text">
<string>D</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="reverseAPIDeviceIndex">
<property name="minimumSize">
<size>
<width>22</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Reverse API destination device index</string>
</property>
<property name="inputMask">
<string>00</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="reverseAPIChannelLabel">
<property name="text">
<string>C</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="reverseAPIChannelIndex">
<property name="minimumSize">
<size>
<width>22</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Reverse API destination channel index</string>
</property>
<property name="inputMask">
<string>00</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">