FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
prototype_timing.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2006-2008 Marc Brooker and Michael Inggs
4// Copyright (c) 2008-present FERS Contributors (see AUTHORS.md).
5//
6// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
7
8/**
9 * @file prototype_timing.h
10 * @brief Header file for the PrototypeTiming class.
11 */
12
13#pragma once
14
15#include <optional>
16#include <string>
17#include <utility>
18#include <vector>
19
20#include "core/config.h"
21#include "core/sim_id.h"
22
23namespace timing
24{
25 /**
26 * @class PrototypeTiming
27 * @brief Manages timing properties such as frequency, offsets, and synchronization.
28 */
30 {
31 public:
32 /**
33 * @brief Constructor for PrototypeTiming.
34 *
35 * @param name The name of the timing source.
36 */
37 explicit PrototypeTiming(std::string name, const SimId id = 0) noexcept :
38 _id(id == 0 ? SimIdGenerator::instance().generateId(ObjectType::Timing) : id), _name(std::move(name))
39 {
40 }
41
42 ~PrototypeTiming() = default;
43
45
47
49
51
52 /**
53 * @brief Copies the alphas and weights vectors.
54 *
55 * @param alphas Reference to the vector where alpha values will be copied.
56 * @param weights Reference to the vector where weight values will be copied.
57 */
58 void copyAlphas(std::vector<RealType>& alphas, std::vector<RealType>& weights) const noexcept;
59
60 /**
61 * @brief Gets the current frequency.
62 *
63 * @return The current frequency value.
64 */
65 [[nodiscard]] RealType getFrequency() const noexcept { return _frequency; }
66
67 /**
68 * @brief Gets the name of the timing source.
69 *
70 * @return The name of the timing source.
71 */
72 [[nodiscard]] std::string getName() const { return _name; }
73
74 /**
75 * @brief Gets the unique ID of the timing source.
76 *
77 * @return The timing source SimId.
78 */
79 [[nodiscard]] SimId getId() const noexcept { return _id; }
80
81 /**
82 * @brief Checks if synchronization on pulse is enabled.
83 *
84 * @return True if synchronization on pulse is enabled, false otherwise.
85 */
86 [[nodiscard]] bool getSyncOnPulse() const noexcept { return _sync_on_pulse; }
87
88 /**
89 * @brief Gets the phase offset.
90 *
91 * @return The phase offset value.
92 */
93 [[nodiscard]] std::optional<RealType> getPhaseOffset() const noexcept { return _phase_offset; }
94
95 /**
96 * @brief Gets the frequency offset.
97 *
98 * @return The frequency offset value.
99 */
100 [[nodiscard]] std::optional<RealType> getFreqOffset() const noexcept { return _freq_offset; }
101
102 /** @brief Gets the random frequency-offset standard deviation. */
103 [[nodiscard]] std::optional<RealType> getRandomFreqOffsetStdev() const noexcept { return _random_freq_stdev; }
104
105 /** @brief Gets the random phase-offset standard deviation. */
106 [[nodiscard]] std::optional<RealType> getRandomPhaseOffsetStdev() const noexcept { return _random_phase_stdev; }
107
108 /**
109 * @brief Sets the frequency value.
110 *
111 * @param freq The frequency value to be set.
112 */
113 void setFrequency(const RealType freq) noexcept { _frequency = freq; }
114
115 /**
116 * @brief Enables synchronization on pulse.
117 */
118 void setSyncOnPulse() noexcept { _sync_on_pulse = true; }
119
120 /**
121 * @brief Disables synchronization on pulse.
122 */
123 void clearSyncOnPulse() noexcept { _sync_on_pulse = false; }
124
125 /**
126 * @brief Sets an alpha and weight value.
127 *
128 * @param alpha The alpha value to be added.
129 * @param weight The weight value to be added.
130 */
131 void setAlpha(RealType alpha, RealType weight) noexcept;
132
133 /**
134 * @brief Clears all noise entries.
135 */
137
138 /**
139 * @brief Sets the frequency offset.
140 *
141 * @param offset The frequency offset to be set.
142 */
143 void setFreqOffset(RealType offset) noexcept { _freq_offset = offset; }
144
145 /**
146 * @brief Clears the frequency offset.
147 */
148 void clearFreqOffset() noexcept { _freq_offset = std::nullopt; }
149
150 /**
151 * @brief Sets the phase offset.
152 *
153 * @param offset The phase offset to be set.
154 */
155 void setPhaseOffset(RealType offset) noexcept { _phase_offset = offset; }
156
157 /**
158 * @brief Clears the phase offset.
159 */
160 void clearPhaseOffset() noexcept { _phase_offset = std::nullopt; }
161
162 /**
163 * @brief Sets a random frequency offset standard deviation.
164 *
165 * @param stdev The standard deviation for generating the random frequency offset.
166 */
167 void setRandomFreqOffsetStdev(RealType stdev) noexcept { _random_freq_stdev = stdev; }
168
169 /**
170 * @brief Sets a random phase offset standard deviation.
171 *
172 * @param stdev The standard deviation for generating the random phase offset.
173 */
174 void setRandomPhaseOffsetStdev(RealType stdev) noexcept { _random_phase_stdev = stdev; }
175
176 /**
177 * @brief Clears the random frequency offset standard deviation.
178 */
179 void clearRandomFreqOffsetStdev() noexcept { _random_freq_stdev = std::nullopt; }
180
181 /**
182 * @brief Clears the random phase offset standard deviation.
183 */
184 void clearRandomPhaseOffsetStdev() noexcept { _random_phase_stdev = std::nullopt; }
185
186 /**
187 * @brief Sets the name of the timing source.
188 *
189 * @param name The new name.
190 */
191 void setName(std::string name) noexcept { _name = std::move(name); }
192
193 private:
194 SimId _id; ///< Unique ID for this timing source.
195 std::string _name; ///< The name of the timing source.
196 std::vector<RealType> _alphas; ///< Vector of alpha values.
197 std::vector<RealType> _weights; ///< Vector of weight values.
198 std::optional<RealType> _freq_offset; ///< Constant frequency offset.
199 std::optional<RealType> _phase_offset; ///< Constant phase offset.
200 std::optional<RealType> _random_phase_stdev; ///< Random phase offset standard deviation.
201 std::optional<RealType> _random_freq_stdev; ///< Random frequency offset standard deviation.
202 RealType _frequency{0}; ///< The frequency value.
203 bool _sync_on_pulse{false}; ///< Flag indicating synchronization on pulse.
204 };
205}
Thread-safe Meyers singleton for generating unique object IDs.
Definition sim_id.h:42
Manages timing properties such as frequency, offsets, and synchronization.
PrototypeTiming & operator=(PrototypeTiming &&)=default
void clearNoiseEntries() noexcept
Clears all noise entries.
void setSyncOnPulse() noexcept
Enables synchronization on pulse.
void clearPhaseOffset() noexcept
Clears the phase offset.
void setName(std::string name) noexcept
Sets the name of the timing source.
PrototypeTiming(std::string name, const SimId id=0) noexcept
Constructor for PrototypeTiming.
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.
std::optional< RealType > getRandomPhaseOffsetStdev() const noexcept
Gets the random phase-offset standard deviation.
bool getSyncOnPulse() const noexcept
Checks if synchronization on pulse is enabled.
PrototypeTiming & operator=(const PrototypeTiming &)=default
void clearSyncOnPulse() noexcept
Disables synchronization on pulse.
std::string getName() const
Gets the name of the timing source.
void setFreqOffset(RealType offset) noexcept
Sets the frequency offset.
std::optional< RealType > getRandomFreqOffsetStdev() const noexcept
Gets the random frequency-offset standard deviation.
PrototypeTiming(const PrototypeTiming &)=default
void setPhaseOffset(RealType offset) noexcept
Sets the phase offset.
void setRandomFreqOffsetStdev(RealType stdev) noexcept
Sets a random frequency offset standard deviation.
RealType getFrequency() const noexcept
Gets the current frequency.
void setFrequency(const RealType freq) noexcept
Sets the frequency value.
void clearRandomPhaseOffsetStdev() noexcept
Clears the random phase offset standard deviation.
PrototypeTiming(PrototypeTiming &&)=default
std::optional< RealType > getPhaseOffset() const noexcept
Gets the phase offset.
void clearFreqOffset() noexcept
Clears the frequency 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.
void clearRandomFreqOffsetStdev() noexcept
Clears the random frequency offset standard deviation.
std::optional< RealType > getFreqOffset() const noexcept
Gets the frequency offset.
Represents a timing source for simulation.
Definition timing.h:36
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
uint64_t SimId
64-bit Unique Simulation ID.
Definition sim_id.h:18
ObjectType
Categorizes objects for ID generation.
Definition sim_id.h:25
math::Vec3 max