From b947acff653562c5be7d21128555a16f87924d18 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 8 Nov 2004 23:30:07 +0000 Subject: [PATCH 01/16] network problems partially fixed --- nlsop_client.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/nlsop_client.c b/nlsop_client.c index ce42433..3f76549 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -66,6 +66,7 @@ int *gi; unsigned char dc; int get_data_and_calc(t_event *event,void *allineed); +int nop(t_event *event,void *allineed); int usage(char *prog) { @@ -304,19 +305,28 @@ u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { void send_data(int signum) { int c; + unsigned char data; c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z; + printf("%d <-\n",c); + network_send(gnet->connection[0].fd,&dc,1); /* network_send(gnet->connection[0].fd,(unsigned char *)gd3_l, sizeof(d3_lattice)); network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info)); */ + printf("debug: sent dc\n"); network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char)); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent ac\n"); network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra, c*sizeof(int)); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent cc\n"); network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int)); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); } @@ -397,7 +407,12 @@ int main(int argc,char **argv) /* wait for job */ event_math(net.connection[0].fd,&event,READ,ADD); printf("idle, waiting for jobs ...\n"); - event_start(&event,NULL,get_data_and_calc,NULL); + event_start(&event,NULL,get_data_and_calc,nop); + + return 1; +} + +int nop(t_event *event,void *allineed) { return 1; } @@ -413,7 +428,7 @@ int get_data_and_calc(t_event *event,void *allineed) { u32 x_c,y_c,z_c; int i,j; int c_step; - unsigned char data[256]; + unsigned char data; t_net *net; @@ -430,8 +445,8 @@ int get_data_and_calc(t_event *event,void *allineed) { printf("got a new job ...\n"); /* get info (+data) */ - network_receive(net->connection[0].fd,data,1); - if(data[0]==NLSOP_NJOB || data[0]==NLSOP_CJOB) { + network_receive(net->connection[0].fd,&data,sizeof(unsigned char)); + if(data==NLSOP_NJOB || data==NLSOP_CJOB) { network_receive(net->connection[0].fd,(unsigned char *)&d3_l, sizeof(d3_lattice)); network_receive(net->connection[0].fd,(unsigned char *)&my_info, @@ -448,15 +463,23 @@ int get_data_and_calc(t_event *event,void *allineed) { printf("extra malloc failed\n"); return -1; } - if(data[0]==NLSOP_CJOB) { + if(data==NLSOP_CJOB) { + data=DATA_OK; network_receive(net->connection[0].fd,d3_l.status, j*sizeof(unsigned char)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); network_receive(net->connection[0].fd,(unsigned char *)d3_l.extra, j*sizeof(int)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); network_receive(net->connection[0].fd,(unsigned char *)&c_step, sizeof(int)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); } } + else { + printf("unknown instruction, restarting ...\n"); + return -1; + } printf("starting simulation with following parameters:\n"); printf("b = %f | c = %f | s = %f\n",my_info.b,my_info.c,my_info.s); @@ -533,6 +556,8 @@ int get_data_and_calc(t_event *event,void *allineed) { dc=DC_QUIT; /* shutdown/free/close everything now ... */ + free(d3_l.status); + free(d3_l.extra); return 1; } -- 2.20.1 From d7dbaf20818533d5c2ed93907da01859e3a786bf Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 8 Nov 2004 23:31:46 +0000 Subject: [PATCH 02/16] network related fixes + debug printfs (will get removed) --- nlsop_server.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nlsop_server.c b/nlsop_server.c index 71eabf6..1fa3135 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -124,15 +124,25 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { int ret; d3_lattice d3l; info info; + unsigned char data; + + printf("receiving data from client (%d)\n",job->size); + data=DATA_OK; ret=network_receive_chan(net,channel,job->ac,job->size*sizeof(unsigned char)); if(ret==N_ERROR) printf("FATAL: getting ac status failed\n"); + network_send_chan(net,channel,&data,sizeof(unsigned char)); + printf("debug: got ac\n"); ret=network_receive_chan(net,channel,(unsigned char *)job->cc, job->size*sizeof(int)); if(ret==N_ERROR) printf("FATAL: getting cc failed\n"); + network_send_chan(net,channel,&data,sizeof(unsigned char)); + printf("debug: got cc\n"); ret=network_receive_chan(net,channel,(unsigned char *)&(job->step), sizeof(int)); if(ret==N_ERROR) printf("FATAL: getting step number failed\n"); + network_send_chan(net,channel,&data,sizeof(unsigned char)); + printf("debug: got steps\n"); if(dc!=DC_QUIT) { snprintf(filename,128,"./data/nlsop_b%f_c%f_s%f_ds%d_dr%f_-_%d_of_%d.save", @@ -369,7 +379,7 @@ int distribute_jobs(t_event *event,void *allineed) { if(min!=0) { printf("d: distributing jobs ...\n"); - printf("%d queued jobs, %d idle clients\n",count_j,count_c); + printf("%d queued jobs, %d idle clients\n\n",count_j,count_c); } list_reset(job); @@ -405,8 +415,12 @@ int distribute_jobs(t_event *event,void *allineed) { if(data==NLSOP_CJOB) { network_send_chan(net,c->channel,j->ac,j->size*sizeof(unsigned char)); + network_receive_chan(net,c->channel,&data,sizeof(unsigned char)); network_send_chan(net,c->channel,(unsigned char *)&(j->cc), j->size*sizeof(int)); + network_receive_chan(net,c->channel,&data,sizeof(unsigned char)); + network_send_chan(net,c->channel,(unsigned char *)&(j->step),sizeof(int)); + network_receive_chan(net,c->channel,&data,sizeof(unsigned char)); } --min; -- 2.20.1 From 520f56881396deed5206591ccc09f8734db8cc6b Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 10 Nov 2004 10:43:09 +0000 Subject: [PATCH 03/16] some more bugfixes + testing --- TODO | 5 +++-- nlsop_client.c | 15 ++++++++++++--- nlsop_server.c | 24 +++++++++++++++--------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index 26ce46b..236442f 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,7 @@ nlsop TODO ---------- -- more hits per loop (read #hits from trim result) -- c concentration against depth (a,c,both) +server,client,gui: +################## +test & fix! diff --git a/nlsop_client.c b/nlsop_client.c index 3f76549..535dc89 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -312,21 +312,30 @@ void send_data(int signum) { printf("%d <-\n",c); network_send(gnet->connection[0].fd,&dc,1); - /* + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent dc\n"); + network_send(gnet->connection[0].fd,(unsigned char *)gd3_l, sizeof(d3_lattice)); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent d3_lattice\n"); + network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info)); - */ - printf("debug: sent dc\n"); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent info\n"); + network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char)); network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); printf("debug: sent ac\n"); + network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra, c*sizeof(int)); network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); printf("debug: sent cc\n"); + network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int)); network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent steps\n"); } diff --git a/nlsop_server.c b/nlsop_server.c index 1fa3135..4f02c1f 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -129,18 +129,25 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { printf("receiving data from client (%d)\n",job->size); data=DATA_OK; + ret=network_receive_chan(net,channel,&d3l,sizeof(d3_lattice)); + network_send_chan(net,channel,&data,sizeof(unsigned char)); + printf("debug: got d3_lattice\n"); + + ret=network_receive_chan(net,channel,&info,sizeof(info)); + network_send_chan(net,channel,&data,sizeof(unsigned char)); + printf("debug: got info\n"); + ret=network_receive_chan(net,channel,job->ac,job->size*sizeof(unsigned char)); - if(ret==N_ERROR) printf("FATAL: getting ac status failed\n"); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got ac\n"); + ret=network_receive_chan(net,channel,(unsigned char *)job->cc, job->size*sizeof(int)); - if(ret==N_ERROR) printf("FATAL: getting cc failed\n"); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got cc\n"); + ret=network_receive_chan(net,channel,(unsigned char *)&(job->step), sizeof(int)); - if(ret==N_ERROR) printf("FATAL: getting step number failed\n"); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got steps\n"); @@ -154,16 +161,12 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { return -1; } - memset(&d3l,0,sizeof(d3_lattice)); - d3l.max_x=job->x; - d3l.max_y=job->y; - d3l.max_z=job->z; if(write(fd,&d3l,sizeof(d3_lattice))info),sizeof(info))status=IDLE; + /* free job memory */ + free(j->ac); + free(j->cc); /* delete job entry */ list_del_current(job); printf("job ended, saved and removed from list.\n"); @@ -371,7 +377,7 @@ int distribute_jobs(t_event *event,void *allineed) { if(j->status==IN_QUEUE) count_j++; } while(list_next(c_list)!=L_NO_NEXT_ELEMENT) { - if(j->status==IN_QUEUE) count_j++; + c=(t_client *)c_list->current->data; if(c->status==IDLE) count_c++; } -- 2.20.1 From e59c8d8fa97a1b2a0143b5aac9c0d437af07ea7a Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 10 Nov 2004 10:44:51 +0000 Subject: [PATCH 04/16] casting stuff --- nlsop_server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nlsop_server.c b/nlsop_server.c index 4f02c1f..747aa25 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -129,11 +129,12 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { printf("receiving data from client (%d)\n",job->size); data=DATA_OK; - ret=network_receive_chan(net,channel,&d3l,sizeof(d3_lattice)); + ret=network_receive_chan(net,channel,(unsigned char *)&d3l, + sizeof(d3_lattice)); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got d3_lattice\n"); - ret=network_receive_chan(net,channel,&info,sizeof(info)); + ret=network_receive_chan(net,channel,(unsigned char *)&info,sizeof(info)); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got info\n"); -- 2.20.1 From 3c6b696777d3ecc13534fe4054fc1ffa8c706044 Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 10 Nov 2004 12:46:48 +0000 Subject: [PATCH 05/16] some bugfixes + new tests --- nlsop_server.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/nlsop_server.c b/nlsop_server.c index 747aa25..232f5cc 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -129,26 +129,27 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { printf("receiving data from client (%d)\n",job->size); data=DATA_OK; - ret=network_receive_chan(net,channel,(unsigned char *)&d3l, + network_send_chan(net,channel,&data,sizeof(unsigned char)); + + network_receive_chan(net,channel,(unsigned char *)&d3l, sizeof(d3_lattice)); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got d3_lattice\n"); - ret=network_receive_chan(net,channel,(unsigned char *)&info,sizeof(info)); + network_receive_chan(net,channel,(unsigned char *)&info,sizeof(info)); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got info\n"); - ret=network_receive_chan(net,channel,job->ac,job->size*sizeof(unsigned char)); + network_receive_chan(net,channel,job->ac,job->size*sizeof(unsigned char)); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got ac\n"); - ret=network_receive_chan(net,channel,(unsigned char *)job->cc, + network_receive_chan(net,channel,(unsigned char *)job->cc, job->size*sizeof(int)); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got cc\n"); - ret=network_receive_chan(net,channel,(unsigned char *)&(job->step), - sizeof(int)); + network_receive_chan(net,channel,(unsigned char *)&(job->step),sizeof(int)); network_send_chan(net,channel,&data,sizeof(unsigned char)); printf("debug: got steps\n"); @@ -281,7 +282,10 @@ int handle_node(t_net *net,t_event *event, if(data==DC_END) { save_job(net,i,j,DC_END); /* reset client */ + printf("client in state %c now\n",c->status&IDLE?'i':'a'); c->status=IDLE; + printf("now: %c\n",c->status&IDLE?'i':'a'); + printf("it is channel %d\n",c->channel); /* free job memory */ free(j->ac); free(j->cc); -- 2.20.1 From e4463158c7f277c443ee31171c2e0e519a310269 Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 10 Nov 2004 12:47:38 +0000 Subject: [PATCH 06/16] new tests --- nlsop_client.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/nlsop_client.c b/nlsop_client.c index 535dc89..201c48c 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -306,6 +306,7 @@ void send_data(int signum) { int c; unsigned char data; + int fd; c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z; @@ -337,6 +338,16 @@ void send_data(int signum) { network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); printf("debug: sent steps\n"); + if(signum==121) { + printf("save test file\n"); + fd=open("./test.save",O_WRONLY|O_CREAT); + write(fd,gd3_l,sizeof(d3_lattice)); + write(fd,gmy_info,sizeof(info)); + write(fd,gd3_l->status,c*sizeof(unsigned char)); + write(fd,gd3_l->extra,c*sizeof(int)); + close(fd); + } + } @@ -357,7 +368,7 @@ int main(int argc,char **argv) gnet=&net; /* default values */ - strcpy(server_ip,""); + strcpy(server_ip,"137.250.82.105"); strcpy(p_file,IMP_PROFILE); strcpy(n_e_file,NEL_PROFILE); strcpy(r_file,""); @@ -423,6 +434,8 @@ int main(int argc,char **argv) int nop(t_event *event,void *allineed) { + printf("\ni did a nop :)\n"); + return 1; } @@ -553,7 +566,7 @@ int get_data_and_calc(t_event *event,void *allineed) { i++; if(i%my_info.save_rate==0) { dc=DC_OK; - send_data(0); + send_data(120); dc=DC_QUIT; } if(i%my_info.s_rate==0) sputter(&d3_l); @@ -561,12 +574,15 @@ int get_data_and_calc(t_event *event,void *allineed) { /* finished */ dc=DC_END; - send_data(0); + send_data(121); dc=DC_QUIT; /* shutdown/free/close everything now ... */ free(d3_l.status); free(d3_l.extra); + free(c_profile); + free(n_e_loss); + free(nel_z); return 1; } -- 2.20.1 From 4c5373958d4b8d38e51560ba898cfd0473d7c108 Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 12 Nov 2004 01:33:12 +0000 Subject: [PATCH 07/16] cleaned up dirty pointer handling -> global priv struct --- nlsop_server.c | 309 ++++++++++++++++++++++--------------------------- 1 file changed, 138 insertions(+), 171 deletions(-) diff --git a/nlsop_server.c b/nlsop_server.c index 232f5cc..353979b 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -51,13 +51,18 @@ #include "nlsop_general.h" -/* globals */ -int *gi; -t_net *gnet; -t_event *gevent; -t_list *gc_list; -t_list *gg_list; +typedef struct s_priv { + t_event event; + t_net net; + t_list client; + t_list gui; + t_list job; +} t_priv; + +/* global */ int alert; +int gi; +t_priv priv; /* * server specific stuff @@ -70,14 +75,14 @@ int usage(char *prog) return 1; } -int add_node(t_net *net,t_event *event,t_list *c_list,t_list *g_list) { +int add_node(void) { int channel; unsigned char data; t_client client; int gui_chan; - channel=network_manage_incoming(net); + channel=network_manage_incoming(&(priv.net)); if(channel==N_E_ACCEPT) { printf("accept failed!\n"); return -1; @@ -86,38 +91,38 @@ int add_node(t_net *net,t_event *event,t_list *c_list,t_list *g_list) { printf("maximum connections reached!\n"); return -1; } - printf("connection from %s port %d (ch: %d)\n",net->connection[channel].ip, - net->connection[channel].port, - channel); + printf("connection from %s port %d (ch: %d)\n", + priv.net.connection[channel].ip,priv.net.connection[channel].port, + channel); /* are you client or gui? */ - network_receive_chan(net,channel,&data,1); + network_receive_chan(&(priv.net),channel,&data,1); if(data==NLSOP_GUI) { gui_chan=channel; - list_add_element(g_list,&gui_chan,sizeof(int)); + list_add_element(&(priv.gui),&gui_chan,sizeof(int)); printf("node is a gui\n"); } else if(data==NLSOP_CLIENT) { client.status=IDLE; client.channel=channel; - list_add_element(c_list,&client,sizeof(t_client)); + list_add_element(&(priv.client),&client,sizeof(t_client)); printf("node is a client\n"); } else { printf("not a client or gui - lets kick that ass out of here!\n"); - network_close(net,channel); + network_close(&(priv.net),channel); return -1; } /* if we have a new node - care for it! */ - event_math(net->connection[channel].fd,event,READ,ADD); + event_math(priv.net.connection[channel].fd,&(priv.event),READ,ADD); printf("\n"); return 1; } -int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { +int save_job(unsigned char dc) { char filename[128]; int fd; @@ -125,39 +130,43 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { d3_lattice d3l; info info; unsigned char data; + t_job *j; - printf("receiving data from client (%d)\n",job->size); + j=(t_job *)priv.job.current->data; + + printf("receiving data from client (%d)\n",j->size); data=DATA_OK; - network_send_chan(net,channel,&data,sizeof(unsigned char)); + /* initial data_ok to start transmit on client */ + network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); - network_receive_chan(net,channel,(unsigned char *)&d3l, - sizeof(d3_lattice)); - network_send_chan(net,channel,&data,sizeof(unsigned char)); + network_receive_chan(&(priv.net),gi,(unsigned char *)&d3l, + sizeof(d3_lattice)); + network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); printf("debug: got d3_lattice\n"); - network_receive_chan(net,channel,(unsigned char *)&info,sizeof(info)); - network_send_chan(net,channel,&data,sizeof(unsigned char)); + network_receive_chan(&(priv.net),gi,(unsigned char *)&info,sizeof(info)); + network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); printf("debug: got info\n"); - network_receive_chan(net,channel,job->ac,job->size*sizeof(unsigned char)); - network_send_chan(net,channel,&data,sizeof(unsigned char)); + network_receive_chan(&(priv.net),gi,j->ac,j->size*sizeof(unsigned char)); + network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); printf("debug: got ac\n"); - network_receive_chan(net,channel,(unsigned char *)job->cc, - job->size*sizeof(int)); - network_send_chan(net,channel,&data,sizeof(unsigned char)); + network_receive_chan(&(priv.net),gi,(unsigned char *)j->cc, + j->size*sizeof(int)); + network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); printf("debug: got cc\n"); - network_receive_chan(net,channel,(unsigned char *)&(job->step),sizeof(int)); - network_send_chan(net,channel,&data,sizeof(unsigned char)); + network_receive_chan(&(priv.net),gi,(unsigned char *)&(j->step),sizeof(int)); + network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); printf("debug: got steps\n"); if(dc!=DC_QUIT) { 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->step,job->info.steps); + j->info.b,j->info.c,j->info.s, + j->info.diff_rate,j->info.dr_ac, + j->step,j->info.steps); if((fd=open(filename,O_WRONLY|O_CREAT))<0) { printf("FATAL: unable to open file %s\n",filename); return -1; @@ -173,14 +182,14 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { return -1; } - ret=write(fd,job->ac,job->size*sizeof(unsigned char)); - if(retsize*sizeof(unsigned char)) { + ret=write(fd,j->ac,j->size*sizeof(unsigned char)); + if(retsize*sizeof(unsigned char)) { printf("FATAL: write of a/c states failed\n"); return -1; } - ret=write(fd,job->cc,job->size*sizeof(int)); - if(retsize*sizeof(int)) { + ret=write(fd,j->cc,j->size*sizeof(int)); + if(retsize*sizeof(int)) { printf("FATAL: write of c.-conc. failed\n"); return -1; } @@ -192,7 +201,7 @@ int save_job(t_net *net,int channel,t_job *job,unsigned char dc) { return 1; } -int add_job(t_net *net,int chan,t_list *jl) { +int add_job(void) { t_job job; @@ -200,10 +209,11 @@ int add_job(t_net *net,int chan,t_list *jl) { job.status=IN_QUEUE; job.progress=0; - network_receive_chan(net,chan,(unsigned char *)&(job.x),sizeof(int)); - network_receive_chan(net,chan,(unsigned char *)&(job.y),sizeof(int)); - network_receive_chan(net,chan,(unsigned char *)&(job.z),sizeof(int)); - network_receive_chan(net,chan,(unsigned char *)&(job.info),sizeof(info)); + network_receive_chan(&(priv.net),gi,(unsigned char *)&(job.x),sizeof(int)); + network_receive_chan(&(priv.net),gi,(unsigned char *)&(job.y),sizeof(int)); + network_receive_chan(&(priv.net),gi,(unsigned char *)&(job.z),sizeof(int)); + network_receive_chan(&(priv.net),gi,(unsigned char *)&(job.info), + sizeof(info)); job.size=job.x*job.y*job.z; @@ -221,7 +231,7 @@ int add_job(t_net *net,int chan,t_list *jl) { job.step=0; - list_add_element(jl,&job,sizeof(t_job)); + list_add_element(&(priv.job),&job,sizeof(t_job)); printf("job added: b=%f | c=%f | s=%f ...\n", job.info.b,job.info.c,job.info.s); @@ -229,7 +239,7 @@ int add_job(t_net *net,int chan,t_list *jl) { return 1; } -int send_status(t_net *net,int chan,t_list *jl) { +int send_status(void) { unsigned char data; int count; @@ -237,94 +247,87 @@ int send_status(t_net *net,int chan,t_list *jl) { data=GUI_INFO; - count=list_count(jl); + count=list_count(&(priv.job)); printf("sending job info\n"); - network_send_chan(net,chan,&data,sizeof(unsigned char)); - network_send_chan(net,chan,(unsigned char *)&count,sizeof(int)); + network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); + network_send_chan(&(priv.net),gi,(unsigned char *)&count,sizeof(int)); - list_reset(jl); + list_reset(&(priv.job)); for(i=0;icurrent->data,sizeof(t_job)); - list_next(jl); + network_send_chan(&(priv.net),gi,priv.job.current->data,sizeof(t_job)); + list_next(&(priv.job)); } return 1; } -int handle_node(t_net *net,t_event *event, - t_list *c_list,t_list *g_list,t_list *job) { +int handle_node(void) { - int i; unsigned char data; t_client *c; t_job *j; - gi=&i; - - for(i=0;iconnection[i].fd,&(event->rfds))) { + for(gi=0;gicurrent->data; - c=(t_client *)c_list->current-data; + list_search_data(&(priv.job),&gi,sizeof(int)); + j=(t_job *)priv.job.current->data; + c=(t_client *)priv.client.current->data; if(data==DC_END) { - save_job(net,i,j,DC_END); + save_job(DC_END); /* reset client */ - printf("client in state %c now\n",c->status&IDLE?'i':'a'); c->status=IDLE; - printf("now: %c\n",c->status&IDLE?'i':'a'); - printf("it is channel %d\n",c->channel); /* free job memory */ free(j->ac); free(j->cc); /* delete job entry */ - list_del_current(job); + list_del_current(&(priv.job)); printf("job ended, saved and removed from list.\n"); } if(data==DC_OK) { - save_job(net,i,j,DC_OK); + save_job(DC_OK); /* inc progress state */ j->progress+=1; printf("job at next level, saved.\n"); } if(data==DC_QUIT) { - save_job(net,i,j,DC_QUIT); + save_job(DC_QUIT); /* network disconnect */ - event_math(net->connection[i].fd,event,READ,REMOVE); - network_close(net,i); + event_math(priv.net.connection[gi].fd,&(priv.event),READ,REMOVE); + network_close(&(priv.net),gi); /* del from client list */ - list_del_current(c_list); + list_del_current(&(priv.client)); /* change job state */ j->status=IN_QUEUE; printf("client terminating, job queued, client removed.\n"); } } - else if(list_search_data(g_list,&i,sizeof(int))==L_SUCCESS) { + else if(list_search_data(&(priv.gui),&gi,sizeof(int))==L_SUCCESS) { /* its a gui */ - if(data==GUI_ADDJOB) add_job(net,i,job); + if(data==GUI_ADDJOB) add_job(); - else if(data==GUI_INFO) send_status(net,i,job); + else if(data==GUI_INFO) send_status(); else if(data==GUI_QUIT) { - printf("disconnecting gui on channel %d\n",i); - event_math(net->connection[i].fd,event,READ,REMOVE); - network_close(net,i); - list_del_current(g_list); + printf("disconnecting gui on channel %d\n",gi); + event_math(priv.net.connection[gi].fd,&(priv.event),READ,REMOVE); + network_close(&(priv.net),gi); + list_del_current(&(priv.gui)); } else { @@ -335,8 +338,8 @@ int handle_node(t_net *net,t_event *event, else { printf("this chan is not in client or gui list! i disconnect now!\n"); - event_math(net->connection[i].fd,event,READ,REMOVE); - network_close(net,i); + event_math(priv.net.connection[gi].fd,&(priv.event),READ,REMOVE); + network_close(&(priv.net),gi); } } } @@ -348,41 +351,31 @@ int handle_node(t_net *net,t_event *event, int distribute_jobs(t_event *event,void *allineed) { - t_net *net; - t_list *c_list,*g_list,*job; int count_j,count_c,min; t_job *j; t_client *c; unsigned char data; d3_lattice d3l; - unsigned int addr[4]; - - memcpy(addr,allineed,4*sizeof(unsigned int)); - net=(t_net *)addr[0]; - c_list=(t_list *)addr[1]; - g_list=(t_list *)addr[2]; - job=(t_list *)addr[3]; - - list_reset(job); - list_reset(c_list); + list_reset(&(priv.job)); + list_reset(&(priv.client)); count_j=0; count_c=0; - if((c_list->current==NULL)||(job->current==NULL)) return 2; + if((priv.client.current==NULL)||(priv.job.current==NULL)) return 2; - j=(t_job *)job->current->data; - c=(t_client *)c_list->current->data; + j=(t_job *)priv.job.current->data; + c=(t_client *)priv.client.current->data; if(j->status==IN_QUEUE) count_j++; if(c->status==IDLE) count_c++; - while(list_next(job)!=L_NO_NEXT_ELEMENT) { - j=(t_job *)job->current->data; + while(list_next(&(priv.job))!=L_NO_NEXT_ELEMENT) { + j=(t_job *)priv.job.current->data; if(j->status==IN_QUEUE) count_j++; } - while(list_next(c_list)!=L_NO_NEXT_ELEMENT) { - c=(t_client *)c_list->current->data; + while(list_next(&(priv.client))!=L_NO_NEXT_ELEMENT) { + c=(t_client *)priv.client.current->data; if(c->status==IDLE) count_c++; } @@ -393,19 +386,19 @@ int distribute_jobs(t_event *event,void *allineed) { printf("%d queued jobs, %d idle clients\n\n",count_j,count_c); } - list_reset(job); - list_reset(c_list); + list_reset(&(priv.job)); + list_reset(&(priv.client)); while(min) { - j=(t_job *)job->current->data; - c=(t_client *)c_list->current->data; + j=(t_job *)priv.job.current->data; + c=(t_client *)priv.client.current->data; while(c->status!=IDLE) { - list_next(c_list); - c=(t_client *)c_list->current->data; + list_next(&(priv.client)); + c=(t_client *)priv.client.current->data; } while(j->status!=IN_QUEUE) { - list_next(job); - j=(t_job *)job->current->data; + list_next(&(priv.job)); + j=(t_job *)priv.job.current->data; } /* direct current job to current client */ @@ -420,23 +413,27 @@ int distribute_jobs(t_event *event,void *allineed) { d3l.max_y=j->y; d3l.max_z=j->z; - network_send_chan(net,c->channel,&data,sizeof(unsigned char)); - network_send_chan(net,c->channel,(unsigned char *)&d3l,sizeof(d3_lattice)); - network_send_chan(net,c->channel,(unsigned char *)&(j->info),sizeof(info)); + network_send_chan(&(priv.net),c->channel,&data,sizeof(unsigned char)); + network_send_chan(&(priv.net),c->channel,(unsigned char *)&d3l, + sizeof(d3_lattice)); + network_send_chan(&(priv.net),c->channel,(unsigned char *)&(j->info), + sizeof(info)); if(data==NLSOP_CJOB) { - network_send_chan(net,c->channel,j->ac,j->size*sizeof(unsigned char)); - network_receive_chan(net,c->channel,&data,sizeof(unsigned char)); - network_send_chan(net,c->channel,(unsigned char *)&(j->cc), + network_send_chan(&(priv.net),c->channel,j->ac, + j->size*sizeof(unsigned char)); + network_receive_chan(&(priv.net),c->channel,&data,sizeof(unsigned char)); + network_send_chan(&(priv.net),c->channel,(unsigned char *)&(j->cc), j->size*sizeof(int)); - network_receive_chan(net,c->channel,&data,sizeof(unsigned char)); - network_send_chan(net,c->channel,(unsigned char *)&(j->step),sizeof(int)); - network_receive_chan(net,c->channel,&data,sizeof(unsigned char)); + network_receive_chan(&(priv.net),c->channel,&data,sizeof(unsigned char)); + network_send_chan(&(priv.net),c->channel,(unsigned char *)&(j->step), + sizeof(int)); + network_receive_chan(&(priv.net),c->channel,&data,sizeof(unsigned char)); } --min; - list_next(c_list); - list_next(job); + list_next(&(priv.client)); + list_next(&(priv.job)); } return 1; @@ -444,27 +441,16 @@ int distribute_jobs(t_event *event,void *allineed) { int parse_incoming(t_event *event,void *allineed) { - t_net *net; - t_list *c_list,*g_list,*job; - unsigned int addr[4]; - - memcpy(addr,allineed,4*sizeof(unsigned int)); - - net=(t_net *)addr[0]; - c_list=(t_list *)addr[1]; - g_list=(t_list *)addr[2]; - job=(t_list *)addr[3]; - /* decide what to do */ - if(FD_ISSET(net->l_fd,&(event->rfds))) { + if(FD_ISSET(priv.net.l_fd,&(priv.event.rfds))) { /* new node */ printf("new node ...\n"); - add_node(net,event,c_list,g_list); + add_node(); } else { /* client/gui interaction */ printf("node interaction ...\n"); - handle_node(net,event,c_list,g_list,job); + handle_node(); } return 1; @@ -472,15 +458,15 @@ int parse_incoming(t_event *event,void *allineed) { void destroy_it(int signum) { - printf("connection to client (ch %d) fucked up!\n",*gi); - event_math(gnet->connection[*gi].fd,gevent,READ,REMOVE); - network_close(gnet,*gi); - if(list_search_data(gc_list,gi,sizeof(int))==L_SUCCESS) { - list_del_current(gc_list); + printf("connection to client (ch %d) fucked up!\n",gi); + event_math(priv.net.connection[gi].fd,&(priv.event),READ,REMOVE); + network_close(&(priv.net),gi); + if(list_search_data(&(priv.client),&gi,sizeof(int))==L_SUCCESS) { + list_del_current(&(priv.client)); printf("removed client from list\n"); } - if(list_search_data(gg_list,gi,sizeof(int))==L_SUCCESS) { - list_del_current(gg_list); + if(list_search_data(&(priv.gui),&gi,sizeof(int))==L_SUCCESS) { + list_del_current(&(priv.gui)); printf("removed gui from list\n"); } @@ -497,26 +483,7 @@ int main(int argc,char **argv) { int port; - t_net net; - t_event event; - t_list c_list; - t_list g_list; - t_list job; - void *allyouneed; - unsigned int addr[4]; - - gnet=&net; - gevent=&event; - gc_list=&c_list; - gg_list=&g_list; - - /* tzzz ... */ - allyouneed=(void *)addr; - addr[0]=(unsigned int)&net; - addr[1]=(unsigned int)&c_list; - addr[2]=(unsigned int)&g_list; - addr[3]=(unsigned int)&job; - + /* default values */ port=1025; @@ -524,19 +491,19 @@ int main(int argc,char **argv) if(argc==2) port=atoi(argv[1]); /* event init */ - event_init(&event,1); + event_init(&(priv.event),1); /* 10 sec event timeout - distributing jobs */ - event_set_timeout(&event,10,0); + event_set_timeout(&(priv.event),10,0); /* list init */ - list_init(&c_list,1); - list_init(&g_list,1); - list_init(&job,1); + list_init(&(priv.client),1); + list_init(&(priv.gui),1); + list_init(&(priv.job),1); /* connect to server */ - network_init(&net,1); - network_set_listen_port(&net,port); - if(network_listen(&net)!=N_SUCCESS) { + network_init(&(priv.net),1); + network_set_listen_port(&(priv.net),port); + if(network_listen(&(priv.net))!=N_SUCCESS) { printf("unable to listen on port %d, aborting!\n",port); return -1; } @@ -545,9 +512,9 @@ int main(int argc,char **argv) signal(SIGALRM,destroy_it); /* wait for events :) */ - event_math(net.l_fd,&event,READ,ADD); + event_math(priv.net.l_fd,&(priv.event),READ,ADD); printf("\nNLSOP_SERVER started!\n\n"); - event_start(&event,allyouneed,parse_incoming,distribute_jobs); + event_start(&(priv.event),NULL,parse_incoming,distribute_jobs); return 1; } -- 2.20.1 From fdb9c4fc1debc12c8f97b5105411a95ea001fae1 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 16 Nov 2004 08:44:55 +0000 Subject: [PATCH 08/16] added default server ip --- nlsop_gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nlsop_gui.c b/nlsop_gui.c index ec9de6d..3129fe2 100644 --- a/nlsop_gui.c +++ b/nlsop_gui.c @@ -342,7 +342,7 @@ int main(int argc,char **argv) /* default values */ strcpy(logfile,LOGFILE); - strcpy(server_ip,""); + strcpy(server_ip,"137.250.82.105"); port=1025; /* parse/check argv */ -- 2.20.1 From 064393d5ac0802dc79efa35c5443130708aad511 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 16 Nov 2004 10:53:02 +0000 Subject: [PATCH 09/16] last fixes + removed debug messages --- nlsop_client.c | 50 ++++++++------------------------------------------ nlsop_server.c | 21 +-------------------- 2 files changed, 9 insertions(+), 62 deletions(-) diff --git a/nlsop_client.c b/nlsop_client.c index 201c48c..9718270 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -305,49 +305,15 @@ u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { void send_data(int signum) { int c; - unsigned char data; - int fd; c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z; - printf("%d <-\n",c); - - network_send(gnet->connection[0].fd,&dc,1); - network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); - printf("debug: sent dc\n"); - - network_send(gnet->connection[0].fd,(unsigned char *)gd3_l, - sizeof(d3_lattice)); - network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); - printf("debug: sent d3_lattice\n"); - - network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info)); - network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); - printf("debug: sent info\n"); - - network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char)); - network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); - printf("debug: sent ac\n"); - - network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra, - c*sizeof(int)); - network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); - printf("debug: sent cc\n"); - - network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int)); - network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); - printf("debug: sent steps\n"); - - if(signum==121) { - printf("save test file\n"); - fd=open("./test.save",O_WRONLY|O_CREAT); - write(fd,gd3_l,sizeof(d3_lattice)); - write(fd,gmy_info,sizeof(info)); - write(fd,gd3_l->status,c*sizeof(unsigned char)); - write(fd,gd3_l->extra,c*sizeof(int)); - close(fd); - } - + network_send_chan(gnet,0,&dc,1); + network_send_chan(gnet,0,(unsigned char *)gd3_l,sizeof(d3_lattice)); + network_send_chan(gnet,0,(unsigned char *)gmy_info,sizeof(info)); + network_send_chan(gnet,0,gd3_l->status,c*sizeof(unsigned char)); + network_send_chan(gnet,0,(unsigned char *)gd3_l->extra,c*sizeof(int)); + network_send_chan(gnet,0,(unsigned char *)gi,sizeof(int)); } @@ -566,7 +532,7 @@ int get_data_and_calc(t_event *event,void *allineed) { i++; if(i%my_info.save_rate==0) { dc=DC_OK; - send_data(120); + send_data(0); dc=DC_QUIT; } if(i%my_info.s_rate==0) sputter(&d3_l); @@ -574,7 +540,7 @@ int get_data_and_calc(t_event *event,void *allineed) { /* finished */ dc=DC_END; - send_data(121); + send_data(0); dc=DC_QUIT; /* shutdown/free/close everything now ... */ diff --git a/nlsop_server.c b/nlsop_server.c index 353979b..5a627db 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -129,38 +129,19 @@ int save_job(unsigned char dc) { int ret; d3_lattice d3l; info info; - unsigned char data; t_job *j; j=(t_job *)priv.job.current->data; - printf("receiving data from client (%d)\n",j->size); - data=DATA_OK; - - /* initial data_ok to start transmit on client */ - network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); + printf("receiving data from client (#cells=%d)\n",j->size); network_receive_chan(&(priv.net),gi,(unsigned char *)&d3l, sizeof(d3_lattice)); - network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); - printf("debug: got d3_lattice\n"); - network_receive_chan(&(priv.net),gi,(unsigned char *)&info,sizeof(info)); - network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); - printf("debug: got info\n"); - network_receive_chan(&(priv.net),gi,j->ac,j->size*sizeof(unsigned char)); - network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); - printf("debug: got ac\n"); - network_receive_chan(&(priv.net),gi,(unsigned char *)j->cc, j->size*sizeof(int)); - network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); - printf("debug: got cc\n"); - network_receive_chan(&(priv.net),gi,(unsigned char *)&(j->step),sizeof(int)); - network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); - printf("debug: got steps\n"); if(dc!=DC_QUIT) { snprintf(filename,128,"./data/nlsop_b%f_c%f_s%f_ds%d_dr%f_-_%d_of_%d.save", -- 2.20.1 From b51118179eecd57b59a6de583743c14ce476d0ad Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 16 Nov 2004 11:34:46 +0000 Subject: [PATCH 10/16] improved gui functionality (help + client info) --- nlsop_general.h | 1 + nlsop_gui.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/nlsop_general.h b/nlsop_general.h index 5078ab5..d466775 100644 --- a/nlsop_general.h +++ b/nlsop_general.h @@ -12,6 +12,7 @@ #define GUI_INFO 'i' #define GUI_ADDJOB 'a' #define GUI_QUIT 'q' +#define GUI_HELP 'h' #define DATA_OK (1<<0) diff --git a/nlsop_gui.c b/nlsop_gui.c index 3129fe2..e467791 100644 --- a/nlsop_gui.c +++ b/nlsop_gui.c @@ -109,6 +109,7 @@ int send_and_wait_for_answer(t_net *net,t_display *display,t_input *input) { int i,count; t_job job; + t_client client; char data; char string[MAX_CONTENT]; @@ -124,6 +125,7 @@ int send_and_wait_for_answer(t_net *net,t_display *display,t_input *input) { return -1; } + display_new_line(display,input,"jobs:"); network_receive_chan(net,0,(unsigned char *)&count,sizeof(int)); for(i=0;ic_count==0) { switch(input->content[0]) { + case GUI_HELP: + display_help(display,input); + break; case GUI_INFO: send_and_wait_for_answer(net,display,input); break; -- 2.20.1 From fbc07d62fcdebec39450d69aca254ab91c284ef4 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 16 Nov 2004 11:35:39 +0000 Subject: [PATCH 11/16] added gui functionality (show client info) --- nlsop_server.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/nlsop_server.c b/nlsop_server.c index 5a627db..4409108 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -228,19 +228,26 @@ int send_status(void) { data=GUI_INFO; - count=list_count(&(priv.job)); - - printf("sending job info\n"); - network_send_chan(&(priv.net),gi,&data,sizeof(unsigned char)); - network_send_chan(&(priv.net),gi,(unsigned char *)&count,sizeof(int)); + printf("sending job + client list ...\n"); + count=list_count(&(priv.job)); + network_send_chan(&(priv.net),gi,(unsigned char *)&count,sizeof(int)); list_reset(&(priv.job)); for(i=0;idata,sizeof(t_job)); list_next(&(priv.job)); } + count=list_count(&(priv.client)); + network_send_chan(&(priv.net),gi,(unsigned char *)&count,sizeof(int)); + list_reset(&(priv.client)); + for(i=0;idata, + sizeof(t_client)); + list_next(&(priv.client)); + } + return 1; } -- 2.20.1 From 0dcd23ead2402b25e59a63668c16d375f031177d Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 17 Nov 2004 13:03:38 +0000 Subject: [PATCH 12/16] new TODOs --- TODO | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 236442f..b39ad0a 100644 --- a/TODO +++ b/TODO @@ -4,4 +4,7 @@ nlsop TODO server,client,gui: ################## -test & fix! +- remove jobs! (nlsop_server/nlsop_client) +- if above is implemented, display step should be possible (nlsop_*) +- bugfix client channel display (nlsop_server/nlsop_gui?) + -- 2.20.1 From 8e3d4f991108f6b44e434dde7f11ee9ddfe39b9c Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 24 Nov 2004 18:12:45 +0000 Subject: [PATCH 13/16] added 3dplot + linescan code --- .cvsignore | 2 ++ 3dplot.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ linescan.c | 42 ++++++++++++++++++++++++++++++++++++++++++ makefile | 8 +++++++- 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 3dplot.c create mode 100644 linescan.c diff --git a/.cvsignore b/.cvsignore index b4cb776..4da6a6a 100644 --- a/.cvsignore +++ b/.cvsignore @@ -11,3 +11,5 @@ be2le dft *.bmp *.plot +linescan +3dplot diff --git a/3dplot.c b/3dplot.c new file mode 100644 index 0000000..fbf1d2b --- /dev/null +++ b/3dplot.c @@ -0,0 +1,47 @@ +/* 3dplot.c -- 3d plot bmp image */ + +/* + * author: frank.zirkelbach@physik.uni-augsburg.de + * + */ + +#define _GNU_SOURCE +#include + +#include +#include "bmp.h" + +int main(int argc,char **argv) { + + t_bmp bmp; + int x,y; + int help; + int val; + + if(argc!=2) { + printf("usage: %s \n",argv[0]); + return -1; + } + + bmp_init(&bmp,2); + bmp.mode=READ; + strcpy(bmp.file,argv[1]); + + bmp_read_file(&bmp); + + dprintf(2,"width = %d\n",bmp.info.width); + + for(x=0;x + +#include +#include "bmp.h" + +int main(int argc,char **argv) { + + t_bmp bmp; + int x,y; + + if(argc!=2) { + printf("usage: %s \n",argv[0]); + return -1; + } + + bmp_init(&bmp,2); + bmp.mode=READ; + strcpy(bmp.file,argv[1]); + + bmp_read_file(&bmp); + + dprintf(2,"width = %d\n",bmp.info.width); + + x=bmp.info.width/2; + for(y=0;y Date: Wed, 24 Nov 2004 18:18:21 +0000 Subject: [PATCH 14/16] *** empty log message *** --- start_client.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 start_client.sh diff --git a/start_client.sh b/start_client.sh new file mode 100755 index 0000000..6465520 --- /dev/null +++ b/start_client.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if [ "`ps -ef | grep n[l]sop_client`" = "" ]; then + cd ~/work/nlsop + ./nlsop_client +fi -- 2.20.1 From f9579e76a73b3645f1ab524f04aaca4dff11f039 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 29 Nov 2004 15:31:52 +0000 Subject: [PATCH 15/16] dded destroy_it functionality (find associated jb, reset+queue it) --- nlsop_server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nlsop_server.c b/nlsop_server.c index 4409108..9adc6f8 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -446,6 +446,8 @@ int parse_incoming(t_event *event,void *allineed) { void destroy_it(int signum) { + t_job *j; + printf("connection to client (ch %d) fucked up!\n",gi); event_math(priv.net.connection[gi].fd,&(priv.event),READ,REMOVE); network_close(&(priv.net),gi); @@ -453,6 +455,13 @@ void destroy_it(int signum) { list_del_current(&(priv.client)); printf("removed client from list\n"); } + if(list_search_data(&(priv.job),&gi,sizeof(int))==L_SUCCESS) { + printf("associated job found. resetting & queueing job.\n"); + j=(t_job *)priv.job.current->data; + j->channel=-1; + j->status=IN_QUEUE; + j->progress=0; + } if(list_search_data(&(priv.gui),&gi,sizeof(int))==L_SUCCESS) { list_del_current(&(priv.gui)); printf("removed gui from list\n"); -- 2.20.1 From 00d21a74bbdcef8522ba629280353e84158dc7d1 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 18 Jan 2005 16:17:06 +0000 Subject: [PATCH 16/16] small modifications & addons + introduced am. layout info --- TODO | 8 ++-- dfbapi.c | 2 + nlsop.c | 122 +++++++++++++++++++++++++++++++++++++------------------ nlsop.h | 6 ++- 4 files changed, 93 insertions(+), 45 deletions(-) diff --git a/TODO b/TODO index b39ad0a..fb2a955 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,10 @@ nlsop TODO ---------- +- new parameter set! + server,client,gui: ################## -- remove jobs! (nlsop_server/nlsop_client) -- if above is implemented, display step should be possible (nlsop_*) -- bugfix client channel display (nlsop_server/nlsop_gui?) - +- idle clients channel! +- del jobs possibility diff --git a/dfbapi.c b/dfbapi.c index 58510fc..da7b5f3 100644 --- a/dfbapi.c +++ b/dfbapi.c @@ -357,6 +357,8 @@ int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switch if(ke.key_id==DIKI_DOWN && *y!=d3_l->max_y-1) *y+=1; if(ke.key_id==DIKI_PAGE_UP && *z!=0) *z-=1; if(ke.key_id==DIKI_PAGE_DOWN && *z!=d3_l->max_z-1) *z+=1; + if(ke.key_id==DIKI_END && *z<=d3_l->max_z-10) *z+=10; + if(ke.key_id==DIKI_HOME && *z>=10) *z-=10; if(ke.key_id==DIKI_Q) *q=1; if(ke.key_id==DIKI_ESCAPE) *esc=1; if(ke.key_id==DIKI_M) *switchmode=(*switchmode+1)%4; diff --git a/nlsop.c b/nlsop.c index 578a1de..f030561 100644 --- a/nlsop.c +++ b/nlsop.c @@ -347,9 +347,11 @@ int write_ac_distr(d3_lattice *d3_l,int ac_distr) if(*(d3_l->status+offset)&AMORPH) count+=1; } } -#ifndef MAC if(ac_distr==4) dprintf(fd,"%d %d\n",z*CELL_LENGTH,count); +#ifdef ATPROZ else dprintf(fd,"%d %f\n",z*CELL_LENGTH,100.0*count/si_count); +#else + else dprintf(fd,"%d %d\n",z*CELL_LENGTH,count/(d3_l->max_x*d3_l->max_y)); #endif } close(fd); @@ -932,7 +934,6 @@ int load_from_file(char *lf,d3_lattice *d3_l,info *my_inf) int convert_file(char *cf,d3_lattice *d3_l) { -#ifndef MAC int x,y,z; int c_fd; @@ -953,7 +954,6 @@ int convert_file(char *cf,d3_lattice *d3_l) } } close(c_fd); -#endif return 1; } @@ -1066,12 +1066,45 @@ u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { return max; } +int get_amorphous_layer_info(d3_lattice *d3_l,int *sai,int *sacl,int *eacl) { + int i,j,a,oend,nend,count; + unsigned char sacl_is_set=0; + unsigned char eacl_is_set=0; + unsigned char sai_is_set=0; + + a=d3_l->max_x*d3_l->max_y; + nend=a; + oend=0; + + for(i=0;imax_z;i++) { + count=0; + for(j=oend;jstatus+j)&AMORPH) count++; + oend=nend; + nend+=a; + if((count>=A_START*a)&&(!sai_is_set)) { + *sai=i; + sai_is_set=1; + } + if((count>=AC_START*a)&&(!sacl_is_set)) { + *sacl=i; + sacl_is_set=1; + } + if((count<=A_END*a)&&(sacl_is_set)&&(!eacl_is_set)) { + *eacl=i; + eacl_is_set=1; + } + if((eacl_is_set)&&(count>=A_END*a)) eacl_is_set=0; + } + return 1; +} + int main(int argc,char **argv) { u32 x,y,z,x_c,y_c,z_c; int i,j,quit,escape,switchmode,nowait,bmp,ac_distr; int refresh,resave; int c_step; + int sai,sacl,eacl; char s_file[MAX_CHARS]; char s_file_tmp[MAX_CHARS]; char l_file[MAX_CHARS]; @@ -1095,11 +1128,13 @@ int main(int argc,char **argv) char zdiff_txt[MAX_TXT]; char diff_txt[MAX_TXT]; char dr_ac_txt[MAX_TXT]; - char dr_cc_txt[MAX_TXT]; char dose_txt[MAX_TXT]; char mode_txt[MAX_TXT]; char hpi_txt[MAX_TXT]; - char csat_txt[MAX_TXT]; + char srate_txt[MAX_TXT]; + char start_ai_txt[MAX_TXT]; + char start_acl_txt[MAX_TXT]; + char end_acl_txt[MAX_TXT]; char *arg_v[MAX_ARGV]; #endif d3_lattice d3_l; @@ -1144,6 +1179,9 @@ int main(int argc,char **argv) mode=0; ne_max=0; ip_max=0; + sai=0; + sacl=0; + eacl=0; #ifdef MORE_PRINTF printf("reading argv ..."); @@ -1250,23 +1288,18 @@ int main(int argc,char **argv) } #endif -#ifdef MORE_PRINTF - printf("rand init ..."); -#endif - + printf("random api init ..."); if(!strcmp(r_file,"")) rand_init(NULL); else rand_init(r_file); - -#ifdef MORE_PRINTF printf(" done\n"); - printf("allocating data ..."); -#endif if(!strcmp(l_file,"")) { i=d3_l.max_x*d3_l.max_y*d3_l.max_z; #ifdef USE_DFB_API + printf("d3 lattice init ..."); d3_lattice_init(&argc,argv,&d3_l); + printf(" done\n"); #endif if((d3_l.status=(unsigned char *)malloc(i*sizeof(unsigned char)))==NULL) { @@ -1282,7 +1315,9 @@ int main(int argc,char **argv) memset(d3_l.extra,0,i*sizeof(int)); } else { + printf("loading file ..."); load_from_file(l_file,&d3_l,&my_info); + printf(" done\n"); if(convert) { if(!strcmp(c_file,"")) sprintf(c_file,"%s_gnuplot",l_file); @@ -1292,23 +1327,23 @@ int main(int argc,char **argv) return 1; } #ifdef USE_DFB_API - else d3_lattice_init(&argc,argv,&d3_l); + printf("d3 lattice init ..."); + d3_lattice_init(&argc,argv,&d3_l); + printf(" done\n"); #endif } -#ifdef MORE_PRINTF - printf(" done\n"); -#endif - #ifdef USE_DFB_API + printf("event init ..."); d3_event_init(&d3_l); + printf(" done\n"); #endif #ifdef USE_DFB_API strcpy(a_txt,"args:"); sprintf(s_txt,"steps: %d",my_info.steps); sprintf(dose_txt,"dose: %.2fe+17 C/cm²",my_info.steps*1.0/(d3_l.max_x*d3_l.max_y*CELL_LENGTH*CELL_LENGTH*1000)); - sprintf(r_txt,"pressure range: %d",my_info.range); + sprintf(r_txt,"stress influence range: %d",my_info.range); sprintf(stress_txt,"stress term: %f",my_info.s); sprintf(ballistic_txt,"ballistic term: %f",my_info.b); sprintf(carbon_txt,"carbon term: %f",my_info.c); @@ -1317,7 +1352,11 @@ int main(int argc,char **argv) sprintf(diff_txt,"diffusion every %d steps",my_info.diff_rate); strcpy(mode_txt,"view: a/c mode"); sprintf(hpi_txt,"hits per ion: %d",my_info.cpi); - sprintf(csat_txt,"sputter rate (3nm/#c): %d",my_info.s_rate); + sprintf(srate_txt,"sputter rate (3nm/#c): %d",my_info.s_rate); + get_amorphous_layer_info(&d3_l,&sai,&sacl,&eacl); + sprintf(start_ai_txt,"start of a-inclusions: %d nm (%d)",3*sai,sai); + sprintf(start_acl_txt,"start of a-layer: %d nm (%d)",3*sacl,sacl); + sprintf(end_acl_txt,"end of a-layer: %d nm (%d)",3*eacl,eacl); arg_v[1]=mode_txt; arg_v[2]=xyz_txt; arg_v[3]=status_txt; @@ -1331,25 +1370,22 @@ int main(int argc,char **argv) arg_v[11]=dose_txt; arg_v[12]=diff_txt; arg_v[13]=zdiff_txt; - arg_v[14]=r_txt; + arg_v[14]=dr_ac_txt; arg_v[15]=ballistic_txt; arg_v[16]=carbon_txt; arg_v[17]=stress_txt; - arg_v[18]=dr_ac_txt; - arg_v[19]=dr_cc_txt; - arg_v[20]=hpi_txt; - arg_v[21]=csat_txt; - arg_v[22]=NULL; - arg_v[23]=NULL; - arg_v[24]=NULL; + arg_v[18]=r_txt; + arg_v[19]=hpi_txt; + arg_v[20]=srate_txt; + arg_v[21]=NULL; + arg_v[22]=start_ai_txt; + arg_v[23]=start_acl_txt; + arg_v[24]=end_acl_txt; arg_v[25]=NULL; #endif -#ifdef MORE_PRINTF - printf("random rejection graphs ..."); -#endif - /* compute graphs for random number rejection method */ + printf("random rejection graphs ..."); if((c_profile=(u32 *)malloc(d3_l.max_z*sizeof(unsigned int)))==NULL) { puts("failed allocating memory for carbon profile graph"); @@ -1362,11 +1398,7 @@ int main(int argc,char **argv) } ip_max=get_reject_graph(&my_info,&d3_l,p_file,c_profile); ne_max=get_reject_graph(&my_info,&d3_l,n_e_file,n_e_loss); - -#ifdef MORE_PRINTF printf(" done\n"); -#endif - if((!strcmp(l_file,""))||(c_step)) { @@ -1429,11 +1461,15 @@ int main(int argc,char **argv) #ifdef USE_DFB_API if(i%refresh==0) { - sprintf(xyz_txt,"x: %d y: %d z: %d",x+1,y+1,z+1); + sprintf(xyz_txt,"x: %d y: %d z: %d (%d nm)",x+1,y+1,z+1,z*3); sprintf(status_txt,"status: %c",(*(d3_l.status+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)&AMORPH)?'a':'c'); - sprintf(conc_txt,"conc: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)); + sprintf(conc_txt,"carbon: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)); sprintf(steps_txt,"step: %d",i); sprintf(cc_txt,"total c: %d",my_info.cc); + get_amorphous_layer_info(&d3_l,&sai,&sacl,&eacl); + sprintf(start_ai_txt,"start of a-inclusions: %d nm (%d)",3*sai,sai); + sprintf(start_acl_txt,"start of a-layer: %d nm (%d)",3*sacl,sacl); + sprintf(end_acl_txt,"end of a-layer: %d nm (%d)",3*eacl,eacl); d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,0,NULL,0,NULL,0); } #endif @@ -1458,14 +1494,20 @@ int main(int argc,char **argv) #ifdef USE_DFB_API /* allocating buffer for pressure values */ + printf("allocating buffer for preassure values ..."); if((d3_l.v_ptr=malloc(d3_l.max_x*d3_l.max_y*d3_l.max_z*sizeof(unsigned char)))==NULL) { puts("cannot allocate buffer for pressure values"); return -1; } + printf(" done\n"); /* calc values */ + printf("calculating preassure values ..."); calc_pressure(&d3_l,my_info.range); + printf(" done\n"); + printf("finding maximum carbon concentration ..."); max_extra=calc_max_extra(&d3_l); + printf(" done\n"); while((quit==0) && (escape==0) && (nowait==0)) { @@ -1475,9 +1517,9 @@ int main(int argc,char **argv) if(switchmode==2) mode=2; if(switchmode==3) mode=3; /* end of bahh! */ - sprintf(xyz_txt,"x: %d y: %d z: %d",x+1,y+1,z+1); + sprintf(xyz_txt,"x: %d y: %d z: %d (%d nm)",x+1,y+1,z+1,z*3); sprintf(status_txt,"status: %c",(*(d3_l.status+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)&AMORPH)?'a':'c'); - sprintf(conc_txt,"conc: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)); + sprintf(conc_txt,"carbon: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)); sprintf(steps_txt,"step: end"); sprintf(cc_txt,"total c: %d",my_info.cc); if(switchmode==0) strcpy(mode_txt,"view: a/c mode"); diff --git a/nlsop.h b/nlsop.h index d63a507..5fffea6 100644 --- a/nlsop.h +++ b/nlsop.h @@ -40,7 +40,7 @@ typedef struct __info #define C_D .005 #define MAX_CHARS 128 -#define MAX_TXT 32 +#define MAX_TXT 40 #define MAX_ARGV 27 #define IMP_PROFILE "imp-profile.txt" @@ -53,6 +53,10 @@ typedef struct __info #define S_RATE ((2*3*STEPS)/100) #define SI_PER_VOLUME (168*8) +#define A_START 0.1 +#define AC_START 0.89 +#define A_END 0.84 + #define FFT_HEIGHT 64 #endif /* NLSOP_H */ -- 2.20.1