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.
SWGBFMDemodReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGBFMDemodReport.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  channel_power_db = 0.0f;
33  squelch = 0;
34  m_squelch_isSet = false;
39  pilot_locked = 0;
40  m_pilot_locked_isSet = false;
41  pilot_power_db = 0.0f;
42  m_pilot_power_db_isSet = false;
43  rds_report = nullptr;
44  m_rds_report_isSet = false;
45 }
46 
48  this->cleanup();
49 }
50 
51 void
53  channel_power_db = 0.0f;
55  squelch = 0;
56  m_squelch_isSet = false;
61  pilot_locked = 0;
62  m_pilot_locked_isSet = false;
63  pilot_power_db = 0.0f;
64  m_pilot_power_db_isSet = false;
65  rds_report = new SWGRDSReport();
66  m_rds_report_isSet = false;
67 }
68 
69 void
71 
72 
73 
74 
75 
76 
77  if(rds_report != nullptr) {
78  delete rds_report;
79  }
80 }
81 
84  QByteArray array (json.toStdString().c_str());
85  QJsonDocument doc = QJsonDocument::fromJson(array);
86  QJsonObject jsonObject = doc.object();
87  this->fromJsonObject(jsonObject);
88  return this;
89 }
90 
91 void
92 SWGBFMDemodReport::fromJsonObject(QJsonObject &pJson) {
93  ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", "");
94 
95  ::SWGSDRangel::setValue(&squelch, pJson["squelch"], "qint32", "");
96 
97  ::SWGSDRangel::setValue(&audio_sample_rate, pJson["audioSampleRate"], "qint32", "");
98 
99  ::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", "");
100 
101  ::SWGSDRangel::setValue(&pilot_locked, pJson["pilotLocked"], "qint32", "");
102 
103  ::SWGSDRangel::setValue(&pilot_power_db, pJson["pilotPowerDB"], "float", "");
104 
105  ::SWGSDRangel::setValue(&rds_report, pJson["rdsReport"], "SWGRDSReport", "SWGRDSReport");
106 
107 }
108 
109 QString
111 {
112  QJsonObject* obj = this->asJsonObject();
113 
114  QJsonDocument doc(*obj);
115  QByteArray bytes = doc.toJson();
116  delete obj;
117  return QString(bytes);
118 }
119 
120 QJsonObject*
122  QJsonObject* obj = new QJsonObject();
124  obj->insert("channelPowerDB", QJsonValue(channel_power_db));
125  }
126  if(m_squelch_isSet){
127  obj->insert("squelch", QJsonValue(squelch));
128  }
130  obj->insert("audioSampleRate", QJsonValue(audio_sample_rate));
131  }
133  obj->insert("channelSampleRate", QJsonValue(channel_sample_rate));
134  }
136  obj->insert("pilotLocked", QJsonValue(pilot_locked));
137  }
139  obj->insert("pilotPowerDB", QJsonValue(pilot_power_db));
140  }
141  if((rds_report != nullptr) && (rds_report->isSet())){
142  toJsonValue(QString("rdsReport"), rds_report, obj, QString("SWGRDSReport"));
143  }
144 
145  return obj;
146 }
147 
148 float
150  return channel_power_db;
151 }
152 void
154  this->channel_power_db = channel_power_db;
155  this->m_channel_power_db_isSet = true;
156 }
157 
158 qint32
160  return squelch;
161 }
162 void
164  this->squelch = squelch;
165  this->m_squelch_isSet = true;
166 }
167 
168 qint32
170  return audio_sample_rate;
171 }
172 void
174  this->audio_sample_rate = audio_sample_rate;
175  this->m_audio_sample_rate_isSet = true;
176 }
177 
178 qint32
180  return channel_sample_rate;
181 }
182 void
184  this->channel_sample_rate = channel_sample_rate;
185  this->m_channel_sample_rate_isSet = true;
186 }
187 
188 qint32
190  return pilot_locked;
191 }
192 void
194  this->pilot_locked = pilot_locked;
195  this->m_pilot_locked_isSet = true;
196 }
197 
198 float
200  return pilot_power_db;
201 }
202 void
204  this->pilot_power_db = pilot_power_db;
205  this->m_pilot_power_db_isSet = true;
206 }
207 
210  return rds_report;
211 }
212 void
214  this->rds_report = rds_report;
215  this->m_rds_report_isSet = true;
216 }
217 
218 
219 bool
221  bool isObjectUpdated = false;
222  do{
223  if(m_channel_power_db_isSet){ isObjectUpdated = true; break;}
224  if(m_squelch_isSet){ isObjectUpdated = true; break;}
225  if(m_audio_sample_rate_isSet){ isObjectUpdated = true; break;}
226  if(m_channel_sample_rate_isSet){ isObjectUpdated = true; break;}
227  if(m_pilot_locked_isSet){ isObjectUpdated = true; break;}
228  if(m_pilot_power_db_isSet){ isObjectUpdated = true; break;}
229  if(rds_report != nullptr && rds_report->isSet()){ isObjectUpdated = true; break;}
230  }while(false);
231  return isObjectUpdated;
232 }
233 }
234 
virtual QString asJson() override
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual SWGBFMDemodReport * fromJson(QString &jsonString) override
void setChannelSampleRate(qint32 channel_sample_rate)
virtual void fromJsonObject(QJsonObject &json) override
virtual QJsonObject * asJsonObject() override
void setAudioSampleRate(qint32 audio_sample_rate)
void setPilotPowerDb(float pilot_power_db)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setChannelPowerDb(float channel_power_db)
virtual bool isSet() override
void setPilotLocked(qint32 pilot_locked)
void setRdsReport(SWGRDSReport *rds_report)