Agora  1.2.0
Agora project
radio.h
Go to the documentation of this file.
1 
6 #ifndef RADIO_H_
7 #define RADIO_H_
8 
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 #include "config.h"
14 
15 class Radio {
16  public:
18  //EndReceive is set when the samples returned are the last of a contiguous set
19  enum RxFlags { kRxFlagNone = 0, kEndReceive = 1 };
21  static std::unique_ptr<Radio> Create(RadioType type);
22 
24  virtual ~Radio();
25 
26  //Accessors
27  inline size_t Id() const { return id_; }
28  inline const std::string& SerialNumber() const { return serial_number_; }
29  inline bool HwFramer() const { return hw_framer_; }
30 
31  virtual void Init(const Config* cfg, size_t id, const std::string& serial,
32  const std::vector<size_t>& enabled_channels,
33  bool hw_framer) = 0;
34  virtual void Setup(const std::vector<double>& tx_gains,
35  const std::vector<double>& rx_gains) = 0;
36 
37  // Start?
38  virtual void Activate(
39  Radio::ActivationTypes type = Radio::ActivationTypes::kActivate,
40  long long act_time_ns = 0, size_t samples = 0) = 0;
41  // Stop?
42  virtual void Deactivate() = 0;
43  virtual void Close() = 0;
44  virtual void Flush() = 0;
45 
46  virtual int Tx(const void* const* tx_buffs, size_t tx_size, TxFlags tx_flags,
47  long long& tx_time_ns) = 0;
48 
49  virtual int Rx(std::vector<std::vector<std::complex<int16_t>>>& rx_data,
50  size_t rx_size, RxFlags& out_flags, long long& rx_time_ns) = 0;
51 
52  virtual int Rx(std::vector<std::vector<std::complex<int16_t>>*>& rx_buffs,
53  size_t rx_size, RxFlags& out_flags, long long& rx_time_ns) = 0;
54 
55  virtual int Rx(std::vector<void*>& rx_locs, size_t rx_size,
56  RxFlags& out_flags, long long& rx_time_ns) = 0;
57 
58  inline virtual void ConfigureTddModeBs([[maybe_unused]] bool is_ref_radio) {}
59  inline virtual void ConfigureTddModeUe() {}
60  inline virtual void ClearSyncDelay() {}
61  inline virtual void PrintSettings() const {}
62  inline virtual void Trigger() {}
63  inline virtual void ReadSensor() const {}
64 
65  inline virtual void SetTimeAtTrigger(long long time_ns = 0) { (void)time_ns; }
66  inline virtual long long GetTimeNs() { return 0; }
67 
68  //For digital cal
69  inline virtual void AdjustDelay([[maybe_unused]] const std::string& delay) {}
70 
71  inline const std::vector<size_t>& EnabledChannels() const {
72  return enabled_channels_;
73  }
74 
75  protected:
76  Radio();
77  //Should remove this.
78  const Config* cfg_{nullptr};
79 
80  private:
81  size_t id_{0};
82  std::string serial_number_;
83  std::vector<size_t> enabled_channels_;
84  bool hw_framer_{false};
85 };
86 
87 #endif // RADIO_H_
Radio::Init
virtual void Init(const Config *cfg, size_t id, const std::string &serial, const std::vector< size_t > &enabled_channels, bool hw_framer)=0
Definition: radio.cc:46
radio.h
Defination file for the Radio class.
Radio::Id
size_t Id() const
Definition: radio.h:27
Radio::EnabledChannels
const std::vector< size_t > & EnabledChannels() const
Definition: radio.h:71
Radio::ConfigureTddModeUe
virtual void ConfigureTddModeUe()
Definition: radio.h:59
RadioDataPlane::kLinuxSocket
@ kLinuxSocket
Definition: radio_data_plane.h:18
Radio::hw_framer_
bool hw_framer_
Definition: radio.h:84
Radio::Rx
virtual int Rx(std::vector< std::vector< std::complex< int16_t >>> &rx_data, size_t rx_size, RxFlags &out_flags, long long &rx_time_ns)=0
Radio::PrintSettings
virtual void PrintSettings() const
Definition: radio.h:61
RadioDataPlane::kSoapyStream
@ kSoapyStream
Definition: radio_data_plane.h:18
Radio::Flush
virtual void Flush()=0
Radio::serial_number_
std::string serial_number_
Definition: radio.h:82
Radio::ActivationTypes
ActivationTypes
Definition: radio.h:23
Radio::kEndReceive
@ kEndReceive
Definition: radio.h:19
AGORA_LOG_ERROR
#define AGORA_LOG_ERROR(...)
Definition: logger.h:39
Radio::ReadSensor
virtual void ReadSensor() const
Definition: radio.h:63
Radio::HwFramer
bool HwFramer() const
Definition: radio.h:29
AGORA_LOG_TRACE
#define AGORA_LOG_TRACE(...)
Definition: logger.h:92
Radio::SerialNumber
const std::string & SerialNumber() const
Definition: radio.h:28
Radio::~Radio
virtual ~Radio()
Definition: radio.cc:30
Radio::kTxFlagNone
@ kTxFlagNone
Definition: radio.h:20
Radio::kActivateWaitTrigger
@ kActivateWaitTrigger
Definition: radio.h:23
Radio::kActivate
@ kActivate
Definition: radio.h:23
Radio::kEndTransmit
@ kEndTransmit
Definition: radio.h:20
Radio::Close
virtual void Close()=0
Definition: radio.cc:35
Radio
Definition: radio.h:15
Radio::TxFlags
TxFlags
Definition: radio.h:20
Radio::AdjustDelay
virtual void AdjustDelay([[maybe_unused]] const std::string &delay)
Definition: radio.h:69
Radio::RadioType
RadioType
Definition: radio.h:17
radio_soapysdr.h
Defination file for the RadioSoapySdr class.
Radio::SetTimeAtTrigger
virtual void SetTimeAtTrigger(long long time_ns=0)
Definition: radio.h:65
Radio::Create
static std::unique_ptr< Radio > Create(RadioType type)
Definition: radio.cc:11
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::detail::void
j template void())
Definition: json.hpp:4744
Radio::Radio
Radio()
Definition: radio.cc:26
Radio::cfg_
const Config * cfg_
Definition: radio.h:78
Radio::Setup
virtual void Setup(const std::vector< double > &tx_gains, const std::vector< double > &rx_gains)=0
Definition: radio.cc:57
Radio::RxFlags
RxFlags
Definition: radio.h:19
Radio::ClearSyncDelay
virtual void ClearSyncDelay()
Definition: radio.h:60
Radio::id_
size_t id_
Definition: radio.h:81
Radio::GetTimeNs
virtual long long GetTimeNs()
Definition: radio.h:66
Radio::kSoapySdrStream
@ kSoapySdrStream
Definition: radio.h:17
Radio::kRxFlagNone
@ kRxFlagNone
Definition: radio.h:19
Config
Definition: config.h:26
Radio::kTxWaitTrigger
@ kTxWaitTrigger
Definition: radio.h:20
Radio::kSoapySdrSocket
@ kSoapySdrSocket
Definition: radio.h:17
Radio::ConfigureTddModeBs
virtual void ConfigureTddModeBs([[maybe_unused]] bool is_ref_radio)
Definition: radio.h:58
config.h
Declaration file for the configuration class which importants json configuration values into class va...
id
uint16_t id
Definition: eth_common.h:65
rx_data
case QPSK rx_data
Definition: generate_data.m:160
Radio::Activate
virtual void Activate(Radio::ActivationTypes type=Radio::ActivationTypes::kActivate, long long act_time_ns=0, size_t samples=0)=0
Definition: radio.cc:62
Radio::Deactivate
virtual void Deactivate()=0
Definition: radio.cc:71
Radio::enabled_channels_
std::vector< size_t > enabled_channels_
Definition: radio.h:83
Radio::Tx
virtual int Tx(const void *const *tx_buffs, size_t tx_size, TxFlags tx_flags, long long &tx_time_ns)=0
Radio::Trigger
virtual void Trigger()
Definition: radio.h:62
fmt::v8::detail::type
type
Definition: core.h:1131