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.
SWGWFMDemodSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGWFMDemodSettings.h"
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 
33  rf_bandwidth = 0.0f;
34  m_rf_bandwidth_isSet = false;
35  af_bandwidth = 0.0f;
36  m_af_bandwidth_isSet = false;
37  volume = 0.0f;
38  m_volume_isSet = false;
39  squelch = 0.0f;
40  m_squelch_isSet = false;
41  audio_mute = 0;
42  m_audio_mute_isSet = false;
43  rgb_color = 0;
44  m_rgb_color_isSet = false;
45  title = nullptr;
46  m_title_isSet = false;
47  audio_device_name = nullptr;
49  use_reverse_api = 0;
51  reverse_api_address = nullptr;
53  reverse_api_port = 0;
59 }
60 
62  this->cleanup();
63 }
64 
65 void
69  rf_bandwidth = 0.0f;
70  m_rf_bandwidth_isSet = false;
71  af_bandwidth = 0.0f;
72  m_af_bandwidth_isSet = false;
73  volume = 0.0f;
74  m_volume_isSet = false;
75  squelch = 0.0f;
76  m_squelch_isSet = false;
77  audio_mute = 0;
78  m_audio_mute_isSet = false;
79  rgb_color = 0;
80  m_rgb_color_isSet = false;
81  title = new QString("");
82  m_title_isSet = false;
83  audio_device_name = new QString("");
85  use_reverse_api = 0;
87  reverse_api_address = new QString("");
89  reverse_api_port = 0;
95 }
96 
97 void
99 
100 
101 
102 
103 
104 
105 
106  if(title != nullptr) {
107  delete title;
108  }
109  if(audio_device_name != nullptr) {
110  delete audio_device_name;
111  }
112 
113  if(reverse_api_address != nullptr) {
114  delete reverse_api_address;
115  }
116 
117 
118 
119 }
120 
123  QByteArray array (json.toStdString().c_str());
124  QJsonDocument doc = QJsonDocument::fromJson(array);
125  QJsonObject jsonObject = doc.object();
126  this->fromJsonObject(jsonObject);
127  return this;
128 }
129 
130 void
132  ::SWGSDRangel::setValue(&input_frequency_offset, pJson["inputFrequencyOffset"], "qint64", "");
133 
134  ::SWGSDRangel::setValue(&rf_bandwidth, pJson["rfBandwidth"], "float", "");
135 
136  ::SWGSDRangel::setValue(&af_bandwidth, pJson["afBandwidth"], "float", "");
137 
138  ::SWGSDRangel::setValue(&volume, pJson["volume"], "float", "");
139 
140  ::SWGSDRangel::setValue(&squelch, pJson["squelch"], "float", "");
141 
142  ::SWGSDRangel::setValue(&audio_mute, pJson["audioMute"], "qint32", "");
143 
144  ::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", "");
145 
146  ::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString");
147 
148  ::SWGSDRangel::setValue(&audio_device_name, pJson["audioDeviceName"], "QString", "QString");
149 
150  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
151 
152  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
153 
154  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
155 
156  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
157 
158  ::SWGSDRangel::setValue(&reverse_api_channel_index, pJson["reverseAPIChannelIndex"], "qint32", "");
159 
160 }
161 
162 QString
164 {
165  QJsonObject* obj = this->asJsonObject();
166 
167  QJsonDocument doc(*obj);
168  QByteArray bytes = doc.toJson();
169  delete obj;
170  return QString(bytes);
171 }
172 
173 QJsonObject*
175  QJsonObject* obj = new QJsonObject();
177  obj->insert("inputFrequencyOffset", QJsonValue(input_frequency_offset));
178  }
180  obj->insert("rfBandwidth", QJsonValue(rf_bandwidth));
181  }
183  obj->insert("afBandwidth", QJsonValue(af_bandwidth));
184  }
185  if(m_volume_isSet){
186  obj->insert("volume", QJsonValue(volume));
187  }
188  if(m_squelch_isSet){
189  obj->insert("squelch", QJsonValue(squelch));
190  }
191  if(m_audio_mute_isSet){
192  obj->insert("audioMute", QJsonValue(audio_mute));
193  }
194  if(m_rgb_color_isSet){
195  obj->insert("rgbColor", QJsonValue(rgb_color));
196  }
197  if(title != nullptr && *title != QString("")){
198  toJsonValue(QString("title"), title, obj, QString("QString"));
199  }
200  if(audio_device_name != nullptr && *audio_device_name != QString("")){
201  toJsonValue(QString("audioDeviceName"), audio_device_name, obj, QString("QString"));
202  }
204  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
205  }
206  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
207  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
208  }
210  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
211  }
213  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
214  }
216  obj->insert("reverseAPIChannelIndex", QJsonValue(reverse_api_channel_index));
217  }
218 
219  return obj;
220 }
221 
222 qint64
224  return input_frequency_offset;
225 }
226 void
228  this->input_frequency_offset = input_frequency_offset;
229  this->m_input_frequency_offset_isSet = true;
230 }
231 
232 float
234  return rf_bandwidth;
235 }
236 void
238  this->rf_bandwidth = rf_bandwidth;
239  this->m_rf_bandwidth_isSet = true;
240 }
241 
242 float
244  return af_bandwidth;
245 }
246 void
248  this->af_bandwidth = af_bandwidth;
249  this->m_af_bandwidth_isSet = true;
250 }
251 
252 float
254  return volume;
255 }
256 void
258  this->volume = volume;
259  this->m_volume_isSet = true;
260 }
261 
262 float
264  return squelch;
265 }
266 void
268  this->squelch = squelch;
269  this->m_squelch_isSet = true;
270 }
271 
272 qint32
274  return audio_mute;
275 }
276 void
278  this->audio_mute = audio_mute;
279  this->m_audio_mute_isSet = true;
280 }
281 
282 qint32
284  return rgb_color;
285 }
286 void
288  this->rgb_color = rgb_color;
289  this->m_rgb_color_isSet = true;
290 }
291 
292 QString*
294  return title;
295 }
296 void
298  this->title = title;
299  this->m_title_isSet = true;
300 }
301 
302 QString*
304  return audio_device_name;
305 }
306 void
308  this->audio_device_name = audio_device_name;
309  this->m_audio_device_name_isSet = true;
310 }
311 
312 qint32
314  return use_reverse_api;
315 }
316 void
318  this->use_reverse_api = use_reverse_api;
319  this->m_use_reverse_api_isSet = true;
320 }
321 
322 QString*
324  return reverse_api_address;
325 }
326 void
328  this->reverse_api_address = reverse_api_address;
329  this->m_reverse_api_address_isSet = true;
330 }
331 
332 qint32
334  return reverse_api_port;
335 }
336 void
338  this->reverse_api_port = reverse_api_port;
339  this->m_reverse_api_port_isSet = true;
340 }
341 
342 qint32
345 }
346 void
348  this->reverse_api_device_index = reverse_api_device_index;
350 }
351 
352 qint32
355 }
356 void
358  this->reverse_api_channel_index = reverse_api_channel_index;
360 }
361 
362 
363 bool
365  bool isObjectUpdated = false;
366  do{
367  if(m_input_frequency_offset_isSet){ isObjectUpdated = true; break;}
368  if(m_rf_bandwidth_isSet){ isObjectUpdated = true; break;}
369  if(m_af_bandwidth_isSet){ isObjectUpdated = true; break;}
370  if(m_volume_isSet){ isObjectUpdated = true; break;}
371  if(m_squelch_isSet){ isObjectUpdated = true; break;}
372  if(m_audio_mute_isSet){ isObjectUpdated = true; break;}
373  if(m_rgb_color_isSet){ isObjectUpdated = true; break;}
374  if(title != nullptr && *title != QString("")){ isObjectUpdated = true; break;}
375  if(audio_device_name != nullptr && *audio_device_name != QString("")){ isObjectUpdated = true; break;}
376  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
377  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
378  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
379  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
380  if(m_reverse_api_channel_index_isSet){ isObjectUpdated = true; break;}
381  }while(false);
382  return isObjectUpdated;
383 }
384 }
385 
void setReverseApiAddress(QString *reverse_api_address)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setReverseApiPort(qint32 reverse_api_port)
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setAfBandwidth(float af_bandwidth)
virtual QString asJson() override
void setRfBandwidth(float rf_bandwidth)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual void fromJsonObject(QJsonObject &json) override
virtual QJsonObject * asJsonObject() override
void setUseReverseApi(qint32 use_reverse_api)
virtual SWGWFMDemodSettings * fromJson(QString &jsonString) override
void setAudioDeviceName(QString *audio_device_name)