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.
SWGNFMDemodReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGNFMDemodReport.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  ctcss_tone = 0.0f;
34  m_ctcss_tone_isSet = false;
35  squelch = 0;
36  m_squelch_isSet = false;
41 }
42 
44  this->cleanup();
45 }
46 
47 void
49  channel_power_db = 0.0f;
51  ctcss_tone = 0.0f;
52  m_ctcss_tone_isSet = false;
53  squelch = 0;
54  m_squelch_isSet = false;
59 }
60 
61 void
63 
64 
65 
66 
67 
68 }
69 
72  QByteArray array (json.toStdString().c_str());
73  QJsonDocument doc = QJsonDocument::fromJson(array);
74  QJsonObject jsonObject = doc.object();
75  this->fromJsonObject(jsonObject);
76  return this;
77 }
78 
79 void
80 SWGNFMDemodReport::fromJsonObject(QJsonObject &pJson) {
81  ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", "");
82 
83  ::SWGSDRangel::setValue(&ctcss_tone, pJson["ctcssTone"], "float", "");
84 
85  ::SWGSDRangel::setValue(&squelch, pJson["squelch"], "qint32", "");
86 
87  ::SWGSDRangel::setValue(&audio_sample_rate, pJson["audioSampleRate"], "qint32", "");
88 
89  ::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", "");
90 
91 }
92 
93 QString
95 {
96  QJsonObject* obj = this->asJsonObject();
97 
98  QJsonDocument doc(*obj);
99  QByteArray bytes = doc.toJson();
100  delete obj;
101  return QString(bytes);
102 }
103 
104 QJsonObject*
106  QJsonObject* obj = new QJsonObject();
108  obj->insert("channelPowerDB", QJsonValue(channel_power_db));
109  }
110  if(m_ctcss_tone_isSet){
111  obj->insert("ctcssTone", QJsonValue(ctcss_tone));
112  }
113  if(m_squelch_isSet){
114  obj->insert("squelch", QJsonValue(squelch));
115  }
117  obj->insert("audioSampleRate", QJsonValue(audio_sample_rate));
118  }
120  obj->insert("channelSampleRate", QJsonValue(channel_sample_rate));
121  }
122 
123  return obj;
124 }
125 
126 float
128  return channel_power_db;
129 }
130 void
132  this->channel_power_db = channel_power_db;
133  this->m_channel_power_db_isSet = true;
134 }
135 
136 float
138  return ctcss_tone;
139 }
140 void
142  this->ctcss_tone = ctcss_tone;
143  this->m_ctcss_tone_isSet = true;
144 }
145 
146 qint32
148  return squelch;
149 }
150 void
152  this->squelch = squelch;
153  this->m_squelch_isSet = true;
154 }
155 
156 qint32
158  return audio_sample_rate;
159 }
160 void
162  this->audio_sample_rate = audio_sample_rate;
163  this->m_audio_sample_rate_isSet = true;
164 }
165 
166 qint32
168  return channel_sample_rate;
169 }
170 void
172  this->channel_sample_rate = channel_sample_rate;
173  this->m_channel_sample_rate_isSet = true;
174 }
175 
176 
177 bool
179  bool isObjectUpdated = false;
180  do{
181  if(m_channel_power_db_isSet){ isObjectUpdated = true; break;}
182  if(m_ctcss_tone_isSet){ isObjectUpdated = true; break;}
183  if(m_squelch_isSet){ isObjectUpdated = true; break;}
184  if(m_audio_sample_rate_isSet){ isObjectUpdated = true; break;}
185  if(m_channel_sample_rate_isSet){ isObjectUpdated = true; break;}
186  }while(false);
187  return isObjectUpdated;
188 }
189 }
190 
virtual QString asJson() override
void setChannelSampleRate(qint32 channel_sample_rate)
virtual void fromJsonObject(QJsonObject &json) override
void setAudioSampleRate(qint32 audio_sample_rate)
virtual SWGNFMDemodReport * fromJson(QString &jsonString) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setChannelPowerDb(float channel_power_db)
void setCtcssTone(float ctcss_tone)
virtual QJsonObject * asJsonObject() override