FERS 1.0.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
22namespace timing
23{
24 /**
25 * @class PrototypeTiming
26 * @brief Manages timing properties such as frequency, offsets, and synchronization.
27 */
29 {
30 public:
31 /**
32 * @brief Constructor for PrototypeTiming.
33 *
34 * @param name The name of the timing source.
35 */
36 explicit PrototypeTiming(std::string name) noexcept : _name(std::move(name)) {}
37
38 ~PrototypeTiming() = default;
39
41
43
45
47
48 /**
49 * @brief Copies the alphas and weights vectors.
50 *
51 * @param alphas Reference to the vector where alpha values will be copied.
52 * @param weights Reference to the vector where weight values will be copied.
53 */
54 void copyAlphas(std::vector<RealType>& alphas, std::vector<RealType>& weights) const noexcept;
55
56 /**
57 * @brief Gets the current frequency.
58 *
59 * @return The current frequency value.
60 */
61 [[nodiscard]] RealType getFrequency() const noexcept { return _frequency; }
62
63 /**
64 * @brief Gets the name of the timing source.
65 *
66 * @return The name of the timing source.
67 */
68 [[nodiscard]] std::string getName() const { return _name; }
69
70 /**
71 * @brief Checks if synchronization on pulse is enabled.
72 *
73 * @return True if synchronization on pulse is enabled, false otherwise.
74 */
75 [[nodiscard]] bool getSyncOnPulse() const noexcept { return _sync_on_pulse; }
76
77 /**
78 * @brief Gets the phase offset.
79 *
80 * @return The phase offset value.
81 */
82 [[nodiscard]] std::optional<RealType> getPhaseOffset() const noexcept { return _phase_offset; }
83
84 /**
85 * @brief Gets the frequency offset.
86 *
87 * @return The frequency offset value.
88 */
89 [[nodiscard]] std::optional<RealType> getFreqOffset() const noexcept { return _freq_offset; }
90
91 [[nodiscard]] std::optional<RealType> getRandomFreqOffsetStdev() const noexcept { return _random_freq_stdev; }
92
93 [[nodiscard]] std::optional<RealType> getRandomPhaseOffsetStdev() const noexcept { return _random_phase_stdev; }
94
95 /**
96 * @brief Sets the frequency value.
97 *
98 * @param freq The frequency value to be set.
99 */
100 void setFrequency(const RealType freq) noexcept { _frequency = freq; }
101
102 /**
103 * @brief Enables synchronization on pulse.
104 */
105 void setSyncOnPulse() noexcept { _sync_on_pulse = true; }
106
107 /**
108 * @brief Sets an alpha and weight value.
109 *
110 * @param alpha The alpha value to be added.
111 * @param weight The weight value to be added.
112 */
113 void setAlpha(RealType alpha, RealType weight) noexcept;
114
115 /**
116 * @brief Sets the frequency offset.
117 *
118 * @param offset The frequency offset to be set.
119 */
120 void setFreqOffset(RealType offset) noexcept { _freq_offset = offset; }
121
122 /**
123 * @brief Sets the phase offset.
124 *
125 * @param offset The phase offset to be set.
126 */
127 void setPhaseOffset(RealType offset) noexcept { _phase_offset = offset; }
128
129 /**
130 * @brief Sets a random frequency offset standard deviation.
131 *
132 * @param stdev The standard deviation for generating the random frequency offset.
133 */
134 void setRandomFreqOffsetStdev(RealType stdev) noexcept { _random_freq_stdev = stdev; }
135
136 /**
137 * @brief Sets a random phase offset standard deviation.
138 *
139 * @param stdev The standard deviation for generating the random phase offset.
140 */
141 void setRandomPhaseOffsetStdev(RealType stdev) noexcept { _random_phase_stdev = stdev; }
142
143 private:
144 std::string _name; ///< The name of the timing source.
145 std::vector<RealType> _alphas; ///< Vector of alpha values.
146 std::vector<RealType> _weights; ///< Vector of weight values.
147 std::optional<RealType> _freq_offset; ///< Constant frequency offset.
148 std::optional<RealType> _phase_offset; ///< Constant phase offset.
149 std::optional<RealType> _random_phase_stdev; ///< Random phase offset standard deviation.
150 std::optional<RealType> _random_freq_stdev; ///< Random frequency offset standard deviation.
151 RealType _frequency{0}; ///< The frequency value.
152 bool _sync_on_pulse{false}; ///< Flag indicating synchronization on pulse.
153 };
154}
Manages timing properties such as frequency, offsets, and synchronization.
PrototypeTiming & operator=(PrototypeTiming &&)=default
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.
std::optional< RealType > getRandomPhaseOffsetStdev() const noexcept
bool getSyncOnPulse() const noexcept
Checks if synchronization on pulse is enabled.
PrototypeTiming & operator=(const PrototypeTiming &)=default
std::string getName() const
Gets the name of the timing source.
PrototypeTiming(std::string name) noexcept
Constructor for PrototypeTiming.
void setFreqOffset(RealType offset) noexcept
Sets the frequency offset.
std::optional< RealType > getRandomFreqOffsetStdev() const noexcept
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.
PrototypeTiming(PrototypeTiming &&)=default
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.
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27