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 191 of file json_serializer.cpp.

192 {
193 pt.setFrequency(j.at("frequency").get<RealType>());
194 if (j.value("synconpulse", false))
195 {
196 pt.setSyncOnPulse();
197 }
198
199 if (j.contains("freq_offset"))
200 {
201 pt.setFreqOffset(j.at("freq_offset").get<RealType>());
202 }
203 if (j.contains("random_freq_offset_stdev"))
204 {
205 pt.setRandomFreqOffsetStdev(j.at("random_freq_offset_stdev").get<RealType>());
206 }
207 if (j.contains("phase_offset"))
208 {
209 pt.setPhaseOffset(j.at("phase_offset").get<RealType>());
210 }
211 if (j.contains("random_phase_offset_stdev"))
212 {
213 pt.setRandomPhaseOffsetStdev(j.at("random_phase_offset_stdev").get<RealType>());
214 }
215
216 if (j.contains("noise_entries"))
217 {
218 for (const auto& entry : j.at("noise_entries"))
219 {
220 pt.setAlpha(entry.at("alpha").get<RealType>(), entry.at("weight").get<RealType>());
221 }
222 }
223 }
void setSyncOnPulse() noexcept
Enables synchronization on pulse.
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 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.
double RealType
Type for real numbers.
Definition config.h:27

References 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 155 of file json_serializer.cpp.

156 {
157 j = nlohmann::json{
158 {"name", pt.getName()}, {"frequency", pt.getFrequency()}, {"synconpulse", pt.getSyncOnPulse()}};
159
160 if (pt.getFreqOffset().has_value())
161 {
162 j["freq_offset"] = pt.getFreqOffset().value();
163 }
164 if (pt.getRandomFreqOffsetStdev().has_value())
165 {
166 j["random_freq_offset_stdev"] = pt.getRandomFreqOffsetStdev().value();
167 }
168 if (pt.getPhaseOffset().has_value())
169 {
170 j["phase_offset"] = pt.getPhaseOffset().value();
171 }
172 if (pt.getRandomPhaseOffsetStdev().has_value())
173 {
174 j["random_phase_offset_stdev"] = pt.getRandomPhaseOffsetStdev().value();
175 }
176
177 std::vector<RealType> alphas;
178 std::vector<RealType> weights;
179 pt.copyAlphas(alphas, weights);
180 if (!alphas.empty())
181 {
182 nlohmann::json noise_entries = nlohmann::json::array();
183 for (size_t i = 0; i < alphas.size(); ++i)
184 {
185 noise_entries.push_back({{"alpha", alphas[i]}, {"weight", weights[i]}});
186 }
187 j["noise_entries"] = noise_entries;
188 }
189 }
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.
std::optional< RealType > getFreqOffset() const noexcept
Gets the frequency offset.

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

+ Here is the call graph for this function: