FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1#ifndef FERS_API_H
2#define FERS_API_H
3
4#include <stddef.h>
5#include <stdint.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11/**
12 * @brief An opaque handle to an in-memory FERS simulation context.
13 *
14 * This pointer represents a live simulation instance. It is an "opaque" type,
15 * meaning its internal structure is hidden from the API consumer. This design
16 * is intentional to decouple the client from the C++ implementation details of
17 * the simulator core. It ensures that the client code (e.g., in Rust) will not
18 * break even if the internal C++ `FersContext` class is changed, maintaining ABI
19 * stability across library versions.
20 *
21 * @note The client is responsible for managing the lifetime of this handle via
22 * `fers_context_create()` and `fers_context_destroy()`.
23 */
24struct fers_context;
25
26typedef struct fers_context fers_context_t; // NOLINT(*-use-using)
27
28/**
29 * @brief A function pointer type for progress reporting callbacks.
30 *
31 * This callback can be implemented by the client to receive progress updates
32 * during long-running operations like `fers_run_simulation`.
33 *
34 * @param message A descriptive message about the current operation.
35 * @param current The current progress step.
36 * @param total The total number of steps for the operation.
37 * @param user_data An opaque pointer passed back to the caller, useful for
38 * maintaining state (e.g., a class instance or application handle).
39 */
40typedef void (*fers_progress_callback_t)(const char* message, int current, int total,
41 void* user_data); // NOLINT(*-use-using)
42
43
44// --- Context Lifecycle ---
45
46/**
47 * @brief Creates a new FERS simulation context.
48 *
49 * Allocates and initializes a new, empty simulation context in memory. This
50 * context serves as the container for a scenario loaded via one of the
51 * `fers_load_...` or `fers_update_...` functions.
52 *
53 * @note In a C API, RAII is not available. The caller is responsible for
54 * destroying the returned context using `fers_context_destroy()` to
55 * prevent resource leaks.
56 *
57 * @return A non-null opaque pointer (handle) to the simulation context on success.
58 * Returns NULL on failure (e.g., out of memory).
59 */
61
62/**
63 * @brief Destroys a FERS simulation context and releases all associated memory.
64 *
65 * This function must be called for every context created by `fers_context_create()`
66 * to ensure proper cleanup of the underlying C++ objects. Accessing the context
67 * handle after calling this function results in undefined behavior.
68 *
69 * @param context A valid pointer to a `fers_context_t` handle. If context is NULL,
70 * the function performs no action for safety and does not set an error.
71 */
73
74/**
75 * @brief Sets the output directory for simulation results.
76 * @param context A valid `fers_context_t` handle.
77 * @param out_dir A null-terminated UTF-8 string for the output directory path.
78 * @return 0 on success, non-zero on error.
79 */
80int fers_set_output_directory(fers_context_t* context, const char* out_dir);
81
82/**
83 * @brief Log levels for the FERS library.
84 */
95
96/**
97 * @brief A function pointer type for receiving formatted log lines.
98 *
99 * @param level The severity level of the log line.
100 * @param line The full formatted log line, without a trailing newline.
101 * @param user_data An opaque pointer passed back to the caller.
102 */
103typedef void (*fers_log_callback_t)(fers_log_level_t level, const char* line, void* user_data); // NOLINT(*-use-using)
104
105/**
106 * @brief Configures the internal logger.
107 * @param level The minimum severity level to log.
108 * @param log_file_path Optional path to a log file. Pass NULL to disable file logging.
109 * @return 0 on success, non-zero on error.
110 */
111int fers_configure_logging(fers_log_level_t level, const char* log_file_path);
112
113/**
114 * @brief Returns the current internal logger level.
115 */
117
118/**
119 * @brief Registers a callback for formatted log lines.
120 * Pass NULL as callback to disable log callbacks.
121 */
122void fers_set_log_callback(fers_log_callback_t callback, void* user_data);
123
124/**
125 * @brief Submits a log message to the library's unified logging system.
126 * This ensures CLI messages match the format (timestamps, alignment) of library messages.
127 */
128void fers_log(fers_log_level_t level, const char* message);
129
130/**
131 * @brief Sets the number of worker threads for the simulation.
132 * @param num_threads The number of threads to use.
133 * @return 0 on success, non-zero on error. This function clears any previous
134 * thread-local error message at entry, like the other fallible API calls.
135 */
136int fers_set_thread_count(unsigned num_threads);
137
138// --- Scenario Loading & Serialization ---
139
140/**
141 * @brief Loads a scenario into the context from a FERS XML file.
142 *
143 * This is the standard method for initializing a simulation context from a file on
144 * disk. It is essential for interoperability with the CLI and legacy workflows that
145 * rely on the FERS XML format.
146 *
147 * @param context A valid `fers_context_t` handle.
148 * @param xml_filepath A null-terminated UTF-8 string for the input XML file path.
149 * @param validate A boolean (0 or 1) indicating whether to validate the XML
150 * against the embedded FERS schema. Validation is recommended to
151 * ensure scenario correctness.
152 * @return 0 on success, a non-zero error code on failure. Use
153 * `fers_get_last_error_message()` to retrieve error details.
154 */
155int fers_load_scenario_from_xml_file(fers_context_t* context, const char* xml_filepath, int validate);
156
157/**
158 * @brief Loads a scenario into the context from a FERS XML string.
159 *
160 * This function provides a way to load a scenario from an in-memory string,
161 * avoiding file I/O. It is useful for test harnesses or for UIs that manage
162 * scenarios as text content before parsing.
163 *
164 * @param context A valid `fers_context_t` handle.
165 * @param xml_content A null-terminated UTF-8 string containing the FERS scenario in XML format.
166 * @param validate A boolean (0 or 1) indicating whether to validate the XML
167 * against the embedded FERS schema.
168 * @return 0 on success, a non-zero error code on failure. Use
169 * `fers_get_last_error_message()` to retrieve error details.
170 */
171int fers_load_scenario_from_xml_string(fers_context_t* context, const char* xml_content, int validate);
172
173/**
174 * @brief Serializes the current simulation scenario into a JSON string.
175 *
176 * This function is the primary method for the UI to retrieve the full state of
177 * the simulation. JSON is used as the interchange format because it is lightweight,
178 * human-readable, and natively supported by web technologies, making it trivial
179 * to parse and use in the React/TypeScript frontend.
180 *
181 * @note Memory Management: The returned string is allocated by this library and
182 * its ownership is transferred to the caller. It is crucial to free this
183 * string using `fers_free_string()` to prevent memory leaks.
184 *
185 * @param context A valid `fers_context_t` handle.
186 * @return A dynamically allocated, null-terminated C-string containing the
187 * JSON representation of the scenario. Returns NULL on failure.
188 */
190
191/**
192 * @brief Serializes the current simulation scenario into a FERS XML string.
193 *
194 * This function enables exporting the in-memory state back into the standard FERS
195 * XML file format. This is essential for interoperability with legacy tools and
196 * for allowing a user to save a scenario that was created or modified in the UI.
197 *
198 * @note Memory Management: The returned string is dynamically allocated and
199 * its ownership is transferred to the caller. It must be freed using
200 * `fers_free_string()` to prevent memory leaks.
201 *
202 * @param context A valid `fers_context_t` handle.
203 * @return A dynamically allocated, null-terminated C-string containing the
204 * XML representation of the scenario. Returns NULL on failure.
205 */
207
208/**
209 * @brief Returns JSON metadata for the most recent simulation output files.
210 *
211 * The returned JSON describes generated HDF5 file structure and sample ranges.
212 * The caller owns the returned string and must free it with `fers_free_string`.
213 * If no simulation has completed yet, the returned JSON contains an empty `files`
214 * array.
215 *
216 * @param context A valid `fers_context_t` handle.
217 * @return A heap-allocated JSON string, or NULL on error.
218 */
220
221/**
222 * @brief Updates the simulation scenario from a JSON string.
223 *
224 * This is the primary method for the UI to push its state back to the C++
225 * core. It performs a full replacement of the existing scenario.
226 *
227 * @param context A valid `fers_context_t` handle.
228 * @param scenario_json A null-terminated UTF-8 string containing the FERS scenario in JSON format.
229 * @return 0 on success.
230 * 1 on generic logic error.
231 * 2 on JSON parsing/schema validation error.
232 * Use `fers_get_last_error_message()` to retrieve error details.
233 */
234int fers_update_scenario_from_json(fers_context_t* context, const char* scenario_json);
235
236/**
237 * @brief Updates a single platform's paths and name from JSON without full context recreation.
238 * @param context A valid `fers_context_t` handle.
239 * @param id The unique ID of the platform.
240 * @param json The JSON string for the platform.
241 * @return 0 on success, non-zero on failure.
242 */
243int fers_update_platform_from_json(fers_context_t* context, uint64_t id, const char* json);
244
245/**
246 * @brief Updates the global simulation parameters from JSON without full context recreation.
247 * @param context A valid `fers_context_t` handle.
248 * @param json The JSON string for the parameters.
249 * @return 0 on success, non-zero on failure.
250 */
251int fers_update_parameters_from_json(fers_context_t* context, const char* json);
252
253/**
254 * @brief Updates a single antenna from JSON without full context recreation.
255 * @param context A valid `fers_context_t` handle.
256 * @param json The JSON string for the antenna.
257 * @return 0 on success, non-zero on failure.
258 */
259int fers_update_antenna_from_json(fers_context_t* context, const char* json);
260
261/**
262 * @brief Updates a single waveform from JSON without full context recreation.
263 * @param context A valid `fers_context_t` handle.
264 * @param json The JSON string for the waveform.
265 * @return 0 on success, non-zero on failure.
266 */
267int fers_update_waveform_from_json(fers_context_t* context, const char* json);
268
269/**
270 * @brief Updates a single transmitter from JSON without full context recreation.
271 * @param context A valid `fers_context_t` handle.
272 * @param id The unique ID of the transmitter.
273 * @param json The JSON string for the transmitter.
274 * @return 0 on success, non-zero on failure.
275 */
276int fers_update_transmitter_from_json(fers_context_t* context, uint64_t id, const char* json);
277
278/**
279 * @brief Updates a single receiver from JSON without full context recreation.
280 * @param context A valid `fers_context_t` handle.
281 * @param id The unique ID of the receiver.
282 * @param json The JSON string for the receiver.
283 * @return 0 on success, non-zero on failure.
284 */
285int fers_update_receiver_from_json(fers_context_t* context, uint64_t id, const char* json);
286
287/**
288 * @brief Updates a single target from JSON without full context recreation.
289 * @param context A valid `fers_context_t` handle.
290 * @param id The unique ID of the target.
291 * @param json The JSON string for the target.
292 * @return 0 on success, non-zero on failure.
293 */
294int fers_update_target_from_json(fers_context_t* context, uint64_t id, const char* json);
295
296/**
297 * @brief Updates a monostatic radar from JSON without full context recreation.
298 * @param context A valid `fers_context_t` handle.
299 * @param json The JSON string for the monostatic component.
300 * @return 0 on success, non-zero on failure.
301 */
302int fers_update_monostatic_from_json(fers_context_t* context, const char* json);
303
304/**
305 * @brief Updates a single timing source from JSON without full context recreation.
306 * @param context A valid `fers_context_t` handle.
307 * @param id The unique ID of the timing source.
308 * @param json The JSON string for the timing source.
309 * @return 0 on success, non-zero on failure.
310 */
311int fers_update_timing_from_json(fers_context_t* context, uint64_t id, const char* json);
312
313// --- Error Handling ---
314
315/**
316 * @brief Retrieves the last error message that occurred on the current thread.
317 *
318 * Because C++ exceptions cannot safely propagate across the FFI boundary into
319 * other languages, this function provides the standard C-style error reporting
320 * mechanism. The error state is stored in a thread-local variable to ensure that
321 * concurrent API calls from different threads do not overwrite each other's error
322 * messages. The error is cleared at the start of each fallible API call.
323 *
324 * @note Memory Management: The returned string's ownership is transferred to the
325 * caller. It MUST be freed using `fers_free_string()` to prevent memory leaks.
326 *
327 * @return A dynamically allocated, null-terminated C-string containing the last
328 * error message, or NULL if no error has occurred.
329 */
331
332/**
333 * @brief Returns the last deduplicated rotation-unit warning list for the calling thread as JSON.
334 *
335 * The returned value is a JSON array of strings. It is populated by successful XML/JSON
336 * load and update calls that detect suspicious rotation values. The caller owns the string
337 * and must free it with `fers_free_string()`.
338 *
339 * @return A dynamically allocated JSON array string, or NULL if no warnings are available.
340 */
342
343/**
344 * @brief Frees a string that was allocated and returned by the libfers API.
345 *
346 * This function must be used to release memory for any string returned by
347 * functions like `fers_get_scenario_as_json` or `fers_get_last_error_message`.
348 * It exists to ensure that the memory deallocation mechanism (`free`) matches the
349 * allocation mechanism (`strdup`/`malloc`) used within the C++ library, preventing
350 * potential crashes from mismatched allocators across language boundaries.
351 *
352 * @param str A pointer to the string to be freed. If str is NULL, no action is taken.
353 */
354void fers_free_string(char* str);
355
356
357// --- Simulation Execution ---
358
359/**
360 * @brief Runs the simulation defined in the provided context.
361 *
362 * This function is synchronous and will block the calling thread until the
363 * simulation is complete. This design keeps the API simple. For use in a
364 * responsive UI, it is the responsibility of the caller (e.g., the Tauri
365 * backend) to invoke this function on a separate worker thread to avoid
366 * freezing the user interface.
367 *
368 * @param context A valid `fers_context_t` handle containing a loaded scenario.
369 * @param callback A function pointer to a progress callback. Can be NULL.
370 * @param user_data An opaque pointer passed to the callback function.
371 * @return 0 on success, a non-zero error code on failure. Use
372 * `fers_get_last_error_message()` to retrieve error details.
373 */
374int fers_run_simulation(fers_context_t* context, fers_progress_callback_t callback, void* user_data);
375
376
377// --- Utility Functions ---
378
379/**
380 * @brief Generates a KML file for visualizing the scenario in the context.
381 *
382 * This utility exists to provide a simple, out-of-the-box method for users to
383 * validate and visualize the geographic layout and motion paths of their
384 * scenarios in common external tools like Google Earth.
385 *
386 * @param context A valid `fers_context_t` handle containing a loaded scenario.
387 * @param output_kml_filepath A null-terminated UTF-8 string for the output KML file path.
388 * @return 0 on success, a non-zero error code on failure. Use
389 * `fers_get_last_error_message()` to retrieve error details.
390 */
391int fers_generate_kml(const fers_context_t* context, const char* output_kml_filepath);
392
393// --- Antenna Pattern Utilities ---
394
395/**
396 * @brief Represents a sampled 2D antenna gain pattern.
397 * Gains are in linear scale (not dB), normalized to the antenna's peak gain.
398 * The data is structured as a flat array in row-major order (elevation rows, then azimuth columns).
399 * @note The `gains` array must be freed using `fers_free_antenna_pattern_data`.
400 */
401typedef struct // NOLINT(*-use-using)
402{
403 double* gains; // Flat array of gain values [el_count * az_count]
404 size_t az_count; // Number of samples along azimuth (-180 to +180 deg)
405 size_t el_count; // Number of samples along elevation (-90 to +90 deg)
406 double max_gain; // The peak gain found in the pattern (linear scale)
408
409
410/**
411 * @brief Samples the gain pattern of a specified antenna and provides the data.
412 *
413 * This function calculates the antenna's far-field gain at a specified resolution
414 * over the full sphere of directions (azimuth and elevation). The resulting gain
415 * values are linear (not in dB) and normalized relative to the pattern's peak gain.
416 * This is a stateless utility useful for UI previews and analysis.
417 *
418 * @param context A valid `fers_context_t` handle containing a loaded scenario with the antenna.
419 * @param antenna_id The unique ID of the antenna asset to sample.
420 * @param az_samples The desired number of sample points along the azimuth axis.
421 * Must be at least 2 to span the full azimuth range.
422 * @param el_samples The desired number of sample points along the elevation axis.
423 * Must be at least 2 to span the full elevation range.
424 * @param frequency_hz The frequency in Hz to use for gain calculation (affects aperture antennas).
425 * @return A pointer to a `fers_antenna_pattern_data_t` struct containing the results.
426 * Returns NULL on failure (e.g., antenna not found). The caller owns the
427 * returned struct and must free it with `fers_free_antenna_pattern_data`.
428 */
429fers_antenna_pattern_data_t* fers_get_antenna_pattern(const fers_context_t* context, uint64_t antenna_id,
430 size_t az_samples, size_t el_samples, double frequency_hz);
431
432/**
433 * @brief Frees the memory allocated for an antenna pattern data structure.
434 * @param data A pointer to the `fers_antenna_pattern_data_t` struct to free.
435 */
437
438
439// --- Path Interpolation Utilities ---
440
441/**
442 * @brief Defines the interpolation methods available for path generation.
443 * This enum provides a language-agnostic way to specify the desired
444 * interpolation algorithm when calling the path generation functions.
445 */
452
453/**
454 * @brief Units used for external rotation angles and rates.
455 */
456typedef enum // NOLINT(*-use-using)
457{
461
462/**
463 * @brief Represents a single waypoint for a motion path.
464 * Coordinates are in the scenario's defined coordinate system (e.g., ENU meters).
465 */
466typedef struct // NOLINT(*-use-using)
467{
468 double time; /**< Time in seconds. */
469 double x; /**< X coordinate in meters (East in ENU). */
470 double y; /**< Y coordinate in meters (North in ENU). */
471 double z; /**< Z coordinate in meters (Up/Altitude in ENU). */
473
474/**
475 * @brief Represents a single waypoint for a rotation path.
476 * Angles are in compass units (CW from North) selected by the caller.
477 */
478typedef struct // NOLINT(*-use-using)
479{
480 double time; /**< Time in seconds. */
481 double azimuth; /**< Azimuth angle in compass units (0=North, pi/2 or 90=East). */
482 double elevation; /**< Elevation angle in compass units (positive up). */
484
485/**
486 * @brief Represents a single interpolated point on a motion path.
487 * Includes position and velocity in the scenario's coordinate frame.
488 */
489typedef struct // NOLINT(*-use-using)
490{
491 double x; /**< X position in meters. */
492 double y; /**< Y position in meters. */
493 double z; /**< Z position in meters. */
494 double vx; /**< X velocity in m/s. */
495 double vy; /**< Y velocity in m/s. */
496 double vz; /**< Z velocity in m/s. */
498
499/**
500 * @brief Represents a single interpolated point on a rotation path.
501 * Angles are in compass units (CW from North) selected by the caller.
502 */
503typedef struct // NOLINT(*-use-using)
504{
505 double azimuth; /**< Azimuth angle in compass units. */
506 double elevation; /**< Elevation angle in compass units. */
508
509
510/**
511 * @brief A container for an array of interpolated motion path points.
512 * @note The `points` array must be freed using `fers_free_interpolated_motion_path`.
513 */
514typedef struct // NOLINT(*-use-using)
515{
517 size_t count;
519
520/**
521 * @brief A container for an array of interpolated rotation path points.
522 * @note The `points` array must be freed using `fers_free_interpolated_rotation_path`.
523 */
524typedef struct // NOLINT(*-use-using)
525{
527 size_t count;
529
530
531/**
532 * @brief Calculates an interpolated motion path from a set of waypoints.
533 * This function is a stateless utility that computes the path without needing a
534 * full simulation context. It is useful for UI previews.
535 *
536 * @param waypoints An array of `fers_motion_waypoint_t` structs.
537 * @param waypoint_count The number of waypoints in the array.
538 * @param interp_type The interpolation algorithm to use.
539 * @param num_points The desired number of points in the output interpolated path.
540 * @return A pointer to a `fers_interpolated_path_t` struct containing the results.
541 * Returns NULL on failure. The caller owns the returned struct and must
542 * free it with `fers_free_interpolated_motion_path`.
543 */
545 size_t waypoint_count, fers_interp_type_t interp_type,
546 size_t num_points);
547
548/**
549 * @brief Frees the memory allocated for an interpolated motion path.
550 * @param path A pointer to the `fers_interpolated_path_t` struct to free.
551 */
553
554/**
555 * @brief Calculates an interpolated rotation path from a set of waypoints.
556 * This function is a stateless utility for UI previews.
557 *
558 * @param waypoints An array of `fers_rotation_waypoint_t` structs.
559 * @param waypoint_count The number of waypoints in the array.
560 * @param interp_type The interpolation algorithm to use (STATIC, LINEAR, CUBIC).
561 * @param angle_unit The unit used by the waypoint angles and desired output angles.
562 * @param num_points The desired number of points in the output interpolated path.
563 * @return A pointer to a `fers_interpolated_rotation_path_t` struct containing the results.
564 * Returns NULL on failure. The caller owns the returned struct and must
565 * free it with `fers_free_interpolated_rotation_path`.
566 */
568 size_t waypoint_count,
569 fers_interp_type_t interp_type,
570 fers_angle_unit_t angle_unit, size_t num_points);
571
572/**
573 * @brief Frees the memory allocated for an interpolated rotation path.
574 * @param path A pointer to the `fers_interpolated_rotation_path_t` struct to free.
575 */
577
578// --- Preview Link Calculation ---
579
580/**
581 * @brief Quality of the radio link based on SNR.
582 */
583typedef enum // NOLINT(*-use-using)
584{
585 FERS_LINK_STRONG, // SNR > 0 dB
586 FERS_LINK_WEAK // SNR < 0 dB (Geometric possibility but sub-noise)
588
589/**
590 * @brief Type of visual link to render.
591 */
592typedef enum // NOLINT(*-use-using)
593{
594 FERS_LINK_MONOSTATIC, // Combined Tx/Rx path
595 FERS_LINK_BISTATIC_TX_TGT, // Illuminator path
596 FERS_LINK_BISTATIC_TGT_RX, // Scattered path
597 FERS_LINK_DIRECT_TX_RX // Interference path
599
600/**
601 * @brief Represents a single renderable line segment metadata.
602 * Geometry is resolved client-side.
603 */
604typedef struct // NOLINT(*-use-using)
605{
606 fers_link_type_t type; /**< Type of the link (Monostatic, Bistatic, etc.). */
607 fers_link_quality_t quality; /**< Signal quality (Strong/Weak). */
608 char label[128]; /**< Pre-formatted label (e.g., "-95 dBm"). */
609 uint64_t source_id; /**< ID of the source component (e.g. Transmitter). */
610 uint64_t dest_id; /**< ID of the destination component (e.g. Receiver/Target). */
611 uint64_t origin_id; /**< ID of the originating Transmitter (for scattered paths). */
613
614/**
615 * @brief A container for a list of visual links.
616 * @note The `links` array is owned by this struct and must be freed using `fers_free_preview_links`.
617 */
618typedef struct // NOLINT(*-use-using)
619{
621 size_t count;
623
624/**
625 * @brief Calculates visual links for a specific simulation time.
626 * @param context The simulation context.
627 * @param time The simulation time in seconds.
628 * @return A pointer to a link list. Caller must free with fers_free_preview_links.
629 */
631
632/**
633 * @brief Frees the memory allocated for a preview link list.
634 * @param list The list to free.
635 */
637
638#ifdef __cplusplus
639}
640#endif
641
642#endif
char * fers_get_scenario_as_xml(fers_context_t *context)
Serializes the current simulation scenario into a FERS XML string.
Definition api.cpp:397
int fers_update_antenna_from_json(fers_context_t *context, const char *json)
Updates a single antenna from JSON without full context recreation.
Definition api.cpp:511
void fers_free_antenna_pattern_data(fers_antenna_pattern_data_t *data)
Frees the memory allocated for an antenna pattern data structure.
Definition api.cpp:1126
fers_angle_unit_t
Units used for external rotation angles and rates.
Definition api.h:457
@ FERS_ANGLE_UNIT_DEG
Definition api.h:458
@ FERS_ANGLE_UNIT_RAD
Definition api.h:459
void(* fers_progress_callback_t)(const char *message, int current, int total, void *user_data)
A function pointer type for progress reporting callbacks.
Definition api.h:40
void fers_log(fers_log_level_t level, const char *message)
Submits a log message to the library's unified logging system.
Definition api.cpp:225
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.
Definition api.cpp:274
char * fers_get_last_warning_messages_json()
Returns the last deduplicated rotation-unit warning list for the calling thread as JSON.
Definition api.cpp:740
int fers_update_waveform_from_json(fers_context_t *context, const char *json)
Updates a single waveform from JSON without full context recreation.
Definition api.cpp:537
int fers_update_transmitter_from_json(fers_context_t *context, uint64_t id, const char *json)
Updates a single transmitter from JSON without full context recreation.
Definition api.cpp:560
char * fers_get_last_error_message()
Retrieves the last error message that occurred on the current thread.
Definition api.cpp:728
void fers_free_interpolated_motion_path(fers_interpolated_path_t *path)
Frees the memory allocated for an interpolated motion path.
Definition api.cpp:933
void(* fers_log_callback_t)(fers_log_level_t level, const char *line, void *user_data)
A function pointer type for receiving formatted log lines.
Definition api.h:103
int fers_update_parameters_from_json(fers_context_t *context, const char *json)
Updates the global simulation parameters from JSON without full context recreation.
Definition api.cpp:486
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.
Definition api.cpp:798
fers_log_level_t
Log levels for the FERS library.
Definition api.h:86
@ FERS_LOG_FATAL
Definition api.h:92
@ FERS_LOG_DEBUG
Definition api.h:88
@ FERS_LOG_ERROR
Definition api.h:91
@ FERS_LOG_OFF
Definition api.h:93
@ FERS_LOG_INFO
Definition api.h:89
@ FERS_LOG_TRACE
Definition api.h:87
@ FERS_LOG_WARNING
Definition api.h:90
int fers_set_output_directory(fers_context_t *context, const char *out_dir)
Sets the output directory for simulation results.
Definition api.cpp:252
void fers_context_destroy(fers_context_t *context)
Destroys a FERS simulation context and releases all associated memory.
Definition api.cpp:108
fers_context_t * fers_context_create()
Creates a new FERS simulation context.
Definition api.cpp:88
int fers_update_target_from_json(fers_context_t *context, uint64_t id, const char *json)
Updates a single target from JSON without full context recreation.
Definition api.cpp:610
void fers_free_preview_links(fers_visual_link_list_t *list)
Frees the memory allocated for a preview link list.
Definition api.cpp:1206
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.
Definition api.cpp:858
fers_antenna_pattern_data_t * fers_get_antenna_pattern(const fers_context_t *context, uint64_t antenna_id, size_t az_samples, size_t el_samples, double frequency_hz)
Samples the gain pattern of a specified antenna and provides the data.
Definition api.cpp:1040
int fers_update_receiver_from_json(fers_context_t *context, uint64_t id, const char *json)
Updates a single receiver from JSON without full context recreation.
Definition api.cpp:585
int fers_run_simulation(fers_context_t *context, fers_progress_callback_t callback, void *user_data)
Runs the simulation defined in the provided context.
Definition api.cpp:760
void fers_free_string(char *str)
Frees a string that was allocated and returned by the libfers API.
Definition api.cpp:752
fers_log_level_t fers_get_log_level()
Returns the current internal logger level.
Definition api.cpp:212
fers_visual_link_list_t * fers_calculate_preview_links(const fers_context_t *context, double time)
Calculates visual links for a specific simulation time.
Definition api.cpp:1137
fers_interp_type_t
Defines the interpolation methods available for path generation.
Definition api.h:447
@ FERS_INTERP_CUBIC
Definition api.h:450
@ FERS_INTERP_STATIC
Definition api.h:448
@ FERS_INTERP_LINEAR
Definition api.h:449
int fers_configure_logging(fers_log_level_t level, const char *log_file_path)
Configures the internal logger.
Definition api.cpp:188
void fers_free_interpolated_rotation_path(fers_interpolated_rotation_path_t *path)
Frees the memory allocated for an interpolated rotation path.
Definition api.cpp:1029
void fers_set_log_callback(fers_log_callback_t callback, void *user_data)
Registers a callback for formatted log lines.
Definition api.cpp:214
char * fers_get_scenario_as_json(fers_context_t *context)
Serializes the current simulation scenario into a JSON string.
Definition api.cpp:370
int fers_update_monostatic_from_json(fers_context_t *context, const char *json)
Updates a monostatic radar from JSON without full context recreation.
Definition api.cpp:635
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, fers_angle_unit_t angle_unit, size_t num_points)
Calculates an interpolated rotation path from a set of waypoints.
Definition api.cpp:942
int fers_update_platform_from_json(fers_context_t *context, uint64_t id, const char *json)
Updates a single platform's paths and name from JSON without full context recreation.
Definition api.cpp:450
fers_link_type_t
Type of visual link to render.
Definition api.h:593
@ FERS_LINK_BISTATIC_TX_TGT
Definition api.h:595
@ FERS_LINK_MONOSTATIC
Definition api.h:594
@ FERS_LINK_BISTATIC_TGT_RX
Definition api.h:596
@ FERS_LINK_DIRECT_TX_RX
Definition api.h:597
int fers_update_timing_from_json(fers_context_t *context, uint64_t id, const char *json)
Updates a single timing source from JSON without full context recreation.
Definition api.cpp:665
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.
Definition api.cpp:325
int fers_update_scenario_from_json(fers_context_t *context, const char *scenario_json)
Updates the simulation scenario from a JSON string.
Definition api.cpp:689
char * fers_get_last_output_metadata_json(fers_context_t *context)
Returns JSON metadata for the most recent simulation output files.
Definition api.cpp:427
int fers_set_thread_count(unsigned num_threads)
Sets the number of worker threads for the simulation.
Definition api.cpp:233
fers_link_quality_t
Quality of the radio link based on SNR.
Definition api.h:584
@ FERS_LINK_WEAK
Definition api.h:586
@ FERS_LINK_STRONG
Definition api.h:585
Represents a sampled 2D antenna gain pattern.
Definition api.h:402
A container for an array of interpolated motion path points.
Definition api.h:515
fers_interpolated_point_t * points
Definition api.h:516
Represents a single interpolated point on a motion path.
Definition api.h:490
double vz
Z velocity in m/s.
Definition api.h:496
double x
X position in meters.
Definition api.h:491
double y
Y position in meters.
Definition api.h:492
double z
Z position in meters.
Definition api.h:493
double vx
X velocity in m/s.
Definition api.h:494
double vy
Y velocity in m/s.
Definition api.h:495
A container for an array of interpolated rotation path points.
Definition api.h:525
fers_interpolated_rotation_point_t * points
Definition api.h:526
Represents a single interpolated point on a rotation path.
Definition api.h:504
double azimuth
Azimuth angle in compass units.
Definition api.h:505
double elevation
Elevation angle in compass units.
Definition api.h:506
Represents a single waypoint for a motion path.
Definition api.h:467
double x
X coordinate in meters (East in ENU).
Definition api.h:469
double time
Time in seconds.
Definition api.h:468
double y
Y coordinate in meters (North in ENU).
Definition api.h:470
double z
Z coordinate in meters (Up/Altitude in ENU).
Definition api.h:471
Represents a single waypoint for a rotation path.
Definition api.h:479
double azimuth
Azimuth angle in compass units (0=North, pi/2 or 90=East).
Definition api.h:481
double elevation
Elevation angle in compass units (positive up).
Definition api.h:482
double time
Time in seconds.
Definition api.h:480