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

REST API: config: GET (2) presets channels and devices loop

This commit is contained in:
f4exb 2019-08-01 08:49:35 +02:00
parent 233a84c2b3
commit b95fa98e5a
13 changed files with 92 additions and 147 deletions

View File

@ -1765,10 +1765,6 @@ margin-bottom: 20px;
"type" : "string",
"description" : "Channel type ID in URI form"
},
"channelId" : {
"type" : "string",
"description" : "Channel type ID in short form from object name"
},
"config" : {
"$ref" : "#/definitions/ChannelSettings"
}
@ -4340,11 +4336,13 @@ margin-bottom: 20px;
};
defs.Preferences = {
"properties" : {
"sourceType" : {
"type" : "string"
},
"sourceDevice" : {
"type" : "string"
"type" : "string",
"description" : "Identification of the source used in R0 tab (GUI flavor) at startup"
},
"sourceIndex" : {
"type" : "integer",
"description" : "Index of the source used in R0 tab (GUI flavor) at startup"
},
"audioType" : {
"type" : "string"
@ -4352,9 +4350,6 @@ margin-bottom: 20px;
"audioDevice" : {
"type" : "string"
},
"sourceIndex" : {
"type" : "integer"
},
"latitude" : {
"type" : "number",
"format" : "float"
@ -4397,7 +4392,7 @@ margin-bottom: 20px;
"type" : "integer",
"format" : "int64"
},
"m_spectrumConfig" : {
"spectrumConfig" : {
"$ref" : "#/definitions/GLSpectrum"
},
"dcOffsetCorrection" : {
@ -26960,7 +26955,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2019-07-31T23:30:54.359+02:00
Generated 2019-08-01T08:47:20.086+02:00
</div>
</div>
</div>

View File

@ -1,16 +1,16 @@
Preferences:
description: Repreents a Prefernce object
properties:
sourceType:
type: string
sourceDevice:
description: Identification of the source used in R0 tab (GUI flavor) at startup
type: string
sourceIndex:
description: Index of the source used in R0 tab (GUI flavor) at startup
type: integer
audioType:
type: string
audioDevice:
type: string
sourceIndex:
type: integer
latitude:
type: number
format: float

View File

@ -16,9 +16,6 @@ ChannelConfig:
channelIdURI:
description: Channel type ID in URI form
type: string
channelId:
description: Channel type ID in short form from object name
type: string
config:
$ref: "/doc/swagger/include/ChannelSettings.yaml#/ChannelSettings"
@ -35,7 +32,7 @@ Preset:
centerFrequency:
type: integer
format: int64
m_spectrumConfig:
spectrumConfig:
$ref: "/doc/swagger/include/GLSpectrum.yaml#/GLSpectrum"
dcOffsetCorrection:
description: boolean

View File

@ -29,7 +29,6 @@ class SDRBASE_API Preset {
public:
struct ChannelConfig {
QString m_channelIdURI; //!< Channel type ID in URI form
QString m_channelId; //!< Channel type ID in short form from object name TODO: use in the future
QByteArray m_config;
ChannelConfig(const QString& channelIdURI, const QByteArray& config) :
@ -86,10 +85,12 @@ public:
int getChannelCount() const { return m_channelConfigs.count(); }
const ChannelConfig& getChannelConfig(int index) const { return m_channelConfigs.at(index); }
void setDeviceConfig(const QString& deviceId, const QString& deviceSerial, int deviceSequence, const QByteArray& config)
{
void clearDevices() { m_deviceConfigs.clear(); }
void setDeviceConfig(const QString& deviceId, const QString& deviceSerial, int deviceSequence, const QByteArray& config) {
addOrUpdateDeviceConfig(deviceId, deviceSerial, deviceSequence, config);
}
int getDeviceCount() const { return m_deviceConfigs.count(); }
const DeviceConfig& getDeviceConfig(int index) const { return m_deviceConfigs.at(index); }
void addOrUpdateDeviceConfig(const QString& deviceId,
const QString& deviceSerial,

View File

@ -46,9 +46,27 @@ void WebAPIAdapterBase::webapiFormatPreset(
apiPreset->setGroup(new QString(preset.m_group));
apiPreset->setDescription(new QString(preset.m_description));
apiPreset->setCenterFrequency(preset.m_centerFrequency);
apiPreset->getMSpectrumConfig()->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->setIqImbalanceCorrection(preset.m_iqImbalanceCorrection ? 1 : 0);
// TODO: channel configs
// TODO: device configs
int nbChannels = preset.getChannelCount();
for (int i = 0; i < nbChannels; i++)
{
const Preset::ChannelConfig& channelConfig = preset.getChannelConfig(i);
QList<SWGSDRangel::SWGChannelConfig *> *swgChannelConfigs = apiPreset->getChannelConfigs();
swgChannelConfigs->append(new SWGSDRangel::SWGChannelConfig);
swgChannelConfigs->back()->setChannelIdUri(new QString(channelConfig.m_channelIdURI));
}
int nbDevices = preset.getDeviceCount();
for (int i = 0; i < nbDevices; i++)
{
const Preset::DeviceConfig& deviceConfig = preset.getDeviceConfig(i);
QList<SWGSDRangel::SWGDeviceConfig *> *swgdeviceConfigs = apiPreset->getDeviceConfigs();
swgdeviceConfigs->append(new SWGSDRangel::SWGDeviceConfig);
swgdeviceConfigs->back()->setDeviceId(new QString(deviceConfig.m_deviceId));
swgdeviceConfigs->back()->setDeviceSerial(new QString(deviceConfig.m_deviceSerial));
swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence);
}
}

View File

@ -16,9 +16,6 @@ ChannelConfig:
channelIdURI:
description: Channel type ID in URI form
type: string
channelId:
description: Channel type ID in short form from object name
type: string
config:
$ref: "http://localhost:8081/api/swagger/include/ChannelSettings.yaml#/ChannelSettings"

View File

@ -1765,10 +1765,6 @@ margin-bottom: 20px;
"type" : "string",
"description" : "Channel type ID in URI form"
},
"channelId" : {
"type" : "string",
"description" : "Channel type ID in short form from object name"
},
"config" : {
"$ref" : "#/definitions/ChannelSettings"
}
@ -4340,11 +4336,13 @@ margin-bottom: 20px;
};
defs.Preferences = {
"properties" : {
"sourceType" : {
"type" : "string"
},
"sourceDevice" : {
"type" : "string"
"type" : "string",
"description" : "Identification of the source used in R0 tab (GUI flavor) at startup"
},
"sourceIndex" : {
"type" : "integer",
"description" : "Index of the source used in R0 tab (GUI flavor) at startup"
},
"audioType" : {
"type" : "string"
@ -4352,9 +4350,6 @@ margin-bottom: 20px;
"audioDevice" : {
"type" : "string"
},
"sourceIndex" : {
"type" : "integer"
},
"latitude" : {
"type" : "number",
"format" : "float"
@ -4397,7 +4392,7 @@ margin-bottom: 20px;
"type" : "integer",
"format" : "int64"
},
"m_spectrumConfig" : {
"spectrumConfig" : {
"$ref" : "#/definitions/GLSpectrum"
},
"dcOffsetCorrection" : {
@ -26960,7 +26955,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2019-07-31T23:30:54.359+02:00
Generated 2019-08-01T08:47:20.086+02:00
</div>
</div>
</div>

View File

@ -30,8 +30,6 @@ SWGChannelConfig::SWGChannelConfig(QString* json) {
SWGChannelConfig::SWGChannelConfig() {
channel_id_uri = nullptr;
m_channel_id_uri_isSet = false;
channel_id = nullptr;
m_channel_id_isSet = false;
config = nullptr;
m_config_isSet = false;
}
@ -44,8 +42,6 @@ void
SWGChannelConfig::init() {
channel_id_uri = new QString("");
m_channel_id_uri_isSet = false;
channel_id = new QString("");
m_channel_id_isSet = false;
config = new SWGChannelSettings();
m_config_isSet = false;
}
@ -55,9 +51,6 @@ SWGChannelConfig::cleanup() {
if(channel_id_uri != nullptr) {
delete channel_id_uri;
}
if(channel_id != nullptr) {
delete channel_id;
}
if(config != nullptr) {
delete config;
}
@ -76,8 +69,6 @@ void
SWGChannelConfig::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&channel_id_uri, pJson["channelIdURI"], "QString", "QString");
::SWGSDRangel::setValue(&channel_id, pJson["channelId"], "QString", "QString");
::SWGSDRangel::setValue(&config, pJson["config"], "SWGChannelSettings", "SWGChannelSettings");
}
@ -99,9 +90,6 @@ SWGChannelConfig::asJsonObject() {
if(channel_id_uri != nullptr && *channel_id_uri != QString("")){
toJsonValue(QString("channelIdURI"), channel_id_uri, obj, QString("QString"));
}
if(channel_id != nullptr && *channel_id != QString("")){
toJsonValue(QString("channelId"), channel_id, obj, QString("QString"));
}
if((config != nullptr) && (config->isSet())){
toJsonValue(QString("config"), config, obj, QString("SWGChannelSettings"));
}
@ -119,16 +107,6 @@ SWGChannelConfig::setChannelIdUri(QString* channel_id_uri) {
this->m_channel_id_uri_isSet = true;
}
QString*
SWGChannelConfig::getChannelId() {
return channel_id;
}
void
SWGChannelConfig::setChannelId(QString* channel_id) {
this->channel_id = channel_id;
this->m_channel_id_isSet = true;
}
SWGChannelSettings*
SWGChannelConfig::getConfig() {
return config;
@ -145,7 +123,6 @@ SWGChannelConfig::isSet(){
bool isObjectUpdated = false;
do{
if(channel_id_uri != nullptr && *channel_id_uri != QString("")){ isObjectUpdated = true; break;}
if(channel_id != nullptr && *channel_id != QString("")){ isObjectUpdated = true; break;}
if(config != nullptr && config->isSet()){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;

View File

@ -46,9 +46,6 @@ public:
QString* getChannelIdUri();
void setChannelIdUri(QString* channel_id_uri);
QString* getChannelId();
void setChannelId(QString* channel_id);
SWGChannelSettings* getConfig();
void setConfig(SWGChannelSettings* config);
@ -59,9 +56,6 @@ private:
QString* channel_id_uri;
bool m_channel_id_uri_isSet;
QString* channel_id;
bool m_channel_id_isSet;
SWGChannelSettings* config;
bool m_config_isSet;

View File

@ -28,16 +28,14 @@ SWGPreferences::SWGPreferences(QString* json) {
}
SWGPreferences::SWGPreferences() {
source_type = nullptr;
m_source_type_isSet = false;
source_device = nullptr;
m_source_device_isSet = false;
source_index = 0;
m_source_index_isSet = false;
audio_type = nullptr;
m_audio_type_isSet = false;
audio_device = nullptr;
m_audio_device_isSet = false;
source_index = 0;
m_source_index_isSet = false;
latitude = 0.0f;
m_latitude_isSet = false;
longitude = 0.0f;
@ -58,16 +56,14 @@ SWGPreferences::~SWGPreferences() {
void
SWGPreferences::init() {
source_type = new QString("");
m_source_type_isSet = false;
source_device = new QString("");
m_source_device_isSet = false;
source_index = 0;
m_source_index_isSet = false;
audio_type = new QString("");
m_audio_type_isSet = false;
audio_device = new QString("");
m_audio_device_isSet = false;
source_index = 0;
m_source_index_isSet = false;
latitude = 0.0f;
m_latitude_isSet = false;
longitude = 0.0f;
@ -84,12 +80,10 @@ SWGPreferences::init() {
void
SWGPreferences::cleanup() {
if(source_type != nullptr) {
delete source_type;
}
if(source_device != nullptr) {
delete source_device;
}
if(audio_type != nullptr) {
delete audio_type;
}
@ -100,7 +94,6 @@ SWGPreferences::cleanup() {
if(log_file_name != nullptr) {
delete log_file_name;
}
@ -118,16 +111,14 @@ SWGPreferences::fromJson(QString &json) {
void
SWGPreferences::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&source_type, pJson["sourceType"], "QString", "QString");
::SWGSDRangel::setValue(&source_device, pJson["sourceDevice"], "QString", "QString");
::SWGSDRangel::setValue(&source_index, pJson["sourceIndex"], "qint32", "");
::SWGSDRangel::setValue(&audio_type, pJson["audioType"], "QString", "QString");
::SWGSDRangel::setValue(&audio_device, pJson["audioDevice"], "QString", "QString");
::SWGSDRangel::setValue(&source_index, pJson["sourceIndex"], "qint32", "");
::SWGSDRangel::setValue(&latitude, pJson["latitude"], "float", "");
::SWGSDRangel::setValue(&longitude, pJson["longitude"], "float", "");
@ -156,21 +147,18 @@ SWGPreferences::asJson ()
QJsonObject*
SWGPreferences::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(source_type != nullptr && *source_type != QString("")){
toJsonValue(QString("sourceType"), source_type, obj, QString("QString"));
}
if(source_device != nullptr && *source_device != QString("")){
toJsonValue(QString("sourceDevice"), source_device, obj, QString("QString"));
}
if(m_source_index_isSet){
obj->insert("sourceIndex", QJsonValue(source_index));
}
if(audio_type != nullptr && *audio_type != QString("")){
toJsonValue(QString("audioType"), audio_type, obj, QString("QString"));
}
if(audio_device != nullptr && *audio_device != QString("")){
toJsonValue(QString("audioDevice"), audio_device, obj, QString("QString"));
}
if(m_source_index_isSet){
obj->insert("sourceIndex", QJsonValue(source_index));
}
if(m_latitude_isSet){
obj->insert("latitude", QJsonValue(latitude));
}
@ -193,16 +181,6 @@ SWGPreferences::asJsonObject() {
return obj;
}
QString*
SWGPreferences::getSourceType() {
return source_type;
}
void
SWGPreferences::setSourceType(QString* source_type) {
this->source_type = source_type;
this->m_source_type_isSet = true;
}
QString*
SWGPreferences::getSourceDevice() {
return source_device;
@ -213,6 +191,16 @@ SWGPreferences::setSourceDevice(QString* source_device) {
this->m_source_device_isSet = true;
}
qint32
SWGPreferences::getSourceIndex() {
return source_index;
}
void
SWGPreferences::setSourceIndex(qint32 source_index) {
this->source_index = source_index;
this->m_source_index_isSet = true;
}
QString*
SWGPreferences::getAudioType() {
return audio_type;
@ -233,16 +221,6 @@ SWGPreferences::setAudioDevice(QString* audio_device) {
this->m_audio_device_isSet = true;
}
qint32
SWGPreferences::getSourceIndex() {
return source_index;
}
void
SWGPreferences::setSourceIndex(qint32 source_index) {
this->source_index = source_index;
this->m_source_index_isSet = true;
}
float
SWGPreferences::getLatitude() {
return latitude;
@ -308,11 +286,10 @@ bool
SWGPreferences::isSet(){
bool isObjectUpdated = false;
do{
if(source_type != nullptr && *source_type != QString("")){ isObjectUpdated = true; break;}
if(source_device != nullptr && *source_device != QString("")){ isObjectUpdated = true; break;}
if(m_source_index_isSet){ isObjectUpdated = true; break;}
if(audio_type != nullptr && *audio_type != QString("")){ isObjectUpdated = true; break;}
if(audio_device != nullptr && *audio_device != QString("")){ isObjectUpdated = true; break;}
if(m_source_index_isSet){ isObjectUpdated = true; break;}
if(m_latitude_isSet){ isObjectUpdated = true; break;}
if(m_longitude_isSet){ isObjectUpdated = true; break;}
if(m_console_min_log_level_isSet){ isObjectUpdated = true; break;}

View File

@ -42,21 +42,18 @@ public:
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGPreferences* fromJson(QString &jsonString) override;
QString* getSourceType();
void setSourceType(QString* source_type);
QString* getSourceDevice();
void setSourceDevice(QString* source_device);
qint32 getSourceIndex();
void setSourceIndex(qint32 source_index);
QString* getAudioType();
void setAudioType(QString* audio_type);
QString* getAudioDevice();
void setAudioDevice(QString* audio_device);
qint32 getSourceIndex();
void setSourceIndex(qint32 source_index);
float getLatitude();
void setLatitude(float latitude);
@ -79,21 +76,18 @@ public:
virtual bool isSet() override;
private:
QString* source_type;
bool m_source_type_isSet;
QString* source_device;
bool m_source_device_isSet;
qint32 source_index;
bool m_source_index_isSet;
QString* audio_type;
bool m_audio_type_isSet;
QString* audio_device;
bool m_audio_device_isSet;
qint32 source_index;
bool m_source_index_isSet;
float latitude;
bool m_latitude_isSet;

View File

@ -36,8 +36,8 @@ SWGPreset::SWGPreset() {
m_description_isSet = false;
center_frequency = 0L;
m_center_frequency_isSet = false;
m_spectrum_config = nullptr;
m_m_spectrum_config_isSet = false;
spectrum_config = nullptr;
m_spectrum_config_isSet = false;
dc_offset_correction = 0;
m_dc_offset_correction_isSet = false;
iq_imbalance_correction = 0;
@ -64,8 +64,8 @@ SWGPreset::init() {
m_description_isSet = false;
center_frequency = 0L;
m_center_frequency_isSet = false;
m_spectrum_config = new SWGGLSpectrum();
m_m_spectrum_config_isSet = false;
spectrum_config = new SWGGLSpectrum();
m_spectrum_config_isSet = false;
dc_offset_correction = 0;
m_dc_offset_correction_isSet = false;
iq_imbalance_correction = 0;
@ -88,8 +88,8 @@ SWGPreset::cleanup() {
delete description;
}
if(m_spectrum_config != nullptr) {
delete m_spectrum_config;
if(spectrum_config != nullptr) {
delete spectrum_config;
}
@ -131,7 +131,7 @@ SWGPreset::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint64", "");
::SWGSDRangel::setValue(&m_spectrum_config, pJson["m_spectrumConfig"], "SWGGLSpectrum", "SWGGLSpectrum");
::SWGSDRangel::setValue(&spectrum_config, pJson["spectrumConfig"], "SWGGLSpectrum", "SWGGLSpectrum");
::SWGSDRangel::setValue(&dc_offset_correction, pJson["dcOffsetCorrection"], "qint32", "");
@ -171,8 +171,8 @@ SWGPreset::asJsonObject() {
if(m_center_frequency_isSet){
obj->insert("centerFrequency", QJsonValue(center_frequency));
}
if((m_spectrum_config != nullptr) && (m_spectrum_config->isSet())){
toJsonValue(QString("m_spectrumConfig"), m_spectrum_config, obj, QString("SWGGLSpectrum"));
if((spectrum_config != nullptr) && (spectrum_config->isSet())){
toJsonValue(QString("spectrumConfig"), spectrum_config, obj, QString("SWGGLSpectrum"));
}
if(m_dc_offset_correction_isSet){
obj->insert("dcOffsetCorrection", QJsonValue(dc_offset_correction));
@ -234,13 +234,13 @@ SWGPreset::setCenterFrequency(qint64 center_frequency) {
}
SWGGLSpectrum*
SWGPreset::getMSpectrumConfig() {
return m_spectrum_config;
SWGPreset::getSpectrumConfig() {
return spectrum_config;
}
void
SWGPreset::setMSpectrumConfig(SWGGLSpectrum* m_spectrum_config) {
this->m_spectrum_config = m_spectrum_config;
this->m_m_spectrum_config_isSet = true;
SWGPreset::setSpectrumConfig(SWGGLSpectrum* spectrum_config) {
this->spectrum_config = spectrum_config;
this->m_spectrum_config_isSet = true;
}
qint32
@ -302,7 +302,7 @@ SWGPreset::isSet(){
if(group != nullptr && *group != QString("")){ isObjectUpdated = true; break;}
if(description != nullptr && *description != QString("")){ isObjectUpdated = true; break;}
if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
if(m_spectrum_config != nullptr && m_spectrum_config->isSet()){ isObjectUpdated = true; break;}
if(spectrum_config != nullptr && spectrum_config->isSet()){ isObjectUpdated = true; break;}
if(m_dc_offset_correction_isSet){ isObjectUpdated = true; break;}
if(m_iq_imbalance_correction_isSet){ isObjectUpdated = true; break;}
if(channel_configs->size() > 0){ isObjectUpdated = true; break;}

View File

@ -58,8 +58,8 @@ public:
qint64 getCenterFrequency();
void setCenterFrequency(qint64 center_frequency);
SWGGLSpectrum* getMSpectrumConfig();
void setMSpectrumConfig(SWGGLSpectrum* m_spectrum_config);
SWGGLSpectrum* getSpectrumConfig();
void setSpectrumConfig(SWGGLSpectrum* spectrum_config);
qint32 getDcOffsetCorrection();
void setDcOffsetCorrection(qint32 dc_offset_correction);
@ -92,8 +92,8 @@ private:
qint64 center_frequency;
bool m_center_frequency_isSet;
SWGGLSpectrum* m_spectrum_config;
bool m_m_spectrum_config_isSet;
SWGGLSpectrum* spectrum_config;
bool m_spectrum_config_isSet;
qint32 dc_offset_correction;
bool m_dc_offset_correction_isSet;