Changeset 52 for anr/gantt.l
- Timestamp:
- Jan 31, 2010, 10:17:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anr/gantt.l
r51 r52 39 39 0 40 40 }; 41 struct partner_def { char *key, *name, *file; } partner_table[] = { 42 { "UNKNOW", "relax", 0, }, 43 { "irisa", "irisa", "table_irisa.tex" }, 44 { "lip", "lip", "table_lip.tex" }, 45 { "tima", "tima", "table_tima.tex" }, 46 { "ubs", "ubs", "table_ubs.tex" }, 47 { "upmc", "upmc", "table_upmc.tex" }, 48 { "altera", "altera", "table_altera.tex" }, 49 { "xilinx", "xilinx", "table_xilinx.tex" }, 50 { "bull", "bull", "table_bull.tex" }, 51 { "thales", "thales", "table_thales.tex" }, 52 { "zied", "zied", "table_zied.tex" }, 53 { "navtel", "navtel", "table_navtel.tex" }, 54 { 0, 0, 0 }, 55 }; 41 56 42 57 typedef struct _Tlivrable { … … 44 59 char v; // 0, 1, 2, ..., F 45 60 char* title; 46 int bm,em; // mois de bebut et de fin 61 int bm,em; // mois de bebut et de fin 62 double hman[3]; // nombre de mh par an 63 int partner; // index dans partner_table 47 64 // these fields are filled by the program for data[tn][0][0][0] 48 65 double task_y; // top of task 49 66 double task_dy; // bot of task is task_y+task_dy 50 67 double task_y_del; // delivrables start at task_y+task_y_del 68 double nbma[3]; // durée en mois par annee 51 69 // these fields are filled by the program for data[tn][stn][dn][0] 52 70 struct _Tlivrable … … 106 124 *l = *data_org.ls[tn][stn][dn][v]; 107 125 data->ls[tn][stn][dn][v] = l; 108 fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d\n",tn,stn,dn,v);126 //fprintf(stderr,"selected: [tn][stn][dn][v]=%d,%d,%d,%d\n",tn,stn,dn,v); 109 127 } 110 128 return data; … … 196 214 %% 197 215 int tn,stn,dn,v,bm,em; char* title; 216 double an[3]; 217 char* an_comment; 218 int partner; 198 219 #.*\n ; 199 T=[0-9]+ { tn=atoi(yytext+2); } 200 T=D[0-9]+ { tn=atoi(yytext+3); } 201 S=[0-9]+ { stn=atoi(yytext+2); } 202 D=[0-9]+ { dn=atoi(yytext+2); } 203 V=V. { v=yytext[3]; } 204 V= { v='F'; } 220 T=[0-9]+ { tn=atoi(yytext+2); } 221 S=[0-9]+ { stn=atoi(yytext+2); } 222 D=[0-9]+ { dn=atoi(yytext+2); } 223 V=V[1-8F] { v=yytext[3]; } 205 224 ML=[0-9]+ { 206 225 int i; … … 208 227 milestones[i] = atoi(yytext+3); 209 228 } 210 211 229 BM=[0-9]+ { bm=atoi(yytext+3); } 212 230 EM=[0-9]+ { em=atoi(yytext+3); } 231 R=none { an[0]=0; an[1]=0; an[2]=0; an_comment=0; } 232 R=[0-9:.]+ { 233 char tmp[1000]; 234 int status = sscanf(yytext+2,"%lf:%lf:%lf:%s",an+0,an+1,an+2,tmp); 235 if (status<3) { 236 fprintf(stderr,"%s: is not resource definition, expected format \"N:N:N\" (near D%d%d%d-V%c)\n", 237 yytext+2,tn,stn,dn,v); 238 an[0]=0; an[1]=0; an[2]=0; an_comment=0; 239 } else if (status==3) { 240 an_comment = 0; 241 } else 242 an_comment = strdup(tmp); 243 } 244 PART="{"[^}]+"}" { 245 int i; 246 partner=-1; 247 for (i=0; partner_table[i].key!=0 ; i++) { 248 if (strstr(yytext,partner_table[i].key)!=0 ) { 249 partner=i; 250 break; 251 } 252 } 253 if ( partner==-1 ) { 254 fprintf(stderr,"%s: does not contains a partner key (near D%d%d%d-V%c)\n", 255 yytext+5,tn,stn,dn,v); 256 partner=0; 257 } 258 } 213 259 TITLE=.*\n { 214 260 char* pc=yytext+6; … … 221 267 p->dn = dn; 222 268 p->v = v; 269 p->hman[0] = an[0]; 270 p->hman[1] = an[1]; 271 p->hman[2] = an[2]; 272 p->partner = partner; 223 273 p->title = title; 224 274 p->bm = bm; … … 228 278 for (v=0; data_org.ls[tn][stn][dn][v]!=0 ; v++); 229 279 data_org.ls[tn][stn][dn][v] = p; 230 fprintf(stderr,"ADDED: %d %d %d %d\n",tn,stn,dn,v); 231 //{int i,tn=0; fprintf(stderr,"CURR:t=%d:: ",tn); for (i=0; i<S_MAX ; i++) fprintf(stderr,"%d:%p ",i,data[tn][i][0][0]); fprintf(stderr,"\n"); } 232 } 233 .|\n ; 280 //fprintf(stderr,"ADDED: %d %d %d %d\n",tn,stn,dn,v); 281 } 282 [ \t\n] ; 283 . { fprintf(stderr,"%c: unexpected value in anr.gantt file (near D%d%d%d-V%c)\n", 284 *yytext,tn,stn,dn,v); } 234 285 %% 235 286 … … 327 378 h += (p->vers[p->nbvers-1]->nbTitleLines-1)*(DELIVRABLE_TITLEHEIGHT/5.); 328 379 if ( h>p->height) p->height=h; 380 } 381 Tlivrable* lu= p->vers[p->nbvers-1]; 382 int i; 383 fprintf(stderr,"--------------------\n"); 384 for (i=0 ; i<p->nbvers ; i++) { 385 Tlivrable* l= p->vers[i]; 386 double bm= l->bm; 387 double em= l->em; 388 //fprintf(stderr," %d%d%d-V%c: bm=%2.f em=%2.f --> %2.1f %2.1f %2.1f\n",l->tn,l->stn,l->dn,l->v,bm,em, lu->nbma[0],lu->nbma[1],lu->nbma[2]); 389 if (bm<12 && em>0) { 390 lu->nbma[0] += (em>12?12:em)-bm; 391 bm=12; 392 } 393 if (bm<24 && em>12) { 394 lu->nbma[1] += (em>24?24:em)-bm; 395 bm=24; 396 } 397 if (bm<36 && em>24) { 398 lu->nbma[2] += em-bm; 399 } 400 //fprintf(stderr," %d%d%d-V%c: bm=%2.f em=%2.f --> %2.1f %2.1f %2.1f %p\n",l->tn,l->stn,l->dn,l->v,bm,em, lu->nbma[0],lu->nbma[1],lu->nbma[2], lu); 329 401 } 330 402 } … … 536 608 print_milestones(gantt_x,0,gantt_dx,gantt_dy+gantt_y); 537 609 fprintf(curr->os,"\\end{picture}\n"); 610 fclose(curr->os); 611 curr->os=0; 612 } 613 614 void do_partner_table(int partner) 615 { 616 struct partner_def* part = partner_table+partner; 617 if ( (curr->os=fopen(part->file,"w"))==0 ) { 618 fprintf(stderr,"can not open %s file for writing.\n",part->file); 619 fprintf(stderr,"generation of %s partner table is skipped.\n",part->file); 620 return; 621 } 622 fprintf(curr->os,"\\begin{tabular}{|c|p{3.5cm}||r|r|r||r|}\\hline\n"); 623 fprintf(curr->os, 624 "number & \\multicolumn{1}{c||}{title} & \\multicolumn{3}{c||}{years } & total \\\\\\cline{3-5}\n"); 625 fprintf(curr->os, 626 " & & \\multicolumn{1}{c|}{1} & \\multicolumn{1}{c|}{2} & " 627 "\\multicolumn{1}{c||}{3} & \\\\\\hline\\hline\n"); 628 int tn,stn,dn,v=0; 629 double an1=0,an2=0,an3=0,an=0; 630 int newlineadded=1; 631 for (tn=0 ; tn<T_MAX ; tn++) { 632 if (curr->ls[tn][0][0][0]==0) break; 633 if (tn!=0 && newlineadded==0 ) { 634 newlineadded = 1; 635 fprintf(curr->os,"\\hline "); 636 } 637 for (stn=0; stn<S_MAX; stn++) { 638 for (dn=0; dn<D_MAX; dn++) { 639 Tlivrable* top=curr->ls[tn][stn][dn][v]; 640 if (top==0) continue; 641 Tlivrable* last=top->vers[top->nbvers-1]; 642 if (last->partner!=partner) continue; 643 double sum1,sum2,sum3,sum=0; 644 sum1 = last->hman[0]; sum +=sum1; 645 sum2 = last->hman[1]; sum +=sum2; 646 sum3 = last->hman[2]; sum +=sum3; 647 char label[1000],title[1000]; 648 gen_label_base(label,last); 649 sprintf(title,"\\resstablestyletitle{%s}",last->title); 650 fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n", 651 label,title,sum1,sum2,sum3,sum); 652 an1 += sum1 ; 653 an2 += sum2 ; 654 an3 += sum3 ; 655 an += sum ; 656 newlineadded=0; 657 if ( (sum1!=0 && sum1>last->nbma[0] ) || (sum1==0 && last->nbma[0]!=0) ) 658 fprintf(stderr,"ERROR: %s:%s probleme sur l'an 1 (in table=%2.1f, in gantt=%2.1f\n", 659 part->name,label,sum1,last->nbma[0]); 660 if ( (sum2!=0 && sum2>last->nbma[1]) || (sum2==0 && last->nbma[1]!=0) ) 661 fprintf(stderr,"ERROR: %s:%s probleme sur l'an 2 (in table=%2.1f, in gantt=%2.1f\n", 662 part->name,label,sum2,last->nbma[1]); 663 if ( (sum3!=0 && sum3>last->nbma[2]) || (sum3==0 && last->nbma[2]!=0) ) 664 fprintf(stderr,"ERROR: %s:%s probleme sur l'an 3 (in table=%2.1f, in gantt=%2.1f\n", 665 part->name,label,sum3,last->nbma[2]); 666 } 667 } 668 } 669 if ( an!=(an1+an2+an3) ) { 670 fprintf(stderr,"bad computation in %s table.\n",part->file); 671 } 672 fprintf(curr->os,"%s & %s & %2.1f & %2.1f & %2.1f & %2.1f \\\\\\hline\n", 673 "","total",an1,an2,an3,an); 674 675 fprintf(curr->os,"\\end{tabular}\n"); 676 fclose(curr->os); 677 curr->os=0; 538 678 } 539 679 … … 548 688 do_gantt("gantt2.tex",0,tnmoins); 549 689 690 curr = data_new(0,0); 691 prepare0(curr); 692 prepare1(curr); 693 prepare2(curr); 694 prepare3(curr); 695 do_partner_table(4); 696 do_partner_table(5); 697 550 698 return 0; 551 699 }
Note: See TracChangeset
for help on using the changeset viewer.