35 void World::add(std::unique_ptr<Platform> plat)
noexcept { _platforms.push_back(std::move(plat)); }
37 void World::add(std::unique_ptr<Transmitter> trans)
noexcept { _transmitters.push_back(std::move(trans)); }
39 void World::add(std::unique_ptr<Receiver> recv)
noexcept { _receivers.push_back(std::move(recv)); }
41 void World::add(std::unique_ptr<Target> target)
noexcept { _targets.push_back(std::move(target)); }
45 if (_waveforms.contains(waveform->getName()))
47 throw std::runtime_error(
"A waveform with the name " + waveform->getName() +
" already exists.");
49 _waveforms[waveform->getName()] = std::move(waveform);
54 if (_antennas.contains(
antenna->getName()))
56 throw std::runtime_error(
"An antenna with the name " +
antenna->getName() +
" already exists.");
63 if (_timings.contains(
timing->getName()))
65 throw std::runtime_error(
"A timing source with the name " +
timing->getName() +
" already exists.");
72 return _waveforms.contains(name) ? _waveforms[name].get() :
nullptr;
77 return _antennas.contains(name) ? _antennas[name].get() :
nullptr;
82 return _timings.contains(name) ? _timings[name].get() :
nullptr;
88 _transmitters.clear();
95 _simulation_state = {};
103 for (
const auto& transmitter : _transmitters)
108 if (
auto start_time = transmitter->getNextPulseTime(sim_start); start_time)
110 if (*start_time <= sim_end)
118 const auto& schedule = transmitter->getSchedule();
119 if (schedule.empty())
127 for (
const auto& period : schedule)
130 const RealType start = std::max(sim_start, period.start);
131 const RealType end = std::min(sim_end, period.end);
143 for (
const auto& receiver : _receivers)
148 const RealType nominal_start = receiver->getWindowStart(0);
149 if (
auto start = receiver->getNextWindowTime(nominal_start); start && *start <
params::endTime())
156 const auto& schedule = receiver->getSchedule();
157 if (schedule.empty())
165 for (
const auto& period : schedule)
182 if (_event_queue.empty())
184 return "Event Queue is empty.\n";
187 std::stringstream ss;
188 ss << std::fixed << std::setprecision(6);
190 const std::string separator =
"--------------------------------------------------------------------";
191 const std::string title =
"| Event Queue Contents (" + std::to_string(_event_queue.size()) +
" events)";
193 ss << separator <<
"\n"
194 << std::left << std::setw(separator.length() - 1) << title <<
"|\n"
196 <<
"| " << std::left << std::setw(12) <<
"Timestamp" <<
" | " << std::setw(21) <<
"Event Type" <<
" | "
197 << std::setw(25) <<
"Source Object" <<
" |\n"
198 << separator <<
"\n";
200 auto queue_copy = _event_queue;
202 while (!queue_copy.empty())
204 const auto [timestamp, event_type, source_object] = queue_copy.top();
207 ss <<
"| " << std::right << std::setw(12) << timestamp <<
" | " << std::left << std::setw(21)
208 <<
toString(event_type) <<
" | " << std::left << std::setw(25) << source_object->getName() <<
" |\n";
210 ss << separator <<
"\n";
Header file defining various types of antennas and their gain patterns.
Abstract base class representing an antenna.
void scheduleInitialEvents()
Populates the event queue with the initial events for the simulation.
timing::PrototypeTiming * findTiming(const std::string &name)
Finds a timing source by name.
void add(std::unique_ptr< radar::Platform > plat) noexcept
Adds a radar platform to the simulation world.
antenna::Antenna * findAntenna(const std::string &name)
Finds an antenna by name.
fers_signal::RadarSignal * findWaveform(const std::string &name)
Finds a radar signal by name.
void clear() noexcept
Clears all objects and assets from the simulation world.
std::string dumpEventQueue() const
Dumps the current state of the event queue to a string for debugging.
Class representing a radar signal with associated properties.
Manages radar signal reception and response processing.
Base class for radar targets.
Represents a radar transmitter system.
Manages timing properties such as frequency, offsets, and synchronization.
double RealType
Type for real numbers.
std::string toString(const EventType type)
Converts an EventType enum to its string representation.
@ RX_PULSED_WINDOW_START
A pulsed receiver opens its listening window.
@ TX_CW_START
A continuous-wave transmitter starts transmitting.
@ TX_CW_END
A continuous-wave transmitter stops transmitting.
@ TX_PULSED_START
A pulsed transmitter begins emitting a pulse.
@ RX_CW_END
A continuous-wave receiver stops listening.
@ RX_CW_START
A continuous-wave receiver starts listening.
RealType endTime() noexcept
Get the end time for the simulation.
RealType startTime() noexcept
Get the start time for the simulation.
@ PULSED_MODE
The component operates in a pulsed mode.
Defines the Parameters struct and provides methods for managing simulation parameters.
Header file for the PrototypeTiming class.
Defines the Radar class and associated functionality.
Classes for handling radar waveforms and signals.
Defines the core structures for the event-driven simulation engine.
Header file for the World class in the simulator.