|
FERS 1.0.0
The Flexible Extensible Radar Simulator
|
#include <stddef.h>
Include dependency graph for api.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| struct | fers_antenna_pattern_data_t |
| Represents a sampled 2D antenna gain pattern. More... | |
| struct | fers_motion_waypoint_t |
| Represents a single waypoint for a motion path. More... | |
| struct | fers_rotation_waypoint_t |
| Represents a single waypoint for a rotation path. More... | |
| struct | fers_interpolated_point_t |
| Represents a single interpolated point on a motion path. More... | |
| struct | fers_interpolated_rotation_point_t |
| Represents a single interpolated point on a rotation path. More... | |
| struct | fers_interpolated_path_t |
| A container for an array of interpolated motion path points. More... | |
| struct | fers_interpolated_rotation_path_t |
| A container for an array of interpolated rotation path points. More... | |
| struct | fers_visual_link_t |
| Represents a single renderable line segment metadata. More... | |
| struct | fers_visual_link_list_t |
| A container for a list of visual links. More... | |
Typedefs | |
| typedef struct fers_context | fers_context_t |
| typedef void(* | fers_progress_callback_t) (const char *message, int current, int total, void *user_data) |
| A function pointer type for progress reporting callbacks. | |
Enumerations | |
| enum | fers_log_level_t { FERS_LOG_TRACE , FERS_LOG_DEBUG , FERS_LOG_INFO , FERS_LOG_WARNING , FERS_LOG_ERROR , FERS_LOG_FATAL } |
| Log levels for the FERS library. More... | |
| enum | fers_interp_type_t { FERS_INTERP_STATIC , FERS_INTERP_LINEAR , FERS_INTERP_CUBIC } |
| Defines the interpolation methods available for path generation. More... | |
| enum | fers_link_quality_t { FERS_LINK_STRONG , FERS_LINK_WEAK } |
| Quality of the radio link based on SNR. More... | |
| enum | fers_link_type_t { FERS_LINK_MONOSTATIC , FERS_LINK_BISTATIC_TX_TGT , FERS_LINK_BISTATIC_TGT_RX , FERS_LINK_DIRECT_TX_RX } |
| Type of visual link to render. More... | |
Functions | |
| fers_context_t * | fers_context_create () |
| Creates a new FERS simulation context. | |
| void | fers_context_destroy (fers_context_t *context) |
| Destroys a FERS simulation context and releases all associated memory. | |
| int | fers_configure_logging (fers_log_level_t level, const char *log_file_path) |
| Configures the internal logger. | |
| void | fers_log (fers_log_level_t level, const char *message) |
| Submits a log message to the library's unified logging system. | |
| int | fers_set_thread_count (unsigned num_threads) |
| Sets the number of worker threads for the simulation. | |
| int | fers_load_scenario_from_xml_file (fers_context_t *context, const char *xml_filepath, int validate) |
| Loads a scenario into the context from a FERS XML file. | |
| int | fers_load_scenario_from_xml_string (fers_context_t *context, const char *xml_content, int validate) |
| Loads a scenario into the context from a FERS XML string. | |
| char * | fers_get_scenario_as_json (fers_context_t *context) |
| Serializes the current simulation scenario into a JSON string. | |
| char * | fers_get_scenario_as_xml (fers_context_t *context) |
| Serializes the current simulation scenario into a FERS XML string. | |
| int | fers_update_scenario_from_json (fers_context_t *context, const char *scenario_json) |
| Updates the simulation scenario from a JSON string. | |
| char * | fers_get_last_error_message () |
| Retrieves the last error message that occurred on the current thread. | |
| void | fers_free_string (char *str) |
| Frees a string that was allocated and returned by the libfers API. | |
| int | fers_run_simulation (fers_context_t *context, fers_progress_callback_t callback, void *user_data) |
| Runs the simulation defined in the provided context. | |
| int | fers_generate_kml (const fers_context_t *context, const char *output_kml_filepath) |
| Generates a KML file for visualizing the scenario in the context. | |
| fers_antenna_pattern_data_t * | fers_get_antenna_pattern (const fers_context_t *context, const char *antenna_name, size_t az_samples, size_t el_samples, double frequency_hz) |
| Samples the gain pattern of a specified antenna and provides the data. | |
| void | fers_free_antenna_pattern_data (fers_antenna_pattern_data_t *data) |
| Frees the memory allocated for an antenna pattern data structure. | |
| fers_interpolated_path_t * | fers_get_interpolated_motion_path (const fers_motion_waypoint_t *waypoints, size_t waypoint_count, fers_interp_type_t interp_type, size_t num_points) |
| Calculates an interpolated motion path from a set of waypoints. | |
| void | fers_free_interpolated_motion_path (fers_interpolated_path_t *path) |
| Frees the memory allocated for an interpolated motion path. | |
| fers_interpolated_rotation_path_t * | fers_get_interpolated_rotation_path (const fers_rotation_waypoint_t *waypoints, size_t waypoint_count, fers_interp_type_t interp_type, size_t num_points) |
| Calculates an interpolated rotation path from a set of waypoints. | |
| void | fers_free_interpolated_rotation_path (fers_interpolated_rotation_path_t *path) |
| Frees the memory allocated for an interpolated rotation path. | |
| fers_visual_link_list_t * | fers_calculate_preview_links (const fers_context_t *context, double time) |
| Calculates visual links for a specific simulation time. | |
| void | fers_free_preview_links (fers_visual_link_list_t *list) |
| Frees the memory allocated for a preview link list. | |
| typedef struct fers_context fers_context_t |
| typedef void(* fers_progress_callback_t) (const char *message, int current, int total, void *user_data) |
A function pointer type for progress reporting callbacks.
This callback can be implemented by the client to receive progress updates during long-running operations like fers_run_simulation.
| message | A descriptive message about the current operation. |
| current | The current progress step. |
| total | The total number of steps for the operation. |
| user_data | An opaque pointer passed back to the caller, useful for maintaining state (e.g., a class instance or application handle). |
| enum fers_interp_type_t |
Defines the interpolation methods available for path generation.
This enum provides a language-agnostic way to specify the desired interpolation algorithm when calling the path generation functions.
| Enumerator | |
|---|---|
| FERS_INTERP_STATIC | |
| FERS_INTERP_LINEAR | |
| FERS_INTERP_CUBIC | |
Definition at line 312 of file api.h.
| enum fers_link_quality_t |
Quality of the radio link based on SNR.
| Enumerator | |
|---|---|
| FERS_LINK_STRONG | |
| FERS_LINK_WEAK | |
Definition at line 439 of file api.h.
| enum fers_link_type_t |
Type of visual link to render.
| Enumerator | |
|---|---|
| FERS_LINK_MONOSTATIC | |
| FERS_LINK_BISTATIC_TX_TGT | |
| FERS_LINK_BISTATIC_TGT_RX | |
| FERS_LINK_DIRECT_TX_RX | |
Definition at line 448 of file api.h.
| enum fers_log_level_t |
Log levels for the FERS library.
| Enumerator | |
|---|---|
| FERS_LOG_TRACE | |
| FERS_LOG_DEBUG | |
| FERS_LOG_INFO | |
| FERS_LOG_WARNING | |
| FERS_LOG_ERROR | |
| FERS_LOG_FATAL | |
Definition at line 75 of file api.h.
| fers_visual_link_list_t * fers_calculate_preview_links | ( | const fers_context_t * | context, |
| double | time | ||
| ) |
Calculates visual links for a specific simulation time.
| context | The simulation context. |
| time | The simulation time in seconds. |
Definition at line 725 of file api.cpp.
References simulation::BistaticTgtRx, simulation::BistaticTxTgt, simulation::calculatePreviewLinks(), simulation::DirectTxRx, logging::ERROR, FERS_LINK_BISTATIC_TGT_RX, FERS_LINK_BISTATIC_TX_TGT, FERS_LINK_DIRECT_TX_RX, FERS_LINK_MONOSTATIC, FERS_LINK_STRONG, FERS_LINK_WEAK, handle_api_exception(), last_error_message, LOG, simulation::Monostatic, simulation::Strong, and fers_visual_link_t::type.
Here is the call graph for this function:| int fers_configure_logging | ( | fers_log_level_t | level, |
| const char * | log_file_path | ||
| ) |
Configures the internal logger.
| level | The minimum severity level to log. |
| log_file_path | Optional path to a log file. Pass NULL to disable file logging. |
Definition at line 112 of file api.cpp.
References handle_api_exception(), last_error_message, logging::logger, logging::Logger::logToFile(), map_level(), and logging::Logger::setLevel().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| fers_context_t * fers_context_create | ( | ) |
Creates a new FERS simulation context.
Allocates and initializes a new, empty simulation context in memory. This context serves as the container for a scenario loaded via one of the fers_load_... or fers_update_... functions.
fers_context_destroy() to prevent resource leaks.Definition at line 60 of file api.cpp.
References handle_api_exception(), and last_error_message.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void fers_context_destroy | ( | fers_context_t * | context | ) |
Destroys a FERS simulation context and releases all associated memory.
This function must be called for every context created by fers_context_create() to ensure proper cleanup of the underlying C++ objects. Accessing the context handle after calling this function results in undefined behavior.
| context | A valid pointer to a fers_context_t handle. If context is NULL, the function performs no action for safety. |
Definition at line 79 of file api.cpp.
References last_error_message, LOG, and logging::WARNING.
Referenced by main().
Here is the caller graph for this function:| void fers_free_antenna_pattern_data | ( | fers_antenna_pattern_data_t * | data | ) |
Frees the memory allocated for an antenna pattern data structure.
| data | A pointer to the fers_antenna_pattern_data_t struct to free. |
Definition at line 714 of file api.cpp.
References fers_antenna_pattern_data_t::gains.
| void fers_free_interpolated_motion_path | ( | fers_interpolated_path_t * | path | ) |
Frees the memory allocated for an interpolated motion path.
| path | A pointer to the fers_interpolated_path_t struct to free. |
Definition at line 524 of file api.cpp.
References fers_interpolated_path_t::points.
| void fers_free_interpolated_rotation_path | ( | fers_interpolated_rotation_path_t * | path | ) |
Frees the memory allocated for an interpolated rotation path.
| path | A pointer to the fers_interpolated_rotation_path_t struct to free. |
Definition at line 617 of file api.cpp.
References fers_interpolated_rotation_path_t::points.
| void fers_free_preview_links | ( | fers_visual_link_list_t * | list | ) |
Frees the memory allocated for a preview link list.
| list | The list to free. |
Definition at line 799 of file api.cpp.
References fers_visual_link_list_t::links.
| void fers_free_string | ( | char * | str | ) |
Frees a string that was allocated and returned by the libfers API.
This function must be used to release memory for any string returned by functions like fers_get_scenario_as_json or fers_get_last_error_message. It exists to ensure that the memory deallocation mechanism (free) matches the allocation mechanism (strdup/malloc) used within the C++ library, preventing potential crashes from mismatched allocators across language boundaries.
| str | A pointer to the string to be freed. If str is NULL, no action is taken. |
Definition at line 346 of file api.cpp.
Referenced by main().
Here is the caller graph for this function:| int fers_generate_kml | ( | const fers_context_t * | context, |
| const char * | output_kml_filepath | ||
| ) |
Generates a KML file for visualizing the scenario in the context.
This utility exists to provide a simple, out-of-the-box method for users to validate and visualize the geographic layout and motion paths of their scenarios in common external tools like Google Earth.
| context | A valid fers_context_t handle containing a loaded scenario. |
| output_kml_filepath | A null-terminated UTF-8 string for the output KML file path. |
fers_get_last_error_message() to retrieve error details. Definition at line 390 of file api.cpp.
References logging::ERROR, serial::KmlGenerator::generateKml(), handle_api_exception(), last_error_message, and LOG.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| fers_antenna_pattern_data_t * fers_get_antenna_pattern | ( | const fers_context_t * | context, |
| const char * | antenna_name, | ||
| size_t | az_samples, | ||
| size_t | el_samples, | ||
| double | frequency_hz | ||
| ) |
Samples the gain pattern of a specified antenna and provides the data.
This function calculates the antenna's far-field gain at a specified resolution over the full sphere of directions (azimuth and elevation). The resulting gain values are linear (not in dB) and normalized relative to the pattern's peak gain. This is a stateless utility useful for UI previews and analysis.
| context | A valid fers_context_t handle containing a loaded scenario with the antenna. |
| antenna_name | The name of the antenna asset to sample. |
| az_samples | The desired number of sample points along the azimuth axis. |
| el_samples | The desired number of sample points along the elevation axis. |
| frequency_hz | The frequency in Hz to use for gain calculation (affects aperture antennas). |
fers_antenna_pattern_data_t struct containing the results. Returns NULL on failure (e.g., antenna not found). The caller owns the returned struct and must free it with fers_free_antenna_pattern_data. Definition at line 628 of file api.cpp.
References params::c(), logging::ERROR, antenna::Antenna::getGain(), handle_api_exception(), last_error_message, LOG, and PI.
Here is the call graph for this function:| fers_interpolated_path_t * fers_get_interpolated_motion_path | ( | const fers_motion_waypoint_t * | waypoints, |
| size_t | waypoint_count, | ||
| fers_interp_type_t | interp_type, | ||
| size_t | num_points | ||
| ) |
Calculates an interpolated motion path from a set of waypoints.
This function is a stateless utility that computes the path without needing a full simulation context. It is useful for UI previews.
| waypoints | An array of fers_motion_waypoint_t structs. |
| waypoint_count | The number of waypoints in the array. |
| interp_type | The interpolation algorithm to use. |
| num_points | The desired number of points in the output interpolated path. |
fers_interpolated_path_t struct containing the results. Returns NULL on failure. The caller owns the returned struct and must free it with fers_free_interpolated_motion_path. Definition at line 450 of file api.cpp.
References math::Path::addCoord(), logging::ERROR, FERS_INTERP_CUBIC, math::Path::finalize(), math::Path::getPosition(), math::Path::getVelocity(), handle_api_exception(), last_error_message, LOG, math::Path::setInterp(), fers_motion_waypoint_t::time, to_cpp_interp_type(), fers_motion_waypoint_t::x, math::Vec3::x, fers_motion_waypoint_t::y, math::Vec3::y, fers_motion_waypoint_t::z, and math::Vec3::z.
Here is the call graph for this function:| fers_interpolated_rotation_path_t * fers_get_interpolated_rotation_path | ( | const fers_rotation_waypoint_t * | waypoints, |
| size_t | waypoint_count, | ||
| fers_interp_type_t | interp_type, | ||
| size_t | num_points | ||
| ) |
Calculates an interpolated rotation path from a set of waypoints.
This function is a stateless utility for UI previews.
| waypoints | An array of fers_rotation_waypoint_t structs. |
| waypoint_count | The number of waypoints in the array. |
| interp_type | The interpolation algorithm to use (STATIC, LINEAR, CUBIC). |
| num_points | The desired number of points in the output interpolated path. |
fers_interpolated_rotation_path_t struct containing the results. Returns NULL on failure. The caller owns the returned struct and must free it with fers_free_interpolated_rotation_path. Definition at line 533 of file api.cpp.
References math::RotationPath::addCoord(), math::SVec3::azimuth, fers_rotation_waypoint_t::azimuth_deg, math::SVec3::elevation, fers_rotation_waypoint_t::elevation_deg, logging::ERROR, FERS_INTERP_CUBIC, math::RotationPath::finalize(), math::RotationPath::getPosition(), handle_api_exception(), last_error_message, LOG, PI, math::RotationPath::setInterp(), fers_rotation_waypoint_t::time, and to_cpp_rot_interp_type().
Here is the call graph for this function:| char * fers_get_last_error_message | ( | ) |
Retrieves the last error message that occurred on the current thread.
Because C++ exceptions cannot safely propagate across the FFI boundary into other languages, this function provides the standard C-style error reporting mechanism. The error state is stored in a thread-local variable to ensure that concurrent API calls from different threads do not overwrite each other's error messages. The error is cleared at the start of each fallible API call.
fers_free_string() to prevent memory leaks.Definition at line 334 of file api.cpp.
References last_error_message.
Referenced by main().
Here is the caller graph for this function:| char * fers_get_scenario_as_json | ( | fers_context_t * | context | ) |
Serializes the current simulation scenario into a JSON string.
This function is the primary method for the UI to retrieve the full state of the simulation. JSON is used as the interchange format because it is lightweight, human-readable, and natively supported by web technologies, making it trivial to parse and use in the React/TypeScript frontend.
fers_free_string() to prevent memory leaks.| context | A valid fers_context_t handle. |
Definition at line 243 of file api.cpp.
References logging::ERROR, handle_api_exception(), last_error_message, LOG, and serial::world_to_json().
Here is the call graph for this function:| char * fers_get_scenario_as_xml | ( | fers_context_t * | context | ) |
Serializes the current simulation scenario into a FERS XML string.
This function enables exporting the in-memory state back into the standard FERS XML file format. This is essential for interoperability with legacy tools and for allowing a user to save a scenario that was created or modified in the UI.
fers_free_string() to prevent memory leaks.| context | A valid fers_context_t handle. |
Definition at line 270 of file api.cpp.
References logging::ERROR, handle_api_exception(), last_error_message, LOG, and serial::world_to_xml_string().
Here is the call graph for this function:| int fers_load_scenario_from_xml_file | ( | fers_context_t * | context, |
| const char * | xml_filepath, | ||
| int | validate | ||
| ) |
Loads a scenario into the context from a FERS XML file.
This is the standard method for initializing a simulation context from a file on disk. It is essential for interoperability with the CLI and legacy workflows that rely on the FERS XML format.
| context | A valid fers_context_t handle. |
| xml_filepath | A null-terminated UTF-8 string for the input XML file path. |
| validate | A boolean (0 or 1) indicating whether to validate the XML against the embedded FERS schema. Validation is recommended to ensure scenario correctness. |
fers_get_last_error_message() to retrieve error details. Definition at line 162 of file api.cpp.
References logging::ERROR, handle_api_exception(), logging::INFO, last_error_message, LOG, params::params, serial::parseSimulation(), and params::Parameters::random_seed.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int fers_load_scenario_from_xml_string | ( | fers_context_t * | context, |
| const char * | xml_content, | ||
| int | validate | ||
| ) |
Loads a scenario into the context from a FERS XML string.
This function provides a way to load a scenario from an in-memory string, avoiding file I/O. It is useful for test harnesses or for UIs that manage scenarios as text content before parsing.
| context | A valid fers_context_t handle. |
| xml_content | A null-terminated UTF-8 string containing the FERS scenario in XML format. |
| validate | A boolean (0 or 1) indicating whether to validate the XML against the embedded FERS schema. |
fers_get_last_error_message() to retrieve error details. Definition at line 202 of file api.cpp.
References logging::ERROR, handle_api_exception(), logging::INFO, last_error_message, LOG, params::params, serial::parseSimulationFromString(), and params::Parameters::random_seed.
Here is the call graph for this function:| void fers_log | ( | fers_log_level_t | level, |
| const char * | message | ||
| ) |
Submits a log message to the library's unified logging system.
This ensures CLI messages match the format (timestamps, alignment) of library messages.
Definition at line 136 of file api.cpp.
References logging::Logger::log(), logging::logger, and map_level().
Here is the call graph for this function:| int fers_run_simulation | ( | fers_context_t * | context, |
| fers_progress_callback_t | callback, | ||
| void * | user_data | ||
| ) |
Runs the simulation defined in the provided context.
This function is synchronous and will block the calling thread until the simulation is complete. This design keeps the API simple. For use in a responsive UI, it is the responsibility of the caller (e.g., the Tauri backend) to invoke this function on a separate worker thread to avoid freezing the user interface.
| context | A valid fers_context_t handle containing a loaded scenario. |
| callback | A function pointer to a progress callback. Can be NULL. |
| user_data | An opaque pointer passed to the callback function. |
fers_get_last_error_message() to retrieve error details. Definition at line 354 of file api.cpp.
References logging::ERROR, handle_api_exception(), last_error_message, LOG, params::renderThreads(), and core::runEventDrivenSim().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int fers_set_thread_count | ( | unsigned | num_threads | ) |
Sets the number of worker threads for the simulation.
| num_threads | The number of threads to use. |
Definition at line 144 of file api.cpp.
References handle_api_exception(), last_error_message, and params::setThreads().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int fers_update_scenario_from_json | ( | fers_context_t * | context, |
| const char * | scenario_json | ||
| ) |
Updates the simulation scenario from a JSON string.
This is the primary method for the UI to push its state back to the C++ core. It performs a full replacement of the existing scenario.
| context | A valid fers_context_t handle. |
| scenario_json | A null-terminated UTF-8 string containing the FERS scenario in JSON format. |
fers_get_last_error_message() to retrieve error details. Definition at line 300 of file api.cpp.
References logging::ERROR, handle_api_exception(), serial::json_to_world(), last_error_message, and LOG.
Here is the call graph for this function: