From 5246e11671ef0cceef2086f1c9d75c35198683e2 Mon Sep 17 00:00:00 2001 From: hackbard Date: Thu, 4 Nov 2004 01:12:17 +0000 Subject: [PATCH] nearly finished gui code. adaptions / bugfixes. --- nlsop.h | 6 ++-- nlsop_client.c | 48 +++++++++++++----------------- nlsop_gui.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ nlsop_server.c | 3 +- 4 files changed, 102 insertions(+), 34 deletions(-) diff --git a/nlsop.h b/nlsop.h index 5e8db78..d41f84c 100644 --- a/nlsop.h +++ b/nlsop.h @@ -15,9 +15,8 @@ typedef unsigned int u32; typedef struct __info { - int cc,steps,range,diff_rate,cpi,s_rate; - double s,b,c,dr_ac,dr_cc; - char z_diff,c_diff; + int cc,steps,range,diff_rate,cpi,s_rate,save_rate; + double s,b,c,dr_ac; } info; #define AMORPH 1 @@ -34,7 +33,6 @@ typedef struct __info #define CC 0 #define DR_AC .5 -#define DR_CC .2 #define DIFF_RATE 1000 #define S_D .00001 diff --git a/nlsop_client.c b/nlsop_client.c index 6467827..6ac9c92 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -54,10 +54,6 @@ #define MAKE_AMORPH(N) *(N)|=AMORPH #define MAKE_CRYST(N) *(N)&=~AMORPH -#define NLSOP_CLIENT 'c' -#define NLSOP_NJOB 'N' -#define NLSOP_CJOB 'C' - /* globals */ char p_file[MAX_CHARS]; @@ -205,31 +201,29 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,u32 rj_m,u32 *rj_g) } } } - if(my_info->z_diff) + /* diff in z direction */ + if(k!=0) { - if(k!=0) + off=i+j*d3_l->max_x+(k-1)*d3_l->max_x*d3_l->max_y; + carry=0; + if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); + if(carry!=0) { - off=i+j*d3_l->max_x+(k-1)*d3_l->max_x*d3_l->max_y; - carry=0; - if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); - if(carry!=0) - { - *(d3_l->extra+off)-=carry; - *(d3_l->extra+offset)+=carry; - } + *(d3_l->extra+off)-=carry; + *(d3_l->extra+offset)+=carry; } - if(k!=d3_l->max_z-1) + } + if(k!=d3_l->max_z-1) + { + off=i+j*d3_l->max_x+(k+1)*d3_l->max_x*d3_l->max_y; + carry=0; + if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); + if(carry!=0) { - off=i+j*d3_l->max_x+(k+1)*d3_l->max_x*d3_l->max_y; - carry=0; - if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); - if(carry!=0) - { - *(d3_l->extra+off)-=carry; - *(d3_l->extra+offset)+=carry; - } + *(d3_l->extra+off)-=carry; + *(d3_l->extra+offset)+=carry; } - } + } } } /* for z */ } /* for y */ @@ -417,13 +411,11 @@ int get_data_and_calc(t_event *event,void *allineed) { u32 *nel_z; u32 x_c,y_c,z_c; int i,j; - int resave; int c_step; unsigned char data[256]; t_net *net; - resave=RESAVE; c_step=0; ne_max=0; ip_max=0; @@ -516,12 +508,12 @@ int get_data_and_calc(t_event *event,void *allineed) { process_cell(&d3_l,x_c,y_c,z_c,&my_info,nel_z[z_c]); } distrib_c(&d3_l,&my_info,i,ip_max,c_profile); - if(i%resave==0 && i!=0) { + i++; + if(i%my_info.save_rate==0) { dc=DC_OK; send_data(0); dc=DC_QUIT; } - i++; if(i%my_info.s_rate==0) sputter(&d3_l); } diff --git a/nlsop_gui.c b/nlsop_gui.c index 7949c55..0c56147 100644 --- a/nlsop_gui.c +++ b/nlsop_gui.c @@ -75,6 +75,85 @@ int send_and_wait_for_answer(t_net *net,t_display *display) { int send_job(t_net *net,t_input *input,t_display *display) { + char command[MAX_CONTENT]; + int x,y,z; + info info; + + /* default values */ + x=X; + y=Y; + z=Z; + info.cc=CC; + info.steps=STEPS; + info.range=RANGE; + info.diff_rate=DIFF_RATE; + info.cpi=CPI; + info.s_rate=S_RATE; + info.save_rate=RESAVE; + info.s=S_D; + info.b=B_D; + info.c=C_D; + info.dr_ac=DR_AC; + + strncpy(command,input->content,MAX_CONTENT); + + strtok(command," "); + while(strtok(NULL," ")!=NULL) { + switch(command[0]) { + case 'b': + info.b=atof(command+1); + break; + case 'c': + info.c=atof(command+1); + break; + case 's': + info.s=atof(command+1); + break; + case 'd': + info.diff_rate=atoi(command+1); + break; + case 'D': + info.dr_ac=atof(command+1); + break; + case 'S': + info.steps=atoi(command+1); + break; + case 'C': + info.cpi=atoi(command+1); + break; + case 'r': + info.range=atoi(command+1); + break; + case 'R': + info.s_rate=atoi(command+1); + break; + case 'x': + info.save_rate=atoi(command+1); + break; + case 'X': + x=atoi(command+1); + break; + case 'Y': + y=atoi(command+1); + break; + case 'Z': + z=atoi(command+1); + break; + default: + display_new_line(display,"unknown command"); + break; + } + } + + command[0]=GUI_ADDJOB; + network_send_chan(net,0,data,1); + + network_send_chan(net,0,(unsigned char *)&x,sizeof(int)); + network_send_chan(net,0,(unsigned char *)&y,sizeof(int)); + network_send_chan(net,0,(unsigned char *)&z,sizeof(int)); + + network_send_chan(net,0,(unsigned char *)&info,sizeof(info)); + return 1; } diff --git a/nlsop_server.c b/nlsop_server.c index 528c634..5d11e48 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -122,10 +122,9 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { if(ret==N_ERROR) printf("FATAL: getting step number failed\n"); if(dc!=DC_QUIT) { - snprintf(filename,128,"nlsop_b%f_c%f_s%f_ds%d_dr%f_Z%c__%d_of_%d.save", + snprintf(filename,128,"./data/nlsop_b%f_c%f_s%f_ds%d_dr%f_-_%d_of_%d.save", job->info.b,job->info.c,job->info.s, job->info.diff_rate,job->info.dr_ac, - job->info.z_diff?'y':'n', job->step,job->info.steps); if((fd=open(filename,O_WRONLY|O_CREAT))<0) { printf("FATAL: unable to open file %s\n",filename); -- 2.39.2