Changeset 52 for anr/gantt.l


Ignore:
Timestamp:
Jan 31, 2010, 10:17:25 PM (15 years ago)
Author:
coach
Message:

IA: modification des macros livrable & sortie des tableaux de ressources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anr/gantt.l

    r51 r52  
    3939    0
    4040};
     41struct 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};
    4156
    4257typedef struct _Tlivrable {
     
    4459    char v;            // 0, 1, 2, ..., F
    4560    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
    4764    // these fields are filled by the program for data[tn][0][0][0]
    4865    double task_y;           // top of task
    4966    double task_dy;          // bot of task is task_y+task_dy
    5067    double task_y_del;       // delivrables start at task_y+task_y_del
     68    double nbma[3];          // durée en mois par annee
    5169    // these fields are filled by the program for data[tn][stn][dn][0]
    5270    struct _Tlivrable
     
    106124        *l = *data_org.ls[tn][stn][dn][v];
    107125        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);
    109127    }
    110128    return data;
     
    196214%%
    197215 int tn,stn,dn,v,bm,em; char* title;
     216 double an[3];
     217 char*  an_comment;
     218 int    partner;
    198219#.*\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'; }
     220T=[0-9]+  { tn=atoi(yytext+2); }
     221S=[0-9]+  { stn=atoi(yytext+2); }
     222D=[0-9]+  { dn=atoi(yytext+2); }
     223V=V[1-8F] { v=yytext[3]; }
    205224ML=[0-9]+ {
    206225        int i;
     
    208227        milestones[i] = atoi(yytext+3);
    209228    }
    210 
    211229BM=[0-9]+ { bm=atoi(yytext+3); }
    212230EM=[0-9]+ { em=atoi(yytext+3); }
     231R=none    { an[0]=0; an[1]=0; an[2]=0; an_comment=0; }
     232R=[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    }
     244PART="{"[^}]+"}"  {
     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    }
    213259TITLE=.*\n {
    214260        char* pc=yytext+6;
     
    221267        p->dn = dn;
    222268        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;
    223273        p->title = title;
    224274        p->bm = bm;
     
    228278        for (v=0; data_org.ls[tn][stn][dn][v]!=0 ; v++);
    229279        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); }
    234285%%
    235286
     
    327378            h += (p->vers[p->nbvers-1]->nbTitleLines-1)*(DELIVRABLE_TITLEHEIGHT/5.);
    328379            if ( h>p->height) p->height=h;
     380        }
     381        Tlivrable* lu= p->vers[p->nbvers-1];
     382        int i;
     383fprintf(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);
    329401        }
    330402    }
     
    536608    print_milestones(gantt_x,0,gantt_dx,gantt_dy+gantt_y);
    537609    fprintf(curr->os,"\\end{picture}\n");
     610    fclose(curr->os);
     611    curr->os=0;
     612}
     613
     614void 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;
    538678}
    539679
     
    548688    do_gantt("gantt2.tex",0,tnmoins);
    549689
     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
    550698    return 0;
    551699}
Note: See TracChangeset for help on using the changeset viewer.