mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 13:51:47 -05:00
REST API: config: PUT (5): mapper work and rework. ChannelAnalyzer complements
This commit is contained in:
parent
4897e82e28
commit
c777ec881d
@ -164,8 +164,8 @@ void ChannelAnalyzerWebAPIAdapter::webapiUpdateChannelSettings(
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response)
|
||||
{
|
||||
if (channelSettingsKeys.contains("frequency")) {
|
||||
settings.m_frequency = response.getChannelAnalyzerSettings()->getFrequency();
|
||||
if (channelSettingsKeys.contains("bandwidth")) {
|
||||
settings.m_bandwidth = response.getChannelAnalyzerSettings()->getBandwidth();
|
||||
}
|
||||
if (channelSettingsKeys.contains("downSample")) {
|
||||
settings.m_downSample = response.getChannelAnalyzerSettings()->getDownSample() != 0;
|
||||
@ -173,23 +173,26 @@ void ChannelAnalyzerWebAPIAdapter::webapiUpdateChannelSettings(
|
||||
if (channelSettingsKeys.contains("downSampleRate")) {
|
||||
settings.m_downSampleRate = response.getChannelAnalyzerSettings()->getDownSampleRate();
|
||||
}
|
||||
if (channelSettingsKeys.contains("bandwidth")) {
|
||||
settings.m_bandwidth = response.getChannelAnalyzerSettings()->getBandwidth();
|
||||
if (channelSettingsKeys.contains("fll")) {
|
||||
settings.m_fll = response.getChannelAnalyzerSettings()->getFll() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("frequency")) {
|
||||
settings.m_frequency = response.getChannelAnalyzerSettings()->getFrequency();
|
||||
}
|
||||
if (channelSettingsKeys.contains("inputType")) {
|
||||
settings.m_inputType = (ChannelAnalyzerSettings::InputType) response.getChannelAnalyzerSettings()->getInputType();
|
||||
}
|
||||
if (channelSettingsKeys.contains("lowCutoff")) {
|
||||
settings.m_lowCutoff = response.getChannelAnalyzerSettings()->getLowCutoff();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spanLog2")) {
|
||||
settings.m_spanLog2 = response.getChannelAnalyzerSettings()->getSpanLog2();
|
||||
}
|
||||
if (channelSettingsKeys.contains("ssb")) {
|
||||
settings.m_ssb = response.getChannelAnalyzerSettings()->getSsb() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("pll")) {
|
||||
settings.m_pll = response.getChannelAnalyzerSettings()->getPll() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("fll")) {
|
||||
settings.m_fll = response.getChannelAnalyzerSettings()->getFll() != 0;
|
||||
if (channelSettingsKeys.contains("pllPskOrder")) {
|
||||
settings.m_pllPskOrder = response.getChannelAnalyzerSettings()->getPllPskOrder();
|
||||
}
|
||||
if (channelSettingsKeys.contains("rgbColor")) {
|
||||
settings.m_rgbColor = response.getChannelAnalyzerSettings()->getRgbColor();
|
||||
}
|
||||
if (channelSettingsKeys.contains("rrc")) {
|
||||
settings.m_rrc = response.getChannelAnalyzerSettings()->getRrc() != 0;
|
||||
@ -197,26 +200,218 @@ void ChannelAnalyzerWebAPIAdapter::webapiUpdateChannelSettings(
|
||||
if (channelSettingsKeys.contains("rrcRolloff")) {
|
||||
settings.m_rrcRolloff = response.getChannelAnalyzerSettings()->getRrcRolloff();
|
||||
}
|
||||
if (channelSettingsKeys.contains("pllPskOrder")) {
|
||||
settings.m_pllPskOrder = response.getChannelAnalyzerSettings()->getPllPskOrder();
|
||||
if (channelSettingsKeys.contains("spanLog2")) {
|
||||
settings.m_spanLog2 = response.getChannelAnalyzerSettings()->getSpanLog2();
|
||||
}
|
||||
if (channelSettingsKeys.contains("inputType")) {
|
||||
settings.m_inputType = (ChannelAnalyzerSettings::InputType) response.getChannelAnalyzerSettings()->getInputType();
|
||||
}
|
||||
if (channelSettingsKeys.contains("rgbColor")) {
|
||||
settings.m_rgbColor = response.getChannelAnalyzerSettings()->getRgbColor();
|
||||
if (channelSettingsKeys.contains("ssb")) {
|
||||
settings.m_ssb = response.getChannelAnalyzerSettings()->getSsb() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("title")) {
|
||||
settings.m_title = *response.getChannelAnalyzerSettings()->getTitle();
|
||||
}
|
||||
// scope
|
||||
if (channelSettingsKeys.contains("scopeConfig.displayMode")) {
|
||||
scopeSettings.m_displayMode = (GLScopeSettings::DisplayMode) response.getChannelAnalyzerSettings()->getScopeConfig()->getDisplayMode();
|
||||
}
|
||||
// TODO ...
|
||||
for (int i = 0; i < 10; i++) // no more than 10 traces anyway
|
||||
if (channelSettingsKeys.contains("scopeConfig"))
|
||||
{
|
||||
// TODO ...
|
||||
if (channelSettingsKeys.contains("scopeConfig.displayMode")) {
|
||||
scopeSettings.m_displayMode = (GLScopeSettings::DisplayMode) response.getChannelAnalyzerSettings()->getScopeConfig()->getDisplayMode();
|
||||
}
|
||||
if (channelSettingsKeys.contains("scopeConfig.gridIntensity")) {
|
||||
scopeSettings.m_gridIntensity = response.getChannelAnalyzerSettings()->getScopeConfig()->getGridIntensity();
|
||||
}
|
||||
if (channelSettingsKeys.contains("scopeConfig.time")) {
|
||||
scopeSettings.m_time = response.getChannelAnalyzerSettings()->getScopeConfig()->getTime();
|
||||
}
|
||||
if (channelSettingsKeys.contains("scopeConfig.timeOfs")) {
|
||||
scopeSettings.m_timeOfs = response.getChannelAnalyzerSettings()->getScopeConfig()->getTimeOfs();
|
||||
}
|
||||
if (channelSettingsKeys.contains("scopeConfig.traceIntensity")) {
|
||||
scopeSettings.m_traceIntensity = response.getChannelAnalyzerSettings()->getScopeConfig()->getTraceIntensity();
|
||||
}
|
||||
if (channelSettingsKeys.contains("scopeConfig.traceLen")) {
|
||||
scopeSettings.m_traceLen = response.getChannelAnalyzerSettings()->getScopeConfig()->getTraceLen();
|
||||
}
|
||||
if (channelSettingsKeys.contains("scopeConfig.trigPre")) {
|
||||
scopeSettings.m_trigPre = response.getChannelAnalyzerSettings()->getScopeConfig()->getTrigPre();
|
||||
}
|
||||
// traces
|
||||
if (channelSettingsKeys.contains("scopeConfig.tracesData"))
|
||||
{
|
||||
QList<SWGSDRangel::SWGTraceData *> *tracesData = response.getChannelAnalyzerSettings()->getScopeConfig()->getTracesData();
|
||||
|
||||
for (int i = 0; i < 10; i++) // no more than 10 traces anyway
|
||||
{
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1]").arg(i)))
|
||||
{
|
||||
SWGSDRangel::SWGTraceData *traceData = tracesData->at(i);
|
||||
scopeSettings.m_tracesData.push_back(GLScopeSettings::TraceData());
|
||||
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].amp").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_amp = traceData->getAmp();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].ampIndex").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_ampIndex = traceData->getAmpIndex();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].hasTextOverlay").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_hasTextOverlay = traceData->getHasTextOverlay() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].inputIndex").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_inputIndex = traceData->getInputIndex();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].ofs").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_ofs = traceData->getOfs();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].ofsCoarse").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_ofsCoarse = traceData->getOfsCoarse();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].ofsFine").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_ofsFine = traceData->getOfsFine();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].projectionType").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_projectionType = (Projector::ProjectionType) traceData->getProjectionType();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].traceColor").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceColor = intToQColor(traceData->getTraceColor());
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].traceColorB").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceColorB = traceData->getTraceColorB();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].traceColorG").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceColorG = traceData->getTraceColorG();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].traceColorR").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceColorR = traceData->getTraceColorR();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].traceDelay").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceDelay = traceData->getTraceDelay();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].traceDelayCoarse").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceDelayCoarse = traceData->getTraceDelayCoarse();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].traceDelayFine").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceDelayFine = traceData->getTraceDelayFine();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].triggerDisplayLevel").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_triggerDisplayLevel = traceData->getTriggerDisplayLevel();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].viewTrace").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_viewTrace = traceData->getViewTrace() != 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// triggers
|
||||
if (channelSettingsKeys.contains("scopeConfig.triggersData"))
|
||||
{
|
||||
QList<SWGSDRangel::SWGTriggerData *> *triggersData = response.getChannelAnalyzerSettings()->getScopeConfig()->getTriggersData();
|
||||
|
||||
for (int i = 0; i < 10; i++) // no more than 10 triggers anyway
|
||||
{
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1]").arg(i)))
|
||||
{
|
||||
SWGSDRangel::SWGTriggerData *triggerData = triggersData->at(i);
|
||||
scopeSettings.m_triggersData.push_back(GLScopeSettings::TriggerData());
|
||||
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].inputIndex").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_inputIndex = triggerData->getInputIndex();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].projectionType").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_projectionType = (Projector::ProjectionType) triggerData->getProjectionType();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerBothEdges").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerBothEdges = triggerData->getTriggerBothEdges() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.tracesData[%1].triggerColor").arg(i))) {
|
||||
scopeSettings.m_tracesData.back().m_traceColor = intToQColor(triggerData->getTriggerColor());
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerColorB").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerColorB = triggerData->getTriggerColorB();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerColorG").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerColorG = triggerData->getTriggerColorG();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerColorR").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerColorR = triggerData->getTriggerColorR();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerDelay").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerDelay = triggerData->getTriggerDelay();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerDelayCoarse").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerDelayCoarse = triggerData->getTriggerDelayCoarse();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerDelayFine").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerDelayFine = triggerData->getTriggerDelayFine();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerDelayMult").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerDelayMult = triggerData->getTriggerDelayMult();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerHoldoff").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerHoldoff = triggerData->getTriggerHoldoff();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerLevel").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerLevel = triggerData->getTriggerLevel();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerLevelCoarse").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerLevelCoarse = triggerData->getTriggerLevelCoarse();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerLevelFine").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerLevelFine = triggerData->getTriggerLevelFine();
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerPositiveEdge").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerPositiveEdge = triggerData->getTriggerPositiveEdge() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains(QString("scopeConfig.triggersData[%1].triggerRepeat").arg(i))) {
|
||||
scopeSettings.m_triggersData.back().m_triggerRepeat = triggerData->getTriggerRepeat() != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// spectrum
|
||||
if (channelSettingsKeys.contains("spectrumConfig"))
|
||||
{
|
||||
if (channelSettingsKeys.contains("spectrumConfig.averagingMode")) {
|
||||
spectrumSettings.m_averagingMode = (GLSpectrumSettings::AveragingMode) response.getChannelAnalyzerSettings()->getSpectrumConfig()->getAveragingMode();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.averagingValue")) {
|
||||
spectrumSettings.m_averagingNb = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getAveragingValue();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.decay")) {
|
||||
spectrumSettings.m_decay = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDecay();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.decayDivisor")) {
|
||||
spectrumSettings.m_decayDivisor = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDecayDivisor();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.displayCurrent")) {
|
||||
spectrumSettings.m_displayCurrent = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDisplayCurrent() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.displayGrid")) {
|
||||
spectrumSettings.m_displayGrid = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDisplayGrid() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.displayGridIntensity")) {
|
||||
spectrumSettings.m_displayGridIntensity = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDisplayGridIntensity();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.displayHistogram")) {
|
||||
spectrumSettings.m_displayHistogram = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDisplayHistogram() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.displayMaxHold")) {
|
||||
spectrumSettings.m_displayMaxHold = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDisplayMaxHold() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.displayTraceIntensity")) {
|
||||
spectrumSettings.m_displayTraceIntensity = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDisplayTraceIntensity();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.displayWaterfall")) {
|
||||
spectrumSettings.m_displayWaterfall = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getDisplayWaterfall() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.fftOverlap")) {
|
||||
spectrumSettings.m_fftOverlap = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getFftOverlap();
|
||||
}
|
||||
if (channelSettingsKeys.contains("spectrumConfig.fftSize")) {
|
||||
spectrumSettings.m_fftSize = response.getChannelAnalyzerSettings()->getSpectrumConfig()->getFftSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,18 @@ Preset::Preset()
|
||||
resetToDefaults();
|
||||
}
|
||||
|
||||
Preset::Preset(const Preset& other) :
|
||||
m_group(other.m_group),
|
||||
m_description(other.m_description),
|
||||
m_centerFrequency(other.m_centerFrequency),
|
||||
m_spectrumConfig(other.m_spectrumConfig),
|
||||
m_dcOffsetCorrection(other.m_dcOffsetCorrection),
|
||||
m_iqImbalanceCorrection(other.m_iqImbalanceCorrection),
|
||||
m_channelConfigs(other.m_channelConfigs),
|
||||
m_deviceConfigs(other.m_deviceConfigs),
|
||||
m_layout(other.m_layout)
|
||||
{}
|
||||
|
||||
void Preset::resetToDefaults()
|
||||
{
|
||||
m_sourcePreset = true;
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
typedef QList<DeviceConfig> DeviceeConfigs;
|
||||
|
||||
Preset();
|
||||
Preset(const Preset& other);
|
||||
|
||||
void resetToDefaults();
|
||||
|
||||
|
@ -60,9 +60,38 @@ void WebAPIAdapterBase::webapiInitConfig(
|
||||
|
||||
void WebAPIAdapterBase::webapiUpdatePreferences(
|
||||
SWGSDRangel::SWGPreferences *apiPreferences,
|
||||
const QStringList& preferenceKeys,
|
||||
Preferences& preferences
|
||||
)
|
||||
{
|
||||
if (preferenceKeys.contains("consoleMinLogLevel")) {
|
||||
preferences.setConsoleMinLogLevel((QtMsgType) apiPreferences->getConsoleMinLogLevel());
|
||||
}
|
||||
if (preferenceKeys.contains("fileMinLogLevel")) {
|
||||
preferences.setFileMinLogLevel((QtMsgType) apiPreferences->getFileMinLogLevel());
|
||||
}
|
||||
if (preferenceKeys.contains("latitude")) {
|
||||
preferences.setLatitude(apiPreferences->getLatitude());
|
||||
}
|
||||
if (preferenceKeys.contains("logFileName")) {
|
||||
preferences.setLogFileName(*apiPreferences->getLogFileName());
|
||||
}
|
||||
if (preferenceKeys.contains("longitude")) {
|
||||
preferences.setLongitude(apiPreferences->getLongitude());
|
||||
}
|
||||
if (preferenceKeys.contains("sourceDevice")) {
|
||||
preferences.setSourceDevice(*apiPreferences->getSourceDevice());
|
||||
}
|
||||
if (preferenceKeys.contains("sourceIndex")) {
|
||||
preferences.setSourceIndex(apiPreferences->getSourceIndex());
|
||||
}
|
||||
if (preferenceKeys.contains("useLogFile")) {
|
||||
preferences.setUseLogFile(apiPreferences->getUseLogFile() != 0);
|
||||
}
|
||||
|
||||
if (preferenceKeys.contains("consoleMinLogLevel"))
|
||||
|
||||
|
||||
if (apiPreferences->getSourceDevice()) {
|
||||
preferences.setSourceDevice(*apiPreferences->getSourceDevice());
|
||||
}
|
||||
@ -170,6 +199,14 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIAdapterBase::webapiUpdatePreset(
|
||||
SWGSDRangel::SWGPreset *apiPreset,
|
||||
const WebAPIAdapterInterface::PresetKeys& presetKeys,
|
||||
Preset& preset
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void WebAPIAdapterBase::webapiFormatCommand(
|
||||
SWGSDRangel::SWGCommand *apiCommand,
|
||||
const Command& command
|
||||
@ -186,6 +223,38 @@ void WebAPIAdapterBase::webapiFormatCommand(
|
||||
apiCommand->setRelease(command.getRelease() ? 1 : 0);
|
||||
}
|
||||
|
||||
void WebAPIAdapterBase::webapiUpdateCommand(
|
||||
SWGSDRangel::SWGCommand *apiCommand,
|
||||
const WebAPIAdapterInterface::CommandKeys& commandKeys,
|
||||
Command& command
|
||||
)
|
||||
{
|
||||
if (commandKeys.m_keys.contains("argString")) {
|
||||
command.setArgString(*apiCommand->getArgString());
|
||||
}
|
||||
if (commandKeys.m_keys.contains("associateKey")) {
|
||||
command.setAssociateKey(apiCommand->getAssociateKey());
|
||||
}
|
||||
if (commandKeys.m_keys.contains("command")) {
|
||||
command.setCommand(*apiCommand->getCommand());
|
||||
}
|
||||
if (commandKeys.m_keys.contains("description")) {
|
||||
command.setDescription(*apiCommand->getDescription());
|
||||
}
|
||||
if (commandKeys.m_keys.contains("group")) {
|
||||
command.setGroup(*apiCommand->getGroup());
|
||||
}
|
||||
if (commandKeys.m_keys.contains("key")) {
|
||||
command.setKey((Qt::Key) apiCommand->getKey());
|
||||
}
|
||||
if (commandKeys.m_keys.contains("keyModifiers")) {
|
||||
command.setKeyModifiers((Qt::KeyboardModifiers) apiCommand->getKeyModifiers());
|
||||
}
|
||||
if (commandKeys.m_keys.contains("release")) {
|
||||
command.setRelease(apiCommand->getRelease() != 0);
|
||||
}
|
||||
}
|
||||
|
||||
ChannelWebAPIAdapter *WebAPIAdapterBase::WebAPIChannelAdapters::getChannelWebAPIAdapter(const QString& channelURI, const PluginManager *pluginManager)
|
||||
{
|
||||
QString registeredChannelURI = ChannelUtils::getRegisteredChannelURI(channelURI);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "settings/preset.h"
|
||||
#include "settings/mainsettings.h"
|
||||
#include "commands/command.h"
|
||||
#include "webapiadapterinterface.h"
|
||||
|
||||
class PluginManager;
|
||||
class ChannelWebAPIAdapter;
|
||||
@ -62,8 +63,19 @@ public:
|
||||
);
|
||||
static void webapiUpdatePreferences(
|
||||
SWGSDRangel::SWGPreferences *apiPreferences,
|
||||
const QStringList& preferenceKeys,
|
||||
Preferences& preferences
|
||||
);
|
||||
static void webapiUpdatePreset(
|
||||
SWGSDRangel::SWGPreset *apiPreset,
|
||||
const WebAPIAdapterInterface::PresetKeys& presetKeys,
|
||||
Preset& preset
|
||||
);
|
||||
static void webapiUpdateCommand(
|
||||
SWGSDRangel::SWGCommand *apiCommand,
|
||||
const WebAPIAdapterInterface::CommandKeys& commandKeys,
|
||||
Command& command
|
||||
);
|
||||
|
||||
private:
|
||||
class WebAPIChannelAdapters
|
||||
|
@ -50,7 +50,7 @@ std::regex WebAPIAdapterInterface::devicesetChannelIndexURLRe("^/sdrangel/device
|
||||
std::regex WebAPIAdapterInterface::devicesetChannelSettingsURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel/([0-9]{1,2})/settings$");
|
||||
std::regex WebAPIAdapterInterface::devicesetChannelReportURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel/([0-9]{1,2})/report");
|
||||
|
||||
void WebAPIAdapterInterface::ConfigKeys::debug()
|
||||
void WebAPIAdapterInterface::ConfigKeys::debug() const
|
||||
{
|
||||
qDebug("WebAPIAdapterInterface::ConfigKeys::debug");
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
PresetKeys m_workingPresetKeys;
|
||||
QList<PresetKeys> m_presetKeys;
|
||||
QList<CommandKeys> m_commandKeys;
|
||||
void debug();
|
||||
void debug() const;
|
||||
};
|
||||
|
||||
virtual ~WebAPIAdapterInterface() {}
|
||||
|
@ -378,20 +378,24 @@ void WebAPIRequestMapper::instanceConfigService(qtwebapp::HttpRequest& request,
|
||||
|
||||
if (validateConfig(query, jsonObject, configKeys))
|
||||
{
|
||||
configKeys.debug();
|
||||
int status = 200;
|
||||
// int status = m_adapter->instanceConfigPutPatch(
|
||||
// true,
|
||||
// query,
|
||||
// configKeys,
|
||||
// normalResponse,
|
||||
// errorResponse
|
||||
// );
|
||||
int status = m_adapter->instanceConfigPutPatch(
|
||||
true,
|
||||
query,
|
||||
configKeys,
|
||||
normalResponse,
|
||||
errorResponse
|
||||
);
|
||||
response.setStatus(status);
|
||||
qDebug("WebAPIRequestMapper::instanceConfigService: PUT: %d", status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
if (status/100 == 2)
|
||||
{
|
||||
normalResponse.setMessage(new QString("Configuration updated successfully"));
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
normalResponse.setMessage(new QString("Error occured while updating configuration"));
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
|
@ -160,12 +160,40 @@ int WebAPIAdapterGUI::instanceConfigPutPatch(
|
||||
{
|
||||
WebAPIAdapterBase webAPIAdapterBase;
|
||||
webAPIAdapterBase.setPluginManager(m_mainWindow.getPluginManager());
|
||||
qDebug("WebAPIAdapterGUI::instanceConfigPutPatch: configKeys:");
|
||||
configKeys.debug();
|
||||
return 200;
|
||||
|
||||
if (force) {
|
||||
webAPIAdapterBase.webapiInitConfig(m_mainWindow.m_settings);
|
||||
}
|
||||
|
||||
// TODO
|
||||
Preferences newPreferences = m_mainWindow.m_settings.getPreferences();
|
||||
webAPIAdapterBase.webapiUpdatePreferences(query.getPreferences(), configKeys.m_preferencesKeys, newPreferences);
|
||||
m_mainWindow.m_settings.setPreferences(newPreferences);
|
||||
|
||||
Preset *workingPreset = m_mainWindow.m_settings.getWorkingPreset();
|
||||
webAPIAdapterBase.webapiUpdatePreset(query.getWorkingPreset(), configKeys.m_workingPresetKeys, *workingPreset);
|
||||
|
||||
QList<PresetKeys>::const_iterator presetKeysIt = configKeys.m_presetKeys.begin();
|
||||
int i = 0;
|
||||
for (; presetKeysIt != configKeys.m_presetKeys.end(); ++presetKeysIt, i++)
|
||||
{
|
||||
Preset *newPreset = new Preset(); // created with default values
|
||||
SWGSDRangel::SWGPreset *swgPreset = query.getPresets()->at(i);
|
||||
webAPIAdapterBase.webapiUpdatePreset(swgPreset, *presetKeysIt, *newPreset);
|
||||
m_mainWindow.m_settings.addPreset(newPreset);
|
||||
}
|
||||
|
||||
QList<CommandKeys>::const_iterator commandKeysIt = configKeys.m_commandKeys.begin();
|
||||
i = 0;
|
||||
for (; commandKeysIt != configKeys.m_commandKeys.end(); ++commandKeysIt, i++)
|
||||
{
|
||||
Command *newCommand = new Command(); // created with default values
|
||||
SWGSDRangel::SWGCommand *swgCommand = query.getCommands()->at(i);
|
||||
webAPIAdapterBase.webapiUpdateCommand(swgCommand, *commandKeysIt, *newCommand);
|
||||
m_mainWindow.m_settings.addCommand(newCommand);
|
||||
}
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceDevices(
|
||||
|
Loading…
Reference in New Issue
Block a user