FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
core Namespace Reference

Classes

class  Config
 Configuration structure for the application. More...
 
struct  CwSegmentMetadata
 
struct  Event
 Represents a single event in the simulation's time-ordered queue. More...
 
struct  EventComparator
 A custom comparator for the event priority queue. More...
 
struct  OutputFileMetadata
 
struct  OutputMetadata
 
class  OutputMetadataCollector
 
class  ProgressReporter
 A thread-safe wrapper for the simulation progress callback. More...
 
struct  PulseChunkMetadata
 
struct  RenderingJob
 A data packet containing all information needed to process one receive window. More...
 
class  SimulationEngine
 Encapsulates the state and logic of the event-driven simulation loop. More...
 
struct  SimulationState
 Holds the dynamic global state of the simulation. More...
 
class  World
 The World class manages the simulator environment. More...
 

Enumerations

enum class  EventType {
  TX_PULSED_START , RX_PULSED_WINDOW_START , RX_PULSED_WINDOW_END , TX_CW_START ,
  TX_CW_END , RX_CW_START , RX_CW_END
}
 Enumerates the types of events that can occur in the simulation. More...
 

Functions

std::string outputFileMetadataToJsonString (const OutputFileMetadata &metadata)
 
std::string outputMetadataToJsonString (const OutputMetadata &metadata)
 
RealType besselJ1 (const RealType x) noexcept
 Computes the Bessel function of the first kind (order 1) for a given value.
 
unsigned countProcessors () noexcept
 Detects the number of CPUs on the machine.
 
std::string toString (const EventType type)
 Converts an EventType enum to its string representation.
 
OutputMetadata runEventDrivenSim (World *world, pool::ThreadPool &pool, const std::function< void(const std::string &, int, int)> &progress_callback, const std::string &output_dir)
 Runs the unified, event-driven radar simulation.
 
void showHelp (const char *programName) noexcept
 Displays the help message.
 
void showVersion () noexcept
 Displays the version information.
 
std::expected< Config, std::string > parseArguments (int argc, char *argv[]) noexcept
 Parses command-line arguments.
 
std::filesystem::path resolveOutputDir (const std::string &script_file, const std::optional< std::string > &output_dir) noexcept
 
std::filesystem::path resolveKmlOutputPath (const std::string &script_file, const std::filesystem::path &final_output_dir, const std::optional< std::string > &kml_file) noexcept
 

Enumeration Type Documentation

◆ EventType

enum class core::EventType
strong

Enumerates the types of events that can occur in the simulation.

Enumerator
TX_PULSED_START 

A pulsed transmitter begins emitting a pulse.

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.

RX_CW_START 

A continuous-wave receiver starts listening.

RX_CW_END 

A continuous-wave receiver stops listening.

Definition at line 27 of file sim_events.h.

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 };
@ 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.

Function Documentation

◆ besselJ1()

RealType core::besselJ1 ( const RealType  x)
noexcept

Computes the Bessel function of the first kind (order 1) for a given value.

Parameters
xThe value for which the Bessel function is to be computed.
Returns
The computed value of the Bessel function of the first kind (order 1).

Definition at line 28 of file portable_utils.h.

29 {
30#ifdef _MSC_VER
31 return _j1(x);
32#else
33 return j1(x);
34#endif
35 }

◆ countProcessors()

unsigned core::countProcessors ( )
noexcept

Detects the number of CPUs on the machine.

Returns
The number of CPUs detected, or 1 if detection fails.

Definition at line 42 of file portable_utils.h.

43 {
44 if (const unsigned hardware_threads = std::thread::hardware_concurrency(); hardware_threads > 0)
45 {
46 return hardware_threads;
47 }
48 LOG(logging::Level::ERROR, "Unable to get CPU count, assuming 1.");
49 return 1;
50 }
#define LOG(level,...)
Definition logging.h:19
@ ERROR
Error level for error events.

References logging::ERROR, and LOG.

◆ outputFileMetadataToJsonString()

std::string core::outputFileMetadataToJsonString ( const OutputFileMetadata metadata)

Definition at line 108 of file output_metadata.cpp.

109 {
110 return fileToJson(metadata).dump(2);
111 }

Referenced by serial::writeOutputFileMetadataAttributes().

+ Here is the caller graph for this function:

◆ outputMetadataToJsonString()

std::string core::outputMetadataToJsonString ( const OutputMetadata metadata)

Definition at line 113 of file output_metadata.cpp.

113{ return metadataToJson(metadata).dump(2); }

Referenced by FersContext::getLastOutputMetadataJson().

+ Here is the caller graph for this function:

◆ parseArguments()

std::expected< Config, std::string > core::parseArguments ( int  argc,
char *  argv[] 
)
noexcept

Parses command-line arguments.

Processes the command-line arguments, validating them and extracting configurations like script file, logging level, and thread count.

Parameters
argcThe argument count.
argvThe argument vector.
Returns
std::expected<Config, std::string> Parsed configuration or an error message.

Definition at line 212 of file arg_parser.cpp.

222 :
223 <scriptfile> Path to the simulation script file (XML)
224
225Example:
226 )" << programName
227 << R"( simulation.fersxml --out-dir=./results --log-level=DEBUG -n=4
228
229This program runs radar simulations based on an XML script file.
230Make sure the script file follows the correct format to avoid errors.
231)";
232 }
233
234 void showVersion() noexcept
235 {
236 std::cout << R"(

Referenced by main().

+ Here is the caller graph for this function:

◆ resolveKmlOutputPath()

std::filesystem::path core::resolveKmlOutputPath ( const std::string &  script_file,
const std::filesystem::path &  final_output_dir,
const std::optional< std::string > &  kml_file 
)
noexcept

Definition at line 25 of file cli_paths.cpp.

28 {
29 if (kml_file && !kml_file->empty())
30 {
31 const std::filesystem::path provided_kml_path(*kml_file);
32 if (provided_kml_path.has_parent_path() || provided_kml_path.is_absolute())
33 {
34 return provided_kml_path;
35 }
36
37 return final_output_dir / provided_kml_path;
38 }
39
40 std::filesystem::path kml_output_path = final_output_dir / std::filesystem::path(script_file).filename();
41 kml_output_path.replace_extension(".kml");
42 return kml_output_path;
43 }

Referenced by main().

+ Here is the caller graph for this function:

◆ resolveOutputDir()

std::filesystem::path core::resolveOutputDir ( const std::string &  script_file,
const std::optional< std::string > &  output_dir 
)
noexcept

Definition at line 8 of file cli_paths.cpp.

10 {
11 if (output_dir)
12 {
13 return std::filesystem::path(*output_dir);
14 }
15
16 std::filesystem::path default_out_dir = std::filesystem::path(script_file).parent_path();
17 if (default_out_dir.empty())
18 {
19 default_out_dir = ".";
20 }
21
22 return default_out_dir;
23 }

Referenced by main().

+ Here is the caller graph for this function:

◆ runEventDrivenSim()

OutputMetadata core::runEventDrivenSim ( World world,
pool::ThreadPool pool,
const std::function< void(const std::string &, int, int)> &  progress_callback,
const std::string &  output_dir 
)

Runs the unified, event-driven radar simulation.

This function is the core entry point of the simulator. It advances time by processing events from a global priority queue. It handles both pulsed and continuous-wave (CW) physics, dispatching finalization tasks to worker threads for asynchronous processing.

Parameters
worldA pointer to the simulation world containing all entities and state.
poolA reference to the thread pool for executing tasks.
progress_callbackAn optional callback function for reporting progress.
output_dirOutput directory for the simulation files.

Definition at line 312 of file sim_threading.cpp.

315 {
316 auto reporter = std::make_shared<ProgressReporter>(progress_callback);
317 auto metadata_collector = std::make_shared<OutputMetadataCollector>(output_dir);
318 SimulationEngine engine(world, pool, reporter, output_dir, metadata_collector);
319 engine.run();
320 return metadata_collector->snapshot();
321 }
Encapsulates the state and logic of the event-driven simulation loop.

References core::SimulationEngine::run().

Referenced by fers_run_simulation().

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

◆ showHelp()

void core::showHelp ( const char *  programName)
noexcept

Displays the help message.

Parameters
programNameThe name of the program.

Definition at line 200 of file arg_parser.cpp.

201 {
202 std::cout << R"(/------------------------------------------------\
203| FERS - The Flexible Extensible Radar Simulator |
204| Version 1.0.0 |
205\------------------------------------------------/

◆ showVersion()

void core::showVersion ( )
noexcept

Displays the version information.

Definition at line 207 of file arg_parser.cpp.

209 :
210 --help, -h Show this help message and exit

◆ toString()

std::string core::toString ( const EventType  type)

Converts an EventType enum to its string representation.

Parameters
typeThe event type.
Returns
A string representing the event type.

Definition at line 72 of file sim_events.h.

73 {
74 switch (type)
75 {
76 case EventType::TX_PULSED_START:
77 return "TxPulsedStart";
78 case EventType::RX_PULSED_WINDOW_START:
79 return "RxPulsedWindowStart";
80 case EventType::RX_PULSED_WINDOW_END:
81 return "RxPulsedWindowEnd";
82 case EventType::TX_CW_START:
83 return "TxCwStart";
84 case EventType::TX_CW_END:
85 return "TxCwEnd";
86 case EventType::RX_CW_START:
87 return "RxCwStart";
88 case EventType::RX_CW_END:
89 return "RxCwEnd";
90 default:
91 return "UnknownEvent";
92 }
93 }

References RX_CW_END, RX_CW_START, RX_PULSED_WINDOW_END, RX_PULSED_WINDOW_START, TX_CW_END, TX_CW_START, and TX_PULSED_START.

Referenced by core::World::dumpEventQueue().

+ Here is the caller graph for this function: