FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
vita49_types.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2026-present FERS Contributors (see AUTHORS.md).
4//
5// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
6
7#pragma once
8
9#include <cstddef>
10#include <cstdint>
11#include <limits>
12#include <span>
13#include <string>
14#include <vector>
15
16#include "core/config.h"
18
19namespace serial::vita49
20{
21 constexpr std::uint16_t kDefaultMaxUdpPayloadBytes = 1400;
22 constexpr std::uint32_t kSignalDataFixedBytes = 32;
23
24 // Internal placeholder until FERS obtains/finalizes an assigned VRT profile
25 // identifier. The OUI is deliberately private and must be documented in the ICD.
26 constexpr std::uint32_t kFersInternalOui = 0xFA5253u;
27 constexpr std::uint16_t kFersInformationClassIqStream = 0x0001u;
28 constexpr std::uint16_t kFersPacketClassV1 = 0x0001u;
29 constexpr std::uint64_t kFersVrtIqClassId = (static_cast<std::uint64_t>(kFersInternalOui) << 40u) |
30 (static_cast<std::uint64_t>(kFersInformationClassIqStream) << 24u) |
31 (static_cast<std::uint64_t>(kFersPacketClassV1) << 8u) | 0x01u;
32
33 enum class PacketType : std::uint8_t
34 {
36 Context = 0x4,
37 };
38
39 enum class IntegerTimestampMode : std::uint8_t
40 {
41 None = 0,
42 Utc = 1,
43 Gps = 2,
44 Other = 3,
45 };
46
47 enum class FractionalTimestampMode : std::uint8_t
48 {
49 None = 0,
50 SampleCount = 1,
52 FreeRunning = 3,
53 };
54
55 enum TrailerIndicator : std::uint32_t
56 {
63 TrailerValidData = 1u << 14u,
65 TrailerOverRange = 1u << 12u,
66 TrailerSampleLoss = 1u << 11u,
67 };
68
69 enum ContextIndicator0 : std::uint32_t
70 {
72 Cif0PayloadFormat = 1u << 30u,
73 Cif0SampleRate = 1u << 29u,
75 Cif0IfOffset = 1u << 27u,
76 Cif0Bandwidth = 1u << 26u,
77 Cif0ReferenceLevel = 1u << 25u,
79 Cif0AsciiMetadata = 1u << 23u,
80 };
81
85
86 enum ContextFlags : std::uint32_t // NOLINT(performance-enum-size)
87 {
96 };
97
98 struct Timestamp
99 {
100 std::uint32_t integer_seconds = 0;
101 std::uint64_t fractional_picoseconds = 0;
102 };
103
105 {
106 std::uint32_t stream_id = 0;
109 std::uint8_t packet_count = 0;
110 std::vector<std::int16_t> iq_interleaved;
111 std::uint32_t trailer = 0;
112 };
113
140
142 {
143 std::vector<std::uint8_t> bytes;
144 std::uint32_t stream_id = 0;
145 std::uint64_t sample_count = 0;
147 bool data_packet = false;
148 bool context_packet = false;
149 bool over_range = false;
150 bool sample_loss = false;
152 };
153
155 {
156 std::vector<SerializedPacket> packets;
157 std::uint64_t samples_emitted = 0;
158 std::uint64_t over_range_count = 0;
159 };
160
162 {
163 std::vector<std::uint8_t> bytes;
164 std::uint64_t clipped_sample_count = 0;
165 };
166
168 {
169 public:
170 [[nodiscard]] std::uint8_t next() noexcept;
171 void setNext(std::uint8_t packet_count) noexcept;
172 [[nodiscard]] std::uint8_t peek() const noexcept;
173
174 private:
175 std::uint8_t _next = 0;
176 };
177
178 [[nodiscard]] std::uint32_t makeHeader(PacketType type, bool class_id_present, bool trailer_present,
180 std::uint8_t packet_count, std::uint16_t packet_size_words) noexcept;
181
182 [[nodiscard]] Timestamp timestampFromEpoch(std::uint64_t epoch_unix_nanoseconds, RealType sample_time_seconds);
183 [[nodiscard]] std::uint32_t makeTrailer(bool valid_data, bool calibrated_time, bool reference_lock, bool over_range,
184 bool sample_loss) noexcept;
185 [[nodiscard]] std::uint32_t makeContextStateIndicators(bool valid_data, bool calibrated_time, bool reference_lock,
186 bool over_range, bool sample_loss) noexcept;
189}
void setNext(std::uint8_t packet_count) noexcept
std::uint8_t peek() const noexcept
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
std::size_t maxComplexSamplesPerSignalPacket(const std::uint16_t max_udp_payload_bytes)
constexpr std::uint32_t kFersContextCif0
constexpr std::uint32_t kSignalDataFixedBytes
constexpr std::uint32_t kFersInternalOui
Timestamp timestampFromEpoch(const std::uint64_t epoch_unix_nanoseconds, const RealType sample_time_seconds)
std::uint32_t makeTrailer(const bool valid_data, const bool calibrated_time, const bool reference_lock, const bool over_range, const bool sample_loss) noexcept
@ ContextFlagFmcwMetadataPresent
@ ContextFlagCwMetadataPresent
@ ContextFlagPulsedMetadataPresent
constexpr std::uint16_t kFersPacketClassV1
constexpr std::uint64_t kFersVrtIqClassId
@ TrailerEnableCalibratedTime
constexpr std::uint16_t kDefaultMaxUdpPayloadBytes
std::uint32_t makeContextStateIndicators(const bool valid_data, const bool calibrated_time, const bool reference_lock, const bool over_range, const bool sample_loss) noexcept
std::uint32_t makeHeader(const PacketType type, const bool class_id_present, const bool trailer_present, const IntegerTimestampMode tsi, const FractionalTimestampMode tsf, const std::uint8_t packet_count, const std::uint16_t packet_size_words) noexcept
constexpr std::uint16_t kFersInformationClassIqStream
std::uint64_t makeComplexInt16PayloadFormat() noexcept
uint64_t SimId
64-bit Unique Simulation ID.
Definition sim_id.h:18
math::Vec3 max
core::ReceiverStreamDescriptor::CoordinateContext coordinate
core::ReceiverStreamDescriptor::PulsedContext pulsed
core::ReceiverStreamDescriptor::FmcwContext fmcw
core::ReceiverStreamDescriptor::PlatformState initial_platform_state
core::ReceiverStreamDescriptor::CwContext cw
std::vector< SerializedPacket > packets
std::vector< std::uint8_t > bytes
std::vector< std::int16_t > iq_interleaved
std::uint64_t fractional_picoseconds
std::uint32_t integer_seconds