2019-08-08 03:25:34 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-08-08 12:42:17 -04:00
|
|
|
#include <QString>
|
|
|
|
|
2019-08-08 03:25:34 -04:00
|
|
|
#include "SWGChannelSettings.h"
|
|
|
|
#include "chanalyzerwebapiadapter.h"
|
|
|
|
|
|
|
|
ChannelAnalyzerWebAPIAdapter::ChannelAnalyzerWebAPIAdapter()
|
|
|
|
{
|
|
|
|
m_settings.setScopeGUI(&m_glScopeSettings);
|
2021-04-20 04:32:21 -04:00
|
|
|
m_settings.setSpectrumGUI(&m_SpectrumSettings);
|
2019-08-08 03:25:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ChannelAnalyzerWebAPIAdapter::~ChannelAnalyzerWebAPIAdapter()
|
|
|
|
{}
|
|
|
|
|
2019-08-08 12:42:17 -04:00
|
|
|
int ChannelAnalyzerWebAPIAdapter::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setChannelAnalyzerSettings(new SWGSDRangel::SWGChannelAnalyzerSettings());
|
|
|
|
response.getChannelAnalyzerSettings()->init();
|
2021-04-20 04:32:21 -04:00
|
|
|
webapiFormatChannelSettings(response, m_settings, m_glScopeSettings, m_SpectrumSettings);
|
2019-08-08 12:42:17 -04:00
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2019-08-08 03:25:34 -04:00
|
|
|
void ChannelAnalyzerWebAPIAdapter::webapiFormatChannelSettings(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
const ChannelAnalyzerSettings& settings,
|
|
|
|
const GLScopeSettings& scopeSettings,
|
2021-04-20 04:32:21 -04:00
|
|
|
const SpectrumSettings& spectrumSettings)
|
2019-08-08 03:25:34 -04:00
|
|
|
{
|
2019-11-24 04:12:58 -05:00
|
|
|
response.getChannelAnalyzerSettings()->setFrequency(settings.m_inputFrequencyOffset);
|
|
|
|
response.getChannelAnalyzerSettings()->setDownSample(settings.m_rationalDownSample ? 1 : 0);
|
|
|
|
response.getChannelAnalyzerSettings()->setDownSampleRate(settings.m_rationalDownSamplerRate);
|
2019-08-08 03:25:34 -04:00
|
|
|
response.getChannelAnalyzerSettings()->setBandwidth(settings.m_bandwidth);
|
|
|
|
response.getChannelAnalyzerSettings()->setLowCutoff(settings.m_lowCutoff);
|
2019-11-24 04:12:58 -05:00
|
|
|
response.getChannelAnalyzerSettings()->setSpanLog2(settings.m_log2Decim);
|
2019-08-08 03:25:34 -04:00
|
|
|
response.getChannelAnalyzerSettings()->setSsb(settings.m_ssb ? 1 : 0);
|
|
|
|
response.getChannelAnalyzerSettings()->setPll(settings.m_pll ? 1 : 0);
|
|
|
|
response.getChannelAnalyzerSettings()->setFll(settings.m_fll ? 1 : 0);
|
2021-03-05 08:37:49 -05:00
|
|
|
response.getChannelAnalyzerSettings()->setCostasLoop(settings.m_costasLoop ? 1 : 0);
|
2019-08-08 03:25:34 -04:00
|
|
|
response.getChannelAnalyzerSettings()->setRrc(settings.m_rrc ? 1 : 0);
|
|
|
|
response.getChannelAnalyzerSettings()->setRrcRolloff(settings.m_rrcRolloff);
|
|
|
|
response.getChannelAnalyzerSettings()->setPllPskOrder(settings.m_pllPskOrder);
|
2021-03-05 08:37:49 -05:00
|
|
|
response.getChannelAnalyzerSettings()->setPllBandwidth(settings.m_pllBandwidth);
|
|
|
|
response.getChannelAnalyzerSettings()->setPllDampingFactor(settings.m_pllBandwidth);
|
|
|
|
response.getChannelAnalyzerSettings()->setPllLoopGain(settings.m_pllLoopGain);
|
2019-08-08 03:25:34 -04:00
|
|
|
response.getChannelAnalyzerSettings()->setInputType((int) settings.m_inputType);
|
|
|
|
response.getChannelAnalyzerSettings()->setRgbColor(settings.m_rgbColor);
|
|
|
|
response.getChannelAnalyzerSettings()->setTitle(new QString(settings.m_title));
|
2019-08-08 12:42:17 -04:00
|
|
|
|
|
|
|
// scope
|
2019-08-08 03:25:34 -04:00
|
|
|
SWGSDRangel::SWGGLScope *swgScope = new SWGSDRangel::SWGGLScope();
|
|
|
|
swgScope->init();
|
|
|
|
response.getChannelAnalyzerSettings()->setScopeConfig(swgScope);
|
2021-11-30 18:20:14 -05:00
|
|
|
scopeSettings.formatTo(swgScope);
|
2019-08-08 12:42:17 -04:00
|
|
|
|
|
|
|
// spectrum
|
2019-08-08 03:25:34 -04:00
|
|
|
SWGSDRangel::SWGGLSpectrum *swgSpectrum = new SWGSDRangel::SWGGLSpectrum();
|
|
|
|
swgSpectrum->init();
|
|
|
|
response.getChannelAnalyzerSettings()->setSpectrumConfig(swgSpectrum);
|
2021-11-30 18:20:14 -05:00
|
|
|
spectrumSettings.formatTo(swgSpectrum);
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
2019-08-08 03:25:34 -04:00
|
|
|
|
2019-08-08 12:42:17 -04:00
|
|
|
int ChannelAnalyzerWebAPIAdapter::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) force;
|
|
|
|
(void) errorMessage;
|
2021-04-20 04:32:21 -04:00
|
|
|
webapiUpdateChannelSettings(m_settings, m_glScopeSettings, m_SpectrumSettings, channelSettingsKeys, response);
|
2019-08-10 19:27:19 -04:00
|
|
|
return 200;
|
2019-08-08 03:25:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelAnalyzerWebAPIAdapter::webapiUpdateChannelSettings(
|
|
|
|
ChannelAnalyzerSettings& settings,
|
|
|
|
GLScopeSettings& scopeSettings,
|
2021-04-20 04:32:21 -04:00
|
|
|
SpectrumSettings& spectrumSettings,
|
2019-08-08 03:25:34 -04:00
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response)
|
|
|
|
{
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("bandwidth")) {
|
|
|
|
settings.m_bandwidth = response.getChannelAnalyzerSettings()->getBandwidth();
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("downSample")) {
|
2019-11-24 04:12:58 -05:00
|
|
|
settings.m_rationalDownSample = response.getChannelAnalyzerSettings()->getDownSample() != 0;
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("downSampleRate")) {
|
2019-11-24 04:12:58 -05:00
|
|
|
settings.m_rationalDownSamplerRate = response.getChannelAnalyzerSettings()->getDownSampleRate();
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("fll")) {
|
|
|
|
settings.m_fll = response.getChannelAnalyzerSettings()->getFll() != 0;
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("frequency")) {
|
2019-11-24 04:12:58 -05:00
|
|
|
settings.m_inputFrequencyOffset = response.getChannelAnalyzerSettings()->getFrequency();
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("inputType")) {
|
|
|
|
settings.m_inputType = (ChannelAnalyzerSettings::InputType) response.getChannelAnalyzerSettings()->getInputType();
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("lowCutoff")) {
|
|
|
|
settings.m_lowCutoff = response.getChannelAnalyzerSettings()->getLowCutoff();
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("pll")) {
|
|
|
|
settings.m_pll = response.getChannelAnalyzerSettings()->getPll() != 0;
|
|
|
|
}
|
2021-03-05 08:37:49 -05:00
|
|
|
if (channelSettingsKeys.contains("costasLoop")) {
|
|
|
|
settings.m_costasLoop = response.getChannelAnalyzerSettings()->getCostasLoop() != 0;
|
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("pllPskOrder")) {
|
|
|
|
settings.m_pllPskOrder = response.getChannelAnalyzerSettings()->getPllPskOrder();
|
|
|
|
}
|
2021-03-05 08:37:49 -05:00
|
|
|
if (channelSettingsKeys.contains("pllBandwidth")) {
|
|
|
|
settings.m_pllBandwidth = response.getChannelAnalyzerSettings()->getPllBandwidth();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("pllDampingFactor")) {
|
|
|
|
settings.m_pllDampingFactor = response.getChannelAnalyzerSettings()->getPllDampingFactor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("pllLoopGain")) {
|
|
|
|
settings.m_pllLoopGain = response.getChannelAnalyzerSettings()->getPllLoopGain();
|
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
|
|
|
settings.m_rgbColor = response.getChannelAnalyzerSettings()->getRgbColor();
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rrc")) {
|
|
|
|
settings.m_rrc = response.getChannelAnalyzerSettings()->getRrc() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rrcRolloff")) {
|
|
|
|
settings.m_rrcRolloff = response.getChannelAnalyzerSettings()->getRrcRolloff();
|
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("spanLog2")) {
|
2019-11-24 04:12:58 -05:00
|
|
|
settings.m_log2Decim = response.getChannelAnalyzerSettings()->getSpanLog2();
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
if (channelSettingsKeys.contains("ssb")) {
|
|
|
|
settings.m_ssb = response.getChannelAnalyzerSettings()->getSsb() != 0;
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
|
|
|
settings.m_title = *response.getChannelAnalyzerSettings()->getTitle();
|
|
|
|
}
|
|
|
|
// scope
|
2021-11-30 18:20:14 -05:00
|
|
|
if (channelSettingsKeys.contains("scopeConfig")) {
|
|
|
|
scopeSettings.updateFrom(channelSettingsKeys, response.getChannelAnalyzerSettings()->getScopeConfig());
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
2019-08-09 12:45:10 -04:00
|
|
|
// spectrum
|
2021-11-30 18:20:14 -05:00
|
|
|
if (channelSettingsKeys.contains("spectrumConfig")) {
|
|
|
|
spectrumSettings.updateFrom(channelSettingsKeys, response.getChannelAnalyzerSettings()->getSpectrumConfig());
|
2019-08-08 12:42:17 -04:00
|
|
|
}
|
|
|
|
}
|