From 5ad52a4a1b8a0e31c043987410196db2d6de1bdb Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 25 Sep 2018 17:03:34 +0200 Subject: [PATCH] BladerRF2 input support. Populate gain modes --- devices/bladerf2/devicebladerf2.cpp | 30 ++++ devices/bladerf2/devicebladerf2.h | 1 + .../bladerf2input/bladerf2input.cpp | 32 +++- .../bladerf2input/bladerf2input.h | 4 + .../bladerf2input/bladerf2inputgui.cpp | 9 ++ .../bladerf2input/bladerf2inputgui.h | 2 + sdrbase/resources/webapi/doc/html2/index.html | 37 ++++- .../webapi/doc/swagger/include/BladeRF2.yaml | 11 +- .../webapi/doc/swagger/include/Structs.yaml | 30 +++- .../api/swagger/include/BladeRF2.yaml | 11 +- .../sdrangel/api/swagger/include/Structs.yaml | 30 +++- swagger/sdrangel/code/html2/index.html | 37 ++++- .../qt5/client/SWGBladeRF2InputReport.cpp | 37 ++++- .../code/qt5/client/SWGBladeRF2InputReport.h | 15 +- .../code/qt5/client/SWGFrequencyRange.cpp | 148 ++++++++++++++++++ .../code/qt5/client/SWGFrequencyRange.h | 70 +++++++++ .../code/qt5/client/SWGModelFactory.h | 8 + .../sdrangel/code/qt5/client/SWGNamedEnum.cpp | 129 +++++++++++++++ .../sdrangel/code/qt5/client/SWGNamedEnum.h | 65 ++++++++ 19 files changed, 675 insertions(+), 31 deletions(-) create mode 100644 swagger/sdrangel/code/qt5/client/SWGFrequencyRange.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGFrequencyRange.h create mode 100644 swagger/sdrangel/code/qt5/client/SWGNamedEnum.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGNamedEnum.h diff --git a/devices/bladerf2/devicebladerf2.cpp b/devices/bladerf2/devicebladerf2.cpp index 63d7c4c8c..92f88f313 100644 --- a/devices/bladerf2/devicebladerf2.cpp +++ b/devices/bladerf2/devicebladerf2.cpp @@ -462,6 +462,36 @@ void DeviceBladeRF2::getGlobalGainRangeTx(int& min, int& max, int& step) } } +int DeviceBladeRF2::getGainModesRx(const bladerf_gain_modes **modes) +{ + if (m_dev) + { + int n = bladerf_get_gain_modes(m_dev, BLADERF_CHANNEL_RX(0), 0); + + if (n < 0) + { + qCritical("DeviceBladeRF2::getGainModesRx: Failed to get the number of Rx gain modes: %s", bladerf_strerror(n)); + return 0; + } + + int status = bladerf_get_gain_modes(m_dev, BLADERF_CHANNEL_RX(0), modes); + + if (status < 0) + { + qCritical("DeviceBladeRF2::getGainModesRx: Failed to get Rx gain modes: %s", bladerf_strerror(status)); + return 0; + } + else + { + return n; + } + } + else + { + return 0; + } +} + void DeviceBladeRF2::setBiasTeeRx(bool enable) { if (m_dev) diff --git a/devices/bladerf2/devicebladerf2.h b/devices/bladerf2/devicebladerf2.h index 70df89f17..a19147909 100644 --- a/devices/bladerf2/devicebladerf2.h +++ b/devices/bladerf2/devicebladerf2.h @@ -46,6 +46,7 @@ public: void getBandwidthRangeTx(int& min, int& max, int& step); void getGlobalGainRangeRx(int& min, int& max, int& step); void getGlobalGainRangeTx(int& min, int& max, int& step); + int getGainModesRx(const bladerf_gain_modes**); void setBiasTeeRx(bool enable); void setBiasTeeTx(bool enable); diff --git a/plugins/samplesource/bladerf2input/bladerf2input.cpp b/plugins/samplesource/bladerf2input/bladerf2input.cpp index 7abdc14e4..26512a1e1 100644 --- a/plugins/samplesource/bladerf2input/bladerf2input.cpp +++ b/plugins/samplesource/bladerf2input/bladerf2input.cpp @@ -16,6 +16,8 @@ #include +#include "libbladeRF.h" + #include "SWGDeviceSettings.h" #include "SWGBladeRF2InputSettings.h" #include "SWGDeviceState.h" @@ -507,6 +509,19 @@ void BladeRF2Input::getGlobalGainRange(int& min, int& max, int& step) } } +const bladerf_gain_modes *BladeRF2Input::getGainModes(int& nbGains) +{ + const bladerf_gain_modes *modes = 0; + + if (m_deviceShared.m_dev) { + nbGains = m_deviceShared.m_dev->getGainModesRx(&modes); + } else { + nbGains = 0; + } + + return modes; +} + bool BladeRF2Input::handleMessage(const Message& message) { if (MsgConfigureBladeRF2::match(message)) @@ -978,7 +993,7 @@ void BladeRF2Input::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo device->getFrequencyRangeRx(f_min, f_max, step); - response.getBladeRf2InputReport()->setFrequencyRange(new SWGSDRangel::SWGRange); + response.getBladeRf2InputReport()->setFrequencyRange(new SWGSDRangel::SWGFrequencyRange); response.getBladeRf2InputReport()->getFrequencyRange()->setMin(f_min); response.getBladeRf2InputReport()->getFrequencyRange()->setMax(f_max); response.getBladeRf2InputReport()->getFrequencyRange()->setStep(step); @@ -996,6 +1011,21 @@ void BladeRF2Input::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo response.getBladeRf2InputReport()->getSampleRateRange()->setMin(min); response.getBladeRf2InputReport()->getSampleRateRange()->setMax(max); response.getBladeRf2InputReport()->getSampleRateRange()->setStep(step); + + response.getBladeRf2InputReport()->setGainModes(new QList); + + int nbModes; + const bladerf_gain_modes *modes = getGainModes(nbModes); + + if (modes) + { + for (int i = 0; i < nbModes; modes++) + { + response.getBladeRf2InputReport()->getGainModes()->append(new SWGSDRangel::SWGNamedEnum); + response.getBladeRf2InputReport()->getGainModes()->back()->setName(new QString(modes[i].name)); + response.getBladeRf2InputReport()->getGainModes()->back()->setValue(modes[i].mode); + } + } } } diff --git a/plugins/samplesource/bladerf2input/bladerf2input.h b/plugins/samplesource/bladerf2input/bladerf2input.h index f2d8486ba..0cd59b212 100644 --- a/plugins/samplesource/bladerf2input/bladerf2input.h +++ b/plugins/samplesource/bladerf2input/bladerf2input.h @@ -28,6 +28,7 @@ class DeviceSourceAPI; class BladeRF2InputThread; class FileRecord; +struct bladerf_gain_modes; class BladeRF2Input : public DeviceSampleSource { @@ -116,6 +117,7 @@ public: void getSampleRateRange(int& min, int& max, int& step); void getBandwidthRange(int& min, int& max, int& step); void getGlobalGainRange(int& min, int& max, int& step); + const bladerf_gain_modes *getGainModes(int& nbGains); virtual bool handleMessage(const Message& message); @@ -151,6 +153,8 @@ private: DeviceBladeRF2Shared m_deviceShared; BladeRF2InputThread *m_thread; FileRecord *m_fileSink; //!< File sink to record device I/Q output + bladerf_gain_modes **m_gainModes; + int m_nbGainModes; bool openDevice(); void closeDevice(); diff --git a/plugins/samplesource/bladerf2input/bladerf2inputgui.cpp b/plugins/samplesource/bladerf2input/bladerf2inputgui.cpp index 3fb1020e9..6307e3f78 100644 --- a/plugins/samplesource/bladerf2input/bladerf2inputgui.cpp +++ b/plugins/samplesource/bladerf2input/bladerf2inputgui.cpp @@ -58,6 +58,15 @@ BladeRF2InputGui::BladeRF2InputGui(DeviceUISet *deviceUISet, QWidget* parent) : ui->bandwidth->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); ui->bandwidth->setValueRange(6, min/1000, max/1000); + m_gainModes = m_sampleSource->getGainModes(m_nbGainModes); + + if (m_gainModes) + { + for (int i = 0; i < m_nbGainModes; i++) { + ui->gainMode->addItem(tr("%1").arg(m_gainModes[i].name)); + } + } + connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); m_statusTimer.start(500); diff --git a/plugins/samplesource/bladerf2input/bladerf2inputgui.h b/plugins/samplesource/bladerf2input/bladerf2inputgui.h index f52c82022..3f6a0df99 100644 --- a/plugins/samplesource/bladerf2input/bladerf2inputgui.h +++ b/plugins/samplesource/bladerf2input/bladerf2inputgui.h @@ -65,6 +65,8 @@ private: quint64 m_deviceCenterFrequency; //!< Center frequency in device int m_lastEngineState; MessageQueue m_inputMessageQueue; + const struct bladerf_gain_modes *m_gainModes; + int m_nbGainModes; void displaySettings(); void sendSettings(); diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 941d139fd..52d4b1fa3 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -1305,7 +1305,7 @@ margin-bottom: 20px; defs.BladeRF2InputReport = { "properties" : { "frequencyRange" : { - "$ref" : "#/definitions/Range" + "$ref" : "#/definitions/FrequencyRange" }, "sampleRateRange" : { "$ref" : "#/definitions/Range" @@ -1315,6 +1315,12 @@ margin-bottom: 20px; }, "globalGainRange" : { "$ref" : "#/definitions/Range" + }, + "gainModes" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/NamedEnum" + } } }, "description" : "BladeRF2" @@ -2250,6 +2256,22 @@ margin-bottom: 20px; } }, "description" : "A band of frequencies given its boudaries in Hertz (Hz)" +}; + defs.FrequencyRange = { + "properties" : { + "min" : { + "type" : "integer", + "format" : "int64" + }, + "max" : { + "type" : "integer", + "format" : "int64" + }, + "step" : { + "type" : "integer" + } + }, + "description" : "An frequency range with 64 bit support for min and max" }; defs.Gain = { "properties" : { @@ -2811,6 +2833,17 @@ margin-bottom: 20px; } }, "description" : "NFMMod" +}; + defs.NamedEnum = { + "properties" : { + "name" : { + "type" : "string" + }, + "value" : { + "type" : "integer" + } + }, + "description" : "Enumeration with name for values" }; defs.PerseusReport = { "properties" : { @@ -23142,7 +23175,7 @@ except ApiException as e:
- Generated 2018-09-22T10:27:51.856+02:00 + Generated 2018-09-25T16:51:16.493+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/BladeRF2.yaml b/sdrbase/resources/webapi/doc/swagger/include/BladeRF2.yaml index 9b44f6c2d..39332634b 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/BladeRF2.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/BladeRF2.yaml @@ -23,17 +23,20 @@ BladeRF2InputSettings: iqCorrection: type: integer fileRecordName: - type: string - + type: string + BladeRF2InputReport: description: BladeRF2 properties: frequencyRange: - $ref: "/doc/swagger/include/Structs.yaml#/Range" + $ref: "/doc/swagger/include/Structs.yaml#/FrequencyRange" sampleRateRange: $ref: "/doc/swagger/include/Structs.yaml#/Range" bandwidthRange: $ref: "/doc/swagger/include/Structs.yaml#/Range" globalGainRange: $ref: "/doc/swagger/include/Structs.yaml#/Range" - \ No newline at end of file + gainModes: + type: array + items: + $ref: "/doc/swagger/include/Structs.yaml#/NamedEnum" diff --git a/sdrbase/resources/webapi/doc/swagger/include/Structs.yaml b/sdrbase/resources/webapi/doc/swagger/include/Structs.yaml index ccdedd7ba..a8976c4a5 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/Structs.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/Structs.yaml @@ -3,19 +3,19 @@ SampleRate: properties: rate: type: integer - + Bandwidth: description: A bandwidth expressed in Hertz (Hz) properties: bandwidth: type: integer - + Frequency: description: A frequency expressed in Hertz (Hz) properties: frequency: type: integer - + FrequencyBand: description: A band of frequencies given its boudaries in Hertz (Hz) properties: @@ -38,6 +38,26 @@ Range: min: type: integer max: - type: integer + type: integer step: - type: integer \ No newline at end of file + type: integer + +FrequencyRange: + description: An frequency range with 64 bit support for min and max + properties: + min: + type: integer + format: int64 + max: + type: integer + format: int64 + step: + type: integer + +NamedEnum: + description: Enumeration with name for values + properties: + name: + type: string + value: + type: integer diff --git a/swagger/sdrangel/api/swagger/include/BladeRF2.yaml b/swagger/sdrangel/api/swagger/include/BladeRF2.yaml index 40eb4d52c..c87dc8d81 100644 --- a/swagger/sdrangel/api/swagger/include/BladeRF2.yaml +++ b/swagger/sdrangel/api/swagger/include/BladeRF2.yaml @@ -23,17 +23,20 @@ BladeRF2InputSettings: iqCorrection: type: integer fileRecordName: - type: string - + type: string + BladeRF2InputReport: description: BladeRF2 properties: frequencyRange: - $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range" + $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/FrequencyRange" sampleRateRange: $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range" bandwidthRange: $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range" globalGainRange: $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range" - \ No newline at end of file + gainModes: + type: array + items: + $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/NamedEnum" diff --git a/swagger/sdrangel/api/swagger/include/Structs.yaml b/swagger/sdrangel/api/swagger/include/Structs.yaml index ccdedd7ba..a8976c4a5 100644 --- a/swagger/sdrangel/api/swagger/include/Structs.yaml +++ b/swagger/sdrangel/api/swagger/include/Structs.yaml @@ -3,19 +3,19 @@ SampleRate: properties: rate: type: integer - + Bandwidth: description: A bandwidth expressed in Hertz (Hz) properties: bandwidth: type: integer - + Frequency: description: A frequency expressed in Hertz (Hz) properties: frequency: type: integer - + FrequencyBand: description: A band of frequencies given its boudaries in Hertz (Hz) properties: @@ -38,6 +38,26 @@ Range: min: type: integer max: - type: integer + type: integer step: - type: integer \ No newline at end of file + type: integer + +FrequencyRange: + description: An frequency range with 64 bit support for min and max + properties: + min: + type: integer + format: int64 + max: + type: integer + format: int64 + step: + type: integer + +NamedEnum: + description: Enumeration with name for values + properties: + name: + type: string + value: + type: integer diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 941d139fd..52d4b1fa3 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -1305,7 +1305,7 @@ margin-bottom: 20px; defs.BladeRF2InputReport = { "properties" : { "frequencyRange" : { - "$ref" : "#/definitions/Range" + "$ref" : "#/definitions/FrequencyRange" }, "sampleRateRange" : { "$ref" : "#/definitions/Range" @@ -1315,6 +1315,12 @@ margin-bottom: 20px; }, "globalGainRange" : { "$ref" : "#/definitions/Range" + }, + "gainModes" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/NamedEnum" + } } }, "description" : "BladeRF2" @@ -2250,6 +2256,22 @@ margin-bottom: 20px; } }, "description" : "A band of frequencies given its boudaries in Hertz (Hz)" +}; + defs.FrequencyRange = { + "properties" : { + "min" : { + "type" : "integer", + "format" : "int64" + }, + "max" : { + "type" : "integer", + "format" : "int64" + }, + "step" : { + "type" : "integer" + } + }, + "description" : "An frequency range with 64 bit support for min and max" }; defs.Gain = { "properties" : { @@ -2811,6 +2833,17 @@ margin-bottom: 20px; } }, "description" : "NFMMod" +}; + defs.NamedEnum = { + "properties" : { + "name" : { + "type" : "string" + }, + "value" : { + "type" : "integer" + } + }, + "description" : "Enumeration with name for values" }; defs.PerseusReport = { "properties" : { @@ -23142,7 +23175,7 @@ except ApiException as e:
- Generated 2018-09-22T10:27:51.856+02:00 + Generated 2018-09-25T16:51:16.493+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.cpp b/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.cpp index b641d2a1c..e68b32e38 100644 --- a/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.cpp @@ -36,6 +36,8 @@ SWGBladeRF2InputReport::SWGBladeRF2InputReport() { m_bandwidth_range_isSet = false; global_gain_range = nullptr; m_global_gain_range_isSet = false; + gain_modes = nullptr; + m_gain_modes_isSet = false; } SWGBladeRF2InputReport::~SWGBladeRF2InputReport() { @@ -44,7 +46,7 @@ SWGBladeRF2InputReport::~SWGBladeRF2InputReport() { void SWGBladeRF2InputReport::init() { - frequency_range = new SWGRange(); + frequency_range = new SWGFrequencyRange(); m_frequency_range_isSet = false; sample_rate_range = new SWGRange(); m_sample_rate_range_isSet = false; @@ -52,6 +54,8 @@ SWGBladeRF2InputReport::init() { m_bandwidth_range_isSet = false; global_gain_range = new SWGRange(); m_global_gain_range_isSet = false; + gain_modes = new QList(); + m_gain_modes_isSet = false; } void @@ -68,6 +72,13 @@ SWGBladeRF2InputReport::cleanup() { if(global_gain_range != nullptr) { delete global_gain_range; } + if(gain_modes != nullptr) { + auto arr = gain_modes; + for(auto o: *arr) { + delete o; + } + delete gain_modes; + } } SWGBladeRF2InputReport* @@ -81,7 +92,7 @@ SWGBladeRF2InputReport::fromJson(QString &json) { void SWGBladeRF2InputReport::fromJsonObject(QJsonObject &pJson) { - ::SWGSDRangel::setValue(&frequency_range, pJson["frequencyRange"], "SWGRange", "SWGRange"); + ::SWGSDRangel::setValue(&frequency_range, pJson["frequencyRange"], "SWGFrequencyRange", "SWGFrequencyRange"); ::SWGSDRangel::setValue(&sample_rate_range, pJson["sampleRateRange"], "SWGRange", "SWGRange"); @@ -89,6 +100,8 @@ SWGBladeRF2InputReport::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&global_gain_range, pJson["globalGainRange"], "SWGRange", "SWGRange"); + + ::SWGSDRangel::setValue(&gain_modes, pJson["gainModes"], "QList", "SWGNamedEnum"); } QString @@ -106,7 +119,7 @@ QJsonObject* SWGBladeRF2InputReport::asJsonObject() { QJsonObject* obj = new QJsonObject(); if((frequency_range != nullptr) && (frequency_range->isSet())){ - toJsonValue(QString("frequencyRange"), frequency_range, obj, QString("SWGRange")); + toJsonValue(QString("frequencyRange"), frequency_range, obj, QString("SWGFrequencyRange")); } if((sample_rate_range != nullptr) && (sample_rate_range->isSet())){ toJsonValue(QString("sampleRateRange"), sample_rate_range, obj, QString("SWGRange")); @@ -117,16 +130,19 @@ SWGBladeRF2InputReport::asJsonObject() { if((global_gain_range != nullptr) && (global_gain_range->isSet())){ toJsonValue(QString("globalGainRange"), global_gain_range, obj, QString("SWGRange")); } + if(gain_modes->size() > 0){ + toJsonArray((QList*)gain_modes, obj, "gainModes", "SWGNamedEnum"); + } return obj; } -SWGRange* +SWGFrequencyRange* SWGBladeRF2InputReport::getFrequencyRange() { return frequency_range; } void -SWGBladeRF2InputReport::setFrequencyRange(SWGRange* frequency_range) { +SWGBladeRF2InputReport::setFrequencyRange(SWGFrequencyRange* frequency_range) { this->frequency_range = frequency_range; this->m_frequency_range_isSet = true; } @@ -161,6 +177,16 @@ SWGBladeRF2InputReport::setGlobalGainRange(SWGRange* global_gain_range) { this->m_global_gain_range_isSet = true; } +QList* +SWGBladeRF2InputReport::getGainModes() { + return gain_modes; +} +void +SWGBladeRF2InputReport::setGainModes(QList* gain_modes) { + this->gain_modes = gain_modes; + this->m_gain_modes_isSet = true; +} + bool SWGBladeRF2InputReport::isSet(){ @@ -170,6 +196,7 @@ SWGBladeRF2InputReport::isSet(){ if(sample_rate_range != nullptr && sample_rate_range->isSet()){ isObjectUpdated = true; break;} if(bandwidth_range != nullptr && bandwidth_range->isSet()){ isObjectUpdated = true; break;} if(global_gain_range != nullptr && global_gain_range->isSet()){ isObjectUpdated = true; break;} + if(gain_modes->size() > 0){ isObjectUpdated = true; break;} }while(false); return isObjectUpdated; } diff --git a/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.h b/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.h index 0f8b5d5d9..4aeeb3fcb 100644 --- a/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.h +++ b/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.h @@ -22,7 +22,10 @@ #include +#include "SWGFrequencyRange.h" +#include "SWGNamedEnum.h" #include "SWGRange.h" +#include #include "SWGObject.h" #include "export.h" @@ -42,8 +45,8 @@ public: virtual void fromJsonObject(QJsonObject &json) override; virtual SWGBladeRF2InputReport* fromJson(QString &jsonString) override; - SWGRange* getFrequencyRange(); - void setFrequencyRange(SWGRange* frequency_range); + SWGFrequencyRange* getFrequencyRange(); + void setFrequencyRange(SWGFrequencyRange* frequency_range); SWGRange* getSampleRateRange(); void setSampleRateRange(SWGRange* sample_rate_range); @@ -54,11 +57,14 @@ public: SWGRange* getGlobalGainRange(); void setGlobalGainRange(SWGRange* global_gain_range); + QList* getGainModes(); + void setGainModes(QList* gain_modes); + virtual bool isSet() override; private: - SWGRange* frequency_range; + SWGFrequencyRange* frequency_range; bool m_frequency_range_isSet; SWGRange* sample_rate_range; @@ -70,6 +76,9 @@ private: SWGRange* global_gain_range; bool m_global_gain_range_isSet; + QList* gain_modes; + bool m_gain_modes_isSet; + }; } diff --git a/swagger/sdrangel/code/qt5/client/SWGFrequencyRange.cpp b/swagger/sdrangel/code/qt5/client/SWGFrequencyRange.cpp new file mode 100644 index 000000000..e50e1faef --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFrequencyRange.cpp @@ -0,0 +1,148 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 4.2.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGFrequencyRange.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGFrequencyRange::SWGFrequencyRange(QString* json) { + init(); + this->fromJson(*json); +} + +SWGFrequencyRange::SWGFrequencyRange() { + min = 0L; + m_min_isSet = false; + max = 0L; + m_max_isSet = false; + step = 0; + m_step_isSet = false; +} + +SWGFrequencyRange::~SWGFrequencyRange() { + this->cleanup(); +} + +void +SWGFrequencyRange::init() { + min = 0L; + m_min_isSet = false; + max = 0L; + m_max_isSet = false; + step = 0; + m_step_isSet = false; +} + +void +SWGFrequencyRange::cleanup() { + + + +} + +SWGFrequencyRange* +SWGFrequencyRange::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGFrequencyRange::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&min, pJson["min"], "qint64", ""); + + ::SWGSDRangel::setValue(&max, pJson["max"], "qint64", ""); + + ::SWGSDRangel::setValue(&step, pJson["step"], "qint32", ""); + +} + +QString +SWGFrequencyRange::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGFrequencyRange::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(m_min_isSet){ + obj->insert("min", QJsonValue(min)); + } + if(m_max_isSet){ + obj->insert("max", QJsonValue(max)); + } + if(m_step_isSet){ + obj->insert("step", QJsonValue(step)); + } + + return obj; +} + +qint64 +SWGFrequencyRange::getMin() { + return min; +} +void +SWGFrequencyRange::setMin(qint64 min) { + this->min = min; + this->m_min_isSet = true; +} + +qint64 +SWGFrequencyRange::getMax() { + return max; +} +void +SWGFrequencyRange::setMax(qint64 max) { + this->max = max; + this->m_max_isSet = true; +} + +qint32 +SWGFrequencyRange::getStep() { + return step; +} +void +SWGFrequencyRange::setStep(qint32 step) { + this->step = step; + this->m_step_isSet = true; +} + + +bool +SWGFrequencyRange::isSet(){ + bool isObjectUpdated = false; + do{ + if(m_min_isSet){ isObjectUpdated = true; break;} + if(m_max_isSet){ isObjectUpdated = true; break;} + if(m_step_isSet){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGFrequencyRange.h b/swagger/sdrangel/code/qt5/client/SWGFrequencyRange.h new file mode 100644 index 000000000..0967d0706 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGFrequencyRange.h @@ -0,0 +1,70 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 4.2.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGFrequencyRange.h + * + * An frequency range with 64 bit support for min and max + */ + +#ifndef SWGFrequencyRange_H_ +#define SWGFrequencyRange_H_ + +#include + + + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGFrequencyRange: public SWGObject { +public: + SWGFrequencyRange(); + SWGFrequencyRange(QString* json); + virtual ~SWGFrequencyRange(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGFrequencyRange* fromJson(QString &jsonString) override; + + qint64 getMin(); + void setMin(qint64 min); + + qint64 getMax(); + void setMax(qint64 max); + + qint32 getStep(); + void setStep(qint32 step); + + + virtual bool isSet() override; + +private: + qint64 min; + bool m_min_isSet; + + qint64 max; + bool m_max_isSet; + + qint32 step; + bool m_step_isSet; + +}; + +} + +#endif /* SWGFrequencyRange_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index d49a92e09..1ac604c66 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -60,6 +60,7 @@ #include "SWGFileSourceSettings.h" #include "SWGFrequency.h" #include "SWGFrequencyBand.h" +#include "SWGFrequencyRange.h" #include "SWGGain.h" #include "SWGHackRFInputSettings.h" #include "SWGHackRFOutputSettings.h" @@ -76,6 +77,7 @@ #include "SWGNFMDemodSettings.h" #include "SWGNFMModReport.h" #include "SWGNFMModSettings.h" +#include "SWGNamedEnum.h" #include "SWGPerseusReport.h" #include "SWGPerseusSettings.h" #include "SWGPlutoSdrInputReport.h" @@ -258,6 +260,9 @@ namespace SWGSDRangel { if(QString("SWGFrequencyBand").compare(type) == 0) { return new SWGFrequencyBand(); } + if(QString("SWGFrequencyRange").compare(type) == 0) { + return new SWGFrequencyRange(); + } if(QString("SWGGain").compare(type) == 0) { return new SWGGain(); } @@ -306,6 +311,9 @@ namespace SWGSDRangel { if(QString("SWGNFMModSettings").compare(type) == 0) { return new SWGNFMModSettings(); } + if(QString("SWGNamedEnum").compare(type) == 0) { + return new SWGNamedEnum(); + } if(QString("SWGPerseusReport").compare(type) == 0) { return new SWGPerseusReport(); } diff --git a/swagger/sdrangel/code/qt5/client/SWGNamedEnum.cpp b/swagger/sdrangel/code/qt5/client/SWGNamedEnum.cpp new file mode 100644 index 000000000..2220a6bd7 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGNamedEnum.cpp @@ -0,0 +1,129 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 4.2.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGNamedEnum.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGNamedEnum::SWGNamedEnum(QString* json) { + init(); + this->fromJson(*json); +} + +SWGNamedEnum::SWGNamedEnum() { + name = nullptr; + m_name_isSet = false; + value = 0; + m_value_isSet = false; +} + +SWGNamedEnum::~SWGNamedEnum() { + this->cleanup(); +} + +void +SWGNamedEnum::init() { + name = new QString(""); + m_name_isSet = false; + value = 0; + m_value_isSet = false; +} + +void +SWGNamedEnum::cleanup() { + if(name != nullptr) { + delete name; + } + +} + +SWGNamedEnum* +SWGNamedEnum::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGNamedEnum::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&name, pJson["name"], "QString", "QString"); + + ::SWGSDRangel::setValue(&value, pJson["value"], "qint32", ""); + +} + +QString +SWGNamedEnum::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGNamedEnum::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(name != nullptr && *name != QString("")){ + toJsonValue(QString("name"), name, obj, QString("QString")); + } + if(m_value_isSet){ + obj->insert("value", QJsonValue(value)); + } + + return obj; +} + +QString* +SWGNamedEnum::getName() { + return name; +} +void +SWGNamedEnum::setName(QString* name) { + this->name = name; + this->m_name_isSet = true; +} + +qint32 +SWGNamedEnum::getValue() { + return value; +} +void +SWGNamedEnum::setValue(qint32 value) { + this->value = value; + this->m_value_isSet = true; +} + + +bool +SWGNamedEnum::isSet(){ + bool isObjectUpdated = false; + do{ + if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;} + if(m_value_isSet){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGNamedEnum.h b/swagger/sdrangel/code/qt5/client/SWGNamedEnum.h new file mode 100644 index 000000000..82a762d07 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGNamedEnum.h @@ -0,0 +1,65 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- + * + * OpenAPI spec version: 4.2.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGNamedEnum.h + * + * Enumeration with name for values + */ + +#ifndef SWGNamedEnum_H_ +#define SWGNamedEnum_H_ + +#include + + +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGNamedEnum: public SWGObject { +public: + SWGNamedEnum(); + SWGNamedEnum(QString* json); + virtual ~SWGNamedEnum(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGNamedEnum* fromJson(QString &jsonString) override; + + QString* getName(); + void setName(QString* name); + + qint32 getValue(); + void setValue(qint32 value); + + + virtual bool isSet() override; + +private: + QString* name; + bool m_name_isSet; + + qint32 value; + bool m_value_isSet; + +}; + +} + +#endif /* SWGNamedEnum_H_ */