5G-MAG Reference Tools - MBMS Modem
CasFrameProcessor.h
Go to the documentation of this file.
1 // 5G-MAG Reference Tools
2 // MBMS Modem Process
3 //
4 // Copyright (C) 2021 Klaus Kühnhammer (Österreichische Rundfunksender GmbH & Co KG)
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Affero General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Affero General Public License for more details.
15 //
16 // You should have received a copy of the GNU Affero General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 //
19 
20 #pragma once
21 
22 #include <cstdint>
23 #include <string>
24 #include <vector>
25 #include <thread>
26 #include "srsran/srsran.h"
27 #include "srsran/rlc/rlc.h"
28 #include "Phy.h"
29 #include "RestHandler.h"
30 #include <libconfig.h++>
31 
38  public:
47  CasFrameProcessor(const libconfig::Config& cfg, Phy& phy, srsran::rlc& rlc, RestHandler& rest, unsigned rx_channels)
48  : _cfg(cfg)
49  , _phy(phy)
50  , _rest(rest)
51  , _rlc(rlc)
52  , _rx_channels(rx_channels)
53  {}
54 
58  virtual ~CasFrameProcessor();
59 
64  bool init();
65 
72  bool process(uint32_t tti);
73 
79  void set_cell(srsran_cell_t cell);
80 
84  cf_t** get_rx_buffer_and_lock() { _mutex.lock(); return _signal_buffer_rx; }
85 
90 
96  void unlock() { _mutex.unlock(); }
97 
98  void lock() { _mutex.lock(); }
99 
104  std::vector<uint8_t> ce_values();
105 
109  std::vector<uint8_t> pdsch_data();
110 
114  float cinr_db() { return _ue_dl.chest_res.snr_db; }
115 
116 
117 
118 
119  /********************** Getters and setters for chest_cfg params for rt-wui **********************************/
120 
124  void inline set_filter_order(uint8_t filter_order) { _ue_dl_cfg.chest_cfg.filter_coef[0]= filter_order; };
125  uint8_t inline get_filter_order() { return static_cast<uint8_t>(_ue_dl_cfg.chest_cfg.filter_coef[0]); };
126 
130  void inline set_filter_coef(float filter_coef) { _ue_dl_cfg.chest_cfg.filter_coef[1] = filter_coef; };
131  float inline get_filter_coef() { return static_cast<float>(_ue_dl_cfg.chest_cfg.filter_coef[1]); };
132 
136  void inline set_filter_type(srsran_chest_filter_t filter_type) { _ue_dl_cfg.chest_cfg.filter_type = filter_type; };
137  uint8_t inline get_filter_type() { return static_cast<uint8_t>(_ue_dl_cfg.chest_cfg.filter_type); };
138 
142  void inline set_noise_alg(srsran_chest_dl_noise_alg_t noise_alg) { _ue_dl_cfg.chest_cfg.noise_alg = noise_alg; };
143  uint8_t inline get_noise_alg() { return static_cast<uint8_t>(_ue_dl_cfg.chest_cfg.noise_alg); };
144 
148  void inline set_sync_error(bool enable) { _ue_dl_cfg.chest_cfg.sync_error_enable = enable; };
149  bool inline get_sync_error() { return static_cast<uint8_t>(_ue_dl_cfg.chest_cfg.sync_error_enable); };
150 
154  void inline set_estimator_alg(srsran_chest_dl_estimator_alg_t estimator_alg) { _ue_dl_cfg.chest_cfg.estimator_alg = estimator_alg; };
155  uint8_t inline get_estimator_alg() { return static_cast<uint8_t>(_ue_dl_cfg.chest_cfg.estimator_alg); };
156 
160  void inline set_cfo_estimate(bool enable) { _ue_dl_cfg.chest_cfg.cfo_estimate_enable = enable; };
161  bool inline get_cfo_estimate() { return static_cast<uint8_t>(_ue_dl_cfg.chest_cfg.cfo_estimate_enable); };
162 
166  void inline set_evm_meas(bool enable) { _ue_dl_cfg.cfg.pdsch.meas_evm_en = enable; };
167  bool inline get_evm_meas() { return static_cast<uint8_t>(_ue_dl_cfg.cfg.pdsch.meas_evm_en); };
168 
172  bool inline is_started() { return _started; }
173 
174  private:
175  const libconfig::Config& _cfg;
176  srsran::rlc& _rlc;
179 
180  cf_t* _signal_buffer_rx[SRSRAN_MAX_PORTS] = {};
182 
183  srsran_softbuffer_rx_t _softbuffer;
184  uint8_t* _data[SRSRAN_MAX_CODEWORDS];
185 
186  srsran_ue_dl_t _ue_dl = {};
187  srsran_ue_dl_cfg_t _ue_dl_cfg = {};
188  srsran_dl_sf_cfg_t _sf_cfg = {};
189 
190  srsran_cell_t _cell;
191  std::mutex _mutex;
192  unsigned _rx_channels;
193 
194  bool _started = 0;
195 };
Frame processor for CAS subframes.
srsran_softbuffer_rx_t _softbuffer
cf_t ** get_rx_buffer_and_lock()
Get a handle of the signal buffer to store samples for processing in.
srsran_ue_dl_cfg_t _ue_dl_cfg
std::vector< uint8_t > ce_values()
Get the CE values (time domain) for displaying the spectrum of the received signal.
uint8_t * _data[SRSRAN_MAX_CODEWORDS]
void set_noise_alg(srsran_chest_dl_noise_alg_t noise_alg)
Set the noise estimation algorithm used in the channel estimation stage.
void set_sync_error(bool enable)
Enables the estimation os synchronization error.
void set_cfo_estimate(bool enable)
Enables the estimation of the carrier frequency offset.
bool is_started()
Returns if the CasFrameProcessor is started or not.
virtual ~CasFrameProcessor()
Default destructor.
uint32_t _signal_buffer_max_samples
srsran_ue_dl_t _ue_dl
bool init()
Initialize signal- and softbuffers, init all underlying components.
void set_estimator_alg(srsran_chest_dl_estimator_alg_t estimator_alg)
Set the method to estimate the channel estimates of the complete resource grid from the reference sym...
srsran_dl_sf_cfg_t _sf_cfg
void set_filter_coef(float filter_coef)
Set the coef for gauss filtering.
void set_cell(srsran_cell_t cell)
Set the parameters for the cell (Nof PRB, etc).
std::vector< uint8_t > pdsch_data()
Get the constellation diagram data (I/Q data of the subcarriers after CE)
uint32_t rx_buffer_size()
Size of the signal buffer.
void unlock()
Unlock the processor.
void set_filter_order(uint8_t filter_order)
Set the filter order used to filter the channel estimates.
void set_filter_type(srsran_chest_filter_t filter_type)
Set the filter type for chest.
cf_t * _signal_buffer_rx[SRSRAN_MAX_PORTS]
const libconfig::Config & _cfg
void set_evm_meas(bool enable)
Enables the computation of the error vector magnitude on the PDSCH.
float cinr_db()
Get the CINR estimate (in dB)
bool process(uint32_t tti)
Process the sample data in the signal buffer.
CasFrameProcessor(const libconfig::Config &cfg, Phy &phy, srsran::rlc &rlc, RestHandler &rest, unsigned rx_channels)
Default constructor.
The PHY component.
Definition: Phy.h:42
The RESTful API handler.
Definition: RestHandler.h:47
static Config cfg
Global configuration object.
Definition: main.cpp:172