SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
SWGBladeRF2OutputReport.cpp
Go to the documentation of this file.
1 
15 
16 #include "SWGHelpers.h"
17 
18 #include <QJsonDocument>
19 #include <QJsonArray>
20 #include <QObject>
21 #include <QDebug>
22 
23 namespace SWGSDRangel {
24 
26  init();
27  this->fromJson(*json);
28 }
29 
31  frequency_range = nullptr;
33  sample_rate_range = nullptr;
35  bandwidth_range = nullptr;
37  global_gain_range = nullptr;
39 }
40 
42  this->cleanup();
43 }
44 
45 void
51  bandwidth_range = new SWGRange();
55 }
56 
57 void
59  if(frequency_range != nullptr) {
60  delete frequency_range;
61  }
62  if(sample_rate_range != nullptr) {
63  delete sample_rate_range;
64  }
65  if(bandwidth_range != nullptr) {
66  delete bandwidth_range;
67  }
68  if(global_gain_range != nullptr) {
69  delete global_gain_range;
70  }
71 }
72 
75  QByteArray array (json.toStdString().c_str());
76  QJsonDocument doc = QJsonDocument::fromJson(array);
77  QJsonObject jsonObject = doc.object();
78  this->fromJsonObject(jsonObject);
79  return this;
80 }
81 
82 void
84  ::SWGSDRangel::setValue(&frequency_range, pJson["frequencyRange"], "SWGFrequencyRange", "SWGFrequencyRange");
85 
86  ::SWGSDRangel::setValue(&sample_rate_range, pJson["sampleRateRange"], "SWGRange", "SWGRange");
87 
88  ::SWGSDRangel::setValue(&bandwidth_range, pJson["bandwidthRange"], "SWGRange", "SWGRange");
89 
90  ::SWGSDRangel::setValue(&global_gain_range, pJson["globalGainRange"], "SWGRange", "SWGRange");
91 
92 }
93 
94 QString
96 {
97  QJsonObject* obj = this->asJsonObject();
98 
99  QJsonDocument doc(*obj);
100  QByteArray bytes = doc.toJson();
101  delete obj;
102  return QString(bytes);
103 }
104 
105 QJsonObject*
107  QJsonObject* obj = new QJsonObject();
108  if((frequency_range != nullptr) && (frequency_range->isSet())){
109  toJsonValue(QString("frequencyRange"), frequency_range, obj, QString("SWGFrequencyRange"));
110  }
111  if((sample_rate_range != nullptr) && (sample_rate_range->isSet())){
112  toJsonValue(QString("sampleRateRange"), sample_rate_range, obj, QString("SWGRange"));
113  }
114  if((bandwidth_range != nullptr) && (bandwidth_range->isSet())){
115  toJsonValue(QString("bandwidthRange"), bandwidth_range, obj, QString("SWGRange"));
116  }
117  if((global_gain_range != nullptr) && (global_gain_range->isSet())){
118  toJsonValue(QString("globalGainRange"), global_gain_range, obj, QString("SWGRange"));
119  }
120 
121  return obj;
122 }
123 
126  return frequency_range;
127 }
128 void
130  this->frequency_range = frequency_range;
131  this->m_frequency_range_isSet = true;
132 }
133 
134 SWGRange*
136  return sample_rate_range;
137 }
138 void
140  this->sample_rate_range = sample_rate_range;
141  this->m_sample_rate_range_isSet = true;
142 }
143 
144 SWGRange*
146  return bandwidth_range;
147 }
148 void
150  this->bandwidth_range = bandwidth_range;
151  this->m_bandwidth_range_isSet = true;
152 }
153 
154 SWGRange*
156  return global_gain_range;
157 }
158 void
160  this->global_gain_range = global_gain_range;
161  this->m_global_gain_range_isSet = true;
162 }
163 
164 
165 bool
167  bool isObjectUpdated = false;
168  do{
169  if(frequency_range != nullptr && frequency_range->isSet()){ isObjectUpdated = true; break;}
170  if(sample_rate_range != nullptr && sample_rate_range->isSet()){ isObjectUpdated = true; break;}
171  if(bandwidth_range != nullptr && bandwidth_range->isSet()){ isObjectUpdated = true; break;}
172  if(global_gain_range != nullptr && global_gain_range->isSet()){ isObjectUpdated = true; break;}
173  }while(false);
174  return isObjectUpdated;
175 }
176 }
177 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual SWGBladeRF2OutputReport * fromJson(QString &jsonString) override
virtual void fromJsonObject(QJsonObject &json) override
void setFrequencyRange(SWGFrequencyRange *frequency_range)
virtual QJsonObject * asJsonObject() override
void setGlobalGainRange(SWGRange *global_gain_range)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setSampleRateRange(SWGRange *sample_rate_range)
virtual bool isSet() override
Definition: SWGRange.cpp:138
void setBandwidthRange(SWGRange *bandwidth_range)