1+ /*
2+ *
3+ * Copyright 2021-2024 Software Radio Systems Limited
4+ *
5+ * By using this file, you agree to the terms and conditions set
6+ * forth in the LICENSE file which can be found at the top level of
7+ * the distribution.
8+ *
9+ */
10+
11+ #pragma once
12+
13+ #include " srsran/ran/slot_point.h"
14+ #include " srsran/ran/subcarrier_spacing.h"
15+
16+ namespace srsran {
17+
18+ // / Measurement Gap Repetition Period (MGRP) in msec, as per TS 38.331.
19+ enum class meas_gap_repetition_period : uint8_t { ms20 = 20 , ms40 = 40 , ms80 = 80 , ms160 = 160 };
20+
21+ // / Measurement Gap Length (MGL) in msec, as per TS 38.331.
22+ enum class meas_gap_length : uint8_t { ms1dot5, ms3, ms3dot5, ms4, ms5dot5, ms6 };
23+
24+ // / Configuration of a Measurement Gap as per TS 38.331, GapConfig.
25+ struct meas_gap_config {
26+ // / Gap offset of the pattern in msec. Value must be between 0 and gap repetition period - 1.
27+ unsigned offset;
28+ // / Measurement Gap Length (MGL).
29+ meas_gap_length mgl;
30+ // / Measurement Gap Repetition Period (MGRP).
31+ meas_gap_repetition_period mgrp;
32+ };
33+
34+ // / Convert measurement gap length into a float in milliseconds.
35+ inline unsigned meas_gap_length_to_msec (meas_gap_length len)
36+ {
37+ constexpr static std::array<float , 6 > vals{1.5 , 3 , 3.5 , 4 , 5.5 , 6 };
38+ return vals[static_cast <unsigned >(len)];
39+ }
40+
41+ // / Determines whether a slot is inside the measurement gap.
42+ inline bool is_inside_meas_gap (const meas_gap_config& gap, slot_point sl)
43+ {
44+ unsigned period_slots = static_cast <uint8_t >(gap.mgrp ) * sl.nof_slots_per_subframe ();
45+ unsigned length_slots = meas_gap_length_to_msec (gap.mgl ) * sl.nof_slots_per_subframe ();
46+ unsigned slot_mod = sl.to_uint () % period_slots;
47+ return slot_mod <= length_slots;
48+ }
49+
50+ } // namespace srsran
0 commit comments