| 1 | #include "diabolo.h"
 | 
|---|
| 2 | #include "fichier.h"
 | 
|---|
| 3 | #include "bolo.h"
 | 
|---|
| 4 | #include "arcunit.h"
 | 
|---|
| 5 | 
 | 
|---|
| 6 | 
 | 
|---|
| 7 | 
 | 
|---|
| 8 | 
 | 
|---|
| 9 | 
 | 
|---|
| 10 | 
 | 
|---|
| 11 | void    lit_fichier_DIA2(int fen)
 | 
|---|
| 12 | {
 | 
|---|
| 13 | //int i,f;
 | 
|---|
| 14 | F_entete                        *E;
 | 
|---|
| 15 | F_block_desc            *BD;
 | 
|---|
| 16 | F_block_param           *BP;
 | 
|---|
| 17 | F_donne         *       T;                                                      // tableau courant de donnee
 | 
|---|
| 18 | long tt=1397151033;
 | 
|---|
| 19 | long total=0;
 | 
|---|
| 20 | long val_controleur;
 | 
|---|
| 21 | long blockold=0;
 | 
|---|
| 22 | double total_controleur=-1;
 | 
|---|
| 23 | int bb=0;
 | 
|---|
| 24 | int i;
 | 
|---|
| 25 | def_gains;
 | 
|---|
| 26 | 
 | 
|---|
| 27 | T=malloc(max_nb_donne*sizeof(F_donne));
 | 
|---|
| 28 | E=malloc(sizeof(F_entete));
 | 
|---|
| 29 | BD=malloc(sizeof(F_block_desc));
 | 
|---|
| 30 | BP=malloc(sizeof(F_block_param));
 | 
|---|
| 31 | printf("lecture du fichier  \n");
 | 
|---|
| 32 | position(fen,0L);
 | 
|---|
| 33 | select(printf_ref);
 | 
|---|
| 34 | litF(fen,sizeof(F_entete),E);
 | 
|---|
| 35 | printf(" version :  =%d     ",E->version);
 | 
|---|
| 36 | printf("temps debut, fin =%ld , %ld  \n",tt+E->tempsdebut,tt+E->tempsfin);
 | 
|---|
| 37 | E->commentaires[255]=0;
 | 
|---|
| 38 | printf("commentaires à la main : %s \n",E->commentaires);
 | 
|---|
| 39 | 
 | 
|---|
| 40 | while ( litF(fen,sizeof(F_block_desc),BD) != -1)
 | 
|---|
| 41 |         {
 | 
|---|
| 42 | //      printf(" BD.change = %d    nb ligne= %d \n",BD->change,BD->n_ligne_don);
 | 
|---|
| 43 |         if(BD->change>10)
 | 
|---|
| 44 |                 {
 | 
|---|
| 45 |                 char buf[20000];
 | 
|---|
| 46 |                 printf("block  type  %d,  longueur %d ",BD->change,BD->n_ligne_don);
 | 
|---|
| 47 |                 litF(fen,BD->n_ligne_don,buf);
 | 
|---|
| 48 |                 }
 | 
|---|
| 49 |         else
 | 
|---|
| 50 |         
 | 
|---|
| 51 |         if(BD->change==10)
 | 
|---|
| 52 |                 {
 | 
|---|
| 53 |                 char comment[10000];
 | 
|---|
| 54 |                 printf(" commentaire longueur %d ",BD->n_ligne_don);
 | 
|---|
| 55 |                 litF(fen,BD->n_ligne_don,comment);
 | 
|---|
| 56 | //              printf("commentaire : \n");
 | 
|---|
| 57 | //              printf(comment);
 | 
|---|
| 58 |                 printf("\n");
 | 
|---|
| 59 |                 }
 | 
|---|
| 60 |         else
 | 
|---|
| 61 |                 {
 | 
|---|
| 62 |                         
 | 
|---|
| 63 |                 bb++;
 | 
|---|
| 64 |                 litF(fen,sizeof(F_block_param),BP);
 | 
|---|
| 65 |                 if(total_controleur==-1)        {val_controleur=BP->temps_controleur_debut;total_controleur=0;}
 | 
|---|
| 66 |                 total_controleur+=(double)( (BP->temps_controleur_fin - val_controleur) & 0x7fffffff ) ;
 | 
|---|
| 67 |                 val_controleur=BP->temps_controleur_fin;
 | 
|---|
| 68 |                 printf(" block %d :chg=%d , %d lignes , horloge %x ,temps debut %ld , fin =%ld ,  ereur%ld ",           
 | 
|---|
| 69 |                         BD->n_blok,
 | 
|---|
| 70 |                         BD->change,
 | 
|---|
| 71 |                         BD->n_ligne_don,
 | 
|---|
| 72 |                         BP->reglage.horloge,
 | 
|---|
| 73 |                         BP->temps_controleur_debut,BP->temps_controleur_fin,
 | 
|---|
| 74 |                         BP->temps_controleur_fin-(blockold+(long)BD->n_ligne_don));
 | 
|---|
| 75 |                 blockold=BP->temps_controleur_fin;
 | 
|---|
| 76 | //              printf("bololu =%d \n",BD->bololut);
 | 
|---|
| 77 |                 if(BD->n_ligne_don>max_nb_donne) {printf("\n trop de ligne a lire : erreur \n\n");break;}
 | 
|---|
| 78 |                 litF(fen,sizeof(F_donne)*(long)BD->n_ligne_don,T);
 | 
|---|
| 79 |                 total+=BD->n_ligne_don;
 | 
|---|
| 80 |                 if(bb==5) // pour le 5 eme block uniquement
 | 
|---|
| 81 |                                 {
 | 
|---|
| 82 |                                 for(i=0;i<nb_max_bolo;i++)
 | 
|---|
| 83 |                                         {
 | 
|---|
| 84 |                                         printf("\nbolo%d : gain=%d -> %g   V=%d  I=%d  T=%d  L=%d  phase=%d "
 | 
|---|
| 85 |                                                 ,i+1,gainbrut(BP->reglage.bolo[i]),gain_ampli(BP->reglage.bolo[i])
 | 
|---|
| 86 |                                                 ,dac_V(BP->reglage.bolo[i]),dac_I(BP->reglage.bolo[i])
 | 
|---|
| 87 |                                                 ,dac_T(BP->reglage.bolo[i]),dac_L(BP->reglage.bolo[i])
 | 
|---|
| 88 |                                                 ,phase(BP->reglage.bolo[i])   );
 | 
|---|
| 89 |                                         }
 | 
|---|
| 90 |                                 printf("\n periode horloge=%g ,   nb_mesures=%d  ,  frequence=%g  , temps mort=%d  \n"
 | 
|---|
| 91 |                                         ,2./(double)(BP->reglage.horloge.nb_mesures*24),BP->reglage.horloge.nb_mesures/2 ,500000.,BP->reglage.horloge.temp_mort);
 | 
|---|
| 92 |                                 }         
 | 
|---|
| 93 |                 }
 | 
|---|
| 94 |         
 | 
|---|
| 95 |         
 | 
|---|
| 96 |         
 | 
|---|
| 97 |         printf("\n");
 | 
|---|
| 98 |         }
 | 
|---|
| 99 | 
 | 
|---|
| 100 | printf(" total fichier %ld lignes  \n",total);
 | 
|---|
| 101 | printf("temps  fichier %ld sec     \n",E->tempsfin-E->tempsdebut);
 | 
|---|
| 102 | printf("temps  controleur %8.3f sec     \n",1e-6*total_controleur);
 | 
|---|
| 103 | printf("frequence de modulation calculée a partir du temps controleur = %g Hz  \n",((double)(total-1))/(2*1e-6*total_controleur));
 | 
|---|
| 104 | printf("periode calculee  = %g  ms \n",(1e-3*total_controleur/((double)(total-1))));
 | 
|---|
| 105 | printf("frequence moyenne reelle         = %g Hz  \n",((double)total)/(double)(2*(E->tempsfin-E->tempsdebut)));
 | 
|---|
| 106 | printf("frequence generateur     = %g MHz  \n",
 | 
|---|
| 107 |                 15.0*(((double)(total-1))/(double)(E->tempsfin-E->tempsdebut))/(((double)(total-1))/(1e-6*total_controleur)));
 | 
|---|
| 108 | /*
 | 
|---|
| 109 | f=ouvreD(0,0,"",0);
 | 
|---|
| 110 | for(i=0;i<1000;i++)
 | 
|---|
| 111 |         {
 | 
|---|
| 112 |         double x,y;
 | 
|---|
| 113 |         x=i;
 | 
|---|
| 114 |         y=T[i].bolo[0];
 | 
|---|
| 115 | //      y=BP->bol_per[0][i];
 | 
|---|
| 116 |         trace(f,x,y);
 | 
|---|
| 117 |         }
 | 
|---|
| 118 | */      
 | 
|---|
| 119 | }
 | 
|---|