lte_phy_scope.c 37.3 KB
Newer Older
ghaddab's avatar
ghaddab committed
1
/*******************************************************************************
2
    OpenAirInterface
ghaddab's avatar
ghaddab committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
17 18
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
ghaddab's avatar
ghaddab committed
19 20 21 22 23
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
ghaddab's avatar
ghaddab committed
27 28

 *******************************************************************************/
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
/* Form definition file generated by fdesign */

#include <stdlib.h>
#include "lte_phy_scope.h"

#define TPUT_WINDOW_LENGTH 100
int otg_enabled;

FL_COLOR rx_antenna_colors[4] = {FL_RED,FL_BLUE,FL_GREEN,FL_YELLOW};

float tput_time_enb[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
float tput_enb[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
float tput_ue_max[NUMBER_OF_UE_MAX] = {0};

45 46 47 48 49 50 51 52 53 54 55 56
static void ia_receiver_on_off( FL_OBJECT *button, long arg)
{

  if (fl_get_button(button)) {
    fl_set_object_label(button, "IA Receiver ON");
    openair_daq_vars.use_ia_receiver = 1;
    fl_set_object_color(button, FL_GREEN, FL_GREEN);
  } else {
    fl_set_object_label(button, "IA Receiver OFF");
    openair_daq_vars.use_ia_receiver = 0;
    fl_set_object_color(button, FL_RED, FL_RED);
  }
57 58
}

59 60
static void dl_traffic_on_off( FL_OBJECT *button, long arg)
{
61

62 63 64 65 66 67 68 69 70
  if (fl_get_button(button)) {
    fl_set_object_label(button, "DL Traffic ON");
    otg_enabled = 1;
    fl_set_object_color(button, FL_GREEN, FL_GREEN);
  } else {
    fl_set_object_label(button, "DL Traffic OFF");
    otg_enabled = 0;
    fl_set_object_color(button, FL_RED, FL_RED);
  }
71 72
}

73 74 75 76 77 78 79
FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void )
{

  FL_OBJECT *obj;
  FD_lte_phy_scope_enb *fdui = fl_malloc( sizeof *fdui );

  // Define form
80
  fdui->lte_phy_scope_enb = fl_bgn_form( FL_NO_BOX, 800, 800 );
81 82

  // This the whole UI box
83
  obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 800, "" );
84 85 86 87 88 89 90
  fl_set_object_color( obj, FL_BLACK, FL_BLACK );

  // Received signal
  fdui->rxsig_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 20, 370, 100, "Received Signal (Time-Domain, dB)" );
  fl_set_object_boxtype( fdui->rxsig_t, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->rxsig_t, FL_BLACK, FL_RED );
  fl_set_object_lcolor( fdui->rxsig_t, FL_WHITE ); // Label color
91
  fl_set_xyplot_ybounds(fdui->rxsig_t,10,70);
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120

  // Time-domain channel response
  fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "Channel Impulse Response (samples, abs)" );
  fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED );
  fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color

  // Frequency-domain channel response
  fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency  Response (RE, dB)" );
  fl_set_object_boxtype( fdui->chest_f, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->chest_f, FL_BLACK, FL_RED );
  fl_set_object_lcolor( fdui->chest_f, FL_WHITE ); // Label color
  fl_set_xyplot_ybounds( fdui->chest_f,30,70);

  // LLR of PUSCH
  fdui->pusch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 260, 500, 200, "PUSCH Log-Likelihood Ratios (LLR, mag)" );
  fl_set_object_boxtype( fdui->pusch_llr, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->pusch_llr, FL_BLACK, FL_YELLOW );
  fl_set_object_lcolor( fdui->pusch_llr, FL_WHITE ); // Label color
  fl_set_xyplot_symbolsize( fdui->pusch_llr,2);

  // I/Q PUSCH comp
  fdui->pusch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 260, 240, 200, "PUSCH I/Q of MF Output" );
  fl_set_object_boxtype( fdui->pusch_comp, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->pusch_comp, FL_BLACK, FL_YELLOW );
  fl_set_object_lcolor( fdui->pusch_comp, FL_WHITE ); // Label color
  fl_set_xyplot_symbolsize( fdui->pusch_comp,2);
  fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR);

121
  // I/Q PUCCH comp (format 1)
122
  fdui->pucch_comp1 = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 480, 240, 100, "PUCCH1 Energy (SR)" );
123 124 125 126 127 128 129 130
  fl_set_object_boxtype( fdui->pucch_comp1, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->pucch_comp1, FL_BLACK, FL_YELLOW );
  fl_set_object_lcolor( fdui->pucch_comp1, FL_WHITE ); // Label color
  fl_set_xyplot_symbolsize( fdui->pucch_comp1,2);
  //  fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR);

  // I/Q PUCCH comp (fromat 1a/b)
  fdui->pucch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 600, 240, 100, "PUCCH I/Q of MF Output" );
131 132 133 134 135 136
  fl_set_object_boxtype( fdui->pucch_comp, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->pucch_comp, FL_BLACK, FL_YELLOW );
  fl_set_object_lcolor( fdui->pucch_comp, FL_WHITE ); // Label color
  fl_set_xyplot_symbolsize( fdui->pucch_comp,2);
  //  fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR);

137 138 139 140 141 142 143
  // Throughput on PUSCH
  fdui->pusch_tput = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 480, 500, 100, "PUSCH Throughput [frame]/[kbit/s]" );
  fl_set_object_boxtype( fdui->pusch_tput, FL_EMBOSSED_BOX );
  fl_set_object_color( fdui->pusch_tput, FL_BLACK, FL_WHITE );
  fl_set_object_lcolor( fdui->pusch_tput, FL_WHITE ); // Label color

  // Generic eNB Button
144
  fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 20, 600, 240, 40, "" );
145 146 147 148 149 150 151 152 153 154 155 156
  fl_set_object_lalign(fdui->button_0, FL_ALIGN_CENTER );
  fl_set_button(fdui->button_0,0);
  otg_enabled = 0;
  fl_set_object_label(fdui->button_0, "DL Traffic OFF");
  fl_set_object_color(fdui->button_0, FL_RED, FL_RED);
  fl_set_object_callback(fdui->button_0, dl_traffic_on_off, 0 );

  fl_end_form( );
  fdui->lte_phy_scope_enb->fdui = fdui;

  return fdui;
}
157

158 159 160 161 162
void phy_scope_eNB(FD_lte_phy_scope_enb *form,
                   PHY_VARS_eNB *phy_vars_enb,
                   int UE_id)
{
  int eNB_id = 0;
163
  int i,i2,arx,atx,ind,k;
164 165 166 167 168 169 170 171 172
  LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_enb->lte_frame_parms;
  int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti;
  uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
  uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE
  int16_t **rxsig_t;
  int16_t **chest_t;
  int16_t **chest_f;
  int16_t *pusch_llr;
  int16_t *pusch_comp;
173
  int32_t *pucch1_comp;
174
  int32_t *pucch1_thres;
175
  int32_t *pucch1ab_comp;
176 177 178
  float Re,Im,ymax;
  float *llr, *bit;
  float I[nsymb_ce*2], Q[nsymb_ce*2];
179
  float I_pucch[10240],Q_pucch[10240],A_pucch[10240],B_pucch[10240],C_pucch[10240];
180 181 182 183
  float rxsig_t_dB[nb_antennas_rx][FRAME_LENGTH_COMPLEX_SAMPLES];
  float chest_t_abs[nb_antennas_rx][frame_parms->ofdm_symbol_size];
  float *chest_f_abs;
  float time[FRAME_LENGTH_COMPLEX_SAMPLES];
184
  float time2[2048];
185 186 187 188 189 190 191 192 193 194 195
  float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx];
  int frame = phy_vars_enb->proc[0].frame_tx;
  uint32_t total_dlsch_bitrate = phy_vars_enb->total_dlsch_bitrate;
  int coded_bits_per_codeword = 0;
  uint8_t harq_pid; // in TDD config 3 it is sf-2, i.e., can be 0,1,2
  int mcs = 0;

  // choose max MCS to compute coded_bits_per_codeword
  if (phy_vars_enb->ulsch_eNB[UE_id]!=NULL) {
    for (harq_pid=0; harq_pid<3; harq_pid++) {
      mcs = cmax(phy_vars_enb->ulsch_eNB[UE_id]->harq_processes[harq_pid]->mcs,mcs);
196
    }
197
  }
198

199
  coded_bits_per_codeword = frame_parms->N_RB_UL*12*get_Qm(mcs)*frame_parms->symbols_per_tti;
200

201 202 203
  chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float));
  llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero
  bit = malloc(coded_bits_per_codeword*sizeof(float));
204

205 206 207 208 209
  rxsig_t = (int16_t**) phy_vars_enb->lte_eNB_common_vars.rxdata[eNB_id];
  chest_t = (int16_t**) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id];
  chest_f = (int16_t**) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->drs_ch_estimates[eNB_id];
  pusch_llr = (int16_t*) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->llr;
  pusch_comp = (int16_t*) phy_vars_enb->lte_eNB_pusch_vars[UE_id]->rxdataF_comp[eNB_id][0];
210
  pucch1_comp = (int32_t*) phy_vars_enb->pucch1_stats[UE_id];
211
  pucch1_thres = (int32_t*) phy_vars_enb->pucch1_stats_thres[UE_id];
212
  pucch1ab_comp = (int32_t*) phy_vars_enb->pucch1ab_stats[UE_id];
213

214 215 216 217 218 219 220 221 222
  // Received signal in time domain of receive antenna 0
  if (rxsig_t != NULL) {
    if (rxsig_t[0] != NULL) {
      for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
        rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((rxsig_t[0][2*i])*(rxsig_t[0][2*i])+(rxsig_t[0][2*i+1])*(rxsig_t[0][2*i+1])));
        time[i] = (float) i;
      }

      fl_set_xyplot_data(form->rxsig_t,time,rxsig_t_dB[0],FRAME_LENGTH_COMPLEX_SAMPLES,"","","");
223 224
    }

225 226 227 228
    for (arx=1; arx<nb_antennas_rx; arx++) {
      if (rxsig_t[arx] != NULL) {
        for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
          rxsig_t_dB[arx][i] = 10*log10(1.0+(float) ((rxsig_t[arx][2*i])*(rxsig_t[arx][2*i])+(rxsig_t[arx][2*i+1])*(rxsig_t[arx][2*i+1])));
229 230
        }

231 232
        fl_add_xyplot_overlay(form->rxsig_t,arx,time,rxsig_t_dB[arx],FRAME_LENGTH_COMPLEX_SAMPLES,rx_antenna_colors[arx]);
      }
233
    }
234
  }
235

236
  // Channel Impulse Response
237 238
  if (chest_t != NULL) {
    ymax = 0;
239

240 241
    if (chest_t[0] !=NULL) {
      for (i=0; i<(frame_parms->ofdm_symbol_size); i++) {
242 243 244
	i2 = (i+(frame_parms->ofdm_symbol_size>>1))%frame_parms->ofdm_symbol_size;
	time2[i] = (float)(i-(frame_parms->ofdm_symbol_size>>1));
        chest_t_abs[0][i] = 10*log10((float) (1+chest_t[0][2*i2]*chest_t[0][2*i2]+chest_t[0][2*i2+1]*chest_t[0][2*i2+1]));
245

246 247 248
        if (chest_t_abs[0][i] > ymax)
          ymax = chest_t_abs[0][i];
      }
249

250
      fl_set_xyplot_data(form->chest_t,time2,chest_t_abs[0],(frame_parms->ofdm_symbol_size),"","","");
251 252
    }

253 254 255
    for (arx=1; arx<nb_antennas_rx; arx++) {
      if (chest_t[arx] !=NULL) {
        for (i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) {
256
          chest_t_abs[arx][i] = 10*log10((float) (1+chest_t[arx][2*i]*chest_t[arx][2*i]+chest_t[arx][2*i+1]*chest_t[arx][2*i+1]));
257
 
258 259
          if (chest_t_abs[arx][i] > ymax)
            ymax = chest_t_abs[arx][i];
260 261
        }

262 263 264
        fl_add_xyplot_overlay(form->chest_t,arx,time,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]);
        fl_set_xyplot_overlay_type(form->chest_t,arx,FL_DASHED_XYPLOT);
      }
265 266
    }

267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
    // Avoid flickering effect
    //        fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax);
    fl_set_xyplot_ybounds(form->chest_t,0,ymax);
  }

  // Channel Frequency Response
  if (chest_f != NULL) {
    ind = 0;

    for (atx=0; atx<nb_antennas_tx; atx++) {
      for (arx=0; arx<nb_antennas_rx; arx++) {
        if (chest_f[(atx<<1)+arx] != NULL) {
          for (k=0; k<nsymb_ce; k++) {
            freq[ind] = (float)ind;
            Re = (float)(chest_f[(atx<<1)+arx][(2*k)]);
            Im = (float)(chest_f[(atx<<1)+arx][(2*k)+1]);

            chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im));
            ind++;
          }
287
        }
288
      }
289 290
    }

291 292 293 294 295
    // tx antenna 0
    fl_set_xyplot_xbounds(form->chest_f,0,nb_antennas_rx*nb_antennas_tx*nsymb_ce);
    fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*frame_parms->symbols_per_tti,3);
    fl_set_xyplot_xgrid(form->chest_f,FL_GRID_MAJOR);
    fl_set_xyplot_data(form->chest_f,freq,chest_f_abs,nsymb_ce,"","","");
296

297 298
    for (arx=1; arx<nb_antennas_rx; arx++) {
      fl_add_xyplot_overlay(form->chest_f,1,&freq[arx*nsymb_ce],&chest_f_abs[arx*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]);
299
    }
300 301 302 303 304 305 306 307

    // other tx antennas
    if (nb_antennas_tx > 1) {
      if (nb_antennas_rx > 1) {
        for (atx=1; atx<nb_antennas_tx; atx++) {
          for (arx=0; arx<nb_antennas_rx; arx++) {
            fl_add_xyplot_overlay(form->chest_f,(atx<<1)+arx,&freq[((atx<<1)+arx)*nsymb_ce],&chest_f_abs[((atx<<1)+arx)*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]);
          }
308
        }
309 310 311 312 313
      } else { // 1 rx antenna
        atx=1;
        arx=0;
        fl_add_xyplot_overlay(form->chest_f,atx,&freq[atx*nsymb_ce],&chest_f_abs[atx*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]);
      }
314
    }
315 316 317 318 319 320 321
  }

  // PUSCH LLRs
  if (pusch_llr != NULL) {
    for (i=0; i<coded_bits_per_codeword; i++) {
      llr[i] = (float) pusch_llr[i];
      bit[i] = (float) i;
322 323
    }

324 325 326 327 328 329 330 331 332 333 334 335 336
    fl_set_xyplot_data(form->pusch_llr,bit,llr,coded_bits_per_codeword,"","","");
  }

  // PUSCH I/Q of MF Output
  if (pusch_comp!=NULL) {
    ind=0;

    for (k=0; k<frame_parms->symbols_per_tti; k++) {
      for (i=0; i<12*frame_parms->N_RB_UL; i++) {
        I[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i];
        Q[ind] = pusch_comp[(2*frame_parms->N_RB_UL*12*k)+2*i+1];
        ind++;
      }
337
    }
338 339 340 341

    fl_set_xyplot_data(form->pusch_comp,I,Q,ind,"","","");
  }

342 343 344
  // PUSCH I/Q of MF Output
  if (pucch1ab_comp!=NULL) {
    for (ind=0; ind<10240; ind++) {
345 346 347

      I_pucch[ind] = (float)pucch1ab_comp[2*(ind)];
      Q_pucch[ind] = (float)pucch1ab_comp[2*(ind)+1];
348 349
      A_pucch[ind] = 10*log10(pucch1_comp[ind]);
      B_pucch[ind] = ind;
350
      C_pucch[ind] = (float)pucch1_thres[ind]; 
351
    }
352 353
    fl_set_xyplot_data(form->pucch_comp,I_pucch,Q_pucch,10240,"","","");
    fl_set_xyplot_data(form->pucch_comp1,B_pucch,A_pucch,1024,"","","");
354
    fl_add_xyplot_overlay(form->pucch_comp1,1,B_pucch,C_pucch,1024,FL_RED);
355 356 357
    fl_set_xyplot_ybounds(form->pucch_comp,-5000,5000);
    fl_set_xyplot_xbounds(form->pucch_comp,-5000,5000);

358
    fl_set_xyplot_ybounds(form->pucch_comp1,20,80);
359
  }
360

361

362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
  // PUSCH Throughput
  memmove( tput_time_enb[UE_id], &tput_time_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) );
  memmove( tput_enb[UE_id], &tput_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) );

  tput_time_enb[UE_id][TPUT_WINDOW_LENGTH-1]  = (float) frame;
  tput_enb[UE_id][TPUT_WINDOW_LENGTH-1] = ((float) total_dlsch_bitrate)/1000.0;

  fl_set_xyplot_data(form->pusch_tput,tput_time_enb[UE_id],tput_enb[UE_id],TPUT_WINDOW_LENGTH,"","","");

  //    fl_get_xyplot_ybounds(form->pusch_tput,&ymin,&ymax);
  //    fl_set_xyplot_ybounds(form->pusch_tput,0,ymax);

  fl_check_forms();

  free(llr);
  free(bit);
  free(chest_f_abs);
379 380
}

381

382 383 384 385 386 387
FD_lte_phy_scope_ue *create_lte_phy_scope_ue( void ) {

    FL_OBJECT *obj;
    FD_lte_phy_scope_ue *fdui = fl_malloc( sizeof *fdui );
    
    // Define form
388
    fdui->lte_phy_scope_ue = fl_bgn_form( FL_NO_BOX, 800, 1000 );
389 390

    // This the whole UI box
391
    obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 1000, "" );
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
    fl_set_object_color( obj, FL_BLACK, FL_BLACK );

    // Received signal
    fdui->rxsig_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 20, 370, 100, "Received Signal (Time-Domain, dB)" );
    fl_set_object_boxtype( fdui->rxsig_t, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->rxsig_t, FL_BLACK, FL_RED );
    fl_set_object_lcolor( fdui->rxsig_t, FL_WHITE ); // Label color
    fl_set_xyplot_ybounds(fdui->rxsig_t,30,70);

    // Time-domain channel response
    fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "Channel Impulse Response (samples, abs)" );
    fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED );
    fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color

    // Frequency-domain channel response
    fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency Response (RE, dB)" );
    fl_set_object_boxtype( fdui->chest_f, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->chest_f, FL_BLACK, FL_RED );
    fl_set_object_lcolor( fdui->chest_f, FL_WHITE ); // Label color
    fl_set_xyplot_ybounds( fdui->chest_f,30,70);

414
    /*
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
    // LLR of PBCH
    fdui->pbch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 260, 500, 100, "PBCH Log-Likelihood Ratios (LLR, mag)" );
    fl_set_object_boxtype( fdui->pbch_llr, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pbch_llr, FL_BLACK, FL_GREEN );
    fl_set_object_lcolor( fdui->pbch_llr, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pbch_llr,2);    
    fl_set_xyplot_xgrid( fdui->pbch_llr,FL_GRID_MAJOR);
    fl_set_xyplot_xbounds( fdui->pbch_llr,0,1920);

    // I/Q PBCH comp
    fdui->pbch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 260, 240, 100, "PBCH I/Q of MF Output" );
    fl_set_object_boxtype( fdui->pbch_comp, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pbch_comp, FL_BLACK, FL_GREEN );
    fl_set_object_lcolor( fdui->pbch_comp, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pbch_comp,2);
    fl_set_xyplot_xbounds( fdui->pbch_comp,-100,100);
    fl_set_xyplot_ybounds( fdui->pbch_comp,-100,100);

    // LLR of PDCCH
    fdui->pdcch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 380, 500, 100, "PDCCH Log-Likelihood Ratios (LLR, mag)" );
    fl_set_object_boxtype( fdui->pdcch_llr, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pdcch_llr, FL_BLACK, FL_CYAN );
    fl_set_object_lcolor( fdui->pdcch_llr, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pdcch_llr,2);    

    // I/Q PDCCH comp
    fdui->pdcch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 380, 240, 100, "PDCCH I/Q of MF Output" );
    fl_set_object_boxtype( fdui->pdcch_comp, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pdcch_comp, FL_BLACK, FL_CYAN );
    fl_set_object_lcolor( fdui->pdcch_comp, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pdcch_comp,2);
    fl_set_xyplot_xgrid( fdui->pdcch_llr,FL_GRID_MAJOR);
447
    */
448

449
    int offset=240;
450
    // LLR of PDSCH
451
    fdui->pdsch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 500-offset, 500, 200, "PDSCH Log-Likelihood Ratios (LLR, mag)" );
452 453 454 455 456 457 458
    fl_set_object_boxtype( fdui->pdsch_llr, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pdsch_llr, FL_BLACK, FL_YELLOW );
    fl_set_object_lcolor( fdui->pdsch_llr, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pdsch_llr,2);    
    fl_set_xyplot_xgrid( fdui->pdsch_llr,FL_GRID_MAJOR);

    // I/Q PDSCH comp
459
    fdui->pdsch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 500-offset, 240, 200, "PDSCH I/Q of MF Output" );
460 461 462 463
    fl_set_object_boxtype( fdui->pdsch_comp, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pdsch_comp, FL_BLACK, FL_YELLOW );
    fl_set_object_lcolor( fdui->pdsch_comp, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pdsch_comp,2);
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480

    // LLR of PDSCH
    fdui->pdsch_llr1 = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 720-offset, 500, 200, "PDSCH Log-Likelihood Ratios (LLR, mag)" );
    fl_set_object_boxtype( fdui->pdsch_llr1, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pdsch_llr1, FL_BLACK, FL_YELLOW );
    fl_set_object_lcolor( fdui->pdsch_llr1, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pdsch_llr1,2);    
    fl_set_xyplot_xgrid( fdui->pdsch_llr1,FL_GRID_MAJOR);

    // I/Q PDSCH comp
    fdui->pdsch_comp1 = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 720-offset, 240, 200, "PDSCH I/Q of MF Output" );
    fl_set_object_boxtype( fdui->pdsch_comp1, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pdsch_comp1, FL_BLACK, FL_YELLOW );
    fl_set_object_lcolor( fdui->pdsch_comp1, FL_WHITE ); // Label color
    fl_set_xyplot_symbolsize( fdui->pdsch_comp1,2);

    /*    
481 482 483 484 485 486 487 488 489
    // Throughput on PDSCH
    fdui->pdsch_tput = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 720, 500, 100, "PDSCH Throughput [frame]/[kbit/s]" );
    fl_set_object_boxtype( fdui->pdsch_tput, FL_EMBOSSED_BOX );
    fl_set_object_color( fdui->pdsch_tput, FL_BLACK, FL_WHITE );
    fl_set_object_lcolor( fdui->pdsch_tput, FL_WHITE ); // Label color

    // Generic UE Button
    fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 540, 720, 240, 40, "" );
    fl_set_object_lalign(fdui->button_0, FL_ALIGN_CENTER );
490
    //openair_daq_vars.use_ia_receiver = 0;
491 492 493 494 495
    fl_set_button(fdui->button_0,0);
    fl_set_object_label(fdui->button_0, "IA Receiver OFF");
    fl_set_object_color(fdui->button_0, FL_RED, FL_RED);  
    fl_set_object_callback(fdui->button_0, ia_receiver_on_off, 0 );
    fl_hide_object(fdui->button_0);
496
    */
497 498 499 500 501 502

    fl_end_form( );
    fdui->lte_phy_scope_ue->fdui = fdui;

    return fdui;
}
503 504

void phy_scope_UE(FD_lte_phy_scope_ue *form,
505 506 507
                  PHY_VARS_UE *phy_vars_ue,
                  int eNB_id,
                  int UE_id,
gauthier's avatar
gauthier committed
508
                  uint8_t subframe){    
509 510 511
    int i,arx,atx,ind,k;
    LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->lte_frame_parms;
    int nsymb_ce = frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti;
gauthier's avatar
gauthier committed
512 513 514 515 516
    uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
    uint8_t nb_antennas_tx = frame_parms->nb_antennas_tx_eNB;
    int16_t **rxsig_t;
    int16_t **chest_t;
    int16_t **chest_f;
517 518 519
    int16_t *pdsch_llr,*pdsch_llr1;
    int16_t *pdsch_comp,*pdsch_comp1;
    int16_t *pdsch_mag0,*pdsch_mag1,*pdsch_magb0,*pdsch_magb1;
gauthier's avatar
gauthier committed
520 521 522 523
    int8_t *pdcch_llr;
    int16_t *pdcch_comp;
    int8_t *pbch_llr;
    int16_t *pbch_comp;
524 525
    float Re,Im,ymax=1;
    int num_pdcch_symbols=3;
526
    float *llr0, *bit0, *llr1, *bit1, *chest_f_abs, llr_pbch[1920], bit_pbch[1920], *llr_pdcch, *bit_pdcch;
527 528 529 530 531
    float *I, *Q;
    float rxsig_t_dB[nb_antennas_rx][FRAME_LENGTH_COMPLEX_SAMPLES];
    float **chest_t_abs;
    float time[FRAME_LENGTH_COMPLEX_SAMPLES];
    float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx];
532
    int frame = phy_vars_ue->frame_rx;
gauthier's avatar
gauthier committed
533
    uint32_t total_dlsch_bitrate = phy_vars_ue->bitrate[eNB_id];
534 535 536 537
    int coded_bits_per_codeword0=0,coded_bits_per_codeword1=1;
    int mod0,mod1;
    int mcs0 = 0;
    int mcs1=0;
538 539 540 541 542
    unsigned char harq_pid = 0;
    if (phy_vars_ue->dlsch_ue[eNB_id][0]!=NULL) {
        harq_pid = phy_vars_ue->dlsch_ue[eNB_id][0]->current_harq_pid;
	if (harq_pid>=8)
	  return;
Elena Lukashova's avatar
Elena Lukashova committed
543
	
544
    mcs0 = phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs;
545

546
        // Button 0
547
	/*
548 549 550 551
        if(!phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->dl_power_off) {
            // we are in TM5
            fl_show_object(form->button_0);
        } 
552
	*/
553 554 555 556 557 558 559 560 561 562
    }   
    
    
       if (phy_vars_ue->dlsch_ue[eNB_id][1]!=NULL) {
        harq_pid = phy_vars_ue->dlsch_ue[eNB_id][1]->current_harq_pid;
	if (harq_pid>=8)
	  return;
	
    mcs1 = phy_vars_ue->dlsch_ue[eNB_id][1]->harq_processes[harq_pid]->mcs;
    }
563 564 565 566 567 568 569
    
    if (phy_vars_ue->lte_ue_pdcch_vars[eNB_id]!=NULL) {
        num_pdcch_symbols = phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols;
    }

    //    coded_bits_per_codeword = frame_parms->N_RB_DL*12*get_Qm(mcs)*(frame_parms->symbols_per_tti);
    if (phy_vars_ue->dlsch_ue[eNB_id][0]!=NULL) {
570 571
      mod0 = get_Qm(mcs0);
      coded_bits_per_codeword0 = get_G(frame_parms,
572
				      phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->nb_rb,
573 574
				      phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rb_alloc_even,
				      get_Qm(mcs0),
575 576 577 578
				      phy_vars_ue->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->Nl,
				      num_pdcch_symbols,
				      frame,
				      subframe);
579
    } else {
580 581
      coded_bits_per_codeword0 = 0; //frame_parms->N_RB_DL*12*get_Qm(mcs)*(frame_parms->symbols_per_tti);
      mod0=0;
582 583
    }
    if (phy_vars_ue->dlsch_ue[eNB_id][1]!=NULL) {
584
      mod1 = get_Qm(mcs1);
585 586
      coded_bits_per_codeword1 = get_G(frame_parms,
				       phy_vars_ue->dlsch_ue[eNB_id][1]->harq_processes[harq_pid]->nb_rb,
587 588
				       phy_vars_ue->dlsch_ue[eNB_id][1]->harq_processes[harq_pid]->rb_alloc_even,
				       get_Qm(mcs1),
589 590 591 592 593 594 595
				       phy_vars_ue->dlsch_ue[eNB_id][1]->harq_processes[harq_pid]->Nl,
				       num_pdcch_symbols,
				       frame,
				       subframe);
    } else {
      coded_bits_per_codeword1 = 0; //frame_parms->N_RB_DL*12*get_Qm(mcs)*(frame_parms->symbols_per_tti);
      mod1=0;
596 597 598 599 600 601 602 603 604
    }
    
    I = (float*) calloc(nsymb_ce*2,sizeof(float));
    Q = (float*) calloc(nsymb_ce*2,sizeof(float));
    chest_t_abs = (float**) malloc(nb_antennas_rx*sizeof(float*));
    for (arx=0;arx<nb_antennas_rx;arx++) {
        chest_t_abs[arx] = (float*) calloc(frame_parms->ofdm_symbol_size,sizeof(float));
    }
    chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float));
605 606 607 608
    llr0 = (float*) calloc(coded_bits_per_codeword0,sizeof(float)); // init to zero
    bit0 = malloc(coded_bits_per_codeword0*sizeof(float));
    llr1 = (float*) calloc(coded_bits_per_codeword1,sizeof(float)); // init to zero
    bit1 = malloc(coded_bits_per_codeword1*sizeof(float));
609 610 611
    llr_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float)); // init to zero
    bit_pdcch = (float*) calloc(12*frame_parms->N_RB_DL*num_pdcch_symbols*2,sizeof(float));
    
gauthier's avatar
gauthier committed
612 613 614 615 616 617 618 619
    rxsig_t = (int16_t**) phy_vars_ue->lte_ue_common_vars.rxdata;
    chest_t = (int16_t**) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates_time[eNB_id];
    chest_f = (int16_t**) phy_vars_ue->lte_ue_common_vars.dl_ch_estimates[eNB_id];
    pbch_llr = (int8_t*) phy_vars_ue->lte_ue_pbch_vars[eNB_id]->llr;
    pbch_comp = (int16_t*) phy_vars_ue->lte_ue_pbch_vars[eNB_id]->rxdataF_comp[0];
    pdcch_llr = (int8_t*) phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->llr;
    pdcch_comp = (int16_t*) phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->rxdataF_comp[0];
    pdsch_llr = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->llr[0]; // stream 0
620
    pdsch_llr1 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->llr[1]; // stream 1
621
    pdsch_comp = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp0[0];
622 623 624 625 626 627 628 629
    //pdsch_comp = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->rxdataF_ext[0];
    //pdsch_comp1 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->rxdataF_ext[1];
    pdsch_comp1 = (int16_t*) (phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp1[0][0])[0];
    //pdsch_comp1 = (int16_t*) (phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_rho_ext[0][0])[0];
    pdsch_mag0 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag0[0];
    pdsch_mag1 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_mag1[0];
    pdsch_magb0 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_magb0[0];
    pdsch_magb1 = (int16_t*) phy_vars_ue->lte_ue_pdsch_vars[eNB_id]->dl_ch_magb1[0];
630
    
Florian Kaltenberger's avatar
Florian Kaltenberger committed
631
    fl_freeze_form(form->lte_phy_scope_ue);
632

633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
    // Received signal in time domain of receive antenna 0
    if (rxsig_t != NULL) { 
        if (rxsig_t[0] != NULL) { 
            for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
                rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((rxsig_t[0][2*i])*(rxsig_t[0][2*i])+(rxsig_t[0][2*i+1])*(rxsig_t[0][2*i+1])));
                time[i] = (float) i;
            }
            fl_set_xyplot_data(form->rxsig_t,time,rxsig_t_dB[0],FRAME_LENGTH_COMPLEX_SAMPLES,"","","");
        }
        
        for (arx=1;arx<nb_antennas_rx;arx++) {
            if (rxsig_t[arx] != NULL) { 
                for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
                    rxsig_t_dB[arx][i] = 10*log10(1.0+(float) ((rxsig_t[arx][2*i])*(rxsig_t[arx][2*i])+(rxsig_t[arx][2*i+1])*(rxsig_t[arx][2*i+1])));
                }
                fl_add_xyplot_overlay(form->rxsig_t,arx,time,rxsig_t_dB[arx],FRAME_LENGTH_COMPLEX_SAMPLES,rx_antenna_colors[arx]);
            }
        }
    }

653 654 655 656 657 658 659 660 661 662 663 664 665
  // Channel Impulse Response (still repeated format)
  if (chest_t != NULL) {
    ymax = 0;

    if (chest_t[0] !=NULL) {
      for (i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) {
        chest_t_abs[0][i] = (float) (chest_t[0][4*i]*chest_t[0][4*i]+chest_t[0][4*i+1]*chest_t[0][4*i+1]);

        if (chest_t_abs[0][i] > ymax)
          ymax = chest_t_abs[0][i];
      }

      fl_set_xyplot_data(form->chest_t,time,chest_t_abs[0],(frame_parms->ofdm_symbol_size>>3),"","","");
666
    }
667 668 669 670 671 672 673 674

    for (arx=1; arx<nb_antennas_rx; arx++) {
      if (chest_t[arx] !=NULL) {
        for (i=0; i<(frame_parms->ofdm_symbol_size>>3); i++) {
          chest_t_abs[arx][i] = (float) (chest_t[arx][4*i]*chest_t[arx][4*i]+chest_t[arx][4*i+1]*chest_t[arx][4*i+1]);

          if (chest_t_abs[arx][i] > ymax)
            ymax = chest_t_abs[arx][i];
675
        }
676 677 678 679

        fl_add_xyplot_overlay(form->chest_t,arx,time,chest_t_abs[arx],(frame_parms->ofdm_symbol_size>>3),rx_antenna_colors[arx]);
        fl_set_xyplot_overlay_type(form->chest_t,arx,FL_DASHED_XYPLOT);
      }
680
    }
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
     // Avoid flickering effect
        //        fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax);
        fl_set_xyplot_ybounds(form->chest_t,0,ymax);
    }
    
   // Channel Frequency Response (includes 5 complex sample for filter)
    if (chest_f != NULL) {
        ind = 0;
        for (atx=0;atx<nb_antennas_tx;atx++) {
            for (arx=0;arx<nb_antennas_rx;arx++) {
                if (chest_f[(atx<<1)+arx] != NULL) {
                    for (k=0; k<nsymb_ce; k++) {                     
                        freq[ind] = (float)ind;
                        Re = (float)(chest_f[(atx<<1)+arx][(2*k)]);
                        Im = (float)(chest_f[(atx<<1)+arx][(2*k)+1]);
                        
                        chest_f_abs[ind] = (short)10*log10(1.0+((double)Re*Re + (double)Im*Im));
                        ind++;
                    }
                }
            }
        }
        
        // tx antenna 0
        fl_set_xyplot_xbounds(form->chest_f,0,nb_antennas_rx*nb_antennas_tx*nsymb_ce);
        //fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*frame_parms->symbols_per_tti,2);
        //        fl_set_xyplot_xtics(form->chest_f,nb_antennas_rx*nb_antennas_tx*2,2);
        fl_set_xyplot_xgrid(form->chest_f,FL_GRID_MAJOR);
        fl_set_xyplot_data(form->chest_f,freq,chest_f_abs,nsymb_ce,"","","");
        
        for (arx=1;arx<nb_antennas_rx;arx++) {
            fl_add_xyplot_overlay(form->chest_f,1,&freq[arx*nsymb_ce],&chest_f_abs[arx*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]);
        }
        // other tx antennas
        if (nb_antennas_tx > 1) {
            if (nb_antennas_rx > 1) {
                for (atx=1;atx<nb_antennas_tx;atx++) {
                    for (arx=0;arx<nb_antennas_rx;arx++) {
                        fl_add_xyplot_overlay(form->chest_f,(atx<<1)+arx,&freq[((atx<<1)+arx)*nsymb_ce],&chest_f_abs[((atx<<1)+arx)*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]);
                    }
                }
            } else { // 1 rx antenna
                atx=1; arx=0;
                fl_add_xyplot_overlay(form->chest_f,atx,&freq[atx*nsymb_ce],&chest_f_abs[atx*nsymb_ce],nsymb_ce,rx_antenna_colors[arx]);
            }
        }
    }
 /*
729 730 731 732 733 734
    // PBCH LLRs
    if (pbch_llr != NULL) {
        for (i=0; i<1920;i++) {
            llr_pbch[i] = (float) pbch_llr[i];
            bit_pbch[i] = (float) i;
        }
735 736
        
        fl_set_xyplot_data(form->pbch_llr,bit_pbch,llr_pbch,1920,"","","");
737 738
    }

739 740 741 742 743 744 745 746
    // PBCH I/Q of MF Output
    if (pbch_comp!=NULL) {
        for (i=0; i<72*2; i++) {
            I[i] = pbch_comp[2*i];
            Q[i] = pbch_comp[2*i+1];
        }
        
        fl_set_xyplot_data(form->pbch_comp,I,Q,72*2,"","","");
747 748
    }

749 750 751 752 753
    // PDCCH LLRs
    if (pdcch_llr != NULL) {
        for (i=0; i<12*frame_parms->N_RB_DL*2*num_pdcch_symbols;i++) {
            llr_pdcch[i] = (float) pdcch_llr[i];
            bit_pdcch[i] = (float) i;
754 755
        }

756 757
        fl_set_xyplot_xbounds(form->pdcch_llr,0,12*frame_parms->N_RB_DL*2*3);
        fl_set_xyplot_data(form->pdcch_llr,bit_pdcch,llr_pdcch,12*frame_parms->N_RB_DL*2*num_pdcch_symbols,"","","");
758 759
    }

760 761 762 763 764 765 766 767
    // PDCCH I/Q of MF Output
    if (pdcch_comp!=NULL) {
        for (i=0; i<12*frame_parms->N_RB_DL*num_pdcch_symbols; i++) {
            I[i] = pdcch_comp[2*i];
            Q[i] = pdcch_comp[2*i+1];
        }
        
        fl_set_xyplot_data(form->pdcch_comp,I,Q,12*frame_parms->N_RB_DL*num_pdcch_symbols,"","","");
768
    }
769
    */
770

771
    // PDSCH LLRs CW0
772
    if (pdsch_llr != NULL) {
Elena Lukashova's avatar
Elena Lukashova committed
773
        for (i=0; i<coded_bits_per_codeword0; i++) {
774 775
            llr0[i] = (float) pdsch_llr[i];
            bit0[i] = (float) i;
776 777
        }

Elena Lukashova's avatar
Elena Lukashova committed
778
        fl_set_xyplot_xbounds(form->pdsch_llr,0,coded_bits_per_codeword0);        
779
        fl_set_xyplot_data(form->pdsch_llr,bit0,llr0,coded_bits_per_codeword0,"","","");
780
    }
781 782


783 784 785 786 787 788 789 790 791 792 793
  // PDSCH I/Q of MF Output
    if (pdsch_comp!=NULL) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
                I[ind] = pdsch_comp[(2*frame_parms->N_RB_DL*12*k)+4*i];
                Q[ind] = pdsch_comp[(2*frame_parms->N_RB_DL*12*k)+4*i+1];
                ind++;
            }
        }
        fl_set_xyplot_data(form->pdsch_comp,I,Q,ind,"","","");
794
    }
795

796

797 798 799 800 801 802 803 804 805 806 807
    if (pdsch_mag0 != NULL) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
	      I[ind] = pdsch_mag0[(2*frame_parms->N_RB_DL*12*k)+4*i]*cos(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      Q[ind] = pdsch_mag0[(2*frame_parms->N_RB_DL*12*k)+4*i+1]*sin(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      ind++;
            }
        }
        fl_add_xyplot_overlay(form->pdsch_comp,1,I,Q,ind,FL_GREEN);
    }
808 809
    
    
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
    if (pdsch_magb0 != NULL) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
	      I[ind] = pdsch_magb0[(2*frame_parms->N_RB_DL*12*k)+4*i]*cos(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      Q[ind] = pdsch_magb0[(2*frame_parms->N_RB_DL*12*k)+4*i+1]*sin(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      ind++;
            }
        }
        fl_add_xyplot_overlay(form->pdsch_comp,2,I,Q,ind,FL_RED);
    }
    if ((pdsch_mag0 != NULL) && (pdsch_magb0 != NULL)) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
	      I[ind] = 
		(pdsch_mag0[(2*frame_parms->N_RB_DL*12*k)+4*i]+
		 pdsch_magb0[(2*frame_parms->N_RB_DL*12*k)+4*i])*
		cos(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      Q[ind] = 
		(pdsch_mag0[(2*frame_parms->N_RB_DL*12*k)+4*i+1]+
		 pdsch_magb0[(2*frame_parms->N_RB_DL*12*k)+4*i+1])*
		sin(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      ind++;
            }
        }
        fl_add_xyplot_overlay(form->pdsch_comp,3,I,Q,ind,FL_BLUE);
    }
 

840
    // PDSCH LLRs CW1
841
    if (pdsch_llr1 != NULL) {
Elena Lukashova's avatar
Elena Lukashova committed
842
        for (i=0; i<coded_bits_per_codeword1; i++) {
843 844
            llr1[i] = (float) pdsch_llr1[i];
            bit1[i] = (float) i;
845 846
        }

Elena Lukashova's avatar
Elena Lukashova committed
847
        fl_set_xyplot_xbounds(form->pdsch_llr1,0,coded_bits_per_codeword1);        
848
        fl_set_xyplot_data(form->pdsch_llr1,bit1,llr1,coded_bits_per_codeword1,"","","");
849
    }
850
    
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907
    // PDSCH I/Q of MF Output
    if (pdsch_comp1!=NULL) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
                I[ind] = pdsch_comp1[(2*frame_parms->N_RB_DL*12*k)+4*i];
                Q[ind] = pdsch_comp1[(2*frame_parms->N_RB_DL*12*k)+4*i+1];
                ind++;
            }
        }
        fl_set_xyplot_data(form->pdsch_comp1,I,Q,ind,"","","");
    }

    if (pdsch_mag1 != NULL) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
	      I[ind] = pdsch_mag1[(2*frame_parms->N_RB_DL*12*k)+4*i]*cos(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      Q[ind] = pdsch_mag1[(2*frame_parms->N_RB_DL*12*k)+4*i+1]*sin(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      ind++;
            }
        }
        fl_add_xyplot_overlay(form->pdsch_comp1,1,I,Q,ind,FL_GREEN);
    }

    if (pdsch_magb1 != NULL) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
	      I[ind] = pdsch_magb1[(2*frame_parms->N_RB_DL*12*k)+4*i]*cos(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      Q[ind] = pdsch_magb1[(2*frame_parms->N_RB_DL*12*k)+4*i+1]*sin(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      ind++;
            }
        }
        fl_add_xyplot_overlay(form->pdsch_comp1,2,I,Q,ind,FL_RED);
    }

    if ((pdsch_mag1 != NULL) && (pdsch_magb1 != NULL)) {
        ind=0;
        for (k=0; k<frame_parms->symbols_per_tti; k++) {
            for (i=0; i<12*frame_parms->N_RB_DL/2; i++) {
	      I[ind] = 
		(pdsch_mag1[(2*frame_parms->N_RB_DL*12*k)+4*i]+
		 pdsch_magb1[(2*frame_parms->N_RB_DL*12*k)+4*i])*
		cos(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      Q[ind] = 
		(pdsch_mag1[(2*frame_parms->N_RB_DL*12*k)+4*i+1]+
		 pdsch_magb1[(2*frame_parms->N_RB_DL*12*k)+4*i+1])*
		sin(i*2*M_PI/(12*frame_parms->N_RB_DL/2));
	      ind++;
            }
        }
        fl_add_xyplot_overlay(form->pdsch_comp1,3,I,Q,ind,FL_BLUE);
    }
 

    /*    
908 909 910 911 912 913 914 915 916 917 918 919 920 921
    // PDSCH Throughput
    memcpy((void*)tput_time_ue[UE_id],(void*)&tput_time_ue[UE_id][1],(TPUT_WINDOW_LENGTH-1)*sizeof(float));
    memcpy((void*)tput_ue[UE_id],(void*)&tput_ue[UE_id][1],(TPUT_WINDOW_LENGTH-1)*sizeof(float));
    
    tput_time_ue[UE_id][TPUT_WINDOW_LENGTH-1]  = (float) frame;
    tput_ue[UE_id][TPUT_WINDOW_LENGTH-1] = ((float) total_dlsch_bitrate)/1000.0;
    
    if (tput_ue[UE_id][TPUT_WINDOW_LENGTH-1] > tput_ue_max[UE_id]) {
        tput_ue_max[UE_id] = tput_ue[UE_id][TPUT_WINDOW_LENGTH-1];
    }
    
    fl_set_xyplot_data(form->pdsch_tput,tput_time_ue[UE_id],tput_ue[UE_id],TPUT_WINDOW_LENGTH,"","","");
    
    fl_set_xyplot_ybounds(form->pdsch_tput,0,tput_ue_max[UE_id]);
922 923
    */

Florian Kaltenberger's avatar
Florian Kaltenberger committed
924
    fl_unfreeze_form(form->lte_phy_scope_ue);
925 926 927 928 929 930

    fl_check_forms();

    free(I);
    free(Q);
    free(chest_f_abs);
931 932 933 934
    free(llr0);
    free(bit0);
    free(llr1);
    free(bit1);
935 936 937 938 939
    free(bit_pdcch);
    free(llr_pdcch);
    for (arx=0;arx<nb_antennas_rx;arx++) {
        free(chest_t_abs[arx]);
    }
940 941 942

  }