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.
SWGUDPSinkSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGUDPSinkSettings.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 
31  output_sample_rate = 0.0f;
33  sample_format = 0;
34  m_sample_format_isSet = false;
37  rf_bandwidth = 0.0f;
38  m_rf_bandwidth_isSet = false;
39  fm_deviation = 0;
40  m_fm_deviation_isSet = false;
41  channel_mute = 0;
42  m_channel_mute_isSet = false;
43  gain = 0.0f;
44  m_gain_isSet = false;
45  squelch_db = 0;
46  m_squelch_db_isSet = false;
47  squelch_gate = 0;
48  m_squelch_gate_isSet = false;
49  squelch_enabled = 0;
51  agc = 0;
52  m_agc_isSet = false;
53  audio_active = 0;
54  m_audio_active_isSet = false;
55  audio_stereo = 0;
56  m_audio_stereo_isSet = false;
57  volume = 0;
58  m_volume_isSet = false;
59  udp_address = nullptr;
60  m_udp_address_isSet = false;
61  udp_port = 0;
62  m_udp_port_isSet = false;
63  audio_port = 0;
64  m_audio_port_isSet = false;
65  rgb_color = 0;
66  m_rgb_color_isSet = false;
67  title = nullptr;
68  m_title_isSet = false;
69  use_reverse_api = 0;
71  reverse_api_address = nullptr;
73  reverse_api_port = 0;
79 }
80 
82  this->cleanup();
83 }
84 
85 void
87  output_sample_rate = 0.0f;
89  sample_format = 0;
90  m_sample_format_isSet = false;
93  rf_bandwidth = 0.0f;
94  m_rf_bandwidth_isSet = false;
95  fm_deviation = 0;
96  m_fm_deviation_isSet = false;
97  channel_mute = 0;
98  m_channel_mute_isSet = false;
99  gain = 0.0f;
100  m_gain_isSet = false;
101  squelch_db = 0;
102  m_squelch_db_isSet = false;
103  squelch_gate = 0;
104  m_squelch_gate_isSet = false;
105  squelch_enabled = 0;
106  m_squelch_enabled_isSet = false;
107  agc = 0;
108  m_agc_isSet = false;
109  audio_active = 0;
110  m_audio_active_isSet = false;
111  audio_stereo = 0;
112  m_audio_stereo_isSet = false;
113  volume = 0;
114  m_volume_isSet = false;
115  udp_address = new QString("");
116  m_udp_address_isSet = false;
117  udp_port = 0;
118  m_udp_port_isSet = false;
119  audio_port = 0;
120  m_audio_port_isSet = false;
121  rgb_color = 0;
122  m_rgb_color_isSet = false;
123  title = new QString("");
124  m_title_isSet = false;
125  use_reverse_api = 0;
126  m_use_reverse_api_isSet = false;
127  reverse_api_address = new QString("");
129  reverse_api_port = 0;
130  m_reverse_api_port_isSet = false;
135 }
136 
137 void
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153  if(udp_address != nullptr) {
154  delete udp_address;
155  }
156 
157 
158 
159  if(title != nullptr) {
160  delete title;
161  }
162 
163  if(reverse_api_address != nullptr) {
164  delete reverse_api_address;
165  }
166 
167 
168 
169 }
170 
173  QByteArray array (json.toStdString().c_str());
174  QJsonDocument doc = QJsonDocument::fromJson(array);
175  QJsonObject jsonObject = doc.object();
176  this->fromJsonObject(jsonObject);
177  return this;
178 }
179 
180 void
182  ::SWGSDRangel::setValue(&output_sample_rate, pJson["outputSampleRate"], "float", "");
183 
184  ::SWGSDRangel::setValue(&sample_format, pJson["sampleFormat"], "qint32", "");
185 
186  ::SWGSDRangel::setValue(&input_frequency_offset, pJson["inputFrequencyOffset"], "qint64", "");
187 
188  ::SWGSDRangel::setValue(&rf_bandwidth, pJson["rfBandwidth"], "float", "");
189 
190  ::SWGSDRangel::setValue(&fm_deviation, pJson["fmDeviation"], "qint32", "");
191 
192  ::SWGSDRangel::setValue(&channel_mute, pJson["channelMute"], "qint32", "");
193 
194  ::SWGSDRangel::setValue(&gain, pJson["gain"], "float", "");
195 
196  ::SWGSDRangel::setValue(&squelch_db, pJson["squelchDB"], "qint32", "");
197 
198  ::SWGSDRangel::setValue(&squelch_gate, pJson["squelchGate"], "qint32", "");
199 
200  ::SWGSDRangel::setValue(&squelch_enabled, pJson["squelchEnabled"], "qint32", "");
201 
202  ::SWGSDRangel::setValue(&agc, pJson["agc"], "qint32", "");
203 
204  ::SWGSDRangel::setValue(&audio_active, pJson["audioActive"], "qint32", "");
205 
206  ::SWGSDRangel::setValue(&audio_stereo, pJson["audioStereo"], "qint32", "");
207 
208  ::SWGSDRangel::setValue(&volume, pJson["volume"], "qint32", "");
209 
210  ::SWGSDRangel::setValue(&udp_address, pJson["udpAddress"], "QString", "QString");
211 
212  ::SWGSDRangel::setValue(&udp_port, pJson["udpPort"], "qint32", "");
213 
214  ::SWGSDRangel::setValue(&audio_port, pJson["audioPort"], "qint32", "");
215 
216  ::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", "");
217 
218  ::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString");
219 
220  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
221 
222  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
223 
224  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
225 
226  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
227 
228  ::SWGSDRangel::setValue(&reverse_api_channel_index, pJson["reverseAPIChannelIndex"], "qint32", "");
229 
230 }
231 
232 QString
234 {
235  QJsonObject* obj = this->asJsonObject();
236 
237  QJsonDocument doc(*obj);
238  QByteArray bytes = doc.toJson();
239  delete obj;
240  return QString(bytes);
241 }
242 
243 QJsonObject*
245  QJsonObject* obj = new QJsonObject();
247  obj->insert("outputSampleRate", QJsonValue(output_sample_rate));
248  }
250  obj->insert("sampleFormat", QJsonValue(sample_format));
251  }
253  obj->insert("inputFrequencyOffset", QJsonValue(input_frequency_offset));
254  }
256  obj->insert("rfBandwidth", QJsonValue(rf_bandwidth));
257  }
259  obj->insert("fmDeviation", QJsonValue(fm_deviation));
260  }
262  obj->insert("channelMute", QJsonValue(channel_mute));
263  }
264  if(m_gain_isSet){
265  obj->insert("gain", QJsonValue(gain));
266  }
267  if(m_squelch_db_isSet){
268  obj->insert("squelchDB", QJsonValue(squelch_db));
269  }
271  obj->insert("squelchGate", QJsonValue(squelch_gate));
272  }
274  obj->insert("squelchEnabled", QJsonValue(squelch_enabled));
275  }
276  if(m_agc_isSet){
277  obj->insert("agc", QJsonValue(agc));
278  }
280  obj->insert("audioActive", QJsonValue(audio_active));
281  }
283  obj->insert("audioStereo", QJsonValue(audio_stereo));
284  }
285  if(m_volume_isSet){
286  obj->insert("volume", QJsonValue(volume));
287  }
288  if(udp_address != nullptr && *udp_address != QString("")){
289  toJsonValue(QString("udpAddress"), udp_address, obj, QString("QString"));
290  }
291  if(m_udp_port_isSet){
292  obj->insert("udpPort", QJsonValue(udp_port));
293  }
294  if(m_audio_port_isSet){
295  obj->insert("audioPort", QJsonValue(audio_port));
296  }
297  if(m_rgb_color_isSet){
298  obj->insert("rgbColor", QJsonValue(rgb_color));
299  }
300  if(title != nullptr && *title != QString("")){
301  toJsonValue(QString("title"), title, obj, QString("QString"));
302  }
304  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
305  }
306  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
307  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
308  }
310  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
311  }
313  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
314  }
316  obj->insert("reverseAPIChannelIndex", QJsonValue(reverse_api_channel_index));
317  }
318 
319  return obj;
320 }
321 
322 float
324  return output_sample_rate;
325 }
326 void
328  this->output_sample_rate = output_sample_rate;
329  this->m_output_sample_rate_isSet = true;
330 }
331 
332 qint32
334  return sample_format;
335 }
336 void
338  this->sample_format = sample_format;
339  this->m_sample_format_isSet = true;
340 }
341 
342 qint64
344  return input_frequency_offset;
345 }
346 void
348  this->input_frequency_offset = input_frequency_offset;
349  this->m_input_frequency_offset_isSet = true;
350 }
351 
352 float
354  return rf_bandwidth;
355 }
356 void
358  this->rf_bandwidth = rf_bandwidth;
359  this->m_rf_bandwidth_isSet = true;
360 }
361 
362 qint32
364  return fm_deviation;
365 }
366 void
368  this->fm_deviation = fm_deviation;
369  this->m_fm_deviation_isSet = true;
370 }
371 
372 qint32
374  return channel_mute;
375 }
376 void
378  this->channel_mute = channel_mute;
379  this->m_channel_mute_isSet = true;
380 }
381 
382 float
384  return gain;
385 }
386 void
388  this->gain = gain;
389  this->m_gain_isSet = true;
390 }
391 
392 qint32
394  return squelch_db;
395 }
396 void
398  this->squelch_db = squelch_db;
399  this->m_squelch_db_isSet = true;
400 }
401 
402 qint32
404  return squelch_gate;
405 }
406 void
408  this->squelch_gate = squelch_gate;
409  this->m_squelch_gate_isSet = true;
410 }
411 
412 qint32
414  return squelch_enabled;
415 }
416 void
418  this->squelch_enabled = squelch_enabled;
419  this->m_squelch_enabled_isSet = true;
420 }
421 
422 qint32
424  return agc;
425 }
426 void
428  this->agc = agc;
429  this->m_agc_isSet = true;
430 }
431 
432 qint32
434  return audio_active;
435 }
436 void
438  this->audio_active = audio_active;
439  this->m_audio_active_isSet = true;
440 }
441 
442 qint32
444  return audio_stereo;
445 }
446 void
448  this->audio_stereo = audio_stereo;
449  this->m_audio_stereo_isSet = true;
450 }
451 
452 qint32
454  return volume;
455 }
456 void
458  this->volume = volume;
459  this->m_volume_isSet = true;
460 }
461 
462 QString*
464  return udp_address;
465 }
466 void
468  this->udp_address = udp_address;
469  this->m_udp_address_isSet = true;
470 }
471 
472 qint32
474  return udp_port;
475 }
476 void
478  this->udp_port = udp_port;
479  this->m_udp_port_isSet = true;
480 }
481 
482 qint32
484  return audio_port;
485 }
486 void
488  this->audio_port = audio_port;
489  this->m_audio_port_isSet = true;
490 }
491 
492 qint32
494  return rgb_color;
495 }
496 void
498  this->rgb_color = rgb_color;
499  this->m_rgb_color_isSet = true;
500 }
501 
502 QString*
504  return title;
505 }
506 void
508  this->title = title;
509  this->m_title_isSet = true;
510 }
511 
512 qint32
514  return use_reverse_api;
515 }
516 void
518  this->use_reverse_api = use_reverse_api;
519  this->m_use_reverse_api_isSet = true;
520 }
521 
522 QString*
524  return reverse_api_address;
525 }
526 void
528  this->reverse_api_address = reverse_api_address;
529  this->m_reverse_api_address_isSet = true;
530 }
531 
532 qint32
534  return reverse_api_port;
535 }
536 void
538  this->reverse_api_port = reverse_api_port;
539  this->m_reverse_api_port_isSet = true;
540 }
541 
542 qint32
545 }
546 void
548  this->reverse_api_device_index = reverse_api_device_index;
550 }
551 
552 qint32
555 }
556 void
558  this->reverse_api_channel_index = reverse_api_channel_index;
560 }
561 
562 
563 bool
565  bool isObjectUpdated = false;
566  do{
567  if(m_output_sample_rate_isSet){ isObjectUpdated = true; break;}
568  if(m_sample_format_isSet){ isObjectUpdated = true; break;}
569  if(m_input_frequency_offset_isSet){ isObjectUpdated = true; break;}
570  if(m_rf_bandwidth_isSet){ isObjectUpdated = true; break;}
571  if(m_fm_deviation_isSet){ isObjectUpdated = true; break;}
572  if(m_channel_mute_isSet){ isObjectUpdated = true; break;}
573  if(m_gain_isSet){ isObjectUpdated = true; break;}
574  if(m_squelch_db_isSet){ isObjectUpdated = true; break;}
575  if(m_squelch_gate_isSet){ isObjectUpdated = true; break;}
576  if(m_squelch_enabled_isSet){ isObjectUpdated = true; break;}
577  if(m_agc_isSet){ isObjectUpdated = true; break;}
578  if(m_audio_active_isSet){ isObjectUpdated = true; break;}
579  if(m_audio_stereo_isSet){ isObjectUpdated = true; break;}
580  if(m_volume_isSet){ isObjectUpdated = true; break;}
581  if(udp_address != nullptr && *udp_address != QString("")){ isObjectUpdated = true; break;}
582  if(m_udp_port_isSet){ isObjectUpdated = true; break;}
583  if(m_audio_port_isSet){ isObjectUpdated = true; break;}
584  if(m_rgb_color_isSet){ isObjectUpdated = true; break;}
585  if(title != nullptr && *title != QString("")){ isObjectUpdated = true; break;}
586  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
587  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
588  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
589  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
590  if(m_reverse_api_channel_index_isSet){ isObjectUpdated = true; break;}
591  }while(false);
592  return isObjectUpdated;
593 }
594 }
595 
void setSquelchGate(qint32 squelch_gate)
void setSampleFormat(qint32 sample_format)
virtual SWGUDPSinkSettings * fromJson(QString &jsonString) override
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setChannelMute(qint32 channel_mute)
void setFmDeviation(qint32 fm_deviation)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiPort(qint32 reverse_api_port)
void setSquelchDb(qint32 squelch_db)
void setRfBandwidth(float rf_bandwidth)
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setUdpAddress(QString *udp_address)
virtual QJsonObject * asJsonObject() override
void setAudioPort(qint32 audio_port)
void setAudioStereo(qint32 audio_stereo)
void setSquelchEnabled(qint32 squelch_enabled)
virtual QString asJson() override
void setAudioActive(qint32 audio_active)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setUseReverseApi(qint32 use_reverse_api)
void setOutputSampleRate(float output_sample_rate)
virtual void fromJsonObject(QJsonObject &json) override
void setReverseApiAddress(QString *reverse_api_address)