Agora  1.2.0
Agora project
radio_data_plane.h
Go to the documentation of this file.
1 
5 #ifndef RADIO_DATA_PLANE_H_
6 #define RADIO_DATA_PLANE_H_
7 
8 #include <complex>
9 #include <vector>
10 
11 #include "SoapySDR/Device.hpp"
12 #include "config.h"
13 #include "radio.h"
14 
15 //Abstract class defination for the Radio data plane connection
17  public:
19  static std::unique_ptr<RadioDataPlane> Create(DataPlaneType type);
20 
22 
23  virtual ~RadioDataPlane();
24  RadioDataPlane(RadioDataPlane&&) noexcept = delete;
25  explicit RadioDataPlane(const RadioDataPlane&) = delete;
26 
27  virtual void Init(Radio* radio, const Config* cfg, bool hw_framer) = 0;
28  virtual void Setup() = 0;
29  virtual void Activate(
30  Radio::ActivationTypes type = Radio::ActivationTypes::kActivate,
31  long long act_time_ns = 0, size_t samples = 0) = 0;
32  virtual void Deactivate() = 0;
33  virtual void Close() = 0;
34 
35  virtual int Rx(std::vector<std::vector<std::complex<int16_t>>>& rx_data,
36  size_t rx_size, Radio::RxFlags& out_flags,
37  long long& rx_time_ns) = 0;
38  virtual int Rx(std::vector<std::vector<std::complex<int16_t>>*>& rx_buffs,
39  size_t rx_size, Radio::RxFlags& out_flags,
40  long long& rx_time_ns) = 0;
41  virtual int Rx(std::vector<void*>& rx_locations, size_t rx_size,
42  Radio::RxFlags& out_flags, long long& rx_time_ns) = 0;
43 
44  virtual void Flush() = 0;
45 
46  protected:
48 
49  virtual void Setup(const SoapySDR::Kwargs& args);
50  inline const Config* Configuration() const { return cfg_; }
51  inline const Mode& CheckMode() const { return mode_; }
52  inline const bool& HwFramer() const { return hw_framer_; }
53 
54  Radio* radio_{nullptr};
55  SoapySDR::Stream* remote_stream_{nullptr};
56 
57  private:
59  //Should try to remove cfg_
60  const Config* cfg_;
61  bool hw_framer_;
62 };
63 #endif // RADIO_DATA_PLANE_H_
RadioConfig::cfg_
Config * cfg_
Definition: radio_lib.h:84
RadioConfig::AdjustCalibrationGains
static void AdjustCalibrationGains(std::vector< Radio * > &rx_devs, Radio *tx_dev, size_t channel, double fft_bin, bool plot=false)
Definition: radio_calibrate_analog.cc:123
radio.h
Defination file for the Radio class.
RadioDataPlane::Configuration
const Config * Configuration() const
Definition: radio_data_plane.h:50
RadioDataPlane::DataPlaneType
DataPlaneType
Definition: radio_data_plane.h:18
RadioDataPlane::radio_
Radio * radio_
Definition: radio_data_plane.h:54
Radio::Id
size_t Id() const
Definition: radio.h:27
RadioConfig::CalibrateSampleOffsetDownlink
bool CalibrateSampleOffsetDownlink(size_t max_attempts)
Definition: radio_calibrate_digital.cc:395
GetRadioOffsets
static std::vector< int > GetRadioOffsets(size_t num_channels, size_t num_radios, size_t offset_check_channel, const std::vector< int > &offsets)
Definition: radio_calibrate_digital.cc:271
CheckTone
static size_t CheckTone(size_t channel, std::vector< Radio * > &rx_devs, std::vector< float > tone_levels, double fft_bin)
Definition: radio_calibrate_analog.cc:18
RadioDataPlane::mode_
Mode mode_
Definition: radio_data_plane.h:58
datatype_conversion.h
matplotlibcpp::plot
bool plot(const std::vector< Numeric > &x, const std::vector< Numeric > &y, const std::map< std::string, std::string > &keywords)
Definition: matplotlibcpp.h:442
RadioSoapySdr::ResetTxGains
void ResetTxGains()
Definition: radio_soapysdr.cc:722
Config::Rate
double Rate() const
Definition: config.h:58
kRefChannel
static constexpr size_t kRefChannel
Definition: radio_calibrate_digital.cc:21
kVerboseCalibration
static constexpr bool kVerboseCalibration
Definition: radio_calibrate_digital.cc:20
Config::NumChannels
size_t NumChannels() const
Definition: config.h:98
RadioSoapySdr::SnoopSamples
std::vector< std::complex< float > > SnoopSamples(size_t channel, size_t read_size)
Definition: radio_soapysdr.cc:756
ConvertShortToFloat
static void ConvertShortToFloat(const short *in_buf, float *out_buf, size_t n_elems)
Produces outputs -1->+0.999.
Definition: datatype_conversion.h:41
CommsLib::FindPilotSeq
static size_t FindPilotSeq(const std::vector< std::complex< float >> &iq, const std::vector< std::complex< float >> &pilot, size_t seq_len)
Definition: comms-lib.cc:32
RadioSoapySdr::InitCalRx
void InitCalRx(size_t channel, double center_freq)
Definition: radio_soapysdr.cc:713
RadioConfig::CalibrateSampleOffset
void CalibrateSampleOffset()
Definition: radio_calibrate_digital.cc:341
RadioConfig::calib_meas_num_
size_t calib_meas_num_
Definition: radio_lib.h:94
RadioSoapySdr::SetTxCalGain
void SetTxCalGain(size_t channel)
Definition: radio_soapysdr.cc:742
RadioDataPlane::kLinuxSocket
@ kLinuxSocket
Definition: radio_data_plane.h:18
kPrintCalibrationMats
static constexpr bool kPrintCalibrationMats
Definition: radio_calibrate_digital.cc:19
Config::CpLen
size_t CpLen() const
Definition: config.h:46
matplotlibcpp::save
void save(const std::string &filename, const int dpi=0)
Definition: matplotlibcpp.h:2625
kToneTargetLevel
static constexpr double kToneTargetLevel
Definition: radio_calibrate_analog.cc:16
RadioConfig::init_calib_ul_
Table< arma::cx_float > init_calib_ul_
Definition: radio_lib.h:89
kMaxSampleRxTimeSec
static constexpr float kMaxSampleRxTimeSec
Definition: radio_calibrate_digital.cc:22
RadioDataPlane::RadioDataPlane
RadioDataPlane()
RadioDataPlane::kSoapyStream
@ kSoapyStream
Definition: radio_data_plane.h:18
RadioDataPlane::Activate
virtual void Activate(Radio::ActivationTypes type=Radio::ActivationTypes::kActivate, long long act_time_ns=0, size_t samples=0)=0
Definition: radio_data_plane.cc:57
Config::OfdmRxZeroPrefixCalUl
size_t OfdmRxZeroPrefixCalUl() const
Definition: config.h:219
RadioConfig::InitialCalib
bool InitialCalib()
Definition: radio_calibrate_digital.cc:438
radio_data_plane_socket.h
Declaration file for the RadioDataPlaneSocket Class.
Config::BsAntNum
size_t BsAntNum() const
Definition: config.h:35
RadioDataPlane::kModeUninit
@ kModeUninit
Definition: radio_data_plane.h:21
RadioConfig::Go
void Go()
Definition: radio_lib.cc:293
Radio::ActivationTypes
ActivationTypes
Definition: radio.h:23
AdjustRxGains
static void AdjustRxGains(size_t channel, std::vector< Radio * > &rx_devs, std::vector< float > tone_levels, const std::string &gain_stage, double min_setting, double max_setting)
Definition: radio_calibrate_analog.cc:88
RadioSoapySdr::SoapyDevice
SoapySDR::Device * SoapyDevice() const
Definition: radio_soapysdr.h:77
matplotlibcpp::legend
void legend()
Definition: matplotlibcpp.h:1944
AGORA_LOG_ERROR
#define AGORA_LOG_ERROR(...)
Definition: logger.h:39
spdlog::details::os::now
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT
Definition: os-inl.h:71
Config::RefRadio
size_t RefRadio(size_t id) const
Definition: config.h:101
RadioDataPlane::Deactivate
virtual void Deactivate()=0
Definition: radio_data_plane.cc:91
matplotlibcpp::figure_size
void figure_size(size_t w, size_t h)
Definition: matplotlibcpp.h:1922
RadioConfig::CalibrateSampleOffsetUplink
bool CalibrateSampleOffsetUplink(size_t max_attempts)
Definition: radio_calibrate_digital.cc:349
Config::RadioRfFreq
double RadioRfFreq() const
Definition: config.h:61
RadioDataPlane::remote_stream_
SoapySDR::Stream * remote_stream_
Definition: radio_data_plane.h:55
AGORA_LOG_TRACE
#define AGORA_LOG_TRACE(...)
Definition: logger.h:92
RadioConfig::FindTimeOffset
bool FindTimeOffset(const std::vector< std::vector< std::complex< int16_t >>> &rx_mat, std::vector< int > &offset)
Definition: radio_calibrate_digital.cc:210
Radio::SerialNumber
const std::string & SerialNumber() const
Definition: radio.h:28
CheckSnr
static void CheckSnr(size_t offset, const std::vector< std::vector< std::complex< int16_t >>> &check_buff, const Config *cfg)
Definition: radio_calibrate_digital.cc:297
data_stop
data_stop
Definition: inspect_agora_results.m:18
Radio::kActivateWaitTrigger
@ kActivateWaitTrigger
Definition: radio.h:23
Config::OfdmRxZeroPrefixCalDl
size_t OfdmRxZeroPrefixCalDl() const
Definition: config.h:225
Config::PilotCf32
const std::vector< std::complex< float > > & PilotCf32() const
Definition: config.h:341
matplotlibcpp
Definition: matplotlibcpp.h:43
radio_lib.h
Declaration file for the RadioConfig class.
snr
snr
Definition: inspect_agora_results.m:118
fmt::v8::detail::abs
constexpr std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1488
RadioSoapySdr::SetFreqRf
void SetFreqRf(size_t channel, double freq)
Definition: radio_soapysdr.cc:796
RadioDataPlane::kModeActive
@ kModeActive
Definition: radio_data_plane.h:21
Config::OfdmDataNum
size_t OfdmDataNum() const
Definition: config.h:47
Config::ExternalRefNode
bool ExternalRefNode(size_t id) const
Definition: config.h:110
Radio
Definition: radio.h:15
RadioSoapySdr::InitRefTx
void InitRefTx(size_t channel, double freq)
Definition: radio_soapysdr.cc:708
RadioConfig::radios_
std::vector< std::unique_ptr< Radio > > radios_
Definition: radio_lib.h:86
simd_types.h
Aligned types for SIMD compatibility.
radio_soapysdr.h
Defination file for the RadioSoapySdr class.
kIQImbalancePlot
static constexpr bool kIQImbalancePlot
Definition: radio_calibrate_analog.cc:15
data_start
data_start
Definition: inspect_agora_results.m:17
i
for i
Definition: generate_data.m:107
Config::OfdmCaNum
size_t OfdmCaNum() const
Definition: config.h:45
matplotlibcpp::xlim
void xlim(Numeric left, Numeric right)
Definition: matplotlibcpp.h:2048
RadioDataPlane::kModeDeactive
@ kModeDeactive
Definition: radio_data_plane.h:21
fmt::v8::align::center
@ center
Definition: core.h:2021
Catch::cout
std::ostream & cout()
u
Plot Rx waveform for u
Definition: inspect_single_frame.m:108
comms-lib.h
Communications Library: a) Generate pilot/preamble sequences b) OFDM modulation.
rx_mat
Rx data rx_mat
Definition: generate_data.m:115
CommsLib::HannWindowFunction
static std::vector< float > HannWindowFunction(size_t fft_size)
Definition: comms-lib.cc:266
Utils::Cint16ToCfloat32
static std::vector< std::complex< float > > Cint16ToCfloat32(const std::vector< std::complex< int16_t >> &in)
Definition: utils.cc:264
SETTLE_TIME_MS
#define SETTLE_TIME_MS
Definition: symbols.h:21
RadioSoapySdr::SetIQBalance
void SetIQBalance(int direction, size_t channel, std::complex< double > i_qcorr)
Definition: radio_soapysdr.cc:782
start
end start
Definition: inspect_agora_results.m:95
RadioDataPlane::Create
static std::unique_ptr< RadioDataPlane > Create(DataPlaneType type)
Definition: radio_data_plane.cc:16
RadioConfig::init_calib_dl_
Table< arma::cx_float > init_calib_dl_
Definition: radio_lib.h:90
kMaxArraySampleOffset
static constexpr size_t kMaxArraySampleOffset
Definition: radio_calibrate_digital.cc:17
CommsLib::ComputeOfdmSnr
static float ComputeOfdmSnr(const std::vector< std::complex< float >> &data_t, size_t data_start_index, size_t data_stop_index)
Definition: comms-lib.cc:608
CommsLib::FFT
static MKL_LONG FFT(std::vector< std::complex< float >> &in_out, int fft_size)
Definition: comms-lib.cc:460
CommsLib::MagnitudeFft
static std::vector< float > MagnitudeFft(std::vector< std::complex< float >> const &samps, std::vector< float > const &win, size_t fft_size)
Definition: comms-lib.cc:237
RadioConfig::AdjustDelays
void AdjustDelays(const std::vector< int > &ch0_offsets)
Definition: radio_calibrate_digital.cc:251
s
s
Definition: simulate_performance.m:3
Config::OfdmDataStart
size_t OfdmDataStart() const
Definition: config.h:48
RadioDataPlane::CheckMode
const Mode & CheckMode() const
Definition: radio_data_plane.h:51
RadioConfig::SetIqBalance
static void SetIqBalance(Radio *dev, int direction, size_t channel, int gcorr, int iqcorr)
Definition: radio_calibrate_analog.cc:181
RadioConfig::DciqMinimize
static void DciqMinimize(Radio *target_dev, Radio *ref_dev, int direction, size_t channel, double rx_center_tone, double tx_center_tone)
Definition: radio_calibrate_analog.cc:192
PlotTones
static void PlotTones(size_t channel, std::vector< Radio * > &rx_devs, std::vector< float > tone_levels, double fft_bin)
Definition: radio_calibrate_analog.cc:43
matplotlibcpp.h
n
n
Definition: simulate_performance.m:1
RadioDataPlane::cfg_
const Config * cfg_
Definition: radio_data_plane.h:60
AGORA_LOG_SYMBOL
#define AGORA_LOG_SYMBOL(...)
Definition: logger.h:82
fmt::v8::detail::first
const T & first(const T &value, const Tail &...)
Definition: compile.h:178
RadioDataPlane
Definition: radio_data_plane.h:16
Config
Definition: config.h:26
AGORA_LOG_INFO
#define AGORA_LOG_INFO(...)
Definition: logger.h:62
Config::RefAnt
size_t RefAnt(size_t id) const
Definition: config.h:100
std
Definition: json.hpp:5213
extract_version.m
m
Definition: extract_version.py:13
RadioConfig::TxArrayToRef
auto TxArrayToRef(const std::vector< std::complex< int16_t >> &tx_vec)
Definition: radio_calibrate_digital.cc:24
RadioDataPlane::kModeShutdown
@ kModeShutdown
Definition: radio_data_plane.h:21
RadioDataPlane::Close
virtual void Close()=0
Definition: radio_data_plane.cc:113
RtAssert
static void RtAssert(bool condition, const char *throw_str)
Definition: utils.h:104
zeros
N_SC, NUM_UE, NUM_UE zeros()
RadioDataPlane::Mode
Mode
Definition: radio_data_plane.h:21
kDownlinkMaxDiffOffset
static constexpr size_t kDownlinkMaxDiffOffset
Definition: radio_calibrate_digital.cc:394
AGORA_LOG_WARN
#define AGORA_LOG_WARN(...)
Definition: logger.h:53
RadioDataPlane::Init
virtual void Init(Radio *radio, const Config *cfg, bool hw_framer)=0
Definition: radio_data_plane.cc:36
RadioDataPlane::Rx
virtual int Rx(std::vector< std::vector< std::complex< int16_t >>> &rx_data, size_t rx_size, Radio::RxFlags &out_flags, long long &rx_time_ns)=0
noise
noise
Definition: generate_data_dl.m:131
RadioConfig::TxRefToArray
auto TxRefToArray(const std::vector< std::complex< int16_t >> &tx_vec)
Definition: radio_calibrate_digital.cc:118
to_string
std::string to_string() const
Definition: eth_common.h:64
RadioDataPlane::~RadioDataPlane
virtual ~RadioDataPlane()
Definition: radio_data_plane.cc:34
CommsLib::MeasureTone
static float MeasureTone(std::vector< std::complex< float >> const &samps, std::vector< float > const &win, double win_gain, double fft_bin, size_t fft_size, const size_t delta=10)
Definition: comms-lib.cc:317
config.h
Declaration file for the configuration class which importants json configuration values into class va...
radio_data_plane_soapy.h
Declaration file for the RadioDataPlaneSoapy Class.
rx_data
case QPSK rx_data
Definition: generate_data.m:160
CommsLib::WindowFunctionPower
static double WindowFunctionPower(std::vector< float > const &win)
Definition: comms-lib.cc:285
matplotlibcpp::ylim
void ylim(Numeric left, Numeric right)
Definition: matplotlibcpp.h:2029
kReciprocalCalibPlot
static constexpr bool kReciprocalCalibPlot
Definition: radio_calibrate_digital.cc:18
RadioDataPlane::hw_framer_
bool hw_framer_
Definition: radio_data_plane.h:61
RadioDataPlane::Setup
virtual void Setup()=0
Definition: radio_data_plane.cc:153
matplotlibcpp::title
void title(const std::string &titlestr, const std::map< std::string, std::string > &keywords={})
Definition: matplotlibcpp.h:2296
Config::NumRadios
size_t NumRadios() const
Definition: config.h:95
RadioDataPlane::Flush
virtual void Flush()=0
RadioSoapySdr
Definition: radio_soapysdr.h:16
Config::OfdmDataStop
size_t OfdmDataStop() const
Definition: config.h:50
Config::PilotCi16
std::vector< std::complex< int16_t > > & PilotCi16()
Definition: config.h:377
MeasureCorrection
static void MeasureCorrection(RadioSoapySdr *ref, size_t channel, size_t num_samples, size_t rx_center_tone, size_t tx_center_tone, const std::vector< float > &window, double window_gain)
Definition: radio_calibrate_analog.cc:105
radio_data_plane.h
Declaration file for the RadioDataPlane Class.
fmt::v8::detail::type
type
Definition: core.h:1131
RadioDataPlane::HwFramer
const bool & HwFramer() const
Definition: radio_data_plane.h:52
Config::BfAntNum
size_t BfAntNum() const
Definition: config.h:39
RadioConfig::DciqCalibrationProc
void DciqCalibrationProc(size_t channel)
Definition: radio_calibrate_analog.cc:330