Beispiel #1
0
void YMin_cb(FL_OBJECT *ob, long data)
{
  float max,min;
  int i;
  fprintf(stderr,"%ld\n",data);
  for(i=0;i<GlobalNoOfOverlays;i++)
    {
      fl_get_xyplot_ybounds(CHART[i],&min,&max);
      min = (float)fl_get_slider_value(ob);
      fl_set_xyplot_ybounds(CHART[i],(double)min,(double)max);
    }
}
Beispiel #2
0
void show_otg_form() {
  int eNB_id;
  char title[255];
  char *tArgv[] = { "OTG", "OTG" };
  int tArgc = 2;

  int major_owd = 6;
  int minor_owd = 3; 
  int major_thr = 5;
  int minor_thr = 2; 

  fl_initialize(&tArgc,tArgv,"OTG",0,0);
  for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { //NB_eNB_INST
    form_dl= create_form_otg ();
    sprintf (title, "LTE eNB->UE (DL)");
    fl_show_form (form_dl->otg, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
    fl_set_form_position(form_dl->otg, 200, 200);
    fl_set_xyplot_ytics(form_dl->owd,major_owd, minor_owd);
    if (g_otg->owd_radio_access==1)
      fl_set_xyplot_ybounds(form_dl->owd,0,200);
    else
      fl_set_xyplot_ybounds(form_dl->owd,0,400);
    
    fl_set_xyplot_ytics(form_dl->throughput,major_thr, minor_thr);
    fl_set_xyplot_ybounds(form_dl->throughput,0,1000); 
    
    
    
    form_ul= create_form_otg ();
    sprintf (title, "LTE UE->eNB (UL)");
    fl_show_form (form_ul->otg, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
    fl_set_form_position(form_ul->otg, 850, 200);
    fl_set_xyplot_ytics(form_ul->owd,major_owd, minor_owd);
    if (g_otg->owd_radio_access==1)
      fl_set_xyplot_ybounds(form_ul->owd,0,200);
    else
      fl_set_xyplot_ybounds(form_ul->owd,0,400);
    
    //fl_set_positioner_ystep (form_ul->throughput, 100);
    //fl_set_xyplot_xgrid (form_ul->throughput, FL_GRID_MAJOR);
    fl_set_xyplot_ytics(form_ul->throughput,major_thr, minor_thr);
    fl_set_xyplot_ybounds(form_ul->throughput,0,1000); 
    
    
  }

    //create_form_clock();
    //fl_show_form(fclock, FL_PLACE_CENTER,FL_TRANSIENT,"clocks");
    //fl_do_forms();

  fl_check_forms();
}	
int main(int argc, char *argv[])
{
	void lmst_update (FL_OBJECT *, long);
	int i;
	void dismiss_psr();
	void spectrum_hide();
	void tp_hide ();
	void hide_waterfall();
	void hide_interferometer();
	void hide_info();
	void receiver_leave();
	int close_sub ();
	int close_main ();
	char *p;
	char fntstr[128];
	char d[128];
	int binwidth;
	
	/*
	 * Init xforms library
	 */
   fl_initialize(&argc, argv, "Ira", 0, 0);
   fl_get_app_resources (NULL, 0);
   
   time (&started_at);
   
   /*
    * Create various windows, including the main one
	*/
   fd_receiver_main = create_form_receiver_main();
	fl_set_form_atclose(fd_receiver_main->receiver_main, close_main, 0);
	
   fd_receiver_pulsar = create_form_receiver_pulsar();
   fl_set_form_atclose (fd_receiver_pulsar->receiver_pulsar, close_sub, dismiss_psr);
   
   fd_receiver_spectrum = create_form_receiver_spectrum();
   fl_set_form_atclose (fd_receiver_spectrum->receiver_spectrum, close_sub, spectrum_hide);
   
   fd_receiver_continuum = create_form_receiver_continuum();
   fl_set_form_atclose (fd_receiver_continuum->receiver_continuum, close_sub, tp_hide);
   
   fd_receiver_waterfall = create_form_receiver_waterfall();
   fl_set_form_atclose (fd_receiver_waterfall->receiver_waterfall, close_sub, hide_waterfall);
   
   fd_receiver_info = create_form_receiver_info();
   fl_set_form_atclose (fd_receiver_info->receiver_info, close_sub, hide_info);
   
   fd_receiver_lproblem = create_form_receiver_lproblem ();
   fd_receiver_error = create_form_receiver_error ();
   
   fd_receiver_shutdown = create_form_receiver_shutdown ();
   
   
   flps_init();
   fl_free_pixmap_pixmap(fd_receiver_main->ira_xpm_button);
   fl_set_pixmap_data(fd_receiver_main->ira_xpm_button, Ira_xpm);
   
	sprintf (version_info, "Ver: %s  (BETA)", VERSION);
   
   /*
    * Stuff lines in info window
	*/
   for (i = 0; ; i++)
   {
	   if (ira_info[i] == NULL)
	   {
		   break;
	   }
	   fl_add_browser_line (fd_receiver_info->info_browser, ira_info[i]);
   }
   fl_set_browser_fontsize(fd_receiver_info->info_browser, 14);
   
   /* fill-in form initialization code */
   fl_set_object_label (fd_receiver_main->startup_text, "PLEASE WAIT.........");
   
   /* show the first form */
   fl_show_form(fd_receiver_main->receiver_main,FL_PLACE_CENTER,FL_FULLBORDER,"IRA Control Panel");
   fl_check_forms();
   
   /*
    * Now we check a raft of environment variables, and use those to initialize
	*   various settable values
	*/
	
	refmult = 1.0;
	if ((p = getenv ("RCVR_REF_MULT")) != NULL)
	{
   		refmult = atof(p);
	}
   fl_set_slider_value (fd_receiver_main->refmult_slider, refmult);
   
   seti_integ = 15;
   if ((p = getenv ("RCVR_SETI_INTEG")) != NULL)
   {
   		seti_integ = (int)atof(p);
	}
   fl_set_slider_value (fd_receiver_main->seti_integ_slider, (float)seti_integ);
   
   strcpy (datadir, ".");
   if ((p = getenv ("RCVR_DATA_DIR")) != NULL)
   {
   		strcpy (datadir, p);
	}
  
  	/*
	 * Set the input field for freq, as well as the actual frequency
	 */
   if ((p = getenv ("RCVR_INITIAL_FREQ")) != NULL)
   {
	   fl_set_input (fd_receiver_main->frequency_input, p); 
	   frequency = atof(p);
	   sky_freq = frequency;
	   sky_locked = 1;
   }
   
   /*
    * Start out with sky_freq unavailable for input
	*/
   fl_deactivate_object (fd_receiver_main->sky_freq_input);
   fl_set_input (fd_receiver_main->sky_freq_input, "--------");
   
   /* If there's a sky_freq parameter, use it, and re-activate the
    *  sky_freq_input control
	*/
   if ((p = getenv ("RCVR_SKY_FREQ")) != NULL)
   {
	   if (abs(atof(p) - frequency) > 100.0)
	   {
			   
		   sky_locked = 0;
		   fl_set_input (fd_receiver_main->sky_freq_input, p);
			sky_freq = atof(p);
			fl_activate_object (fd_receiver_main->sky_freq_input);
			fl_set_button (fd_receiver_main->sky_lock_button, 0);
		}
		else
		{
			sky_freq = atof(p);
			fl_set_button (fd_receiver_main->sky_lock_button, 1);
			sky_locked = 1;
		}
	}
	PUSHVAR("ifreq", frequency);
	PUSHVAR("skyfreq", sky_freq);
   /*
    * 
    * And again for RF gain
	*/
	if ((p = getenv ("RCVR_RF_GAIN")) != NULL)
	{
   		rf_gain = atoi(p);
	}
   fl_set_slider_value (fd_receiver_main->rf_gain_slider, rf_gain);
	PUSHVAR("igain", rf_gain);
   /*
    * Gain correction values for A and B sides
	*/
   if ((p = getenv ("RCVR_COR_A")) != NULL)
   {
	   gc_a = atof(p);
	  
   }
   sprintf (d, "%f", gc_a);
   fl_set_input (fd_receiver_main->gc_a, d);
   
   if ((p = getenv ("RCVR_COR_B")) != NULL)
   {
	   gc_b = atof(p);
   }
   sprintf (d, "%f", gc_b);
   fl_set_input (fd_receiver_main->gc_b, d);
   
	/*
	 * Set bounds/values for DC gain
	 */
	if ((p = getenv ("RCVR_DC_GAIN")) != NULL)
	{
		dc_gain = atof(p);
	}
   fl_set_slider_value (fd_receiver_main->dc_gain_control, dc_gain);

   
   /*
    * And again for DC offset
	*/
	if ((p = getenv ("RCVR_DC_OFFSET")) != NULL)
	{
		dc_offset = atof(p);
	}
   fl_set_slider_value (fd_receiver_main->dc_offset_control, dc_offset);
   /*
    * Receiver DC Gain multiplier
	*/
   if ((p = getenv ("RCVR_DC_MULT")) != NULL)
   {
	   int which;
	   
	   dc_mult = (double)atoi(p);
	   which = 1;
	   /*
	    * It's a choice widget, so we need to set 'which' appropriately
		*/
	   switch ((int)dc_mult)
	   {
		case 1:
			which = 1;
			break;
		case 5:
			which = 2;
			break;
		case 10:
			which = 3;
			break;
		case 15:
			which = 4;
			break;
		case 20:
			which = 5;
			break;
		case 25:
			which = 6;
			break;
		case 30:
			which=7;
			break;
		case 35:
			which = 8;
			break;
		case 40:
			which = 9;
			break;
		}
		fl_set_choice (fd_receiver_main->mult_choice, which);
   } 
   
   /*
    * Total power integration value
	*/
	tp_integration = 5;
	if ((p = getenv ("RCVR_TP_INTEG")) != NULL)
	{
		tp_integration = atoi(p);
	}
   fl_set_slider_value (fd_receiver_main->continuum_int, (double)atof(getenv("RCVR_TP_INTEG")) );
   
   /*
    * Spectral integration
	*/
	spec_integration = 15;
	if ((p = getenv ("RCVR_SPEC_INTEG")) != NULL)
	{
		spec_integration = atoi(p);
	}
   fl_set_slider_value (fd_receiver_main->spec_int_slider, (double)atof(getenv("RCVR_SPEC_INTEG")) );
   
   /*
    * Sigma_K for SETI analysis
	*/
	sigma_k = 2.5;
	if ((p = getenv ("RCVR_SIGMA_K")) != NULL)
	{
   		sigma_k = atof(p);
	}
   fl_set_slider_value (fd_receiver_main->sigma_k_slider, sigma_k);
   
   /*
    * Check desired receiver mode
	*/
   if (getenv("RCVR_MODE") != NULL)
   {
   	strcpy (rcvr_mode, getenv("RCVR_MODE"));
	}
	else
	{
		strcpy (rcvr_mode, "unknown");
	}
	
	/*
	 * Interferometer?  Create the interferometer window
	 */
   if (strcmp (rcvr_mode, "interferometer") == 0)
   {
	   fd_receiver_interferometer = create_form_receiver_interferometer();
	   fl_set_form_atclose (fd_receiver_interferometer->receiver_interferometer, close_sub, 
	   	hide_interferometer);
   }
   /*
    * Otherwise, delete the "show interferograms" control
	*/
   else
   {
	   fl_delete_object  (fd_receiver_main->interferometer_button);
   }
   
   /*
    * Various values
	*/
	declination = -28.3;
	if ((p = getenv ("RCVR_DECLINATION")) != NULL)
	{
		declination = atof(p);
	}
	fl_set_input (fd_receiver_main->declination_input, getenv("RCVR_DECLINATION"));
	
	longitude = 0.0;
	if ((p = getenv ("RCVR_LONGITUDE")) != NULL)
	{
		longitude = atof(p);
	}
	seti_size = 500000;
	if ((p = getenv ("RCVR_SETI_SIZE")) != NULL)
	{
   		seti_size = atoi (p);
	}

    bandwidth = 5000000;
    if ((p = getenv ("RCVR_BANDWIDTH")) != NULL)
    {
		bandwidth = atoi (p);
	}

   psr_rate = 10000;
   if ((p = getenv ("RCVR_PSR_RATE")) != NULL)
   {
   		psr_rate = atoi (getenv ("RCVR_PSR_RATE"));
	}
   for (i = 0; i < NNOTCHES; i++)
   {
	   notches[i] = -1.0;
   }
   if ((p = getenv ("RCVR_NOTCHES")) != NULL)
   {
	   char *tp;
	   char pcopy[128];
	   FILE *fp;
	   
	   strcpy (pcopy, p);
	   
	   tp = strtok (pcopy, ",");
	   notches[0] = atof(tp);
	   for (i = 1; i < NNOTCHES; i++)
	   {
		   tp = strtok (NULL, ",");
		   if (tp == NULL)
		   {
			   break;
		   }
		   notches[i] = atof(tp);
	   }
   }
   if ((p = getenv ("RCVR_NOTCH_SIZE")) != NULL)
   {
	   notch_length = atoi(p);
   		fl_set_slider_value (fd_receiver_spectrum->notch_slider, (double)notch_length);
	}
	if ((p = getenv ("RCVR_DM")) != NULL)
	{
		pulsar_dm = atof(p);
		fl_set_slider_value (fd_receiver_main->dm_input, (double)pulsar_dm);
	}
	PUSHVAR("idm", pulsar_dm);
	
	if ((p = getenv ("PULSAR_RATE")) != NULL)
	{
		pulsar_rate = atof(p);
		fl_set_input (fd_receiver_main->pulsar_rate_input, p);
	}
	if ((p = getenv ("PULSAR_FOLDING")) != NULL)
	{
		pulsar_folding = atoi(p);
		fl_set_choice (fd_receiver_main->pulsar_choice, pulsar_folding/5);
	}
	/*
	 * Set spec_fft_size based on width of spectral plot display
	 */
   {
	   FL_Coord x, y, w, h;
	   
   		fl_get_object_bbox (fd_receiver_spectrum->spectral_plot, &x, &y, &w, &h);
   		spec_fft_size = w-130;
	}
	
	tp_maxval = 100000;
	tp_span = 20000;
	
	/*
	 * Establish parameters for TP plot
	 */
	if ((p = getenv("RCVR_TP_MAXVAL")) != NULL)
	{
		tp_maxval = (double)atoi(p);
	}
	if ((p = getenv ("RCVR_TP_SPAN")) != NULL)
	{
		tp_span = (double)atoi(p);
	}
	tp_minval = tp_maxval - tp_span;
	fl_set_slider_value (fd_receiver_continuum->tp_max_slider, (double)tp_maxval);
	fl_set_slider_value (fd_receiver_continuum->tp_span_slider, (double)tp_span);  
	fl_set_xyplot_ybounds(fd_receiver_continuum->tp_chart, (double)tp_minval, (double)tp_maxval);
   fl_set_xyplot_ytics(fd_receiver_continuum->tp_chart, 10, 1);
   fl_set_xyplot_xgrid (fd_receiver_continuum->tp_chart, FL_GRID_MINOR);
   fl_set_xyplot_ygrid (fd_receiver_continuum->tp_chart, FL_GRID_MINOR);
   fl_set_object_posthandler(fd_receiver_continuum->tp_chart, continuum_plot_post);
   
   /*
    * Set a post handler for inteferometer display
	*/
   if (strcmp (rcvr_mode, "interferometer") == 0)
   {
   		fl_set_object_posthandler(fd_receiver_interferometer->interferometer_chart, continuum_plot_post);
		if ((p = getenv ("RCVR_INT_GAIN")) != NULL)
		{
			interferometer_gain = atof(p);
		}
		if ((p = getenv ("RCVR_INT_SPAN")) != NULL)
		{
			interferometer_span = atof(p);
		}
		if ((p = getenv ("RCVR_PHCORR")) != NULL)
		{
			interferometer_phase = atof(p);
		}
		if ((p = getenv ("RCVR_DELAY")) != NULL)
		{
			interferometer_delay = atof(p);
		}
		fl_set_xyplot_ytics (fd_receiver_interferometer->interferometer_chart, 10, 1);
		fl_set_xyplot_xgrid (fd_receiver_interferometer->interferometer_chart, FL_GRID_MINOR);
		fl_set_xyplot_ygrid (fd_receiver_interferometer->interferometer_chart, FL_GRID_MINOR);
		fl_set_slider_value (fd_receiver_interferometer->int_gain_slider, interferometer_gain);
		fl_set_slider_value (fd_receiver_interferometer->int_span_slider, interferometer_span);
		fl_set_slider_value (fd_receiver_interferometer->phase_adjust, interferometer_phase);
		fl_set_slider_value (fd_receiver_interferometer->delay_adjust, interferometer_delay);
		fl_set_xyplot_ybounds (fd_receiver_interferometer->interferometer_chart, -1*interferometer_span,
			interferometer_span);
	}
   
   fl_add_timeout (1000.0, (FL_TIMEOUT_CALLBACK)lmst_update, 0);
   
   /*
    * Setup parameters for spectral plot
	*/
	if ((p = getenv ("RCVR_SPEC_MAX")) != NULL)
	{
		current_smax = atoi(p);
	}
	if ((p = getenv ("RCVR_SPEC_SPAN")) != NULL)
	{
		current_span = atoi(p);
	}
	if ((p = getenv ("RCVR_SPEC_FLAT")) != NULL)
	{
		spec_flat_on = atoi(p);
		fl_set_button (fd_receiver_spectrum->flaten_button, spec_flat_on);
	}
	if ((p = getenv ("RCVR_SPEC_METHOD")) != NULL)
	{
		spec_method = atoi (p);
	}
	fl_set_xyplot_xgrid(fd_receiver_spectrum->spectral_plot, FL_GRID_MINOR);
	fl_set_xyplot_ygrid(fd_receiver_spectrum->spectral_plot, FL_GRID_MINOR);
	fl_set_xyplot_ybounds(fd_receiver_spectrum->spectral_plot, (double)(current_smax-current_span), (double)
		current_smax);
	fl_set_xyplot_ytics(fd_receiver_spectrum->spectral_plot, 10, 1);
	fl_set_xyplot_xtics(fd_receiver_spectrum->spectral_plot, 10, 1);
	
	fl_set_object_posthandler(fd_receiver_spectrum->spectral_plot, spectral_plot_post);
	fl_set_choice (fd_receiver_spectrum->spec_method_choice, spec_method);
	fl_set_choice_fontsize (fd_receiver_spectrum->spec_method_choice, 14);
	
	fl_set_slider_value (fd_receiver_spectrum->spec_max_slider, (double)current_smax);
	fl_set_slider_value (fd_receiver_spectrum->spec_span_slider, (double)current_span);
	
	/*
	 * Set post handler for pulsar display
	 */
	fl_set_object_posthandler(fd_receiver_pulsar->pulsar_plot, pulsar_plot_post);
	
	/*
	 * Set parameters for waterfall (SETI) display
	 */
	{
		FL_Coord x, y;
		FL_Coord w, h;
		fl_get_object_bbox(fd_receiver_waterfall->waterfall_display, &x, &y, &w, &h);
		fl_set_slider_bounds (fd_receiver_waterfall->wfall_seg_slider, 1.0, (float)seti_size/w);
		fl_set_object_dblbuffer(fd_receiver_waterfall->waterfall_display, 1);
		
		if ((p = getenv ("RCVR_WFALL_SEGMENT")) != NULL)
		{
			waterfall_segment = atoi(p);
			fl_set_slider_value (fd_receiver_waterfall->wfall_seg_slider, (double)waterfall_segment);
		}
		if ((p = getenv ("RCVR_WFALL_FINE")) != NULL)
		{
			waterfall_fine = atoi(p);
			fl_set_slider_value (fd_receiver_waterfall->fine_segment, waterfall_fine);
		}
		if ((p = getenv ("RCVR_WFALL_BRIGHTNESS")) != NULL)
		{
			double w;
			
			w = atof(p);
			if (fabsf(w-1.0) < 0.1)
			{
				fl_set_choice (fd_receiver_waterfall->wfall_brightness, 1);
				w = 1.0;
			}
			if (fabsf(w-0.75) < 0.1)
			{
				fl_set_choice (fd_receiver_waterfall->wfall_brightness, 2);
				w = 0.75;
			}
			if (fabsf(w-0.66) < 0.1)
			{
				fl_set_choice (fd_receiver_waterfall->wfall_brightness, 3);
				w = 0.66;
			}
			if (fabsf(w-0.50) < 0.1)
			{
				fl_set_choice (fd_receiver_waterfall->wfall_brightness, 4);
				w = 0.50;
			}
			waterfall_brightness = (float)w;
		}
	}
	if ((p = getenv ("RCVR_TRANS_THRESH")) != NULL)
	{
		transient_threshold = atof(p);
		fl_set_slider_value (fd_receiver_main->trans_thr_slider, transient_threshold);
	}
	if ((p = getenv ("RCVR_TRANS_DUR")) != NULL)
	{
		transient_duration = atof(p);
		fl_set_slider_value (fd_receiver_main->trans_dur_slider, transient_duration);
	}
	/*
	 * Open various FIFOs--that's where we get our data from
	 */
	if ((seti_fd = open ("ra_seti_fifo", O_RDONLY|O_NONBLOCK)) > 0)
   {
	   fcntl (seti_fd, F_SETFL, 0);
	   fl_add_io_callback (seti_fd, FL_READ, (FL_IO_CALLBACK)handle_seti_io, fd_receiver_main);
   }
   if ((pulsar_fd = open ("ra_psr_fifo", O_RDONLY|O_NONBLOCK)) > 0)
   {
	    fcntl (pulsar_fd, F_SETFL, 0);
		fl_add_io_callback (pulsar_fd, FL_READ, (FL_IO_CALLBACK)handle_pulsar_io, fd_receiver_main);
   }
   if ((dicke_fd = open ("ra_switching_fifo", O_RDONLY|O_NONBLOCK)) > 0)
   {
	    fcntl (dicke_fd, F_SETFL, 0);
	    fl_set_object_label (fd_receiver_main->dicke_mode, "DICKE: ON");
		fl_add_io_callback (dicke_fd, FL_READ, (FL_IO_CALLBACK)handle_dicke_io, fd_receiver_main);
   }
   if (strcmp (rcvr_mode, "interferometer") == 0)
   {
	   if ((inter_fd = open ("ra_inter_fifo", O_RDONLY|O_NONBLOCK)) > 0)
	   {
		    fcntl (inter_fd, F_SETFL, 0);
	    	fl_add_io_callback (inter_fd, FL_READ, (FL_IO_CALLBACK)handle_inter_io, fd_receiver_main);
		}
	}
	if (strcmp (rcvr_mode, "split") == 0)
	{
		if ((validation_fd = open ("ra_validation_fifo", O_RDONLY|O_NONBLOCK)) > 0)
		{
			fcntl (validation_fd, F_SETFL, 0);
			split_mode = 1;
			fl_add_io_callback (validation_fd, FL_READ, (FL_IO_CALLBACK)handle_validation_io, fd_receiver_main);
		}
	}
	fl_set_oneliner_font (FL_FIXEDBOLDITALIC_STYLE, FL_MEDIUM_FONT);
	fl_set_oneliner_color (FL_GREEN, FL_BLACK);

   while(fl_do_forms())
         ;
   return 0;
}
Beispiel #4
0
void sach_scope_idle_callback(void) {

  int user_index,tchan_index,i;
  
  short *sacch_data,*sach_data;
  float avg,sach_re[4096],sach_im[4096];
  float sacch_re[512],sacch_im[512];
  unsigned short nb_sacch_carriers,nb_sach_carriers;

  SACH_DIAGNOSTICS *sach_diag;


  for (user_index=0;user_index<8;user_index++) {

    for (tchan_index=0;tchan_index<5;tchan_index++) {

      sach_diag = &PHY_vars->Sach_diagnostics[user_index][tchan_index];
      if (sach_diag->active == 1) {

	avg = 0;
	nb_sacch_carriers = (sach_diag->nb_sacch_carriers< 512) ? sach_diag->nb_sacch_carriers : 512;
	nb_sach_carriers = (sach_diag->nb_sach_carriers < 4096) ? sach_diag->nb_sach_carriers : 4096;


	sacch_data = (short *)(mem_base + (unsigned int)PHY_vars->Sach_diagnostics[user_index][tchan_index].sacch_demod_data-(unsigned int)&PHY_vars->tx_vars[0].TX_DMA_BUFFER[0]);
	sach_data = (short *)(mem_base + (unsigned int)PHY_vars->Sach_diagnostics[user_index][tchan_index].sach_demod_data-(unsigned int)&PHY_vars->tx_vars[0].TX_DMA_BUFFER[0]);

	/*	
	printf("User_index %d, tchan_index %d (sacch %d,sach %d) (%p,%p) -> (%p,%p)\n",user_index,tchan_index,nb_sacch_carriers,nb_sach_carriers,PHY_vars->Sach_diagnostics[user_index][tchan_index].sacch_demod_data,PHY_vars->Sach_diagnostics[user_index][tchan_index].sach_demod_data,sacch_data,sach_data);
	*/
	for (i=0;i<nb_sacch_carriers>>1;i++) {
	  sacch_re[i] = (float)sacch_data[i<<2]; 
	  sacch_im[i] = (float)sacch_data[(i<<2) + 1];
	  //	  printf("sacch: i=%d : %d %d %d %d\n",i,sacch_data[i<<2],sacch_data[1+(i<<2)],sacch_data[2+(i<<2)],sacch_data[3+(i<<2)]);
	  avg += fabs(sacch_re[i])+fabs(sacch_im[i]);
	}
	for (i=0;i<nb_sach_carriers>>1;i++) {
	    sach_re[i] = (float)sach_data[i<<2]; 
	    sach_im[i] = (float)sach_data[(i<<2) + 1];
//	    	    printf("sach : i=%d : %d %d %d %d\n",i,sach_data[i<<2],sach_data[1+(i<<2)],sach_data[2+(i<<2)],sach_data[3+(i<<2)]);
	avg += fabs(sach_re[i])+fabs(sach_im[i]);
	}

	avg/=(nb_sacch_carriers+nb_sach_carriers);

	for (i=0;i<nb_sacch_carriers>>1;i++) {
	  sacch_re[i] /= avg;
	  sacch_im[i] /= avg;
	  //	  printf("sacch: i=%d : %d %d %d %d\n",i,sacch_data[i<<2],sacch_data[1+(i<<2)],sacch_data[2+(i<<2)],sacch_data[3+(i<<2)]);
	}
	for (i=0;i<nb_sach_carriers>>1;i++) {
	  sach_re[i] /= avg;
	  sach_im[i] /= avg;
	    //	    printf("sach : i=%d : %d %d %d %d\n",i,sach_data[i<<2],sach_data[1+(i<<2)],sach_data[2+(i<<2)],sach_data[3+(i<<2)]);
	}
	//	avg = 2048.0;

	avg = 2.0;
	if ((user_index == 0) && (tchan_index == 0)) {
	  fl_set_xyplot_xbounds(form->sacch00,-avg,avg);
	  fl_set_xyplot_ybounds(form->sacch00,-avg,avg);
	  fl_set_xyplot_xbounds(form->sach00,-avg,avg);
	  fl_set_xyplot_ybounds(form->sach00,-avg,avg);

	  fl_set_xyplot_data(form->sacch00,sacch_re,sacch_im,nb_sacch_carriers>>1,"","","");
	  fl_set_xyplot_data(form->sach00,sach_re,sach_im,nb_sach_carriers>>1,"","","");
	}

	if ((user_index == 0) && (tchan_index == 1)) {
	  fl_set_xyplot_xbounds(form->sacch01,-avg,avg);
	  fl_set_xyplot_ybounds(form->sacch01,-avg,avg);
	  fl_set_xyplot_xbounds(form->sach01,-avg,avg);
	  fl_set_xyplot_ybounds(form->sach01,-avg,avg);
	  fl_set_xyplot_data(form->sacch01,sacch_re,sacch_im,nb_sacch_carriers>>1,"","","");
	  fl_set_xyplot_data(form->sach01,sach_re,sach_im,nb_sach_carriers>>1,"","","");

	}

	if ((user_index == 0) && (tchan_index == 2)) {
	  fl_set_xyplot_xbounds(form->sacch02,-avg,avg);
	  fl_set_xyplot_ybounds(form->sacch02,-avg,avg);
	  fl_set_xyplot_xbounds(form->sach02,-avg,avg);
	  fl_set_xyplot_ybounds(form->sach02,-avg,avg);

	  fl_set_xyplot_data(form->sacch02,sacch_re,sacch_im,nb_sacch_carriers>>1,"","","");
	  fl_set_xyplot_data(form->sach02,sach_re,sach_im,nb_sach_carriers>>1,"","","");
	}
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
    fdui->lte_phy_scope_enb = fl_bgn_form( FL_NO_BOX, 800, 600 );

    // This the whole UI box
    obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 600, "" );
    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);

    // 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);
    
    // 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
    fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 540, 480, 240, 40, "" );
    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;
}
void phy_scope_eNB(FD_lte_phy_scope_enb *form, 
                   PHY_VARS_eNB *phy_vars_enb,
                   int UE_id) {
    int eNB_id = 0;
    int i,arx,atx,ind,k;
    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;
    float Re,Im,ymax;
    float *llr, *bit;
    float I[nsymb_ce*2], Q[nsymb_ce*2];
    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];
    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);
        }
    }

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

    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));
    
    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];
    
    // 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]);
            }
        }
    }
    
    // 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); 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),"","","");
        }
        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];
                }
                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);
            }
        }
        // Avoid flickering effect
        //        fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax);
        fl_set_xyplot_ybounds(form->chest_t,0,ymax);
    }
Beispiel #7
0
void
do_forms (FD_phy_procedures_sim * form,
	  LTE_UE_DLSCH ** lte_ue_dlsch_vars, LTE_eNB_ULSCH ** lte_eNB_ulsch_vars, struct complex **ch, u32 ch_len)
{

  s32 j, s, i;
  float I[3600], Q[3600], I2[3600], Q2[3600], I3[300], Q3[300];

  j = 0;
  //  printf("rxdataF_comp %p, lte_ue_dlsch_vars[0] %p\n",lte_ue_dlsch_vars[0]->rxdataF_comp[0],lte_ue_dlsch_vars[0]);
  for (s = 4; s < 12; s++) {
    for (i = 0; i < 12 * 12; i++) {
      I[j] = (float) ((short *)
		      lte_ue_dlsch_vars[0]->rxdataF_comp[0])[(2 * 25 * 12 * s) + 2 * i];
      Q[j] = (float) ((short *)
		      lte_ue_dlsch_vars[0]->rxdataF_comp[0])[(2 * 25 * 12 * s) + 2 * i + 1];
      //      printf("%d (%d): %f,%f : %d,%d\n",j,(25*12*s)+i,I[j],Q[j],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i+1]);
      j++;
    }
    if (s == 5)
      s = 6;
    else if (s == 8)
      s = 9;
  }
  if (j > 0)
    fl_set_xyplot_data (form->pdsch_constellation, I, Q, j, "", "", "");


  //fl_set_xyplot_xbounds(form->pdsch_constellation,-800,800);
  //fl_set_xyplot_ybounds(form->pdsch_constellation,-800,800);


  j = 0;
  //  printf("rxdataF_comp %p, lte_ue_dlsch_vars[0] %p\n",lte_ue_dlsch_vars[0]->rxdataF_comp[0],lte_ue_dlsch_vars[0]);
  for (s = 0; s < 12; s++) {
    for (i = 0; i < 6 * 12; i++) {
      I2[j] = (float) ((short *)
		       lte_eNB_ulsch_vars[0]->rxdataF_comp[0][0])[(2 * 25 * 12 * s) + 2 * i];
      Q2[j] = (float) ((short *)
		       lte_eNB_ulsch_vars[0]->rxdataF_comp[0][0])[(2 * 25 * 12 * s) + 2 * i + 1];
      //      printf("%d (%d): %f,%f : %d,%d\n",j,(25*12*s)+i,I[j],Q[j],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i],lte_ue_dlsch_vars[0]->rxdataF_comp[0][(2*25*12*s)+2*i+1]);
      j++;
    }
    if (s == 1)
      s = 2;
    else if (s == 7)
      s = 8;
  }
  if (j > 0)
    fl_set_xyplot_data (form->pusch_constellation, I2, Q2, j, "", "", "");

  fl_set_xyplot_xbounds(form->pusch_constellation,-800,800);
  fl_set_xyplot_ybounds(form->pusch_constellation,-800,800);

  for (j = 0; j < ch_len; j++) {

    I3[j] = j;
    Q3[j] = 10 * log10 (ch[0][j].x * ch[0][j].x + ch[0][j].y * ch[0][j].y);
  }

  fl_set_xyplot_data (form->ch00, I3, Q3, ch_len, "", "", "");
  //fl_set_xyplot_ybounds(form->ch00,-20,20);
}
void
adjust_interferometer_span (FL_OBJECT *ob, long data)
{
    interferometer_span = fl_get_slider_value (ob);
    fl_set_xyplot_ybounds (fd_receiver_interferometer->interferometer_chart, -1*interferometer_span, interferometer_span);
}
void
adjust_spectral_span(FL_OBJECT *ob, long data)
{
    current_span = (int)fl_get_slider_value(ob);
    fl_set_xyplot_ybounds(fd_receiver_spectrum->spectral_plot, (double)current_smax-current_span, (double)current_smax);
}
void adjust_tp_span (FL_OBJECT *ob, long data)
{
    tp_span = fl_get_slider_value (ob);
    tp_minval = tp_maxval - tp_span;
    fl_set_xyplot_ybounds (fd_receiver_continuum->tp_chart, tp_minval, tp_maxval);
}