mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-28 15:19:04 -04:00
REST API: config: GET (3) added commands and removed usless friend class
This commit is contained in:
parent
b95fa98e5a
commit
8ce4788b55
@ -37,8 +37,6 @@ public:
|
|||||||
bool getUseLogFile() const { return m_useLogFile; }
|
bool getUseLogFile() const { return m_useLogFile; }
|
||||||
const QString& getLogFileName() const { return m_logFileName; }
|
const QString& getLogFileName() const { return m_logFileName; }
|
||||||
|
|
||||||
friend class WebAPIAdapterBase;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_sourceDevice; //!< Identification of the source used in R0 tab (GUI flavor) at startup
|
QString m_sourceDevice; //!< Identification of the source used in R0 tab (GUI flavor) at startup
|
||||||
int m_sourceIndex; //!< Index of the source used in R0 tab (GUI flavor) at startup
|
int m_sourceIndex; //!< Index of the source used in R0 tab (GUI flavor) at startup
|
||||||
|
@ -77,6 +77,9 @@ public:
|
|||||||
void setSpectrumConfig(const QByteArray& data) { m_spectrumConfig = data; }
|
void setSpectrumConfig(const QByteArray& data) { m_spectrumConfig = data; }
|
||||||
const QByteArray& getSpectrumConfig() const { return m_spectrumConfig; }
|
const QByteArray& getSpectrumConfig() const { return m_spectrumConfig; }
|
||||||
|
|
||||||
|
bool hasDCOffsetCorrection() const { return m_dcOffsetCorrection; }
|
||||||
|
bool hasIQImbalanceCorrection() const { return m_iqImbalanceCorrection; }
|
||||||
|
|
||||||
void setLayout(const QByteArray& data) { m_layout = data; }
|
void setLayout(const QByteArray& data) { m_layout = data; }
|
||||||
const QByteArray& getLayout() const { return m_layout; }
|
const QByteArray& getLayout() const { return m_layout; }
|
||||||
|
|
||||||
@ -117,8 +120,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class WebAPIAdapterBase;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_sourcePreset;
|
bool m_sourcePreset;
|
||||||
|
|
||||||
|
@ -24,16 +24,16 @@ void WebAPIAdapterBase::webapiFormatPreferences(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
apiPreferences->init();
|
apiPreferences->init();
|
||||||
apiPreferences->setSourceDevice(new QString(preferences.m_sourceDevice));
|
apiPreferences->setSourceDevice(new QString(preferences.getSourceDevice()));
|
||||||
apiPreferences->setSourceIndex(preferences.m_sourceIndex);
|
apiPreferences->setSourceIndex(preferences.getSourceIndex());
|
||||||
apiPreferences->setAudioType(new QString(preferences.m_audioType));
|
apiPreferences->setAudioType(new QString(preferences.getAudioType()));
|
||||||
apiPreferences->setAudioDevice(new QString(preferences.m_audioDevice));
|
apiPreferences->setAudioDevice(new QString(preferences.getAudioDevice()));
|
||||||
apiPreferences->setLatitude(preferences.m_latitude);
|
apiPreferences->setLatitude(preferences.getLatitude());
|
||||||
apiPreferences->setLongitude(preferences.m_longitude);
|
apiPreferences->setLongitude(preferences.getLongitude());
|
||||||
apiPreferences->setConsoleMinLogLevel((int) preferences.m_consoleMinLogLevel);
|
apiPreferences->setConsoleMinLogLevel((int) preferences.getConsoleMinLogLevel());
|
||||||
apiPreferences->setUseLogFile(preferences.m_useLogFile ? 1 : 0);
|
apiPreferences->setUseLogFile(preferences.getUseLogFile() ? 1 : 0);
|
||||||
apiPreferences->setLogFileName(new QString(preferences.m_logFileName));
|
apiPreferences->setLogFileName(new QString(preferences.getLogFileName()));
|
||||||
apiPreferences->setFileMinLogLevel((int) preferences.m_fileMinLogLevel);
|
apiPreferences->setFileMinLogLevel((int) preferences.getFileMinLogLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebAPIAdapterBase::webapiFormatPreset(
|
void WebAPIAdapterBase::webapiFormatPreset(
|
||||||
@ -42,13 +42,13 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
apiPreset->init();
|
apiPreset->init();
|
||||||
apiPreset->setSourcePreset(preset.m_sourcePreset ? 1 : 0);
|
apiPreset->setSourcePreset(preset.isSourcePreset() ? 1 : 0);
|
||||||
apiPreset->setGroup(new QString(preset.m_group));
|
apiPreset->setGroup(new QString(preset.getGroup()));
|
||||||
apiPreset->setDescription(new QString(preset.m_description));
|
apiPreset->setDescription(new QString(preset.getDescription()));
|
||||||
apiPreset->setCenterFrequency(preset.m_centerFrequency);
|
apiPreset->setCenterFrequency(preset.getCenterFrequency());
|
||||||
apiPreset->getSpectrumConfig()->init(); // TODO when spectrum config is extracted to sdrbase
|
apiPreset->getSpectrumConfig()->init(); // TODO when spectrum config is extracted to sdrbase
|
||||||
apiPreset->setDcOffsetCorrection(preset.m_dcOffsetCorrection ? 1 : 0);
|
apiPreset->setDcOffsetCorrection(preset.hasDCOffsetCorrection() ? 1 : 0);
|
||||||
apiPreset->setIqImbalanceCorrection(preset.m_iqImbalanceCorrection ? 1 : 0);
|
apiPreset->setIqImbalanceCorrection(preset.hasIQImbalanceCorrection() ? 1 : 0);
|
||||||
|
|
||||||
int nbChannels = preset.getChannelCount();
|
int nbChannels = preset.getChannelCount();
|
||||||
for (int i = 0; i < nbChannels; i++)
|
for (int i = 0; i < nbChannels; i++)
|
||||||
@ -70,3 +70,19 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
|||||||
swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence);
|
swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebAPIAdapterBase::webapiFormatCommand(
|
||||||
|
SWGSDRangel::SWGCommand *apiCommand,
|
||||||
|
const Command& command
|
||||||
|
)
|
||||||
|
{
|
||||||
|
apiCommand->init();
|
||||||
|
apiCommand->setGroup(new QString(command.getGroup()));
|
||||||
|
apiCommand->setDescription(new QString(command.getDescription()));
|
||||||
|
apiCommand->setCommand(new QString(command.getCommand()));
|
||||||
|
apiCommand->setArgString(new QString(command.getArgString()));
|
||||||
|
apiCommand->setKey((int) command.getKey());
|
||||||
|
apiCommand->setKeyModifiers((int) command.getKeyModifiers());
|
||||||
|
apiCommand->setAssociateKey(command.getAssociateKey() ? 1 : 0);
|
||||||
|
apiCommand->setRelease(command.getRelease() ? 1 : 0);
|
||||||
|
}
|
@ -22,8 +22,10 @@
|
|||||||
#include "export.h"
|
#include "export.h"
|
||||||
#include "SWGPreferences.h"
|
#include "SWGPreferences.h"
|
||||||
#include "SWGPreset.h"
|
#include "SWGPreset.h"
|
||||||
|
#include "SWGCommand.h"
|
||||||
#include "settings/preferences.h"
|
#include "settings/preferences.h"
|
||||||
#include "settings/preset.h"
|
#include "settings/preset.h"
|
||||||
|
#include "commands/command.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter between API and objects in sdrbase library
|
* Adapter between API and objects in sdrbase library
|
||||||
@ -39,6 +41,10 @@ public:
|
|||||||
SWGSDRangel::SWGPreset *apiPreset,
|
SWGSDRangel::SWGPreset *apiPreset,
|
||||||
const Preset& preset
|
const Preset& preset
|
||||||
);
|
);
|
||||||
|
static void webapiFormatCommand(
|
||||||
|
SWGSDRangel::SWGCommand *apiCommand,
|
||||||
|
const Command& command
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
|
#endif // SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
|
@ -136,6 +136,16 @@ int WebAPIAdapterGUI::instanceConfigGet(
|
|||||||
WebAPIAdapterBase::webapiFormatPreset(swgPresets->back(), *preset);
|
WebAPIAdapterBase::webapiFormatPreset(swgPresets->back(), *preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nbCommands = m_mainWindow.m_settings.getCommandCount();
|
||||||
|
QList<SWGSDRangel::SWGCommand*> *swgCommands = response.getCommands();
|
||||||
|
|
||||||
|
for (int i = 0; i < nbCommands; i++)
|
||||||
|
{
|
||||||
|
const Command *command = m_mainWindow.m_settings.getCommand(i);
|
||||||
|
swgCommands->append(new SWGSDRangel::SWGCommand);
|
||||||
|
WebAPIAdapterBase::webapiFormatCommand(swgCommands->back(), *command);
|
||||||
|
}
|
||||||
|
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,16 @@ int WebAPIAdapterSrv::instanceConfigGet(
|
|||||||
WebAPIAdapterBase::webapiFormatPreset(swgPresets->back(), *preset);
|
WebAPIAdapterBase::webapiFormatPreset(swgPresets->back(), *preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nbCommands = m_mainCore.m_settings.getCommandCount();
|
||||||
|
QList<SWGSDRangel::SWGCommand*> *swgCommands = response.getCommands();
|
||||||
|
|
||||||
|
for (int i = 0; i < nbCommands; i++)
|
||||||
|
{
|
||||||
|
const Command *command = m_mainCore.m_settings.getCommand(i);
|
||||||
|
swgCommands->append(new SWGSDRangel::SWGCommand);
|
||||||
|
WebAPIAdapterBase::webapiFormatCommand(swgCommands->back(), *command);
|
||||||
|
}
|
||||||
|
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user