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.
SWGSSBDemodReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGSSBDemodReport.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 }
40 
42  this->cleanup();
43 }
44 
45 void
47  channel_power_db = 0.0f;
49  squelch = 0;
50  m_squelch_isSet = false;
55 }
56 
57 void
59 
60 
61 
62 
63 }
64 
67  QByteArray array (json.toStdString().c_str());
68  QJsonDocument doc = QJsonDocument::fromJson(array);
69  QJsonObject jsonObject = doc.object();
70  this->fromJsonObject(jsonObject);
71  return this;
72 }
73 
74 void
75 SWGSSBDemodReport::fromJsonObject(QJsonObject &pJson) {
76  ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", "");
77 
78  ::SWGSDRangel::setValue(&squelch, pJson["squelch"], "qint32", "");
79 
80  ::SWGSDRangel::setValue(&audio_sample_rate, pJson["audioSampleRate"], "qint32", "");
81 
82  ::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", "");
83 
84 }
85 
86 QString
88 {
89  QJsonObject* obj = this->asJsonObject();
90 
91  QJsonDocument doc(*obj);
92  QByteArray bytes = doc.toJson();
93  delete obj;
94  return QString(bytes);
95 }
96 
97 QJsonObject*
99  QJsonObject* obj = new QJsonObject();
101  obj->insert("channelPowerDB", QJsonValue(channel_power_db));
102  }
103  if(m_squelch_isSet){
104  obj->insert("squelch", QJsonValue(squelch));
105  }
107  obj->insert("audioSampleRate", QJsonValue(audio_sample_rate));
108  }
110  obj->insert("channelSampleRate", QJsonValue(channel_sample_rate));
111  }
112 
113  return obj;
114 }
115 
116 float
118  return channel_power_db;
119 }
120 void
122  this->channel_power_db = channel_power_db;
123  this->m_channel_power_db_isSet = true;
124 }
125 
126 qint32
128  return squelch;
129 }
130 void
132  this->squelch = squelch;
133  this->m_squelch_isSet = true;
134 }
135 
136 qint32
138  return audio_sample_rate;
139 }
140 void
142  this->audio_sample_rate = audio_sample_rate;
143  this->m_audio_sample_rate_isSet = true;
144 }
145 
146 qint32
148  return channel_sample_rate;
149 }
150 void
152  this->channel_sample_rate = channel_sample_rate;
153  this->m_channel_sample_rate_isSet = true;
154 }
155 
156 
157 bool
159  bool isObjectUpdated = false;
160  do{
161  if(m_channel_power_db_isSet){ isObjectUpdated = true; break;}
162  if(m_squelch_isSet){ isObjectUpdated = true; break;}
163  if(m_audio_sample_rate_isSet){ isObjectUpdated = true; break;}
164  if(m_channel_sample_rate_isSet){ isObjectUpdated = true; break;}
165  }while(false);
166  return isObjectUpdated;
167 }
168 }
169 
virtual SWGSSBDemodReport * fromJson(QString &jsonString) override
void setAudioSampleRate(qint32 audio_sample_rate)
virtual QString asJson() override
virtual QJsonObject * asJsonObject() override
void setChannelSampleRate(qint32 channel_sample_rate)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual void fromJsonObject(QJsonObject &json) override
void setChannelPowerDb(float channel_power_db)