Exemplo n.º 1
0
/*
   Reset the bounds of the 2 axis to that allowed by the plotted
   data.  First reset the bounds in the XPLOT object and then
   reset the sliders (which talk to XYPLOT object to get the bounds).
*/
void Reset_cb(FL_OBJECT *ob, long data)
{
  int i;
  for (i=0;i<GlobalNoOfOverlays;i++)
    fl_set_xyplot_xbounds(CHART[i],0,0);
  /*  fl_set_xyplot_ybounds(CHART[0],0,0);*/
  ResetSliders();
}
Exemplo n.º 2
0
void XMax_cb(FL_OBJECT *ob, long data)
{
  float max,min;
  int i;
  for(i=0;i<GlobalNoOfOverlays;i++)
    {
      fl_get_xyplot_xbounds(CHART[i],&min,&max);
      max = (float)fl_get_slider_value(ob);
      fl_set_xyplot_xbounds(CHART[i],(double)min,(double)max);
    }
}
Exemplo n.º 3
0
Arquivo: sach.c Projeto: a4a881d4/oai
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,"","","");
	}
Exemplo n.º 4
0
Arquivo: unit.c Projeto: a4a881d4/oai
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);
}
Exemplo n.º 5
0
void PlotButtonCB(FL_OBJECT *p0, long p1) {
  FL_OBJECT *np = the_gui->NEntry;
  FL_OBJECT *sp = the_gui->ProgressSlider;
  FL_OBJECT *cp = the_gui->DistributionChoice;
  FL_OBJECT *xyp = the_gui->xyplot;
  RNG *rng = CreateRNG();
  int n = atoi(fl_get_input(np));
  double r;
  int i, j;
  int distrib[NB];
  float xv[NB];
  float yv[NB];
  int di;
  float dx;
  unsigned long xl;
  double sum, sumsq;
  static char *mstring = new char[80];
  static char *sdstring = new char[80];
  int ymax;
  double xmin, xmax;

  if (rng == NULL)
    return;

  for (i=0; i<NB; i++)
    distrib[i] = 0;
  sum = sumsq = 0.0;
  ymax = 0;
  
  if (n >= PROGRESS_THRESHOLD) {
    di = n/100;			// update slider every 'di' points
    fl_set_slider_value(sp,0.0);
    fl_show_object(sp);
  }
  else
    di = 0;			// n too small; don't draw slider

  xmin = atof(fl_get_input(the_gui->MinEntry));
  xmax = atof(fl_get_input(the_gui->MaxEntry));

  for (i=0; i<n; i++) {
    r = ++(*rng);		// get a sample from current distribution
    sum += r;
    sumsq += r*r;

    j = fl_get_choice(cp);
    if ((j == Binomial) || (j == Poisson))
      r *= 10.0;		// spread out integer values so we can see them
    
    if (j == CDF)		// 'dx' is a value added to each sample
      dx = 0.0005;		// the CDF demo RNG returns values that are exactly
    else			// on the divide between two bins, and roundoff
      dx = 0.0;			// errors lead to funny looking plots....

    j = floor((r+dx-xmin)*NB/(xmax-xmin));
    
    if ((j >= 0) && (j < NB)) {
      distrib[j] += 1;
      if (distrib[j] > ymax)
	ymax = distrib[j];
    }
    if (di && ((i%di)==0))
      fl_set_slider_value(sp,(double)i/(double)n);
  }

  fl_hide_object(sp);		// all done; put away the slider

  // Bins filled; transfer to x and y vectors and plot.  The xyplot
  // widget will scale x and y automatically.

  fl_delete_xyplot_text(xyp,mstring);
  fl_delete_xyplot_text(xyp,sdstring);

  for (i=0; i<NB; i++) {
    xv[i] = (float)i*(xmax-xmin)/NB + xmin;
    yv[i] = (float)distrib[i];
  }

  if (xmin == xmax)
    fl_set_xyplot_xbounds(xyp,xmin+1.0,xmax); 	// auto-scale if min>max
  else
    fl_set_xyplot_xbounds(xyp,xmin,xmax);
  fl_set_xyplot_data(xyp, xv, yv, NB, "", "", "");

  // compute, display sample mean and sample standard deviation

  double dn = double(n);
  double mean = sum/dn;
  double sd = sqrt(dn*((sumsq/dn)-mean*mean)/(dn-1));

  sprintf(mstring,"Sample Mean =  %f",mean);
  sprintf(sdstring,"Standard Dev = %f",sd);

  // The (x,y) coords of the string are defined in terms of scaled plot
  // units.  If the right edge of the x scale is at 100, put the text
  // at 80.  Put the top string near the top of the plot, and the bottom
  // string 10% lower.

  double y1 = double(ymax) - .05*(double(ymax));
  double y2 = double(ymax) - .10*(double(ymax));

  fl_add_xyplot_text(xyp,(xmax-xmin)*0.8+xmin,y1,mstring,FL_ALIGN_CENTER,FL_BLACK);
  fl_add_xyplot_text(xyp,(xmax-xmin)*0.8+xmin,y2,sdstring,FL_ALIGN_CENTER,FL_BLACK);
  
  delete rng;			// some RNGs allocate internal tables....
}