FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
timing Namespace Reference

Classes

class  PrototypeTiming
 Manages timing properties such as frequency, offsets, and synchronization. More...
 
class  Timing
 Represents a timing source for simulation. More...
 

Functions

void to_json (nlohmann::json &j, const PrototypeTiming &pt)
 
void from_json (const nlohmann::json &j, PrototypeTiming &pt)
 

Function Documentation

◆ from_json()

void timing::from_json ( const nlohmann::json &  j,
PrototypeTiming pt 
)

Definition at line 238 of file json_serializer.cpp.

239 {
240 pt.setFrequency(j.at("frequency").get<RealType>());
241 if (j.value("synconpulse", false))
242 {
243 pt.setSyncOnPulse();
244 }
245 else
246 {
247 pt.clearSyncOnPulse();
248 }
249
250 if (j.contains("freq_offset"))
251 {
252 pt.setFreqOffset(j.at("freq_offset").get<RealType>());
253 }
254 else
255 pt.clearFreqOffset();
256 if (j.contains("random_freq_offset_stdev"))
257 {
258 pt.setRandomFreqOffsetStdev(j.at("random_freq_offset_stdev").get<RealType>());
259 }
260 else
262 if (j.contains("phase_offset"))
263 {
264 pt.setPhaseOffset(j.at("phase_offset").get<RealType>());
265 }
266 else
267 pt.clearPhaseOffset();
268 if (j.contains("random_phase_offset_stdev"))
269 {
270 pt.setRandomPhaseOffsetStdev(j.at("random_phase_offset_stdev").get<RealType>());
271 }
272 else
274
276 if (j.contains("noise_entries"))
277 {
278 for (const auto& entry : j.at("noise_entries"))
279 {
280 pt.setAlpha(entry.at("alpha").get<RealType>(), entry.at("weight").get<RealType>());
281 }
282 }
283 }
void clearNoiseEntries() noexcept
Clears all noise entries.
void setSyncOnPulse() noexcept
Enables synchronization on pulse.
void clearPhaseOffset() noexcept
Clears the phase offset.
void setAlpha(RealType alpha, RealType weight) noexcept
Sets an alpha and weight value.
void setRandomPhaseOffsetStdev(RealType stdev) noexcept
Sets a random phase offset standard deviation.
void clearSyncOnPulse() noexcept
Disables synchronization on pulse.
void setFreqOffset(RealType offset) noexcept
Sets the frequency offset.
void setPhaseOffset(RealType offset) noexcept
Sets the phase offset.
void setRandomFreqOffsetStdev(RealType stdev) noexcept
Sets a random frequency offset standard deviation.
void setFrequency(const RealType freq) noexcept
Sets the frequency value.
void clearRandomPhaseOffsetStdev() noexcept
Clears the random phase offset standard deviation.
void clearFreqOffset() noexcept
Clears the frequency offset.
void clearRandomFreqOffsetStdev() noexcept
Clears the random frequency offset standard deviation.
double RealType
Type for real numbers.
Definition config.h:27

References timing::PrototypeTiming::clearFreqOffset(), timing::PrototypeTiming::clearNoiseEntries(), timing::PrototypeTiming::clearPhaseOffset(), timing::PrototypeTiming::clearRandomFreqOffsetStdev(), timing::PrototypeTiming::clearRandomPhaseOffsetStdev(), timing::PrototypeTiming::clearSyncOnPulse(), timing::PrototypeTiming::setAlpha(), timing::PrototypeTiming::setFreqOffset(), timing::PrototypeTiming::setFrequency(), timing::PrototypeTiming::setPhaseOffset(), timing::PrototypeTiming::setRandomFreqOffsetStdev(), timing::PrototypeTiming::setRandomPhaseOffsetStdev(), and timing::PrototypeTiming::setSyncOnPulse().

+ Here is the call graph for this function:

◆ to_json()

void timing::to_json ( nlohmann::json &  j,
const PrototypeTiming pt 
)

Definition at line 200 of file json_serializer.cpp.

201 {
202 j = nlohmann::json{{"id", sim_id_to_json(pt.getId())},
203 {"name", pt.getName()},
204 {"frequency", pt.getFrequency()},
205 {"synconpulse", pt.getSyncOnPulse()}};
206
207 if (pt.getFreqOffset().has_value())
208 {
209 j["freq_offset"] = pt.getFreqOffset().value();
210 }
211 if (pt.getRandomFreqOffsetStdev().has_value())
212 {
213 j["random_freq_offset_stdev"] = pt.getRandomFreqOffsetStdev().value();
214 }
215 if (pt.getPhaseOffset().has_value())
216 {
217 j["phase_offset"] = pt.getPhaseOffset().value();
218 }
219 if (pt.getRandomPhaseOffsetStdev().has_value())
220 {
221 j["random_phase_offset_stdev"] = pt.getRandomPhaseOffsetStdev().value();
222 }
223
224 std::vector<RealType> alphas;
225 std::vector<RealType> weights;
226 pt.copyAlphas(alphas, weights);
227 if (!alphas.empty())
228 {
229 nlohmann::json noise_entries = nlohmann::json::array();
230 for (size_t i = 0; i < alphas.size(); ++i)
231 {
232 noise_entries.push_back({{"alpha", alphas[i]}, {"weight", weights[i]}});
233 }
234 j["noise_entries"] = noise_entries;
235 }
236 }
std::optional< RealType > getRandomPhaseOffsetStdev() const noexcept
bool getSyncOnPulse() const noexcept
Checks if synchronization on pulse is enabled.
std::string getName() const
Gets the name of the timing source.
std::optional< RealType > getRandomFreqOffsetStdev() const noexcept
RealType getFrequency() const noexcept
Gets the current frequency.
std::optional< RealType > getPhaseOffset() const noexcept
Gets the phase offset.
void copyAlphas(std::vector< RealType > &alphas, std::vector< RealType > &weights) const noexcept
Copies the alphas and weights vectors.
SimId getId() const noexcept
Gets the unique ID of the timing source.
std::optional< RealType > getFreqOffset() const noexcept
Gets the frequency offset.

References timing::PrototypeTiming::copyAlphas(), timing::PrototypeTiming::getFreqOffset(), timing::PrototypeTiming::getFrequency(), timing::PrototypeTiming::getId(), timing::PrototypeTiming::getName(), timing::PrototypeTiming::getPhaseOffset(), timing::PrototypeTiming::getRandomFreqOffsetStdev(), timing::PrototypeTiming::getRandomPhaseOffsetStdev(), and timing::PrototypeTiming::getSyncOnPulse().

+ Here is the call graph for this function: