FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
sim_events.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2025-present FERS Contributors (see AUTHORS.md).
4//
5// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
6
7/**
8 * @file sim_events.h
9 * @brief Defines the core structures for the event-driven simulation engine.
10 */
11
12#pragma once
13
14#include "config.h"
15
16namespace radar
17{
18 class Radar;
19}
20
21namespace core
22{
23 /**
24 * @enum EventType
25 * @brief Enumerates the types of events that can occur in the simulation.
26 */
27 enum class EventType
28 {
29 TX_PULSED_START, ///< A pulsed transmitter begins emitting a pulse.
30 RX_PULSED_WINDOW_START, ///< A pulsed receiver opens its listening window.
31 RX_PULSED_WINDOW_END, ///< A pulsed receiver closes its listening window.
32 TX_CW_START, ///< A continuous-wave transmitter starts transmitting.
33 TX_CW_END, ///< A continuous-wave transmitter stops transmitting.
34 RX_CW_START, ///< A continuous-wave receiver starts listening.
35 RX_CW_END, ///< A continuous-wave receiver stops listening.
36 };
37
38 /**
39 * @struct Event
40 * @brief Represents a single event in the simulation's time-ordered queue.
41 */
42 struct Event
43 {
44 RealType timestamp; ///< The simulation time at which the event occurs.
45 EventType type; ///< The type of the event.
46 radar::Radar* source_object; ///< Pointer to the object that generated the event.
47 };
48
49 /**
50 * @struct EventComparator
51 * @brief A custom comparator for the event priority queue.
52 *
53 * This comparator creates a min-heap, ensuring that the event with the
54 * smallest timestamp is always at the top of the queue.
55 */
57 {
58 /**
59 * @brief Compares two events based on their timestamps.
60 * @param a The first event.
61 * @param b The second event.
62 * @return True if event 'a' should occur after event 'b'.
63 */
64 bool operator()(const Event& a, const Event& b) const noexcept { return a.timestamp > b.timestamp; }
65 };
66
67 /**
68 * @brief Converts an EventType enum to its string representation.
69 * @param type The event type.
70 * @return A string representing the event type.
71 */
72 inline std::string toString(const EventType type)
73 {
74 switch (type)
75 {
77 return "TxPulsedStart";
79 return "RxPulsedWindowStart";
81 return "RxPulsedWindowEnd";
83 return "TxCwStart";
85 return "TxCwEnd";
87 return "RxCwStart";
89 return "RxCwEnd";
90 default:
91 return "UnknownEvent";
92 }
93 }
94}
Represents a radar system on a platform.
Definition radar_obj.h:46
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
std::string toString(const EventType type)
Converts an EventType enum to its string representation.
Definition sim_events.h:72
EventType
Enumerates the types of events that can occur in the simulation.
Definition sim_events.h:28
@ RX_PULSED_WINDOW_START
A pulsed receiver opens its listening window.
@ RX_PULSED_WINDOW_END
A pulsed receiver closes 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.
A custom comparator for the event priority queue.
Definition sim_events.h:57
bool operator()(const Event &a, const Event &b) const noexcept
Compares two events based on their timestamps.
Definition sim_events.h:64
Represents a single event in the simulation's time-ordered queue.
Definition sim_events.h:43
RealType timestamp
The simulation time at which the event occurs.
Definition sim_events.h:44
EventType type
The type of the event.
Definition sim_events.h:45
radar::Radar * source_object
Pointer to the object that generated the event.
Definition sim_events.h:46