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

Test source: implemeted WEB API

This commit is contained in:
f4exb 2018-05-27 22:25:01 +02:00
parent da3cb2d981
commit f5bcbf2e9e
15 changed files with 983 additions and 5 deletions

View File

@ -403,3 +403,121 @@ int TestSourceInput::webapiRun(
return 200; return 200;
} }
int TestSourceInput::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage __attribute__((unused)))
{
response.setTestSourceSettings(new SWGSDRangel::SWGTestSourceSettings());
response.getTestSourceSettings()->init();
webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int TestSourceInput::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage __attribute__((unused)))
{
TestSourceSettings settings = m_settings;
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getTestSourceSettings()->getCenterFrequency();
}
if (deviceSettingsKeys.contains("frequencyShift")) {
settings.m_frequencyShift = response.getTestSourceSettings()->getFrequencyShift();
}
if (deviceSettingsKeys.contains("sampleRate")) {
settings.m_sampleRate = response.getTestSourceSettings()->getSampleRate();
}
if (deviceSettingsKeys.contains("log2Decim")) {
settings.m_log2Decim = response.getTestSourceSettings()->getLog2Decim();
}
if (deviceSettingsKeys.contains("fcPos")) {
int fcPos = response.getTestSourceSettings()->getFcPos();
fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos;
settings.m_fcPos = (TestSourceSettings::fcPos_t) fcPos;
}
if (deviceSettingsKeys.contains("sampleSizeIndex")) {
int sampleSizeIndex = response.getTestSourceSettings()->getSampleSizeIndex();
sampleSizeIndex = sampleSizeIndex < 0 ? 0 : sampleSizeIndex > 1 ? 2 : sampleSizeIndex;
settings.m_sampleSizeIndex = sampleSizeIndex;
}
if (deviceSettingsKeys.contains("amplitudeBits")) {
settings.m_amplitudeBits = response.getTestSourceSettings()->getAmplitudeBits();
}
if (deviceSettingsKeys.contains("autoCorrOptions")) {
int autoCorrOptions = response.getTestSourceSettings()->getAutoCorrOptions();
autoCorrOptions = autoCorrOptions < 0 ? 0 : autoCorrOptions >= TestSourceSettings::AutoCorrLast ? TestSourceSettings::AutoCorrLast-1 : autoCorrOptions;
settings.m_sampleSizeIndex = (TestSourceSettings::AutoCorrOptions) autoCorrOptions;
}
if (deviceSettingsKeys.contains("modulation")) {
int modulation = response.getTestSourceSettings()->getModulation();
modulation = modulation < 0 ? 0 : modulation >= TestSourceSettings::ModulationLast ? TestSourceSettings::ModulationLast-1 : modulation;
settings.m_modulation = (TestSourceSettings::Modulation) modulation;
}
if (deviceSettingsKeys.contains("modulationTone")) {
settings.m_modulationTone = response.getTestSourceSettings()->getModulationTone();
}
if (deviceSettingsKeys.contains("amModulation")) {
settings.m_amModulation = response.getTestSourceSettings()->getAmModulation();
};
if (deviceSettingsKeys.contains("fmDeviation")) {
settings.m_fmDeviation = response.getTestSourceSettings()->getFmDeviation();
};
if (deviceSettingsKeys.contains("dcFactor")) {
settings.m_dcFactor = response.getTestSourceSettings()->getDcFactor();
};
if (deviceSettingsKeys.contains("iFactor")) {
settings.m_iFactor = response.getTestSourceSettings()->getIFactor();
};
if (deviceSettingsKeys.contains("qFactor")) {
settings.m_qFactor = response.getTestSourceSettings()->getQFactor();
};
if (deviceSettingsKeys.contains("phaseImbalance")) {
settings.m_phaseImbalance = response.getTestSourceSettings()->getPhaseImbalance();
};
if (deviceSettingsKeys.contains("fileRecordName")) {
settings.m_fileRecordName = *response.getTestSourceSettings()->getFileRecordName();
}
MsgConfigureTestSource *msg = MsgConfigureTestSource::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureTestSource *msgToGUI = MsgConfigureTestSource::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void TestSourceInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const TestSourceSettings& settings)
{
response.getTestSourceSettings()->setCenterFrequency(settings.m_centerFrequency);
response.getTestSourceSettings()->setFrequencyShift(settings.m_frequencyShift);
response.getTestSourceSettings()->setSampleRate(settings.m_sampleRate);
response.getTestSourceSettings()->setLog2Decim(settings.m_log2Decim);
response.getTestSourceSettings()->setFcPos((int) settings.m_fcPos);
response.getTestSourceSettings()->setSampleSizeIndex((int) settings.m_sampleSizeIndex);
response.getTestSourceSettings()->setAmplitudeBits(settings.m_amplitudeBits);
response.getTestSourceSettings()->setAutoCorrOptions((int) settings.m_autoCorrOptions);
response.getTestSourceSettings()->setModulation((int) settings.m_modulation);
response.getTestSourceSettings()->setModulationTone(settings.m_modulationTone);
response.getTestSourceSettings()->setAmModulation(settings.m_amModulation);
response.getTestSourceSettings()->setFmDeviation(settings.m_fmDeviation);
response.getTestSourceSettings()->setDcFactor(settings.m_dcFactor);
response.getTestSourceSettings()->setIFactor(settings.m_iFactor);
response.getTestSourceSettings()->setQFactor(settings.m_qFactor);
response.getTestSourceSettings()->setPhaseImbalance(settings.m_phaseImbalance);
if (response.getTestSourceSettings()->getFileRecordName()) {
*response.getTestSourceSettings()->getFileRecordName() = settings.m_fileRecordName;
} else {
response.getTestSourceSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
}
}

View File

@ -110,6 +110,16 @@ public:
virtual bool handleMessage(const Message& message); virtual bool handleMessage(const Message& message);
virtual int webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
virtual int webapiRunGet( virtual int webapiRunGet(
SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGDeviceState& response,
QString& errorMessage); QString& errorMessage);
@ -130,6 +140,7 @@ private:
const QTimer& m_masterTimer; const QTimer& m_masterTimer;
bool applySettings(const TestSourceSettings& settings, bool force); bool applySettings(const TestSourceSettings& settings, bool force);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const TestSourceSettings& settings);
}; };
#endif // _TESTSOURCE_TESTSOURCEINPUT_H_ #endif // _TESTSOURCE_TESTSOURCEINPUT_H_

View File

@ -29,7 +29,7 @@
const PluginDescriptor TestSourcePlugin::m_pluginDescriptor = { const PluginDescriptor TestSourcePlugin::m_pluginDescriptor = {
QString("Test Source input"), QString("Test Source input"),
QString("3.14.6"), QString("4.0.0"),
QString("(c) Edouard Griffiths, F4EXB"), QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"), QString("https://github.com/f4exb/sdrangel"),
true, true,

View File

@ -1850,6 +1850,9 @@ margin-bottom: 20px;
}, },
"sdrPlaySettings" : { "sdrPlaySettings" : {
"$ref" : "#/definitions/SDRPlaySettings" "$ref" : "#/definitions/SDRPlaySettings"
},
"testSourceSettings" : {
"$ref" : "#/definitions/TestSourceSettings"
} }
}, },
"description" : "Base device settings. The specific device settings present depends on deviceHwType." "description" : "Base device settings. The specific device settings present depends on deviceHwType."
@ -3492,6 +3495,67 @@ margin-bottom: 20px;
"type" : "string" "type" : "string"
} }
} }
};
defs.TestSourceSettings = {
"properties" : {
"centerFrequency" : {
"type" : "integer",
"format" : "uint64"
},
"frequencyShift" : {
"type" : "integer"
},
"sampleRate" : {
"type" : "integer"
},
"log2Decim" : {
"type" : "integer"
},
"fcPos" : {
"type" : "integer"
},
"sampleSizeIndex" : {
"type" : "integer"
},
"amplitudeBits" : {
"type" : "integer"
},
"autoCorrOptions" : {
"type" : "integer"
},
"modulation" : {
"type" : "integer"
},
"modulationTone" : {
"type" : "integer"
},
"amModulation" : {
"type" : "integer"
},
"fmDeviation" : {
"type" : "integer"
},
"dcFactor" : {
"type" : "number",
"format" : "float"
},
"iFactor" : {
"type" : "number",
"format" : "float"
},
"qFactor" : {
"type" : "number",
"format" : "float"
},
"phaseImbalance" : {
"type" : "number",
"format" : "float"
},
"fileRecordName" : {
"type" : "string"
}
},
"description" : "TestSource"
}; };
defs.UDPSinkReport = { defs.UDPSinkReport = {
"properties" : { "properties" : {
@ -22494,7 +22558,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2018-05-27T13:20:33.079+02:00 Generated 2018-05-27T20:33:10.219+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -33,8 +33,6 @@ SDRPlaySettings:
type: integer type: integer
basebandGain: basebandGain:
type: integer type: integer
iqCorrection:
type: integer
fileRecordName: fileRecordName:
type: string type: string

View File

@ -0,0 +1,43 @@
TestSourceSettings:
description: TestSource
properties:
centerFrequency:
type: integer
format: uint64
frequencyShift:
type: integer
sampleRate:
type: integer
log2Decim:
type: integer
fcPos:
type: integer
sampleSizeIndex:
type: integer
amplitudeBits:
type: integer
autoCorrOptions:
type: integer
modulation:
type: integer
modulationTone:
type: integer
amModulation:
type: integer
fmDeviation:
type: integer
dcFactor:
type: number
format: float
iFactor:
type: number
format: float
qFactor:
type: number
format: float
phaseImbalance:
type: number
format: float
fileRecordName:
type: string

View File

@ -1779,6 +1779,8 @@ definitions:
$ref: "/doc/swagger/include/SDRDaemonSource.yaml#/SDRdaemonSourceSettings" $ref: "/doc/swagger/include/SDRDaemonSource.yaml#/SDRdaemonSourceSettings"
sdrPlaySettings: sdrPlaySettings:
$ref: "/doc/swagger/include/SDRPlay.yaml#/SDRPlaySettings" $ref: "/doc/swagger/include/SDRPlay.yaml#/SDRPlaySettings"
testSourceSettings:
$ref: "/doc/swagger/include/TestSource.yaml#/TestSourceSettings"
DeviceReport: DeviceReport:

View File

@ -0,0 +1,43 @@
TestSourceSettings:
description: TestSource
properties:
centerFrequency:
type: integer
format: uint64
frequencyShift:
type: integer
sampleRate:
type: integer
log2Decim:
type: integer
fcPos:
type: integer
sampleSizeIndex:
type: integer
amplitudeBits:
type: integer
autoCorrOptions:
type: integer
modulation:
type: integer
modulationTone:
type: integer
amModulation:
type: integer
fmDeviation:
type: integer
dcFactor:
type: number
format: float
iFactor:
type: number
format: float
qFactor:
type: number
format: float
phaseImbalance:
type: number
format: float
fileRecordName:
type: string

View File

@ -1779,6 +1779,8 @@ definitions:
$ref: "http://localhost:8081/api/swagger/include/SDRDaemonSource.yaml#/SDRdaemonSourceSettings" $ref: "http://localhost:8081/api/swagger/include/SDRDaemonSource.yaml#/SDRdaemonSourceSettings"
sdrPlaySettings: sdrPlaySettings:
$ref: "http://localhost:8081/api/swagger/include/SDRPlay.yaml#/SDRPlaySettings" $ref: "http://localhost:8081/api/swagger/include/SDRPlay.yaml#/SDRPlaySettings"
testSourceSettings:
$ref: "http://localhost:8081/api/swagger/include/TestSource.yaml#/TestSourceSettings"
DeviceReport: DeviceReport:

View File

@ -1850,6 +1850,9 @@ margin-bottom: 20px;
}, },
"sdrPlaySettings" : { "sdrPlaySettings" : {
"$ref" : "#/definitions/SDRPlaySettings" "$ref" : "#/definitions/SDRPlaySettings"
},
"testSourceSettings" : {
"$ref" : "#/definitions/TestSourceSettings"
} }
}, },
"description" : "Base device settings. The specific device settings present depends on deviceHwType." "description" : "Base device settings. The specific device settings present depends on deviceHwType."
@ -3492,6 +3495,67 @@ margin-bottom: 20px;
"type" : "string" "type" : "string"
} }
} }
};
defs.TestSourceSettings = {
"properties" : {
"centerFrequency" : {
"type" : "integer",
"format" : "uint64"
},
"frequencyShift" : {
"type" : "integer"
},
"sampleRate" : {
"type" : "integer"
},
"log2Decim" : {
"type" : "integer"
},
"fcPos" : {
"type" : "integer"
},
"sampleSizeIndex" : {
"type" : "integer"
},
"amplitudeBits" : {
"type" : "integer"
},
"autoCorrOptions" : {
"type" : "integer"
},
"modulation" : {
"type" : "integer"
},
"modulationTone" : {
"type" : "integer"
},
"amModulation" : {
"type" : "integer"
},
"fmDeviation" : {
"type" : "integer"
},
"dcFactor" : {
"type" : "number",
"format" : "float"
},
"iFactor" : {
"type" : "number",
"format" : "float"
},
"qFactor" : {
"type" : "number",
"format" : "float"
},
"phaseImbalance" : {
"type" : "number",
"format" : "float"
},
"fileRecordName" : {
"type" : "string"
}
},
"description" : "TestSource"
}; };
defs.UDPSinkReport = { defs.UDPSinkReport = {
"properties" : { "properties" : {
@ -22494,7 +22558,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2018-05-27T13:20:33.079+02:00 Generated 2018-05-27T20:33:10.219+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -66,6 +66,8 @@ SWGDeviceSettings::SWGDeviceSettings() {
m_sdr_daemon_source_settings_isSet = false; m_sdr_daemon_source_settings_isSet = false;
sdr_play_settings = nullptr; sdr_play_settings = nullptr;
m_sdr_play_settings_isSet = false; m_sdr_play_settings_isSet = false;
test_source_settings = nullptr;
m_test_source_settings_isSet = false;
} }
SWGDeviceSettings::~SWGDeviceSettings() { SWGDeviceSettings::~SWGDeviceSettings() {
@ -112,6 +114,8 @@ SWGDeviceSettings::init() {
m_sdr_daemon_source_settings_isSet = false; m_sdr_daemon_source_settings_isSet = false;
sdr_play_settings = new SWGSDRPlaySettings(); sdr_play_settings = new SWGSDRPlaySettings();
m_sdr_play_settings_isSet = false; m_sdr_play_settings_isSet = false;
test_source_settings = new SWGTestSourceSettings();
m_test_source_settings_isSet = false;
} }
void void
@ -171,6 +175,9 @@ SWGDeviceSettings::cleanup() {
if(sdr_play_settings != nullptr) { if(sdr_play_settings != nullptr) {
delete sdr_play_settings; delete sdr_play_settings;
} }
if(test_source_settings != nullptr) {
delete test_source_settings;
}
} }
SWGDeviceSettings* SWGDeviceSettings*
@ -222,6 +229,8 @@ SWGDeviceSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&sdr_play_settings, pJson["sdrPlaySettings"], "SWGSDRPlaySettings", "SWGSDRPlaySettings"); ::SWGSDRangel::setValue(&sdr_play_settings, pJson["sdrPlaySettings"], "SWGSDRPlaySettings", "SWGSDRPlaySettings");
::SWGSDRangel::setValue(&test_source_settings, pJson["testSourceSettings"], "SWGTestSourceSettings", "SWGTestSourceSettings");
} }
QString QString
@ -295,6 +304,9 @@ SWGDeviceSettings::asJsonObject() {
if((sdr_play_settings != nullptr) && (sdr_play_settings->isSet())){ if((sdr_play_settings != nullptr) && (sdr_play_settings->isSet())){
toJsonValue(QString("sdrPlaySettings"), sdr_play_settings, obj, QString("SWGSDRPlaySettings")); toJsonValue(QString("sdrPlaySettings"), sdr_play_settings, obj, QString("SWGSDRPlaySettings"));
} }
if((test_source_settings != nullptr) && (test_source_settings->isSet())){
toJsonValue(QString("testSourceSettings"), test_source_settings, obj, QString("SWGTestSourceSettings"));
}
return obj; return obj;
} }
@ -489,6 +501,16 @@ SWGDeviceSettings::setSdrPlaySettings(SWGSDRPlaySettings* sdr_play_settings) {
this->m_sdr_play_settings_isSet = true; this->m_sdr_play_settings_isSet = true;
} }
SWGTestSourceSettings*
SWGDeviceSettings::getTestSourceSettings() {
return test_source_settings;
}
void
SWGDeviceSettings::setTestSourceSettings(SWGTestSourceSettings* test_source_settings) {
this->test_source_settings = test_source_settings;
this->m_test_source_settings_isSet = true;
}
bool bool
SWGDeviceSettings::isSet(){ SWGDeviceSettings::isSet(){
@ -513,6 +535,7 @@ SWGDeviceSettings::isSet(){
if(rtl_sdr_settings != nullptr && rtl_sdr_settings->isSet()){ isObjectUpdated = true; break;} if(rtl_sdr_settings != nullptr && rtl_sdr_settings->isSet()){ isObjectUpdated = true; break;}
if(sdr_daemon_source_settings != nullptr && sdr_daemon_source_settings->isSet()){ isObjectUpdated = true; break;} if(sdr_daemon_source_settings != nullptr && sdr_daemon_source_settings->isSet()){ isObjectUpdated = true; break;}
if(sdr_play_settings != nullptr && sdr_play_settings->isSet()){ isObjectUpdated = true; break;} if(sdr_play_settings != nullptr && sdr_play_settings->isSet()){ isObjectUpdated = true; break;}
if(test_source_settings != nullptr && test_source_settings->isSet()){ isObjectUpdated = true; break;}
}while(false); }while(false);
return isObjectUpdated; return isObjectUpdated;
} }

View File

@ -39,6 +39,7 @@
#include "SWGRtlSdrSettings.h" #include "SWGRtlSdrSettings.h"
#include "SWGSDRPlaySettings.h" #include "SWGSDRPlaySettings.h"
#include "SWGSDRdaemonSourceSettings.h" #include "SWGSDRdaemonSourceSettings.h"
#include "SWGTestSourceSettings.h"
#include <QString> #include <QString>
#include "SWGObject.h" #include "SWGObject.h"
@ -116,6 +117,9 @@ public:
SWGSDRPlaySettings* getSdrPlaySettings(); SWGSDRPlaySettings* getSdrPlaySettings();
void setSdrPlaySettings(SWGSDRPlaySettings* sdr_play_settings); void setSdrPlaySettings(SWGSDRPlaySettings* sdr_play_settings);
SWGTestSourceSettings* getTestSourceSettings();
void setTestSourceSettings(SWGTestSourceSettings* test_source_settings);
virtual bool isSet() override; virtual bool isSet() override;
@ -177,6 +181,9 @@ private:
SWGSDRPlaySettings* sdr_play_settings; SWGSDRPlaySettings* sdr_play_settings;
bool m_sdr_play_settings_isSet; bool m_sdr_play_settings_isSet;
SWGTestSourceSettings* test_source_settings;
bool m_test_source_settings_isSet;
}; };
} }

View File

@ -99,6 +99,7 @@
#include "SWGSampleRate.h" #include "SWGSampleRate.h"
#include "SWGSamplingDevice.h" #include "SWGSamplingDevice.h"
#include "SWGSuccessResponse.h" #include "SWGSuccessResponse.h"
#include "SWGTestSourceSettings.h"
#include "SWGUDPSinkReport.h" #include "SWGUDPSinkReport.h"
#include "SWGUDPSinkSettings.h" #include "SWGUDPSinkSettings.h"
#include "SWGUDPSrcReport.h" #include "SWGUDPSrcReport.h"
@ -366,6 +367,9 @@ namespace SWGSDRangel {
if(QString("SWGSuccessResponse").compare(type) == 0) { if(QString("SWGSuccessResponse").compare(type) == 0) {
return new SWGSuccessResponse(); return new SWGSuccessResponse();
} }
if(QString("SWGTestSourceSettings").compare(type) == 0) {
return new SWGTestSourceSettings();
}
if(QString("SWGUDPSinkReport").compare(type) == 0) { if(QString("SWGUDPSinkReport").compare(type) == 0) {
return new SWGUDPSinkReport(); return new SWGUDPSinkReport();
} }

View File

@ -0,0 +1,444 @@
/**
* 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. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * 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 demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* OpenAPI spec version: 4.0.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 "SWGTestSourceSettings.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGTestSourceSettings::SWGTestSourceSettings(QString* json) {
init();
this->fromJson(*json);
}
SWGTestSourceSettings::SWGTestSourceSettings() {
center_frequency = 0;
m_center_frequency_isSet = false;
frequency_shift = 0;
m_frequency_shift_isSet = false;
sample_rate = 0;
m_sample_rate_isSet = false;
log2_decim = 0;
m_log2_decim_isSet = false;
fc_pos = 0;
m_fc_pos_isSet = false;
sample_size_index = 0;
m_sample_size_index_isSet = false;
amplitude_bits = 0;
m_amplitude_bits_isSet = false;
auto_corr_options = 0;
m_auto_corr_options_isSet = false;
modulation = 0;
m_modulation_isSet = false;
modulation_tone = 0;
m_modulation_tone_isSet = false;
am_modulation = 0;
m_am_modulation_isSet = false;
fm_deviation = 0;
m_fm_deviation_isSet = false;
dc_factor = 0.0f;
m_dc_factor_isSet = false;
i_factor = 0.0f;
m_i_factor_isSet = false;
q_factor = 0.0f;
m_q_factor_isSet = false;
phase_imbalance = 0.0f;
m_phase_imbalance_isSet = false;
file_record_name = nullptr;
m_file_record_name_isSet = false;
}
SWGTestSourceSettings::~SWGTestSourceSettings() {
this->cleanup();
}
void
SWGTestSourceSettings::init() {
center_frequency = 0;
m_center_frequency_isSet = false;
frequency_shift = 0;
m_frequency_shift_isSet = false;
sample_rate = 0;
m_sample_rate_isSet = false;
log2_decim = 0;
m_log2_decim_isSet = false;
fc_pos = 0;
m_fc_pos_isSet = false;
sample_size_index = 0;
m_sample_size_index_isSet = false;
amplitude_bits = 0;
m_amplitude_bits_isSet = false;
auto_corr_options = 0;
m_auto_corr_options_isSet = false;
modulation = 0;
m_modulation_isSet = false;
modulation_tone = 0;
m_modulation_tone_isSet = false;
am_modulation = 0;
m_am_modulation_isSet = false;
fm_deviation = 0;
m_fm_deviation_isSet = false;
dc_factor = 0.0f;
m_dc_factor_isSet = false;
i_factor = 0.0f;
m_i_factor_isSet = false;
q_factor = 0.0f;
m_q_factor_isSet = false;
phase_imbalance = 0.0f;
m_phase_imbalance_isSet = false;
file_record_name = new QString("");
m_file_record_name_isSet = false;
}
void
SWGTestSourceSettings::cleanup() {
if(file_record_name != nullptr) {
delete file_record_name;
}
}
SWGTestSourceSettings*
SWGTestSourceSettings::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGTestSourceSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint32", "");
::SWGSDRangel::setValue(&frequency_shift, pJson["frequencyShift"], "qint32", "");
::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
::SWGSDRangel::setValue(&log2_decim, pJson["log2Decim"], "qint32", "");
::SWGSDRangel::setValue(&fc_pos, pJson["fcPos"], "qint32", "");
::SWGSDRangel::setValue(&sample_size_index, pJson["sampleSizeIndex"], "qint32", "");
::SWGSDRangel::setValue(&amplitude_bits, pJson["amplitudeBits"], "qint32", "");
::SWGSDRangel::setValue(&auto_corr_options, pJson["autoCorrOptions"], "qint32", "");
::SWGSDRangel::setValue(&modulation, pJson["modulation"], "qint32", "");
::SWGSDRangel::setValue(&modulation_tone, pJson["modulationTone"], "qint32", "");
::SWGSDRangel::setValue(&am_modulation, pJson["amModulation"], "qint32", "");
::SWGSDRangel::setValue(&fm_deviation, pJson["fmDeviation"], "qint32", "");
::SWGSDRangel::setValue(&dc_factor, pJson["dcFactor"], "float", "");
::SWGSDRangel::setValue(&i_factor, pJson["iFactor"], "float", "");
::SWGSDRangel::setValue(&q_factor, pJson["qFactor"], "float", "");
::SWGSDRangel::setValue(&phase_imbalance, pJson["phaseImbalance"], "float", "");
::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString");
}
QString
SWGTestSourceSettings::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGTestSourceSettings::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(m_center_frequency_isSet){
obj->insert("centerFrequency", QJsonValue(center_frequency));
}
if(m_frequency_shift_isSet){
obj->insert("frequencyShift", QJsonValue(frequency_shift));
}
if(m_sample_rate_isSet){
obj->insert("sampleRate", QJsonValue(sample_rate));
}
if(m_log2_decim_isSet){
obj->insert("log2Decim", QJsonValue(log2_decim));
}
if(m_fc_pos_isSet){
obj->insert("fcPos", QJsonValue(fc_pos));
}
if(m_sample_size_index_isSet){
obj->insert("sampleSizeIndex", QJsonValue(sample_size_index));
}
if(m_amplitude_bits_isSet){
obj->insert("amplitudeBits", QJsonValue(amplitude_bits));
}
if(m_auto_corr_options_isSet){
obj->insert("autoCorrOptions", QJsonValue(auto_corr_options));
}
if(m_modulation_isSet){
obj->insert("modulation", QJsonValue(modulation));
}
if(m_modulation_tone_isSet){
obj->insert("modulationTone", QJsonValue(modulation_tone));
}
if(m_am_modulation_isSet){
obj->insert("amModulation", QJsonValue(am_modulation));
}
if(m_fm_deviation_isSet){
obj->insert("fmDeviation", QJsonValue(fm_deviation));
}
if(m_dc_factor_isSet){
obj->insert("dcFactor", QJsonValue(dc_factor));
}
if(m_i_factor_isSet){
obj->insert("iFactor", QJsonValue(i_factor));
}
if(m_q_factor_isSet){
obj->insert("qFactor", QJsonValue(q_factor));
}
if(m_phase_imbalance_isSet){
obj->insert("phaseImbalance", QJsonValue(phase_imbalance));
}
if(file_record_name != nullptr && *file_record_name != QString("")){
toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString"));
}
return obj;
}
qint32
SWGTestSourceSettings::getCenterFrequency() {
return center_frequency;
}
void
SWGTestSourceSettings::setCenterFrequency(qint32 center_frequency) {
this->center_frequency = center_frequency;
this->m_center_frequency_isSet = true;
}
qint32
SWGTestSourceSettings::getFrequencyShift() {
return frequency_shift;
}
void
SWGTestSourceSettings::setFrequencyShift(qint32 frequency_shift) {
this->frequency_shift = frequency_shift;
this->m_frequency_shift_isSet = true;
}
qint32
SWGTestSourceSettings::getSampleRate() {
return sample_rate;
}
void
SWGTestSourceSettings::setSampleRate(qint32 sample_rate) {
this->sample_rate = sample_rate;
this->m_sample_rate_isSet = true;
}
qint32
SWGTestSourceSettings::getLog2Decim() {
return log2_decim;
}
void
SWGTestSourceSettings::setLog2Decim(qint32 log2_decim) {
this->log2_decim = log2_decim;
this->m_log2_decim_isSet = true;
}
qint32
SWGTestSourceSettings::getFcPos() {
return fc_pos;
}
void
SWGTestSourceSettings::setFcPos(qint32 fc_pos) {
this->fc_pos = fc_pos;
this->m_fc_pos_isSet = true;
}
qint32
SWGTestSourceSettings::getSampleSizeIndex() {
return sample_size_index;
}
void
SWGTestSourceSettings::setSampleSizeIndex(qint32 sample_size_index) {
this->sample_size_index = sample_size_index;
this->m_sample_size_index_isSet = true;
}
qint32
SWGTestSourceSettings::getAmplitudeBits() {
return amplitude_bits;
}
void
SWGTestSourceSettings::setAmplitudeBits(qint32 amplitude_bits) {
this->amplitude_bits = amplitude_bits;
this->m_amplitude_bits_isSet = true;
}
qint32
SWGTestSourceSettings::getAutoCorrOptions() {
return auto_corr_options;
}
void
SWGTestSourceSettings::setAutoCorrOptions(qint32 auto_corr_options) {
this->auto_corr_options = auto_corr_options;
this->m_auto_corr_options_isSet = true;
}
qint32
SWGTestSourceSettings::getModulation() {
return modulation;
}
void
SWGTestSourceSettings::setModulation(qint32 modulation) {
this->modulation = modulation;
this->m_modulation_isSet = true;
}
qint32
SWGTestSourceSettings::getModulationTone() {
return modulation_tone;
}
void
SWGTestSourceSettings::setModulationTone(qint32 modulation_tone) {
this->modulation_tone = modulation_tone;
this->m_modulation_tone_isSet = true;
}
qint32
SWGTestSourceSettings::getAmModulation() {
return am_modulation;
}
void
SWGTestSourceSettings::setAmModulation(qint32 am_modulation) {
this->am_modulation = am_modulation;
this->m_am_modulation_isSet = true;
}
qint32
SWGTestSourceSettings::getFmDeviation() {
return fm_deviation;
}
void
SWGTestSourceSettings::setFmDeviation(qint32 fm_deviation) {
this->fm_deviation = fm_deviation;
this->m_fm_deviation_isSet = true;
}
float
SWGTestSourceSettings::getDcFactor() {
return dc_factor;
}
void
SWGTestSourceSettings::setDcFactor(float dc_factor) {
this->dc_factor = dc_factor;
this->m_dc_factor_isSet = true;
}
float
SWGTestSourceSettings::getIFactor() {
return i_factor;
}
void
SWGTestSourceSettings::setIFactor(float i_factor) {
this->i_factor = i_factor;
this->m_i_factor_isSet = true;
}
float
SWGTestSourceSettings::getQFactor() {
return q_factor;
}
void
SWGTestSourceSettings::setQFactor(float q_factor) {
this->q_factor = q_factor;
this->m_q_factor_isSet = true;
}
float
SWGTestSourceSettings::getPhaseImbalance() {
return phase_imbalance;
}
void
SWGTestSourceSettings::setPhaseImbalance(float phase_imbalance) {
this->phase_imbalance = phase_imbalance;
this->m_phase_imbalance_isSet = true;
}
QString*
SWGTestSourceSettings::getFileRecordName() {
return file_record_name;
}
void
SWGTestSourceSettings::setFileRecordName(QString* file_record_name) {
this->file_record_name = file_record_name;
this->m_file_record_name_isSet = true;
}
bool
SWGTestSourceSettings::isSet(){
bool isObjectUpdated = false;
do{
if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
if(m_frequency_shift_isSet){ isObjectUpdated = true; break;}
if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
if(m_log2_decim_isSet){ isObjectUpdated = true; break;}
if(m_fc_pos_isSet){ isObjectUpdated = true; break;}
if(m_sample_size_index_isSet){ isObjectUpdated = true; break;}
if(m_amplitude_bits_isSet){ isObjectUpdated = true; break;}
if(m_auto_corr_options_isSet){ isObjectUpdated = true; break;}
if(m_modulation_isSet){ isObjectUpdated = true; break;}
if(m_modulation_tone_isSet){ isObjectUpdated = true; break;}
if(m_am_modulation_isSet){ isObjectUpdated = true; break;}
if(m_fm_deviation_isSet){ isObjectUpdated = true; break;}
if(m_dc_factor_isSet){ isObjectUpdated = true; break;}
if(m_i_factor_isSet){ isObjectUpdated = true; break;}
if(m_q_factor_isSet){ isObjectUpdated = true; break;}
if(m_phase_imbalance_isSet){ isObjectUpdated = true; break;}
if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,155 @@
/**
* 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. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * 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 demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* OpenAPI spec version: 4.0.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.
*/
/*
* SWGTestSourceSettings.h
*
* TestSource
*/
#ifndef SWGTestSourceSettings_H_
#define SWGTestSourceSettings_H_
#include <QJsonObject>
#include <QString>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGTestSourceSettings: public SWGObject {
public:
SWGTestSourceSettings();
SWGTestSourceSettings(QString* json);
virtual ~SWGTestSourceSettings();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGTestSourceSettings* fromJson(QString &jsonString) override;
qint32 getCenterFrequency();
void setCenterFrequency(qint32 center_frequency);
qint32 getFrequencyShift();
void setFrequencyShift(qint32 frequency_shift);
qint32 getSampleRate();
void setSampleRate(qint32 sample_rate);
qint32 getLog2Decim();
void setLog2Decim(qint32 log2_decim);
qint32 getFcPos();
void setFcPos(qint32 fc_pos);
qint32 getSampleSizeIndex();
void setSampleSizeIndex(qint32 sample_size_index);
qint32 getAmplitudeBits();
void setAmplitudeBits(qint32 amplitude_bits);
qint32 getAutoCorrOptions();
void setAutoCorrOptions(qint32 auto_corr_options);
qint32 getModulation();
void setModulation(qint32 modulation);
qint32 getModulationTone();
void setModulationTone(qint32 modulation_tone);
qint32 getAmModulation();
void setAmModulation(qint32 am_modulation);
qint32 getFmDeviation();
void setFmDeviation(qint32 fm_deviation);
float getDcFactor();
void setDcFactor(float dc_factor);
float getIFactor();
void setIFactor(float i_factor);
float getQFactor();
void setQFactor(float q_factor);
float getPhaseImbalance();
void setPhaseImbalance(float phase_imbalance);
QString* getFileRecordName();
void setFileRecordName(QString* file_record_name);
virtual bool isSet() override;
private:
qint32 center_frequency;
bool m_center_frequency_isSet;
qint32 frequency_shift;
bool m_frequency_shift_isSet;
qint32 sample_rate;
bool m_sample_rate_isSet;
qint32 log2_decim;
bool m_log2_decim_isSet;
qint32 fc_pos;
bool m_fc_pos_isSet;
qint32 sample_size_index;
bool m_sample_size_index_isSet;
qint32 amplitude_bits;
bool m_amplitude_bits_isSet;
qint32 auto_corr_options;
bool m_auto_corr_options_isSet;
qint32 modulation;
bool m_modulation_isSet;
qint32 modulation_tone;
bool m_modulation_tone_isSet;
qint32 am_modulation;
bool m_am_modulation_isSet;
qint32 fm_deviation;
bool m_fm_deviation_isSet;
float dc_factor;
bool m_dc_factor_isSet;
float i_factor;
bool m_i_factor_isSet;
float q_factor;
bool m_q_factor_isSet;
float phase_imbalance;
bool m_phase_imbalance_isSet;
QString* file_record_name;
bool m_file_record_name_isSet;
};
}
#endif /* SWGTestSourceSettings_H_ */