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.
SWGRDSReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGRDSReport.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  demod_status = 0;
32  m_demod_status_isSet = false;
33  decod_status = 0;
34  m_decod_status_isSet = false;
35  rds_demod_accum_db = 0.0f;
37  rds_demod_frequency = 0.0f;
39  pid = nullptr;
40  m_pid_isSet = false;
41  pi_type = nullptr;
42  m_pi_type_isSet = false;
43  pi_coverage = nullptr;
44  m_pi_coverage_isSet = false;
45  prog_service_name = nullptr;
47  music_speech = nullptr;
48  m_music_speech_isSet = false;
49  mono_stereo = nullptr;
50  m_mono_stereo_isSet = false;
51  radio_text = nullptr;
52  m_radio_text_isSet = false;
53  time = nullptr;
54  m_time_isSet = false;
55  alt_frequencies = nullptr;
57 }
58 
60  this->cleanup();
61 }
62 
63 void
65  demod_status = 0;
66  m_demod_status_isSet = false;
67  decod_status = 0;
68  m_decod_status_isSet = false;
69  rds_demod_accum_db = 0.0f;
71  rds_demod_frequency = 0.0f;
73  pid = new QString("");
74  m_pid_isSet = false;
75  pi_type = new QString("");
76  m_pi_type_isSet = false;
77  pi_coverage = new QString("");
78  m_pi_coverage_isSet = false;
79  prog_service_name = new QString("");
81  music_speech = new QString("");
82  m_music_speech_isSet = false;
83  mono_stereo = new QString("");
84  m_mono_stereo_isSet = false;
85  radio_text = new QString("");
86  m_radio_text_isSet = false;
87  time = new QString("");
88  m_time_isSet = false;
89  alt_frequencies = new QList<SWGRDSReport_altFrequencies*>();
91 }
92 
93 void
95 
96 
97 
98 
99  if(pid != nullptr) {
100  delete pid;
101  }
102  if(pi_type != nullptr) {
103  delete pi_type;
104  }
105  if(pi_coverage != nullptr) {
106  delete pi_coverage;
107  }
108  if(prog_service_name != nullptr) {
109  delete prog_service_name;
110  }
111  if(music_speech != nullptr) {
112  delete music_speech;
113  }
114  if(mono_stereo != nullptr) {
115  delete mono_stereo;
116  }
117  if(radio_text != nullptr) {
118  delete radio_text;
119  }
120  if(time != nullptr) {
121  delete time;
122  }
123  if(alt_frequencies != nullptr) {
124  auto arr = alt_frequencies;
125  for(auto o: *arr) {
126  delete o;
127  }
128  delete alt_frequencies;
129  }
130 }
131 
133 SWGRDSReport::fromJson(QString &json) {
134  QByteArray array (json.toStdString().c_str());
135  QJsonDocument doc = QJsonDocument::fromJson(array);
136  QJsonObject jsonObject = doc.object();
137  this->fromJsonObject(jsonObject);
138  return this;
139 }
140 
141 void
142 SWGRDSReport::fromJsonObject(QJsonObject &pJson) {
143  ::SWGSDRangel::setValue(&demod_status, pJson["demodStatus"], "qint32", "");
144 
145  ::SWGSDRangel::setValue(&decod_status, pJson["decodStatus"], "qint32", "");
146 
147  ::SWGSDRangel::setValue(&rds_demod_accum_db, pJson["rdsDemodAccumDB"], "float", "");
148 
149  ::SWGSDRangel::setValue(&rds_demod_frequency, pJson["rdsDemodFrequency"], "float", "");
150 
151  ::SWGSDRangel::setValue(&pid, pJson["pid"], "QString", "QString");
152 
153  ::SWGSDRangel::setValue(&pi_type, pJson["piType"], "QString", "QString");
154 
155  ::SWGSDRangel::setValue(&pi_coverage, pJson["piCoverage"], "QString", "QString");
156 
157  ::SWGSDRangel::setValue(&prog_service_name, pJson["progServiceName"], "QString", "QString");
158 
159  ::SWGSDRangel::setValue(&music_speech, pJson["musicSpeech"], "QString", "QString");
160 
161  ::SWGSDRangel::setValue(&mono_stereo, pJson["monoStereo"], "QString", "QString");
162 
163  ::SWGSDRangel::setValue(&radio_text, pJson["radioText"], "QString", "QString");
164 
165  ::SWGSDRangel::setValue(&time, pJson["time"], "QString", "QString");
166 
167 
168  ::SWGSDRangel::setValue(&alt_frequencies, pJson["altFrequencies"], "QList", "SWGRDSReport_altFrequencies");
169 }
170 
171 QString
173 {
174  QJsonObject* obj = this->asJsonObject();
175 
176  QJsonDocument doc(*obj);
177  QByteArray bytes = doc.toJson();
178  delete obj;
179  return QString(bytes);
180 }
181 
182 QJsonObject*
184  QJsonObject* obj = new QJsonObject();
186  obj->insert("demodStatus", QJsonValue(demod_status));
187  }
189  obj->insert("decodStatus", QJsonValue(decod_status));
190  }
192  obj->insert("rdsDemodAccumDB", QJsonValue(rds_demod_accum_db));
193  }
195  obj->insert("rdsDemodFrequency", QJsonValue(rds_demod_frequency));
196  }
197  if(pid != nullptr && *pid != QString("")){
198  toJsonValue(QString("pid"), pid, obj, QString("QString"));
199  }
200  if(pi_type != nullptr && *pi_type != QString("")){
201  toJsonValue(QString("piType"), pi_type, obj, QString("QString"));
202  }
203  if(pi_coverage != nullptr && *pi_coverage != QString("")){
204  toJsonValue(QString("piCoverage"), pi_coverage, obj, QString("QString"));
205  }
206  if(prog_service_name != nullptr && *prog_service_name != QString("")){
207  toJsonValue(QString("progServiceName"), prog_service_name, obj, QString("QString"));
208  }
209  if(music_speech != nullptr && *music_speech != QString("")){
210  toJsonValue(QString("musicSpeech"), music_speech, obj, QString("QString"));
211  }
212  if(mono_stereo != nullptr && *mono_stereo != QString("")){
213  toJsonValue(QString("monoStereo"), mono_stereo, obj, QString("QString"));
214  }
215  if(radio_text != nullptr && *radio_text != QString("")){
216  toJsonValue(QString("radioText"), radio_text, obj, QString("QString"));
217  }
218  if(time != nullptr && *time != QString("")){
219  toJsonValue(QString("time"), time, obj, QString("QString"));
220  }
221  if(alt_frequencies->size() > 0){
222  toJsonArray((QList<void*>*)alt_frequencies, obj, "altFrequencies", "SWGRDSReport_altFrequencies");
223  }
224 
225  return obj;
226 }
227 
228 qint32
230  return demod_status;
231 }
232 void
234  this->demod_status = demod_status;
235  this->m_demod_status_isSet = true;
236 }
237 
238 qint32
240  return decod_status;
241 }
242 void
244  this->decod_status = decod_status;
245  this->m_decod_status_isSet = true;
246 }
247 
248 float
250  return rds_demod_accum_db;
251 }
252 void
254  this->rds_demod_accum_db = rds_demod_accum_db;
255  this->m_rds_demod_accum_db_isSet = true;
256 }
257 
258 float
260  return rds_demod_frequency;
261 }
262 void
264  this->rds_demod_frequency = rds_demod_frequency;
265  this->m_rds_demod_frequency_isSet = true;
266 }
267 
268 QString*
270  return pid;
271 }
272 void
274  this->pid = pid;
275  this->m_pid_isSet = true;
276 }
277 
278 QString*
280  return pi_type;
281 }
282 void
284  this->pi_type = pi_type;
285  this->m_pi_type_isSet = true;
286 }
287 
288 QString*
290  return pi_coverage;
291 }
292 void
294  this->pi_coverage = pi_coverage;
295  this->m_pi_coverage_isSet = true;
296 }
297 
298 QString*
300  return prog_service_name;
301 }
302 void
304  this->prog_service_name = prog_service_name;
305  this->m_prog_service_name_isSet = true;
306 }
307 
308 QString*
310  return music_speech;
311 }
312 void
314  this->music_speech = music_speech;
315  this->m_music_speech_isSet = true;
316 }
317 
318 QString*
320  return mono_stereo;
321 }
322 void
324  this->mono_stereo = mono_stereo;
325  this->m_mono_stereo_isSet = true;
326 }
327 
328 QString*
330  return radio_text;
331 }
332 void
334  this->radio_text = radio_text;
335  this->m_radio_text_isSet = true;
336 }
337 
338 QString*
340  return time;
341 }
342 void
344  this->time = time;
345  this->m_time_isSet = true;
346 }
347 
348 QList<SWGRDSReport_altFrequencies*>*
350  return alt_frequencies;
351 }
352 void
353 SWGRDSReport::setAltFrequencies(QList<SWGRDSReport_altFrequencies*>* alt_frequencies) {
354  this->alt_frequencies = alt_frequencies;
355  this->m_alt_frequencies_isSet = true;
356 }
357 
358 
359 bool
361  bool isObjectUpdated = false;
362  do{
363  if(m_demod_status_isSet){ isObjectUpdated = true; break;}
364  if(m_decod_status_isSet){ isObjectUpdated = true; break;}
365  if(m_rds_demod_accum_db_isSet){ isObjectUpdated = true; break;}
366  if(m_rds_demod_frequency_isSet){ isObjectUpdated = true; break;}
367  if(pid != nullptr && *pid != QString("")){ isObjectUpdated = true; break;}
368  if(pi_type != nullptr && *pi_type != QString("")){ isObjectUpdated = true; break;}
369  if(pi_coverage != nullptr && *pi_coverage != QString("")){ isObjectUpdated = true; break;}
370  if(prog_service_name != nullptr && *prog_service_name != QString("")){ isObjectUpdated = true; break;}
371  if(music_speech != nullptr && *music_speech != QString("")){ isObjectUpdated = true; break;}
372  if(mono_stereo != nullptr && *mono_stereo != QString("")){ isObjectUpdated = true; break;}
373  if(radio_text != nullptr && *radio_text != QString("")){ isObjectUpdated = true; break;}
374  if(time != nullptr && *time != QString("")){ isObjectUpdated = true; break;}
375  if(alt_frequencies->size() > 0){ isObjectUpdated = true; break;}
376  }while(false);
377  return isObjectUpdated;
378 }
379 }
380 
void setAltFrequencies(QList< SWGRDSReport_altFrequencies *> *alt_frequencies)
void setRadioText(QString *radio_text)
virtual void fromJsonObject(QJsonObject &json) override
void setProgServiceName(QString *prog_service_name)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
QList< SWGRDSReport_altFrequencies * > * getAltFrequencies()
void setDemodStatus(qint32 demod_status)
virtual QString asJson() override
void setRdsDemodFrequency(float rds_demod_frequency)
virtual QJsonObject * asJsonObject() override
void setDecodStatus(qint32 decod_status)
void setRdsDemodAccumDb(float rds_demod_accum_db)
virtual SWGRDSReport * fromJson(QString &jsonString) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void toJsonArray(QList< void *> *value, QJsonObject *output, QString innerName, QString innerType)
Definition: SWGHelpers.cpp:445
virtual bool isSet() override
void setMonoStereo(QString *mono_stereo)
void setPiCoverage(QString *pi_coverage)
void setPiType(QString *pi_type)
void setTime(QString *time)
void setPid(QString *pid)
QList< SWGRDSReport_altFrequencies * > * alt_frequencies
Definition: SWGRDSReport.h:126
void setMusicSpeech(QString *music_speech)