int main(void) { t_env env; int ret; if (!power_two(WIN_VALUE)) return (0); signal(SIGINT, sighandler); startwin(&env); while (true) { ret = menu(&env, 0, 0); if (ret == 2) break ; else if (ret == 1) highscore(&env); else if (ret == 0) { init_env_game(&env); game(&env); get_name(&env); get_score(&env, 0); del_env_game(&env); } } return (endwin(), 0); }
int main(int arg, char *argv[]) { int Npoint; //socket variable SOCKET sock; const char *IP="192.168.128.3"; init_TCP_client(&sock, IP, Port); get_RP_settings(&sock); printf("r0=%f\n",r0); printf("rf=%f\n",rf); printf("dec=%i\n",dec); printf("Nline=%i\n",Nline); printf("sector=%f\n",sector); printf("mode_RP=%i\n",mode_RP); int l=0; Npoint=(int)(2.0*(rf-r0)*125.0/1.48/((double)dec)); if (Npoint>16384) {Npoint=16384;} printf("Npoint = %i\n",Npoint); int powd, pad_len; if (power_two(Npoint,&powd)){powd++;} pad_len=int_pow(2,powd); init_table(pad_len); float fech=125000000.0/((float)dec); //gnuplot variable gnuplot_ctrl * h; double *y= (double *)malloc(Npoint*sizeof(double)); int i; int Ymax=1.5; //gnuplot object h=gnuplot_init(); gnuplot_setstyle(h,"lines"); gnuplot_set_xlabel(h,"time (us)"); gnuplot_set_ylabel(h,"signal"); //gnuplot_cmd(h,"set yrange [0:%d]", 2*Ymax); gnuplot_cmd(h,"set xrange [0:%d]",Npoint-1); char name[30]; if (mode_RP==0) { int powd, pad_len; if (power_two(Npoint,&powd)){powd++;} pad_len=int_pow(2,powd); double *pad=NULL; pad=(double *)malloc(pad_len*sizeof(double)); double *env=NULL; env=(double *)malloc(pad_len*sizeof(double)); gnuplot_cmd(h,"set yrange [-0.01:1.5]"); gnuplot_cmd(h,"set xrange [0:%d]",Npoint-1); int16_t *buff=(int16_t *)malloc((Npoint+1)*sizeof(int16_t)); while(1) { if(receive_int16_TCP_client(&sock, buff, Npoint+1)==1){break;} for (i=1 ; i<Npoint+1 ; i++){y[i-1]=(double)(buff[i])/409.6;} //divide by 409.6 to have voltage value zero_padding(y, pad, Npoint, pad_len, 1); envelope(pad, env, pad_len, fech, fmin, fmax, 0); gnuplot_resetplot(h); //gnuplot_plot_x(h, y, Npoint, "Oscillo int16_t"); gnuplot_plot_x(h, env, pad_len, "Oscillo int16_t"); //sprintf(name, "int%i.txt", l); //writefile(y, Npoint, name); l++; } free(buff); free(pad); free(env); } else if (mode_RP==1) { char *buff=(char *)malloc((Npoint+1)*sizeof(char)); while(1) { if(receive_TCP_client(&sock, buff, Npoint+1)==1){break;} for (i=1 ; i<Npoint+1 ; i++){y[i-1]=(double)(int_converter(buff[i]));} gnuplot_resetplot(h); gnuplot_plot_x(h, y, Npoint, "Oscillo 256 gray"); sprintf(name, "char%i.txt", l); //writefile(y, Npoint, name); l++; } free(buff); } else {printf("Problem of settings\n");} usleep(30); close(sock); free(y); return 0; }
int main(int arg, char *argv[]) { //socket variable SOCKET sock; const char *IP="192.168.128.3"; init_TCP_client(&sock, IP, Port); get_RP_settings(&sock); printf("x0=%f\n",x0); printf("xf=%f\n",xf); printf("dec=%i\n",dec); printf("Nline=%i\n",Nline); printf("sector=%f\n",sector); printf("mode_RP=%i\n",mode_RP); char name[50]; Npoint=(int)(2.0*(xf-x0)*125.0/1.48/((double)dec)); if (Npoint>16384){Npoint=16384;} printf("Npoint = %i\n",Npoint); int powd, pad_len; if (power_two(Npoint,&powd)){powd++;} pad_len=int_pow(2,powd); init_table(pad_len); //gnuplot variable gnuplot_ctrl * h; int i, j; double **x = NULL; double **y = NULL; int **z = (int **)malloc(Nline*sizeof(int *)); double *tmp = (double *)malloc(Npoint*sizeof(int)); double *tmp2 = (double *)malloc(pad_len*sizeof(double)); double **env = (double **)malloc(Nline*sizeof(double *)); double *pad = (double *)malloc(pad_len*sizeof(double)); x = malloc(Nline*sizeof(double *)); y = malloc(Nline*sizeof(double *)); for (i=0 ; i<Nline ; i++) { x[i]=malloc((Npoint)*sizeof(double)); y[i]=malloc((Npoint)*sizeof(double)); z[i]=malloc((Npoint)*sizeof(int)); env[i]=(double *)malloc(pad_len*sizeof(double)); if (env[i]==NULL) {printf("boulet!");} for (j=0 ; j<pad_len ; j++) {env[i][j]=0.0;} } init_xy(x,y); //gnuplot object h=gnuplot_init(); gnuplot_cmd(h, "set pm3d map"); gnuplot_cmd(h, "set palette gray"); int k=1, line=0, l=0, temp; if (mode_RP==0) { int16_t *buff=(int16_t *)malloc((Npoint+1)*sizeof(int16_t)); float fech, f0, fm; fech=125000000.0/dec; f0=3500000.0; fm=6500000.0; i=0; j=0; while (1) { receive_int16_TCP_client(&sock, buff, Npoint+1); j=i; i=(int)buff[0]; if (j==63 && i==64) {break;} if (j==2 && i==1) {break;} } while(k) { temp=l/10; for (i=0 ; i<Nline ; i++) { if (receive_int16_TCP_client(&sock, buff, Npoint+1)==1) { i=Nline+2; k=0; break; } if(i<Nline+2) { line=(int)buff[0]-1; for (j=0 ; j<Npoint ; j++) {tmp[j]=(double)buff[j+1];} zero_padding(tmp, pad, Npoint, pad_len, 1); tmp2=env[line]; envelope(pad, tmp2, pad_len, fech, f0, fm, 0); if (temp*10==l) {z[line]=tmp[j];} //for (j=0 ; j<Npoint ; j++) {z[line][j]=(int)env[j];} } } gnuplot_matrix_double(h, env, Npoint, Nline); if (temp*10==l) { sprintf(name, "int%i.txt", l); writefile_double(env, Nline, Npoint, name); } l++; } free(buff); } else if (mode_RP==1) { char *buff=(char *)malloc((Npoint+1)*sizeof(char)); while(k) { for (i=0 ; i<Nline ; i++) { if (receive_TCP_client(&sock, buff, Npoint+1)==1) { i=Nline+2; k=0; break; } if(i<Nline+2) { line=int_converter(buff[0])-1; for (j=0 ; j<Npoint ; j++) {z[line][j]=int_converter(buff[j+1]);} } } gnuplot_matrix(h, z, Npoint, Nline); temp=l/10; if (temp*10==l) { sprintf(name, "char%i.txt", l); writefile(z, Nline, Npoint, name); } l++; } free(buff); } else {printf("problem with RP settings\n");} /*int k=1, line=0, l=0; while(k) { for (i=0 ; i<Nline ; i++) { if (receive_TCP_client(&sock, buff, Npoint+1)==1) { i=Nline+2; k=0; break; } if (i<Nline+2) { line=int_converter(buff[0])-1; for (j=0 ; j<Npoint-1 ; j++) { //z[line][j]=(int)buff[j+1]; z[line][j]=int_converter(buff[j+1]); } } } gnuplot_matrix(h, z, Npoint, Nline); //sprintf(name, "main%i.txt",l); //writefile(z, Nline, Npoint, name); l++; }*/ usleep(30); close(sock); free(x); free(y); free(z); free(env); free(pad); return 0; }