|
| 1 | +/* |
| 2 | + * |
| 3 | + * Copyright 2021-2025 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/radio/radio_base.h" |
| 14 | +#include <cstdint> |
| 15 | +#include <optional> |
| 16 | + |
| 17 | +namespace srsran { |
| 18 | + |
| 19 | +/// Radio event sources. |
| 20 | +enum class radio_event_source { |
| 21 | + /// Default event value meaning it is not set. |
| 22 | + UNDEFINED = 0, |
| 23 | + /// The event is from a receiver chain. |
| 24 | + RECEIVE, |
| 25 | + /// The event is from a transmit chain. |
| 26 | + TRANSMIT, |
| 27 | + /// The event cause is not listed from the above chain. |
| 28 | + OTHER |
| 29 | +}; |
| 30 | + |
| 31 | +/// Translate an event_source to a string. |
| 32 | +inline const char* to_string(radio_event_source value) |
| 33 | +{ |
| 34 | + switch (value) { |
| 35 | + case radio_event_source::UNDEFINED: |
| 36 | + return "undefined"; |
| 37 | + case radio_event_source::RECEIVE: |
| 38 | + return "rx"; |
| 39 | + case radio_event_source::TRANSMIT: |
| 40 | + return "tx"; |
| 41 | + case radio_event_source::OTHER: |
| 42 | + return "other"; |
| 43 | + } |
| 44 | + return ""; |
| 45 | +} |
| 46 | + |
| 47 | +/// Radio event types. |
| 48 | +enum class radio_event_type { |
| 49 | + /// Default event value meaning it is not set. |
| 50 | + UNDEFINED = 0, |
| 51 | + /// Indicates an start of a burst. |
| 52 | + START_OF_BURST, |
| 53 | + /// Indicates the end of a burst. |
| 54 | + END_OF_BURST, |
| 55 | + /// The transmit data arrives late to the baseband unit. |
| 56 | + LATE, |
| 57 | + /// The transmit data is not generated fast enough. |
| 58 | + UNDERFLOW, |
| 59 | + /// The receive buffers are not read fast enough. |
| 60 | + OVERFLOW, |
| 61 | + /// The event cause is not listed from the above causes. |
| 62 | + OTHER |
| 63 | +}; |
| 64 | + |
| 65 | +/// Translate an event_type to a string. |
| 66 | +inline const char* to_string(radio_event_type value) |
| 67 | +{ |
| 68 | + switch (value) { |
| 69 | + case radio_event_type::UNDEFINED: |
| 70 | + return "undefined"; |
| 71 | + case radio_event_type::START_OF_BURST: |
| 72 | + return "start-of-burst"; |
| 73 | + case radio_event_type::END_OF_BURST: |
| 74 | + return "end-of-burst"; |
| 75 | + case radio_event_type::LATE: |
| 76 | + return "late"; |
| 77 | + case radio_event_type::UNDERFLOW: |
| 78 | + return "underflow"; |
| 79 | + case radio_event_type::OVERFLOW: |
| 80 | + return "overflow"; |
| 81 | + case radio_event_type::OTHER: |
| 82 | + return "other"; |
| 83 | + } |
| 84 | + return ""; |
| 85 | +} |
| 86 | + |
| 87 | +/// \brief Describes a baseband unit event notifier interface. |
| 88 | +/// |
| 89 | +/// This class describes an interface used by the baseband unit to notify events related with its operation. |
| 90 | +class radio_event_notifier : public radio_base |
| 91 | +{ |
| 92 | +public: |
| 93 | + /// Describes a radio notification. |
| 94 | + struct event_description { |
| 95 | + /// Indicates the stream identifier that triggered the event if it is available. |
| 96 | + std::optional<unsigned> stream_id; |
| 97 | + /// Indicates the channel identifier that triggered the event if it is available. |
| 98 | + std::optional<unsigned> channel_id; |
| 99 | + /// Indicates the source of the event. |
| 100 | + radio_event_source source = radio_event_source::UNDEFINED; |
| 101 | + /// Indicates the event type. |
| 102 | + radio_event_type type = radio_event_type::UNDEFINED; |
| 103 | + /// Indicates the timestamp of this event if it is available. |
| 104 | + std::optional<uint64_t> timestamp; |
| 105 | + }; |
| 106 | + |
| 107 | + /// Notifies a new event that affected the real-time operation of the radio. |
| 108 | + virtual void on_radio_rt_event(const event_description& description) = 0; |
| 109 | +}; |
| 110 | + |
| 111 | +} // namespace srsran |
0 commit comments