FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
transmitter.cpp
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 transmitter.cpp
10 * @brief Contains the implementation of the Transmitter class.
11 */
12
13#include "transmitter.h"
14
15#include "core/parameters.h"
16
17namespace radar
18{
19 void Transmitter::setPrf(const RealType mprf) noexcept
20 {
22 _prf = 1 / (std::floor(rate / mprf) / rate);
23 }
24
25 void Transmitter::setSchedule(std::vector<SchedulePeriod> schedule)
26 {
27 // The schedule is assumed to be sorted and merged by the parser.
28 _schedule = std::move(schedule);
29 }
30
31 std::optional<RealType> Transmitter::getNextPulseTime(RealType time) const
32 {
33 // If no schedule is defined, assume always on.
34 if (_schedule.empty())
35 {
36 return time;
37 }
38
39 for (const auto& period : _schedule)
40 {
41 // If time is within this period, it's valid.
42 if (time >= period.start && time <= period.end)
43 {
44 return time;
45 }
46 // If time is before this period, skip to the start of this period.
47 if (time < period.start)
48 {
49 return period.start;
50 }
51 // If time is after this period, continue to next period.
52 }
53
54 // Time is after the last scheduled period.
55 return std::nullopt;
56 }
57}
std::optional< RealType > getNextPulseTime(RealType time) const
Determines the valid simulation time for a pulse at or after the given time.
void setSchedule(std::vector< SchedulePeriod > schedule)
Sets the active schedule for the transmitter.
void setPrf(RealType mprf) noexcept
Sets the pulse repetition frequency (PRF) of the transmitter.
double RealType
Type for real numbers.
Definition config.h:27
RealType rate() noexcept
Get the rendering sample rate.
Definition parameters.h:109
unsigned oversampleRatio() noexcept
Get the oversampling ratio.
Definition parameters.h:139
Defines the Parameters struct and provides methods for managing simulation parameters.
Header file for the Transmitter class in the radar namespace.