37 return static_cast<std::uint64_t
>(
nearest);
39 return static_cast<std::uint64_t
>(std::ceil(value));
61 if (source.chirp_count.has_value() &&
first_index >= *source.chirp_count)
94 if (source.triangle_count.has_value() &&
first_index >= *source.triangle_count)
113 source.sfcw_step_count == 0)
128 if (source.sfcw_sweep_count.has_value() &&
129 first_index >=
static_cast<std::uint64_t
>(*source.sfcw_sweep_count) * source.sfcw_step_count)
163 source.carrier_freq =
signal->getCarrier();
164 source.amplitude = std::sqrt(
signal->getPower());
165 if (
const auto*
const fmcw =
signal->getFmcwChirpSignal(); fmcw !=
nullptr)
168 source.is_fmcw =
true;
170 source.chirp_duration = source.fmcw->getChirpDuration();
171 source.chirp_period = source.fmcw->getChirpPeriod();
172 source.chirp_rate = source.fmcw->getChirpRate();
173 source.signed_chirp_rate = source.fmcw->getSignedChirpRate();
174 source.start_freq_off = source.fmcw->getStartFrequencyOffset();
175 source.two_pi_f0 = 2.0 *
PI * source.start_freq_off;
176 source.s_pi_alpha =
PI * source.signed_chirp_rate;
177 source.chirp_count = source.fmcw->getChirpCount();
178 if (source.chirp_count.has_value())
181 std::min(source.segment_end,
182 segment_start +
static_cast<RealType>(*source.chirp_count) * source.chirp_period);
187 if (
const auto*
const sfcw =
signal->getSteppedFrequencySignal(); sfcw !=
nullptr)
190 source.is_sfcw =
true;
192 source.start_freq_off = sfcw->getStartFrequencyOffset();
193 source.sfcw_step_size = sfcw->getStepSize();
194 source.sfcw_step_count = sfcw->getStepCount();
195 source.sfcw_dwell_time = sfcw->getDwellTime();
196 source.sfcw_step_period = sfcw->getStepPeriod();
197 source.sfcw_sweep_period = sfcw->getSweepPeriod();
198 source.sfcw_sweep_count = sfcw->getSweepCount();
199 if (
const auto duration = sfcw->totalDuration(); duration.has_value())
201 source.segment_end = std::min(source.segment_end, segment_start + *duration);
206 if (
const auto*
const triangle =
signal->getFmcwTriangleSignal(); triangle !=
nullptr)
209 source.is_fmcw =
true;
210 source.triangle = triangle;
211 source.chirp_duration = triangle->getChirpDuration();
212 source.chirp_rate = triangle->getChirpRate();
213 source.start_freq_off = triangle->getStartFrequencyOffset();
214 source.triangle_period = triangle->getTrianglePeriod();
215 source.chirp_period = source.triangle_period;
216 source.two_pi_f0 = 2.0 *
PI * source.start_freq_off;
217 source.two_pi_f0_plus_B = 2.0 *
PI * (source.start_freq_off + triangle->getChirpBandwidth());
218 source.pi_alpha =
PI * source.chirp_rate;
219 source.neg_pi_alpha = -source.pi_alpha;
222 source.triangle_count = triangle->getTriangleCount();
228 if (source.triangle_count.has_value())
231 segment_start +
static_cast<RealType>(*source.triangle_count) * source.triangle_period;
239 if (source.triangle_count.has_value())
254 source.segment_start = segment_start;
255 source.segment_end = segment_end;
261 const auto*
const signal =
tx->getSignal();
273 std::max<RealType>(0.0, (source.segment_end - segment_start) / source.triangle_period));
275 "FMCW triangle transmitter '{}' segment [{}, {}] emits {} complete triangles and drops {} s of "
276 "leftover active time.",
287 source.segment_end = segment_end;
Class representing a radar signal with associated properties.
Represents a radar transmitter system.
double RealType
Type for real numbers.
constexpr RealType PI
Mathematical constant π (pi).
Header file for the logging system.
std::uint64_t countFmcwTriangleStarts(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Counts FMCW triangles that start inside the absolute interval.
std::uint64_t countSfcwStepStarts(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Counts SFCW active dwells that start inside the absolute interval.
ActiveStreamingSource makeActiveSource(const radar::Transmitter *const tx, const RealType segment_start, const RealType segment_end)
Builds an active-source cache from a streaming transmitter and segment bounds.
std::uint64_t countFmcwChirpStarts(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Counts FMCW chirps that start inside the absolute interval.
std::optional< RealType > firstFmcwTriangleStart(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Returns the first FMCW triangle start inside the absolute interval, if one exists.
std::optional< RealType > firstSfcwStepStart(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Returns the first SFCW step start inside the absolute interval, if one exists.
ActiveStreamingSource makeActiveSourceFromWaveform(const fers_signal::RadarSignal *const signal, const RealType segment_start, const RealType segment_end)
Builds an active-source cache directly from a waveform for receiver-local LO references.
std::optional< RealType > firstFmcwChirpStart(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Returns the first FMCW chirp start inside the absolute interval, if one exists.
@ WARNING
Warning level for potentially harmful situations.
Classes for handling radar waveforms and signals.
Defines the global state for the event-driven simulation engine.
Cached description of an active streaming transmitter segment.
RealType triangle_period
Cached full triangle period in seconds.
RealType segment_start
Segment start time in seconds.
const radar::Transmitter * transmitter
Transmitter active during this segment.
RealType chirp_period
Cached FMCW chirp period in seconds.
std::size_t sfcw_step_count
Cached SFCW steps per sweep.
std::optional< std::size_t > sfcw_sweep_count
Optional finite SFCW sweep count for the segment.
std::optional< std::size_t > chirp_count
Optional finite chirp count for the segment.
std::optional< std::size_t > triangle_count
Optional finite triangle count for the segment.
RealType segment_end
Segment end time in seconds.
RealType sfcw_step_period
Cached SFCW step period in seconds.