void test4(void) { init_xy(); if ((x < y ? x++ : y++) != 2) abort (); }
void test4(void) { init_xy(); if ((x < y ? x++ : y++) != 2) ASSERT (0); if (x != 3) ASSERT (0); if (y != 3) ASSERT (0); }
void test5(void) { int z; init_xy(); z = (x < y) ? x++ : y++; if (z != 2) ASSERT (0); if (x != 3) ASSERT (0); if (y != 3) ASSERT (0); }
void test5(void) { int z; init_xy(); z = (x < y) ? x++ : y++; if (z != 2) abort (); if (x != 3) abort (); if (y != 3) abort (); }
void test6(void) { int xx = 3, yy = 2; int z; init_xy(); z = (xx < y) ? x++ : y++; if (z != 2) ASSERT (0); if (x != 3) ASSERT (0); if (y != 3) ASSERT (0); }
void test6(void) { int xx = 3, yy = 2; int z; init_xy(); z = (xx < y) ? x++ : y++; if (z != 2) abort (); if (x != 3) abort (); if (y != 3) abort (); }
int main(int arg, char *argv[]) { //socket variable int sock; struct sockaddr_in sin; char buff[BuffLength]; const char *IP="192.168.128.3"; //gnuplot variable gnuplot_ctrl * h; //handler of gnuplot session int i, j, line; double *x = NULL; double *y = NULL; double **z = (double **)malloc(Nline*sizeof(double *)); for (i=0 ; i<Nline ; i++) { x=malloc((BuffLength-1)*sizeof(double)); y=malloc(Nline*sizeof(double)); z[i]=malloc((BuffLength-1)*sizeof(double)); } init_xy(x,y); //Create socket sock=socket(AF_INET, SOCK_STREAM, 0); if (sock==-1) { perror("socket()"); exit(errno); } sin.sin_addr.s_addr=inet_addr(IP); sin.sin_family=AF_INET; sin.sin_port=htons(Port); if (connect(sock, (struct sockaddr *) &sin, sizeof(sin))==-1) { perror("connect()"); exit(errno); } printf("Connected\n"); //gnuplot object h=gnuplot_init(); gnuplot_surf_gray(h, x, y, z, BuffLength-1, Nline, "test"); while(1) { if(recv(sock, buff, BuffLength, MSG_WAITALL)==0) { printf("Server closed\n"); break; } for (i=0 ; i<Nline ; i++) { line=(int)(buff[0]); for (j=0 ; j<BuffLength-1 ; j++) { z[line][j]=(double)(buff[j+1]); } } gnuplot_surf_gray(h, x, y, z, BuffLength-1, Nline,"test"); } writefile(x,y,z,Nline,BuffLength-1); close(sock); gnuplot_close(h); free(x); free(y); free(z); 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; }