Reverse API: AM demod changes (1)

pull/267/head^2^2
f4exb 2018-12-14 08:51:01 +01:00
rodzic e7f123390f
commit 31123dacce
8 zmienionych plików z 141 dodań i 2 usunięć

Wyświetl plik

@ -427,8 +427,11 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
<< " m_audioDeviceName: " << settings.m_audioDeviceName
<< " m_pll: " << settings.m_pll
<< " m_syncAMOperation: " << (int) settings.m_syncAMOperation
<< " m_useReverseAPI" << settings.m_useReverseAPI
<< " force: " << force;
QList<QString> reverseAPIKeys;
if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) ||
(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);
DSBFilter->create_dsb_filter((2.0f * settings.m_rfBandwidth) / (float) m_audioSampleRate);
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)
{
m_squelchLevel = CalcDb::powerFromdB(settings.m_squelch);
reverseAPIKeys.append("squelchLevel");
}
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) {
applyAudioSampleRate(audioSampleRate);
}
reverseAPIKeys.append("audioDeviceName");
}
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);
}
reverseAPIKeys.append("pll");
}
if ((m_settings.m_syncAMOperation != settings.m_syncAMOperation) || force) {
if ((m_settings.m_syncAMOperation != settings.m_syncAMOperation) || force)
{
m_syncAMBuffIndex = 0;
reverseAPIKeys.append("syncAMOperation");
}
m_settings = settings;
if (m_settings.m_useReverseAPI) {
webapiReverseSendSettings(reverseAPIKeys, m_settings, force);
}
}
QByteArray AMDemod::serialize() const
@ -634,3 +655,11 @@ void AMDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
response.getAmDemodReport()->setChannelSampleRate(m_inputSampleRate);
}
void AMDemod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, AMDemodSettings& settings, bool force)
{
(void) channelSettingsKeys;
(void) settings;
(void) force;
// TODO
}

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -49,6 +49,18 @@ void BasicChannelSettingsDialog::setReverseAPIPort(uint16_t port)
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()
{
QPixmap pm(24, 24);

Wyświetl plik

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

Wyświetl plik

@ -152,9 +152,15 @@
</item>
<item>
<widget class="QLineEdit" name="reverseAPIPort">
<property name="minimumSize">
<size>
<width>45</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<width>45</width>
<height>16777215</height>
</size>
</property>
@ -169,6 +175,76 @@
</property>
</widget>
</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>
<spacer name="horizontalSpacer_2">
<property name="orientation">