FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
core::World Class Reference

The World class manages the simulator environment. More...

#include "world.h"

Public Member Functions

 World ()=default
 
 ~World () noexcept=default
 
 World (const World &)=delete
 
Worldoperator= (const World &)=delete
 
 World (World &&)=delete
 
Worldoperator= (World &&)=delete
 
void add (std::unique_ptr< radar::Platform > plat) noexcept
 Adds a radar platform to the simulation world.
 
void add (std::unique_ptr< radar::Transmitter > trans) noexcept
 Adds a radar transmitter to the simulation world.
 
void add (std::unique_ptr< radar::Receiver > recv) noexcept
 Adds a radar receiver to the simulation world.
 
void add (std::unique_ptr< radar::Target > target) noexcept
 Adds a radar target to the simulation world.
 
void add (std::unique_ptr< fers_signal::RadarSignal > waveform)
 Adds a radar signal (waveform) to the simulation world.
 
void add (std::unique_ptr< antenna::Antenna > antenna)
 Adds an antenna to the simulation world.
 
void add (std::unique_ptr< timing::PrototypeTiming > timing)
 Adds a timing source to the simulation world.
 
fers_signal::RadarSignalfindWaveform (const SimId id)
 Finds a radar signal by ID.
 
antenna::AntennafindAntenna (const SimId id)
 Finds an antenna by ID.
 
timing::PrototypeTimingfindTiming (const SimId id)
 Finds a timing source by ID.
 
radar::PlatformfindPlatform (const SimId id)
 Finds a platform by ID.
 
radar::TransmitterfindTransmitter (const SimId id)
 Finds a transmitter by ID.
 
radar::ReceiverfindReceiver (const SimId id)
 Finds a receiver by ID.
 
radar::TargetfindTarget (const SimId id)
 Finds a target by ID.
 
void replace (std::unique_ptr< radar::Target > target)
 Replaces an existing target, updating internal pointers.
 
void replace (std::unique_ptr< antenna::Antenna > antenna)
 Replaces an existing antenna, updating internal pointers.
 
void replace (std::unique_ptr< fers_signal::RadarSignal > waveform)
 Replaces an existing waveform, updating internal pointers.
 
void replace (std::unique_ptr< timing::PrototypeTiming > timing)
 Replaces an existing timing prototype and refreshes dependent radar timing models.
 
const std::vector< std::unique_ptr< radar::Platform > > & getPlatforms () const noexcept
 Retrieves the list of platforms.
 
const std::vector< std::unique_ptr< radar::Target > > & getTargets () const noexcept
 Retrieves the list of radar targets.
 
const std::vector< std::unique_ptr< radar::Receiver > > & getReceivers () const noexcept
 Retrieves the list of radar receivers.
 
const std::vector< std::unique_ptr< radar::Transmitter > > & getTransmitters () const noexcept
 Retrieves the list of radar transmitters.
 
const std::unordered_map< SimId, std::unique_ptr< fers_signal::RadarSignal > > & getWaveforms () const noexcept
 Retrieves the map of radar signals (waveforms).
 
const std::unordered_map< SimId, std::unique_ptr< antenna::Antenna > > & getAntennas () const noexcept
 Retrieves the map of antennas.
 
const std::unordered_map< SimId, std::unique_ptr< timing::PrototypeTiming > > & getTimings () const noexcept
 Retrieves the map of timing prototypes.
 
void clear () noexcept
 Clears all objects and assets from the simulation world.
 
void scheduleInitialEvents ()
 Populates the event queue with the initial events for the simulation.
 
std::string dumpEventQueue () const
 Dumps the current state of the event queue to a string for debugging.
 
std::priority_queue< Event, std::vector< Event >, EventComparator > & getEventQueue () noexcept
 Gets a mutable reference to the global event queue.
 
SimulationStategetSimulationState () noexcept
 Gets a mutable reference to the global simulation state.
 

Detailed Description

The World class manages the simulator environment.

Definition at line 38 of file world.h.

Constructor & Destructor Documentation

◆ World() [1/3]

core::World::World ( )
default

◆ ~World()

core::World::~World ( )
defaultnoexcept

◆ World() [2/3]

core::World::World ( const World )
delete

◆ World() [3/3]

core::World::World ( World &&  )
delete

Member Function Documentation

◆ add() [1/7]

void core::World::add ( std::unique_ptr< antenna::Antenna antenna)

Adds an antenna to the simulation world.

Parameters
antennaA unique pointer to an Antenna object.
Exceptions
std::runtime_errorif an antenna with the same ID already exists.

Definition at line 56 of file world.cpp.

57 {
58 const SimId id = antenna->getId();
59 if (_antennas.contains(id))
60 {
61 throw std::runtime_error("An antenna with the ID " + std::to_string(id) + " already exists.");
62 }
63 _antennas[id] = std::move(antenna);
64 }
uint64_t SimId
64-bit Unique Simulation ID.
Definition sim_id.h:18

◆ add() [2/7]

void core::World::add ( std::unique_ptr< fers_signal::RadarSignal waveform)

Adds a radar signal (waveform) to the simulation world.

Parameters
waveformA unique pointer to a RadarSignal object.
Exceptions
std::runtime_errorif a waveform with the same ID already exists.

Definition at line 46 of file world.cpp.

47 {
48 const SimId id = waveform->getId();
49 if (_waveforms.contains(id))
50 {
51 throw std::runtime_error("A waveform with the ID " + std::to_string(id) + " already exists.");
52 }
53 _waveforms[id] = std::move(waveform);
54 }

◆ add() [3/7]

void core::World::add ( std::unique_ptr< radar::Platform plat)
noexcept

Adds a radar platform to the simulation world.

Parameters
platA unique pointer to a Platform object.

Definition at line 38 of file world.cpp.

38{ _platforms.push_back(std::move(plat)); }

Referenced by serial::xml_parser_utils::parseAntenna(), serial::xml_parser_utils::parsePlatform(), serial::xml_parser_utils::parseReceiver(), serial::xml_parser_utils::parseTarget(), serial::xml_parser_utils::parseTiming(), serial::xml_parser_utils::parseTransmitter(), and serial::xml_parser_utils::parseWaveform().

+ Here is the caller graph for this function:

◆ add() [4/7]

void core::World::add ( std::unique_ptr< radar::Receiver recv)
noexcept

Adds a radar receiver to the simulation world.

Parameters
recvA unique pointer to a Receiver object.

Definition at line 42 of file world.cpp.

42{ _receivers.push_back(std::move(recv)); }

◆ add() [5/7]

void core::World::add ( std::unique_ptr< radar::Target target)
noexcept

Adds a radar target to the simulation world.

Parameters
targetA unique pointer to a Target object.

Definition at line 44 of file world.cpp.

44{ _targets.push_back(std::move(target)); }

◆ add() [6/7]

void core::World::add ( std::unique_ptr< radar::Transmitter trans)
noexcept

Adds a radar transmitter to the simulation world.

Parameters
transA unique pointer to a Transmitter object.

Definition at line 40 of file world.cpp.

40{ _transmitters.push_back(std::move(trans)); }

◆ add() [7/7]

void core::World::add ( std::unique_ptr< timing::PrototypeTiming timing)

Adds a timing source to the simulation world.

Parameters
timingA unique pointer to a PrototypeTiming object.
Exceptions
std::runtime_errorif a timing source with the same ID already exists.

Definition at line 66 of file world.cpp.

67 {
68 const SimId id = timing->getId();
69 if (_timings.contains(id))
70 {
71 throw std::runtime_error("A timing source with the ID " + std::to_string(id) + " already exists.");
72 }
73 _timings[id] = std::move(timing);
74 }

◆ clear()

void core::World::clear ( )
noexcept

Clears all objects and assets from the simulation world.

Definition at line 243 of file world.cpp.

244 {
245 _platforms.clear();
246 _transmitters.clear();
247 _receivers.clear();
248 _targets.clear();
249 _waveforms.clear();
250 _antennas.clear();
251 _timings.clear();
252 _event_queue = {};
253 _simulation_state = {};
254 }

Referenced by serial::json_to_world(), serial::parseSimulation(), and serial::parseSimulationFromString().

+ Here is the caller graph for this function:

◆ dumpEventQueue()

std::string core::World::dumpEventQueue ( ) const

Dumps the current state of the event queue to a string for debugging.

Returns
A formatted string representing the contents of the event queue.

Definition at line 338 of file world.cpp.

339 {
340 if (_event_queue.empty())
341 {
342 return "Event Queue is empty.\n";
343 }
344
345 std::stringstream ss;
346 ss << std::fixed << std::setprecision(6);
347
348 const std::string separator = "--------------------------------------------------------------------";
349 const std::string title = "| Event Queue Contents (" + std::to_string(_event_queue.size()) + " events)";
350 if (separator.size() > static_cast<std::size_t>(std::numeric_limits<int>::max()))
351 {
352 throw std::runtime_error("Separator width exceeds stream formatting limits.");
353 }
354 const int title_width = static_cast<int>(separator.size()) - 1;
355
356 ss << separator << "\n"
357 << std::left << std::setw(title_width) << title << "|\n"
358 << separator << "\n"
359 << "| " << std::left << std::setw(12) << "Timestamp" << " | " << std::setw(21) << "Event Type" << " | "
360 << std::setw(25) << "Source Object" << " |\n"
361 << separator << "\n";
362
363 auto queue_copy = _event_queue;
364
365 while (!queue_copy.empty())
366 {
367 const auto [timestamp, event_type, source_object] = queue_copy.top();
368 queue_copy.pop();
369
370 ss << "| " << std::right << std::setw(12) << timestamp << " | " << std::left << std::setw(21)
371 << toString(event_type) << " | " << std::left << std::setw(25) << source_object->getName() << " |\n";
372 }
373 ss << separator << "\n";
374
375 return ss.str();
376 }
std::string toString(const EventType type)
Converts an EventType enum to its string representation.
Definition sim_events.h:72

References core::toString().

Referenced by serial::xml_parser_utils::processParsedDocument().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findAntenna()

Antenna * core::World::findAntenna ( const SimId  id)

Finds an antenna by ID.

Parameters
idThe ID of the antenna to find.
Returns
A pointer to the Antenna if found, or nullptr if not found.

Definition at line 82 of file world.cpp.

83 {
84 const auto it = _antennas.find(id);
85 return it != _antennas.end() ? it->second.get() : nullptr;
86 }

Referenced by serial::xml_parser_utils::parseReceiver(), serial::xml_parser_utils::parseTransmitter(), serial::update_monostatic_from_json(), serial::update_receiver_from_json(), and serial::update_transmitter_from_json().

+ Here is the caller graph for this function:

◆ findPlatform()

Platform * core::World::findPlatform ( const SimId  id)

Finds a platform by ID.

Parameters
idThe ID of the platform to find.
Returns
A pointer to the Platform if found, or nullptr if not found.

Definition at line 94 of file world.cpp.

95 {
96 for (auto& p : _platforms)
97 {
98 if (p->getId() == id)
99 return p.get();
100 }
101 return nullptr;
102 }

Referenced by fers_update_platform_from_json().

+ Here is the caller graph for this function:

◆ findReceiver()

Receiver * core::World::findReceiver ( const SimId  id)

Finds a receiver by ID.

Parameters
idThe ID of the receiver to find.
Returns
A pointer to the Receiver if found, or nullptr if not found.

Definition at line 112 of file world.cpp.

113 {
114 for (auto& rx : _receivers)
115 if (rx->getId() == id)
116 return rx.get();
117 return nullptr;
118 }

Referenced by fers_update_receiver_from_json().

+ Here is the caller graph for this function:

◆ findTarget()

Target * core::World::findTarget ( const SimId  id)

Finds a target by ID.

Parameters
idThe ID of the target to find.
Returns
A pointer to the Target if found, or nullptr if not found.

Definition at line 120 of file world.cpp.

121 {
122 for (auto& tgt : _targets)
123 if (tgt->getId() == id)
124 return tgt.get();
125 return nullptr;
126 }

Referenced by fers_update_target_from_json().

+ Here is the caller graph for this function:

◆ findTiming()

PrototypeTiming * core::World::findTiming ( const SimId  id)

Finds a timing source by ID.

Parameters
idThe ID of the timing source to find.
Returns
A pointer to the PrototypeTiming if found, or nullptr if not found.

Definition at line 88 of file world.cpp.

89 {
90 const auto it = _timings.find(id);
91 return it != _timings.end() ? it->second.get() : nullptr;
92 }

Referenced by serial::xml_parser_utils::parseReceiver(), serial::xml_parser_utils::parseTransmitter(), serial::update_monostatic_from_json(), serial::update_receiver_from_json(), serial::update_timing_from_json(), and serial::update_transmitter_from_json().

+ Here is the caller graph for this function:

◆ findTransmitter()

Transmitter * core::World::findTransmitter ( const SimId  id)

Finds a transmitter by ID.

Parameters
idThe ID of the transmitter to find.
Returns
A pointer to the Transmitter if found, or nullptr if not found.

Definition at line 104 of file world.cpp.

105 {
106 for (auto& tx : _transmitters)
107 if (tx->getId() == id)
108 return tx.get();
109 return nullptr;
110 }

Referenced by fers_update_transmitter_from_json().

+ Here is the caller graph for this function:

◆ findWaveform()

RadarSignal * core::World::findWaveform ( const SimId  id)

Finds a radar signal by ID.

Parameters
idThe ID of the radar signal to find.
Returns
A pointer to the RadarSignal if found, or nullptr if not found.

Definition at line 76 of file world.cpp.

77 {
78 const auto it = _waveforms.find(id);
79 return it != _waveforms.end() ? it->second.get() : nullptr;
80 }

Referenced by serial::xml_parser_utils::parseTransmitter(), and serial::update_transmitter_from_json().

+ Here is the caller graph for this function:

◆ getAntennas()

const std::unordered_map< SimId, std::unique_ptr< antenna::Antenna > > & core::World::getAntennas ( ) const
noexcept

Retrieves the map of antennas.

Returns
A const reference to the map of antenna names to Antenna objects.

Definition at line 239 of file world.h.

240 {
241 return _antennas;
242 }

Referenced by serial::xml_parser_utils::processParsedDocument(), serial::world_to_json(), and serial::world_to_xml_string().

+ Here is the caller graph for this function:

◆ getEventQueue()

std::priority_queue< Event, std::vector< Event >, EventComparator > & core::World::getEventQueue ( )
noexcept

Gets a mutable reference to the global event queue.

Returns
A reference to the priority queue of events.

Definition at line 275 of file world.h.

276 {
277 return _event_queue;
278 }

Referenced by core::SimulationEngine::handleRxPulsedWindowEnd(), core::SimulationEngine::handleRxPulsedWindowStart(), core::SimulationEngine::handleTxPulsedStart(), and core::SimulationEngine::run().

+ Here is the caller graph for this function:

◆ getPlatforms()

const std::vector< std::unique_ptr< radar::Platform > > & core::World::getPlatforms ( ) const
noexcept

Retrieves the list of platforms.

Returns
A const reference to a vector of unique pointers to Platform objects.

Definition at line 190 of file world.h.

191 {
192 return _platforms;
193 }

Referenced by serial::world_to_json(), and serial::world_to_xml_string().

+ Here is the caller graph for this function:

◆ getReceivers()

const std::vector< std::unique_ptr< radar::Receiver > > & core::World::getReceivers ( ) const
noexcept

Retrieves the list of radar receivers.

Returns
A const reference to a vector of unique pointers to Receiver objects.

Definition at line 210 of file world.h.

211 {
212 return _receivers;
213 }

Referenced by simulation::calculatePreviewLinks(), serial::kml_generator_utils::generateKmlToStream(), core::SimulationEngine::handleTxPulsedStart(), serial::json_to_world(), serial::xml_parser_utils::parseReceiver(), core::SimulationEngine::processCwPhysics(), serial::xml_parser_utils::processParsedDocument(), and serial::xml_serializer_utils::serializePlatform().

+ Here is the caller graph for this function:

◆ getSimulationState()

SimulationState & core::World::getSimulationState ( )
noexcept

Gets a mutable reference to the global simulation state.

Returns
A reference to the SimulationState object.

Definition at line 284 of file world.h.

284{ return _simulation_state; }

Referenced by core::SimulationEngine::handleRxPulsedWindowEnd(), core::SimulationEngine::handleTxCwEnd(), core::SimulationEngine::handleTxCwStart(), core::SimulationEngine::processCwPhysics(), and core::SimulationEngine::run().

+ Here is the caller graph for this function:

◆ getTargets()

const std::vector< std::unique_ptr< radar::Target > > & core::World::getTargets ( ) const
noexcept

Retrieves the list of radar targets.

Returns
A const reference to a vector of unique pointers to Target objects.

Definition at line 200 of file world.h.

201 {
202 return _targets;
203 }

Referenced by core::SimulationEngine::calculateCwSample(), simulation::calculatePreviewLinks(), serial::kml_generator_utils::generateKmlToStream(), core::SimulationEngine::handleTxPulsedStart(), and serial::xml_serializer_utils::serializePlatform().

+ Here is the caller graph for this function:

◆ getTimings()

const std::unordered_map< SimId, std::unique_ptr< timing::PrototypeTiming > > & core::World::getTimings ( ) const
noexcept

Retrieves the map of timing prototypes.

Returns
A const reference to the map of timing names to PrototypeTiming objects.

Definition at line 249 of file world.h.

250 {
251 return _timings;
252 }

Referenced by serial::xml_parser_utils::processParsedDocument(), serial::world_to_json(), and serial::world_to_xml_string().

+ Here is the caller graph for this function:

◆ getTransmitters()

const std::vector< std::unique_ptr< radar::Transmitter > > & core::World::getTransmitters ( ) const
noexcept

Retrieves the list of radar transmitters.

Returns
A const reference to a vector of unique pointers to Transmitter objects.

Definition at line 220 of file world.h.

221 {
222 return _transmitters;
223 }

Referenced by simulation::calculatePreviewLinks(), serial::kml_generator_utils::generateKmlToStream(), serial::xml_parser_utils::parseTransmitter(), and serial::xml_serializer_utils::serializePlatform().

+ Here is the caller graph for this function:

◆ getWaveforms()

const std::unordered_map< SimId, std::unique_ptr< fers_signal::RadarSignal > > & core::World::getWaveforms ( ) const
noexcept

Retrieves the map of radar signals (waveforms).

Returns
A const reference to the map of signal names to RadarSignal objects.

Definition at line 230 of file world.h.

231 {
232 return _waveforms;
233 }

Referenced by serial::xml_parser_utils::processParsedDocument(), serial::world_to_json(), and serial::world_to_xml_string().

+ Here is the caller graph for this function:

◆ operator=() [1/2]

World & core::World::operator= ( const World )
delete

◆ operator=() [2/2]

World & core::World::operator= ( World &&  )
delete

◆ replace() [1/4]

void core::World::replace ( std::unique_ptr< antenna::Antenna antenna)

Replaces an existing antenna, updating internal pointers.

Parameters
antennaUnique pointer to the new antenna.

Definition at line 142 of file world.cpp.

143 {
144 const SimId id = antenna->getId();
145 const Antenna* new_ptr = antenna.get();
146
147 std::unique_ptr<Antenna> old_owned;
148 const Antenna* old_ptr = nullptr;
149
150 if (auto it = _antennas.find(id); it != _antennas.end())
151 {
152 old_owned = std::move(it->second);
153 old_ptr = old_owned.get();
154 it->second = std::move(antenna);
155 }
156 else
157 {
158 _antennas[id] = std::move(antenna);
159 }
160
161 if ((old_ptr != nullptr) && old_ptr != new_ptr)
162 {
163 for (auto& tx : _transmitters)
164 if (tx->getAntenna() == old_ptr)
165 tx->setAntenna(new_ptr);
166
167 for (auto& rx : _receivers)
168 if (rx->getAntenna() == old_ptr)
169 rx->setAntenna(new_ptr);
170 }
171 }
Abstract base class representing an antenna.

◆ replace() [2/4]

void core::World::replace ( std::unique_ptr< fers_signal::RadarSignal waveform)

Replaces an existing waveform, updating internal pointers.

Parameters
waveformUnique pointer to the new waveform.

Definition at line 173 of file world.cpp.

174 {
175 const SimId id = waveform->getId();
176 RadarSignal* new_ptr = waveform.get();
177
178 std::unique_ptr<RadarSignal> old_owned;
179 const RadarSignal* old_ptr = nullptr;
180
181 if (auto it = _waveforms.find(id); it != _waveforms.end())
182 {
183 old_owned = std::move(it->second);
184 old_ptr = old_owned.get();
185 it->second = std::move(waveform);
186 }
187 else
188 {
189 _waveforms[id] = std::move(waveform);
190 }
191
192 if ((old_ptr != nullptr) && old_ptr != new_ptr)
193 {
194 for (auto& tx : _transmitters)
195 if (tx->getSignal() == old_ptr)
196 tx->setSignal(new_ptr);
197 }
198 }
Class representing a radar signal with associated properties.

◆ replace() [3/4]

void core::World::replace ( std::unique_ptr< radar::Target target)

Replaces an existing target, updating internal pointers.

Parameters
targetUnique pointer to the new target.

Definition at line 128 of file world.cpp.

129 {
130 const SimId id = target->getId();
131 for (auto& t : _targets)
132 {
133 if (t->getId() == id)
134 {
135 t = std::move(target);
136 return;
137 }
138 }
139 _targets.push_back(std::move(target));
140 }

References radar::Target::getId().

Referenced by serial::update_antenna_from_json(), serial::update_target_from_json(), and serial::update_timing_from_json().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replace() [4/4]

void core::World::replace ( std::unique_ptr< timing::PrototypeTiming timing)

Replaces an existing timing prototype and refreshes dependent radar timing models.

Parameters
timingUnique pointer to the new timing prototype.

Definition at line 200 of file world.cpp.

201 {
202 const SimId id = timing->getId();
203 const PrototypeTiming* new_ptr = timing.get();
204
205 std::unique_ptr<PrototypeTiming> old_owned;
206 const PrototypeTiming* old_ptr = nullptr;
207
208 if (auto it = _timings.find(id); it != _timings.end())
209 {
210 old_owned = std::move(it->second);
211 old_ptr = old_owned.get();
212 it->second = std::move(timing);
213 }
214 else
215 {
216 _timings[id] = std::move(timing);
217 }
218
219 auto refresh_timing = [id, new_ptr](auto& radar_obj)
220 {
221 const auto current_timing = radar_obj->getTiming();
222 if (!current_timing || (current_timing->getId() != id))
223 {
224 return;
225 }
226
227 auto refreshed =
228 std::make_shared<timing::Timing>(new_ptr->getName(), current_timing->getSeed(), new_ptr->getId());
229 refreshed->initializeModel(new_ptr);
230 radar_obj->setTiming(refreshed);
231 };
232
233 if ((old_ptr != nullptr) && old_ptr != new_ptr)
234 {
235 for (auto& tx : _transmitters)
236 refresh_timing(tx);
237
238 for (auto& rx : _receivers)
239 refresh_timing(rx);
240 }
241 }
Manages timing properties such as frequency, offsets, and synchronization.
std::string getName() const
Gets the name of the timing source.
SimId getId() const noexcept
Gets the unique ID of the timing source.

References timing::PrototypeTiming::getId(), and timing::PrototypeTiming::getName().

+ Here is the call graph for this function:

◆ scheduleInitialEvents()

void core::World::scheduleInitialEvents ( )

Populates the event queue with the initial events for the simulation.

This method should be called after all simulation objects have been parsed and added to the world.

Definition at line 256 of file world.cpp.

257 {
258 const RealType sim_start = params::startTime();
259 const RealType sim_end = params::endTime();
260
261 for (const auto& transmitter : _transmitters)
262 {
263 if (transmitter->getMode() == radar::OperationMode::PULSED_MODE)
264 {
265 // Find the first valid pulse time starting from the simulation start time.
266 if (auto start_time = transmitter->getNextPulseTime(sim_start); start_time)
267 {
268 if (*start_time <= sim_end)
269 {
270 _event_queue.push({*start_time, EventType::TX_PULSED_START, transmitter.get()});
271 }
272 }
273 }
274 else // CW_MODE
275 {
276 const auto& schedule = transmitter->getSchedule();
277 if (schedule.empty())
278 {
279 // Legacy behavior: Always on for simulation duration
280 _event_queue.push({sim_start, EventType::TX_CW_START, transmitter.get()});
281 _event_queue.push({sim_end, EventType::TX_CW_END, transmitter.get()});
282 }
283 else
284 {
285 for (const auto& period : schedule)
286 {
287 // Clip periods to simulation bounds
288 const RealType start = std::max(sim_start, period.start);
289 const RealType end = std::min(sim_end, period.end);
290
291 if (start < end)
292 {
293 _event_queue.push({start, EventType::TX_CW_START, transmitter.get()});
294 _event_queue.push({end, EventType::TX_CW_END, transmitter.get()});
295 }
296 }
297 }
298 }
299 }
300
301 for (const auto& receiver : _receivers)
302 {
303 if (receiver->getMode() == radar::OperationMode::PULSED_MODE)
304 {
305 // Schedule the first receive window checking against schedule
306 const RealType nominal_start = receiver->getWindowStart(0);
307 if (auto start = receiver->getNextWindowTime(nominal_start); start && *start < params::endTime())
308 {
309 _event_queue.push({*start, EventType::RX_PULSED_WINDOW_START, receiver.get()});
310 }
311 }
312 else // CW_MODE
313 {
314 const auto& schedule = receiver->getSchedule();
315 if (schedule.empty())
316 {
317 // Legacy behavior: Always on for simulation duration
318 _event_queue.push({params::startTime(), EventType::RX_CW_START, receiver.get()});
319 _event_queue.push({params::endTime(), EventType::RX_CW_END, receiver.get()});
320 }
321 else
322 {
323 for (const auto& period : schedule)
324 {
325 const RealType start = std::max(params::startTime(), period.start);
326 const RealType end = std::min(params::endTime(), period.end);
327 if (start < end)
328 {
329 _event_queue.push({start, EventType::RX_CW_START, receiver.get()});
330 _event_queue.push({end, EventType::RX_CW_END, receiver.get()});
331 }
332 }
333 }
334 }
335 }
336 }
double RealType
Type for real numbers.
Definition config.h:27
@ 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.
Definition parameters.h:109
RealType startTime() noexcept
Get the start time for the simulation.
Definition parameters.h:103
@ PULSED_MODE
The component operates in a pulsed mode.

References params::endTime(), radar::PULSED_MODE, core::RX_CW_END, core::RX_CW_START, core::RX_PULSED_WINDOW_START, params::startTime(), core::TX_CW_END, core::TX_CW_START, and core::TX_PULSED_START.

Referenced by serial::json_to_world(), and serial::xml_parser_utils::processParsedDocument().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: