FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
serial::xml_serializer_utils Namespace Reference

Functions

void addChildWithText (const XmlElement &parent, const std::string &name, const std::string &text)
 Adds a child element with the specified text content.
 
void setAttributeFromBool (const XmlElement &element, const std::string &name, bool value)
 Sets a boolean attribute on an XML element.
 
void serializeSchedule (const std::vector< radar::SchedulePeriod > &schedule, const XmlElement &parent)
 Serializes a schedule (active periods) into a parent XML element.
 
void serializeParameters (const XmlElement &parent, const params::Parameters &p)
 Serializes a Parameters object into a parent XML element.
 
void serializeWaveform (const fers_signal::RadarSignal &waveform, const XmlElement &parent)
 Serializes a waveform into a parent XML element.
 
void serializeTiming (const timing::PrototypeTiming &timing, const XmlElement &parent)
 Serializes a timing object into a parent XML element.
 
void serializeAntenna (const antenna::Antenna &antenna, const XmlElement &parent)
 Serializes an antenna into a parent XML element.
 
void serializeMotionPath (const math::Path &path, const XmlElement &parent)
 Serializes a motion path into a parent XML element.
 
void serializeRotation (const math::RotationPath &rotPath, const XmlElement &parent)
 Serializes a rotation path into a parent XML element.
 
void serializeTransmitter (const radar::Transmitter &tx, const XmlElement &parent)
 Serializes a transmitter into a parent XML element.
 
void serializeReceiver (const radar::Receiver &rx, const XmlElement &parent)
 Serializes a receiver into a parent XML element.
 
void serializeMonostatic (const radar::Transmitter &tx, const radar::Receiver &rx, const XmlElement &parent)
 Serializes a monostatic radar setup containing both a transmitter and receiver.
 
void serializeTarget (const radar::Target &target, const XmlElement &parent)
 Serializes a target into a parent XML element.
 
void serializePlatform (const radar::Platform &platform, const core::World &world, const XmlElement &parent)
 Serializes a platform and its attached components into a parent XML element.
 
template<typename T >
void addChildWithNumber (const XmlElement &parent, const std::string &name, T value)
 Adds a child element with the specified numeric content.
 

Function Documentation

◆ addChildWithNumber()

template<typename T >
void serial::xml_serializer_utils::addChildWithNumber ( const XmlElement parent,
const std::string &  name,
value 
)

Adds a child element with the specified numeric content.

Template Parameters
TThe numeric type (automatically deduced).
Parameters
parentThe parent XML element.
nameThe name of the child element to create.
valueThe numeric value to set for the child element.

Definition at line 79 of file xml_serializer_utils.h.

80 {
81 if constexpr (std::is_floating_point_v<T>)
82 {
83 std::array<char, 64> buffer{};
84 if (auto [ptr, ec] = std::to_chars(buffer.data(), buffer.data() + buffer.size(), value); ec == std::errc())
85 {
86 const auto length = static_cast<std::string::size_type>(ptr - buffer.data());
87 addChildWithText(parent, name, std::string(buffer.data(), length));
88 }
89 else
90 {
91 // This only executes if std::to_chars(...) returns ec != std::errc()
92 // which will practically never happen unless the output buffer is too small
93 // to hold the formatted value, or the standard library implementation fails
94 // to support/format the given floating-point value.
95 std::stringstream ss;
96 ss << std::setprecision(std::numeric_limits<T>::max_digits10) << value;
97 addChildWithText(parent, name, ss.str());
98 }
99 }
100 else
101 {
102 addChildWithText(parent, name, std::to_string(value));
103 }
104 }
void addChildWithText(const XmlElement &parent, const std::string &name, const std::string &text)
Adds a child element with the specified text content.

References addChildWithText().

Referenced by serializeAntenna(), serializeMonostatic(), serializeMotionPath(), serializeParameters(), serializeReceiver(), serializeRotation(), serializeTarget(), serializeTiming(), serializeTransmitter(), and serializeWaveform().

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

◆ addChildWithText()

void serial::xml_serializer_utils::addChildWithText ( const XmlElement parent,
const std::string &  name,
const std::string &  text 
)

Adds a child element with the specified text content.

Parameters
parentThe parent XML element.
nameThe name of the child element to create.
textThe text content to set for the child element.

Definition at line 27 of file xml_serializer_utils.cpp.

28 {
29 parent.addChild(name).setText(text);
30 }
XmlElement addChild(const std::string_view name) const noexcept
Add a child element to the current node.
void setText(const std::string_view text) const
Set the text content of the XML element.

References XmlElement::addChild(), and XmlElement::setText().

Referenced by addChildWithNumber(), and serializeParameters().

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

◆ serializeAntenna()

void serial::xml_serializer_utils::serializeAntenna ( const antenna::Antenna antenna,
const XmlElement parent 
)

Serializes an antenna into a parent XML element.

Parameters
antennaThe antenna object to serialize.
parentThe parent XML element.

Definition at line 158 of file xml_serializer_utils.cpp.

159 {
160 parent.setAttribute("name", antenna.getName());
161
162 if (const auto* sinc = dynamic_cast<const antenna::Sinc*>(&antenna))
163 {
164 parent.setAttribute("pattern", "sinc");
165 addChildWithNumber(parent, "alpha", sinc->getAlpha());
166 addChildWithNumber(parent, "beta", sinc->getBeta());
167 addChildWithNumber(parent, "gamma", sinc->getGamma());
168 }
169 else if (const auto* gaussian = dynamic_cast<const antenna::Gaussian*>(&antenna))
170 {
171 parent.setAttribute("pattern", "gaussian");
172 addChildWithNumber(parent, "azscale", gaussian->getAzimuthScale());
173 addChildWithNumber(parent, "elscale", gaussian->getElevationScale());
174 }
175 else if (const auto* sh = dynamic_cast<const antenna::SquareHorn*>(&antenna))
176 {
177 parent.setAttribute("pattern", "squarehorn");
178 addChildWithNumber(parent, "diameter", sh->getDimension());
179 }
180 else if (const auto* parabolic = dynamic_cast<const antenna::Parabolic*>(&antenna))
181 {
182 parent.setAttribute("pattern", "parabolic");
183 addChildWithNumber(parent, "diameter", parabolic->getDiameter());
184 }
185 else if (const auto* xml_ant = dynamic_cast<const antenna::XmlAntenna*>(&antenna))
186 {
187 parent.setAttribute("pattern", "xml");
188 parent.setAttribute("filename", xml_ant->getFilename());
189 }
190 else if (const auto* h5_ant = dynamic_cast<const antenna::H5Antenna*>(&antenna))
191 {
192 parent.setAttribute("pattern", "file");
193 parent.setAttribute("filename", h5_ant->getFilename());
194 }
195 else
196 {
197 parent.setAttribute("pattern", "isotropic");
198 }
199
200 if (antenna.getEfficiencyFactor() != 1.0)
201 {
202 addChildWithNumber(parent, "efficiency", antenna.getEfficiencyFactor());
203 }
204 }
void setAttribute(const std::string_view name, const std::string_view value) const
Set an attribute on the XML element.
Represents a Gaussian-shaped antenna gain pattern.
Represents an antenna whose gain pattern is loaded from a HDF5 file.
Represents a parabolic reflector antenna.
Represents a sinc function-based antenna gain pattern.
Represents a square horn antenna.
Represents an antenna whose gain pattern is defined by an XML file.
void addChildWithNumber(const XmlElement &parent, const std::string &name, T value)
Adds a child element with the specified numeric content.

References addChildWithNumber(), and XmlElement::setAttribute().

Referenced by serial::world_to_xml_string().

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

◆ serializeMonostatic()

void serial::xml_serializer_utils::serializeMonostatic ( const radar::Transmitter tx,
const radar::Receiver rx,
const XmlElement parent 
)

Serializes a monostatic radar setup containing both a transmitter and receiver.

Parameters
txThe transmitter object.
rxThe receiver object.
parentThe parent XML element.

Definition at line 338 of file xml_serializer_utils.cpp.

339 {
340 const XmlElement mono_elem = parent.addChild("monostatic");
341 mono_elem.setAttribute("name", tx.getName());
342 mono_elem.setAttribute("antenna", (tx.getAntenna() != nullptr) ? tx.getAntenna()->getName() : "");
343 mono_elem.setAttribute("waveform", (tx.getSignal() != nullptr) ? tx.getSignal()->getName() : "");
344 mono_elem.setAttribute("timing", tx.getTiming() ? tx.getTiming()->getName() : "");
347
349 {
350 const XmlElement mode_elem = mono_elem.addChild("pulsed_mode");
351 addChildWithNumber(mode_elem, "prf", tx.getPrf());
352 addChildWithNumber(mode_elem, "window_skip", rx.getWindowSkip());
353 addChildWithNumber(mode_elem, "window_length", rx.getWindowLength());
354 }
355 else
356 {
357 (void)mono_elem.addChild("cw_mode");
358 }
359
360 if (rx.getNoiseTemperature() > 0)
361 {
362 addChildWithNumber(mono_elem, "noise_temp", rx.getNoiseTemperature());
363 }
364
365 serializeSchedule(tx.getSchedule(), mono_elem);
366 }
Class representing a node in an XML document.
std::string getName() const noexcept
Retrieves the name of the antenna.
const std::string & getName() const noexcept
Gets the name of the radar signal.
const std::string & getName() const noexcept
Retrieves the name of the object.
Definition object.h:79
const antenna::Antenna * getAntenna() const noexcept
Gets the antenna associated with this radar.
Definition radar_obj.h:90
std::shared_ptr< timing::Timing > getTiming() const
Retrieves the timing source for the radar.
Definition radar_obj.cpp:66
bool checkFlag(RecvFlag flag) const noexcept
Checks if a specific flag is set.
Definition receiver.h:88
RealType getNoiseTemperature() const noexcept
Retrieves the noise temperature of the receiver.
Definition receiver.h:102
RealType getWindowSkip() const noexcept
Retrieves the window skip time.
Definition receiver.h:123
RealType getWindowLength() const noexcept
Retrieves the radar window length.
Definition receiver.h:109
RealType getPrf() const noexcept
Retrieves the pulse repetition frequency (PRF).
Definition transmitter.h:64
fers_signal::RadarSignal * getSignal() const noexcept
Retrieves the radar signal currently being transmitted.
Definition transmitter.h:71
const std::vector< SchedulePeriod > & getSchedule() const noexcept
Retrieves the list of active transmission periods.
OperationMode getMode() const noexcept
Gets the operational mode of the transmitter.
Definition transmitter.h:85
@ PULSED_MODE
The component operates in a pulsed mode.
void serializeSchedule(const std::vector< radar::SchedulePeriod > &schedule, const XmlElement &parent)
Serializes a schedule (active periods) into a parent XML element.
void setAttributeFromBool(const XmlElement &element, const std::string &name, const bool value)
Sets a boolean attribute on an XML element.

References XmlElement::addChild(), addChildWithNumber(), radar::Receiver::checkFlag(), radar::Receiver::FLAG_NODIRECT, radar::Receiver::FLAG_NOPROPLOSS, radar::Radar::getAntenna(), radar::Transmitter::getMode(), antenna::Antenna::getName(), radar::Object::getName(), fers_signal::RadarSignal::getName(), radar::Receiver::getNoiseTemperature(), radar::Transmitter::getPrf(), radar::Transmitter::getSchedule(), radar::Transmitter::getSignal(), radar::Radar::getTiming(), radar::Receiver::getWindowLength(), radar::Receiver::getWindowSkip(), radar::PULSED_MODE, serializeSchedule(), XmlElement::setAttribute(), and setAttributeFromBool().

Referenced by serializePlatform().

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

◆ serializeMotionPath()

void serial::xml_serializer_utils::serializeMotionPath ( const math::Path path,
const XmlElement parent 
)

Serializes a motion path into a parent XML element.

Parameters
pathThe motion path object to serialize.
parentThe parent XML element.

Definition at line 206 of file xml_serializer_utils.cpp.

207 {
208 switch (path.getType())
209 {
211 parent.setAttribute("interpolation", "static");
212 break;
214 parent.setAttribute("interpolation", "linear");
215 break;
217 parent.setAttribute("interpolation", "cubic");
218 break;
219 }
220
221 for (const auto& [pos, t] : path.getCoords())
222 {
223 XmlElement wp_elem = parent.addChild("positionwaypoint");
224 addChildWithNumber(wp_elem, "x", pos.x);
225 addChildWithNumber(wp_elem, "y", pos.y);
226 addChildWithNumber(wp_elem, "altitude", pos.z);
227 addChildWithNumber(wp_elem, "time", t);
228 }
229 }
InterpType getType() const noexcept
Retrieves the current interpolation type of the path.
Definition path.h:76

References XmlElement::addChild(), addChildWithNumber(), math::Path::getCoords(), math::Path::getType(), math::Path::INTERP_CUBIC, math::Path::INTERP_LINEAR, math::Path::INTERP_STATIC, and XmlElement::setAttribute().

Referenced by serializePlatform().

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

◆ serializeParameters()

void serial::xml_serializer_utils::serializeParameters ( const XmlElement parent,
const params::Parameters p 
)

Serializes a Parameters object into a parent XML element.

Parameters
parentThe parent XML element.
pThe parameter struct to serialize.

Definition at line 52 of file xml_serializer_utils.cpp.

53 {
54 addChildWithNumber(parent, "starttime", p.start);
55 addChildWithNumber(parent, "endtime", p.end);
56 addChildWithNumber(parent, "rate", p.rate);
57
59 {
60 addChildWithNumber(parent, "c", p.c);
61 }
62 if (p.sim_sampling_rate != 1000.0)
63 {
64 addChildWithNumber(parent, "simSamplingRate", p.sim_sampling_rate);
65 }
66 if (p.random_seed)
67 {
68 addChildWithNumber(parent, "randomseed", *p.random_seed);
69 }
70 if (p.adc_bits != 0)
71 {
72 addChildWithNumber(parent, "adc_bits", p.adc_bits);
73 }
74 if (p.oversample_ratio != 1)
75 {
76 addChildWithNumber(parent, "oversample", p.oversample_ratio);
77 }
79 {
80 addChildWithText(parent, "rotationangleunit",
82 }
83
84 const XmlElement origin = parent.addChild("origin");
85 origin.setAttribute("latitude", std::to_string(p.origin_latitude));
86 origin.setAttribute("longitude", std::to_string(p.origin_longitude));
87 origin.setAttribute("altitude", std::to_string(p.origin_altitude));
88
89 const XmlElement cs = parent.addChild("coordinatesystem");
90 switch (p.coordinate_frame)
91 {
93 cs.setAttribute("frame", "ENU");
94 break;
96 cs.setAttribute("frame", "UTM");
97 cs.setAttribute("zone", std::to_string(p.utm_zone));
98 cs.setAttribute("hemisphere", p.utm_north_hemisphere ? "N" : "S");
99 break;
101 cs.setAttribute("frame", "ECEF");
102 break;
103 }
104 }
@ Degrees
Compass azimuth and elevation expressed in degrees.
@ UTM
Universal Transverse Mercator.
@ ENU
East-North-Up local tangent plane (default)
@ ECEF
Earth-Centered, Earth-Fixed.
constexpr std::string_view rotationAngleUnitToken(const RotationAngleUnit unit) noexcept
Definition parameters.h:294
RealType rate
Rendering sample rate.
Definition parameters.h:69
double origin_longitude
Geodetic origin longitude.
Definition parameters.h:63
RealType start
Start time for the simulation.
Definition parameters.h:56
double origin_altitude
Geodetic origin altitude (in meters)
Definition parameters.h:64
CoordinateFrame coordinate_frame
Scenario coordinate frame.
Definition parameters.h:65
RealType end
End time for the simulation.
Definition parameters.h:57
int utm_zone
UTM zone (1-60), if applicable.
Definition parameters.h:67
unsigned oversample_ratio
Oversampling ratio.
Definition parameters.h:75
std::optional< unsigned > random_seed
Random seed for simulation.
Definition parameters.h:70
RealType sim_sampling_rate
Temporal sampling rate (Hz) that determines time-step resolution for radar pulse simulation.
Definition parameters.h:58
RotationAngleUnit rotation_angle_unit
External rotation angle unit.
Definition parameters.h:66
RealType c
Speed of light (modifiable)
Definition parameters.h:54
static constexpr RealType DEFAULT_C
Speed of light (m/s)
Definition parameters.h:52
unsigned adc_bits
ADC quantization bits.
Definition parameters.h:71
bool utm_north_hemisphere
UTM hemisphere, if applicable.
Definition parameters.h:68
double origin_latitude
Geodetic origin latitude.
Definition parameters.h:62

References params::Parameters::adc_bits, XmlElement::addChild(), addChildWithNumber(), addChildWithText(), params::Parameters::c, params::Parameters::coordinate_frame, params::Parameters::DEFAULT_C, params::Degrees, params::ECEF, params::Parameters::end, params::ENU, params::Parameters::origin_altitude, params::Parameters::origin_latitude, params::Parameters::origin_longitude, params::Parameters::oversample_ratio, params::Parameters::random_seed, params::Parameters::rate, params::Parameters::rotation_angle_unit, params::rotationAngleUnitToken(), XmlElement::setAttribute(), params::Parameters::sim_sampling_rate, params::Parameters::start, params::UTM, params::Parameters::utm_north_hemisphere, and params::Parameters::utm_zone.

Referenced by serial::world_to_xml_string().

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

◆ serializePlatform()

void serial::xml_serializer_utils::serializePlatform ( const radar::Platform platform,
const core::World world,
const XmlElement parent 
)

Serializes a platform and its attached components into a parent XML element.

Parameters
platformThe platform object to serialize.
worldThe simulation world containing global state.
parentThe parent XML element.

Definition at line 397 of file xml_serializer_utils.cpp.

398 {
399 parent.setAttribute("name", platform.getName());
400
401 const XmlElement motion_elem = parent.addChild("motionpath");
402 serializeMotionPath(*platform.getMotionPath(), motion_elem);
403
404 serializeRotation(*platform.getRotationPath(), parent);
405
406 for (const auto& tx : world.getTransmitters())
407 {
408 if (tx->getPlatform() == &platform)
409 {
410 if (tx->getAttached() != nullptr)
411 {
412 serializeMonostatic(*tx, *dynamic_cast<const radar::Receiver*>(tx->getAttached()), parent);
413 }
414 else
415 {
416 serializeTransmitter(*tx, parent);
417 }
418 }
419 }
420
421 for (const auto& rx : world.getReceivers())
422 {
423 if (rx->getPlatform() == &platform && (rx->getAttached() == nullptr))
424 {
425 serializeReceiver(*rx, parent);
426 }
427 }
428
429 for (const auto& target : world.getTargets())
430 {
431 if (target->getPlatform() == &platform)
432 {
433 serializeTarget(*target, parent);
434 }
435 }
436 }
math::Path * getMotionPath() const noexcept
Gets the motion path of the platform.
Definition platform.h:60
const std::string & getName() const noexcept
Gets the name of the platform.
Definition platform.h:90
math::RotationPath * getRotationPath() const noexcept
Gets the rotation path of the platform.
Definition platform.h:67
Manages radar signal reception and response processing.
Definition receiver.h:37
void serializeMotionPath(const math::Path &path, const XmlElement &parent)
Serializes a motion path into a parent XML element.
void serializeReceiver(const radar::Receiver &rx, const XmlElement &parent)
Serializes a receiver into a parent XML element.
void serializeMonostatic(const radar::Transmitter &tx, const radar::Receiver &rx, const XmlElement &parent)
Serializes a monostatic radar setup containing both a transmitter and receiver.
void serializeRotation(const math::RotationPath &rotPath, const XmlElement &parent)
Serializes a rotation path into a parent XML element.
void serializeTarget(const radar::Target &target, const XmlElement &parent)
Serializes a target into a parent XML element.

References XmlElement::addChild(), radar::Platform::getMotionPath(), radar::Platform::getName(), core::World::getReceivers(), radar::Platform::getRotationPath(), core::World::getTargets(), core::World::getTransmitters(), serializeMonostatic(), serializeMotionPath(), serializeReceiver(), serializeRotation(), serializeTarget(), serializeTransmitter(), and XmlElement::setAttribute().

Referenced by serial::world_to_xml_string().

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

◆ serializeReceiver()

void serial::xml_serializer_utils::serializeReceiver ( const radar::Receiver rx,
const XmlElement parent 
)

Serializes a receiver into a parent XML element.

Parameters
rxThe receiver object to serialize.
parentThe parent XML element.

Definition at line 309 of file xml_serializer_utils.cpp.

310 {
311 const XmlElement rx_elem = parent.addChild("receiver");
312 rx_elem.setAttribute("name", rx.getName());
313 rx_elem.setAttribute("antenna", (rx.getAntenna() != nullptr) ? rx.getAntenna()->getName() : "");
314 rx_elem.setAttribute("timing", rx.getTiming() ? rx.getTiming()->getName() : "");
317
319 {
320 const XmlElement mode_elem = rx_elem.addChild("pulsed_mode");
321 addChildWithNumber(mode_elem, "prf", rx.getWindowPrf());
322 addChildWithNumber(mode_elem, "window_skip", rx.getWindowSkip());
323 addChildWithNumber(mode_elem, "window_length", rx.getWindowLength());
324 }
325 else
326 {
327 (void)rx_elem.addChild("cw_mode");
328 }
329
330 if (rx.getNoiseTemperature() > 0)
331 {
332 addChildWithNumber(rx_elem, "noise_temp", rx.getNoiseTemperature());
333 }
334
335 serializeSchedule(rx.getSchedule(), rx_elem);
336 }
const std::vector< SchedulePeriod > & getSchedule() const noexcept
Retrieves the list of active reception periods.
Definition receiver.h:277
OperationMode getMode() const noexcept
Gets the operational mode of the receiver.
Definition receiver.h:160
RealType getWindowPrf() const noexcept
Retrieves the pulse repetition frequency (PRF) of the radar window.
Definition receiver.h:116

References XmlElement::addChild(), addChildWithNumber(), radar::Receiver::checkFlag(), radar::Receiver::FLAG_NODIRECT, radar::Receiver::FLAG_NOPROPLOSS, radar::Radar::getAntenna(), radar::Receiver::getMode(), antenna::Antenna::getName(), radar::Object::getName(), radar::Receiver::getNoiseTemperature(), radar::Receiver::getSchedule(), radar::Radar::getTiming(), radar::Receiver::getWindowLength(), radar::Receiver::getWindowPrf(), radar::Receiver::getWindowSkip(), radar::PULSED_MODE, serializeSchedule(), XmlElement::setAttribute(), and setAttributeFromBool().

Referenced by serializePlatform().

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

◆ serializeRotation()

void serial::xml_serializer_utils::serializeRotation ( const math::RotationPath rotPath,
const XmlElement parent 
)

Serializes a rotation path into a parent XML element.

Parameters
rotPathThe rotation path object to serialize.
parentThe parent XML element.

Definition at line 231 of file xml_serializer_utils.cpp.

232 {
234 {
235 const XmlElement fixed_elem = parent.addChild("fixedrotation");
236 const auto start = rotPath.getStart();
237 const auto rate = rotPath.getRate();
238 const auto unit = params::rotationAngleUnit();
239
240 RealType start_az = rotation_angle_utils::internal_azimuth_to_external(start.azimuth, unit);
242 {
243 start_az = std::fmod(start_az + 360.0, 360.0);
244 }
245 const RealType start_el = rotation_angle_utils::internal_elevation_to_external(start.elevation, unit);
246 const RealType rate_az = rotation_angle_utils::internal_azimuth_rate_to_external(rate.azimuth, unit);
247 const RealType rate_el = rotation_angle_utils::internal_elevation_rate_to_external(rate.elevation, unit);
248
249 addChildWithNumber(fixed_elem, "startazimuth", start_az);
250 addChildWithNumber(fixed_elem, "startelevation", start_el);
251 addChildWithNumber(fixed_elem, "azimuthrate", rate_az);
252 addChildWithNumber(fixed_elem, "elevationrate", rate_el);
253 }
254 else
255 {
256 const XmlElement rot_elem = parent.addChild("rotationpath");
257 switch (rotPath.getType())
258 {
260 rot_elem.setAttribute("interpolation", "static");
261 break;
263 rot_elem.setAttribute("interpolation", "linear");
264 break;
266 rot_elem.setAttribute("interpolation", "cubic");
267 break;
268 default:
269 break;
270 }
271 const auto unit = params::rotationAngleUnit();
272 for (const auto& wp : rotPath.getCoords())
273 {
274 XmlElement wp_elem = rot_elem.addChild("rotationwaypoint");
275 RealType azimuth = rotation_angle_utils::internal_azimuth_to_external(wp.azimuth, unit);
277 {
278 azimuth = std::fmod(azimuth + 360.0, 360.0);
279 }
280 const RealType elevation = rotation_angle_utils::internal_elevation_to_external(wp.elevation, unit);
281 addChildWithNumber(wp_elem, "azimuth", azimuth);
282 addChildWithNumber(wp_elem, "elevation", elevation);
283 addChildWithNumber(wp_elem, "time", wp.t);
284 }
285 }
286 }
InterpType getType() const noexcept
Gets the interpolation type of the path.
RotationCoord getRate() const noexcept
Gets the rate of change for the rotation.
RotationCoord getStart() const noexcept
Gets the starting rotation coordinate.
double RealType
Type for real numbers.
Definition config.h:27
RotationAngleUnit rotationAngleUnit() noexcept
Definition parameters.h:286

References XmlElement::addChild(), addChildWithNumber(), params::Degrees, math::RotationPath::getCoords(), math::RotationPath::getRate(), math::RotationPath::getStart(), math::RotationPath::getType(), serial::rotation_angle_utils::internal_azimuth_rate_to_external(), serial::rotation_angle_utils::internal_azimuth_to_external(), serial::rotation_angle_utils::internal_elevation_rate_to_external(), serial::rotation_angle_utils::internal_elevation_to_external(), math::RotationPath::INTERP_CONSTANT, math::RotationPath::INTERP_CUBIC, math::RotationPath::INTERP_LINEAR, math::RotationPath::INTERP_STATIC, params::rotationAngleUnit(), and XmlElement::setAttribute().

Referenced by serializePlatform().

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

◆ serializeSchedule()

void serial::xml_serializer_utils::serializeSchedule ( const std::vector< radar::SchedulePeriod > &  schedule,
const XmlElement parent 
)

Serializes a schedule (active periods) into a parent XML element.

Parameters
scheduleThe schedule periods to serialize.
parentThe parent XML element.

Definition at line 37 of file xml_serializer_utils.cpp.

38 {
39 if (schedule.empty())
40 {
41 return;
42 }
43 const XmlElement sched_elem = parent.addChild("schedule");
44 for (const auto& period : schedule)
45 {
46 XmlElement p_elem = sched_elem.addChild("period");
47 p_elem.setAttribute("start", std::to_string(period.start));
48 p_elem.setAttribute("end", std::to_string(period.end));
49 }
50 }

References XmlElement::addChild(), and XmlElement::setAttribute().

Referenced by serializeMonostatic(), serializeReceiver(), and serializeTransmitter().

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

◆ serializeTarget()

void serial::xml_serializer_utils::serializeTarget ( const radar::Target target,
const XmlElement parent 
)

Serializes a target into a parent XML element.

Parameters
targetThe target object to serialize.
parentThe parent XML element.

Definition at line 368 of file xml_serializer_utils.cpp.

369 {
370 const XmlElement target_elem = parent.addChild("target");
371 target_elem.setAttribute("name", target.getName());
372
373 const XmlElement rcs_elem = target_elem.addChild("rcs");
374 if (const auto* iso = dynamic_cast<const radar::IsoTarget*>(&target))
375 {
376 rcs_elem.setAttribute("type", "isotropic");
377 addChildWithNumber(rcs_elem, "value", iso->getConstRcs());
378 }
379 else if (const auto* file_target = dynamic_cast<const radar::FileTarget*>(&target))
380 {
381 rcs_elem.setAttribute("type", "file");
382 rcs_elem.setAttribute("filename", file_target->getFilename());
383 }
384
385 // Serialize fluctuation model if present
386 if (const auto* model = target.getFluctuationModel())
387 {
388 if (const auto* chi = dynamic_cast<const radar::RcsChiSquare*>(model))
389 {
390 XmlElement model_elem = target_elem.addChild("model");
391 model_elem.setAttribute("type", "chisquare");
392 addChildWithNumber(model_elem, "k", chi->getK());
393 }
394 }
395 }
File-based radar target.
Definition target.h:226
Isotropic radar target.
Definition target.h:188
Chi-square distributed RCS model.
Definition target.h:82
const RcsModel * getFluctuationModel() const
Gets the RCS fluctuation model.
Definition target.h:167

References XmlElement::addChild(), addChildWithNumber(), radar::Target::getFluctuationModel(), radar::Object::getName(), and XmlElement::setAttribute().

Referenced by serializePlatform().

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

◆ serializeTiming()

void serial::xml_serializer_utils::serializeTiming ( const timing::PrototypeTiming timing,
const XmlElement parent 
)

Serializes a timing object into a parent XML element.

Parameters
timingThe timing object to serialize.
parentThe parent XML element.

Definition at line 125 of file xml_serializer_utils.cpp.

126 {
127 parent.setAttribute("name", timing.getName());
128 setAttributeFromBool(parent, "synconpulse", timing.getSyncOnPulse());
129
130 addChildWithNumber(parent, "frequency", timing.getFrequency());
131 if (const auto val = timing.getFreqOffset())
132 {
133 addChildWithNumber(parent, "freq_offset", *val);
134 }
135 if (const auto val = timing.getRandomFreqOffsetStdev())
136 {
137 addChildWithNumber(parent, "random_freq_offset_stdev", *val);
138 }
139 if (const auto val = timing.getPhaseOffset())
140 {
141 addChildWithNumber(parent, "phase_offset", *val);
142 }
143 if (const auto val = timing.getRandomPhaseOffsetStdev())
144 {
145 addChildWithNumber(parent, "random_phase_offset_stdev", *val);
146 }
147
148 std::vector<RealType> alphas, weights;
149 timing.copyAlphas(alphas, weights);
150 for (size_t i = 0; i < alphas.size(); ++i)
151 {
152 XmlElement entry = parent.addChild("noise_entry");
153 addChildWithNumber(entry, "alpha", alphas[i]);
154 addChildWithNumber(entry, "weight", weights[i]);
155 }
156 }

References XmlElement::addChild(), addChildWithNumber(), XmlElement::setAttribute(), and setAttributeFromBool().

Referenced by serial::world_to_xml_string().

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

◆ serializeTransmitter()

void serial::xml_serializer_utils::serializeTransmitter ( const radar::Transmitter tx,
const XmlElement parent 
)

Serializes a transmitter into a parent XML element.

Parameters
txThe transmitter object to serialize.
parentThe parent XML element.

Definition at line 288 of file xml_serializer_utils.cpp.

289 {
290 const XmlElement tx_elem = parent.addChild("transmitter");
291 tx_elem.setAttribute("name", tx.getName());
292 tx_elem.setAttribute("waveform", (tx.getSignal() != nullptr) ? tx.getSignal()->getName() : "");
293 tx_elem.setAttribute("antenna", (tx.getAntenna() != nullptr) ? tx.getAntenna()->getName() : "");
294 tx_elem.setAttribute("timing", tx.getTiming() ? tx.getTiming()->getName() : "");
295
297 {
298 const XmlElement mode_elem = tx_elem.addChild("pulsed_mode");
299 addChildWithNumber(mode_elem, "prf", tx.getPrf());
300 }
301 else
302 {
303 (void)tx_elem.addChild("cw_mode");
304 }
305
306 serializeSchedule(tx.getSchedule(), tx_elem);
307 }

References XmlElement::addChild(), addChildWithNumber(), radar::Radar::getAntenna(), radar::Transmitter::getMode(), antenna::Antenna::getName(), radar::Object::getName(), fers_signal::RadarSignal::getName(), radar::Transmitter::getPrf(), radar::Transmitter::getSchedule(), radar::Transmitter::getSignal(), radar::Radar::getTiming(), radar::PULSED_MODE, serializeSchedule(), and XmlElement::setAttribute().

Referenced by serializePlatform().

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

◆ serializeWaveform()

void serial::xml_serializer_utils::serializeWaveform ( const fers_signal::RadarSignal waveform,
const XmlElement parent 
)

Serializes a waveform into a parent XML element.

Parameters
waveformThe waveform object to serialize.
parentThe parent XML element.

Definition at line 106 of file xml_serializer_utils.cpp.

107 {
108 parent.setAttribute("name", waveform.getName());
109
110 addChildWithNumber(parent, "power", waveform.getPower());
111 addChildWithNumber(parent, "carrier_frequency", waveform.getCarrier());
112
113 if (dynamic_cast<const fers_signal::CwSignal*>(waveform.getSignal()) != nullptr)
114 {
115 (void)parent.addChild("cw"); // Empty element
116 }
117 else
118 {
119 const XmlElement pulsed_file = parent.addChild("pulsed_from_file");
120 const auto& filename = waveform.getFilename();
121 pulsed_file.setAttribute("filename", filename.value_or(""));
122 }
123 }
const std::optional< std::string > & getFilename() const noexcept
Gets the filename associated with this signal.
RealType getCarrier() const noexcept
Gets the carrier frequency of the radar signal.
const Signal * getSignal() const noexcept
Gets the underlying signal object.
RealType getPower() const noexcept
Gets the power of the radar signal.

References XmlElement::addChild(), addChildWithNumber(), fers_signal::RadarSignal::getCarrier(), fers_signal::RadarSignal::getFilename(), fers_signal::RadarSignal::getName(), fers_signal::RadarSignal::getPower(), fers_signal::RadarSignal::getSignal(), and XmlElement::setAttribute().

Referenced by serial::world_to_xml_string().

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

◆ setAttributeFromBool()

void serial::xml_serializer_utils::setAttributeFromBool ( const XmlElement element,
const std::string &  name,
bool  value 
)

Sets a boolean attribute on an XML element.

Parameters
elementThe XML element to modify.
nameThe name of the attribute to set.
valueThe boolean value to set.

Definition at line 32 of file xml_serializer_utils.cpp.

33 {
34 element.setAttribute(name, value ? "true" : "false");
35 }

References XmlElement::setAttribute().

Referenced by serializeMonostatic(), serializeReceiver(), and serializeTiming().

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