| 1 | #include "manip.h" | 
|---|
| 2 | #include "choix_acquisition.h" | 
|---|
| 3 | #include "archeops.h" | 
|---|
| 4 | #include "choix_param.h" | 
|---|
| 5 | #include "structure.h" | 
|---|
| 6 | #include "tm.h" | 
|---|
| 7 | #include "tache.h" | 
|---|
| 8 | #include "bolo.h" | 
|---|
| 9 | #include "carte_acqui.h" | 
|---|
| 10 | #include "carte_pci.h" | 
|---|
| 11 |  | 
|---|
| 12 |  | 
|---|
| 13 | //***************************************************************************************** | 
|---|
| 14 | //                                                                                      *** | 
|---|
| 15 | #ifdef _archeops                //---------   pour  Archeops  sans transputer  -------  *** | 
|---|
| 16 | #ifdef _sans_transputer         //---------   pour  Archeops avec ctb    -------------  *** | 
|---|
| 17 | //                                                                                      *** | 
|---|
| 18 | //***************************************************************************************** | 
|---|
| 19 | // | 
|---|
| 20 | // | 
|---|
| 21 | // | 
|---|
| 22 | //  lit le tableau de données brute recue des bebo via le ctb | 
|---|
| 23 | // | 
|---|
| 24 | //  ensuite, prepare les blocs formaté type archeops pour les envoyer au programme principal | 
|---|
| 25 | // | 
|---|
| 26 |  | 
|---|
| 27 | // | 
|---|
| 28 |  | 
|---|
| 29 |  | 
|---|
| 30 |  | 
|---|
| 31 | def_long_block | 
|---|
| 32 | def_nom_block | 
|---|
| 33 |  | 
|---|
| 34 | #define avance_erreur  {tt->te.pos_ecrit++; if(tt->te.pos_ecrit>=long_table_err) tt->te.pos_ecrit=0;} | 
|---|
| 35 | #define ecrit_erreur(xx)        {avance_erreur;tt->te.err[tt->te.pos_ecrit]=900+(xx);} | 
|---|
| 36 |  | 
|---|
| 37 | void fabrique_block_type_data_brute(tmtc* tt,int num_block); | 
|---|
| 38 | void fabrique_block_type_une_periode(tmtc* tt,int num_block); | 
|---|
| 39 | void fabrique_block_type_bolo(tmtc* tt,int num_block); | 
|---|
| 40 |  | 
|---|
| 41 | void    sauve_un_block(tmtc* tt); | 
|---|
| 42 |  | 
|---|
| 43 |  | 
|---|
| 44 | void init_tache(void) | 
|---|
| 45 | { | 
|---|
| 46 | int i,j; | 
|---|
| 47 |  | 
|---|
| 48 | tt->vi.a=0; | 
|---|
| 49 | tt->vi.b=0; | 
|---|
| 50 | tt->vi.c=0; | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 | j=0; | 
|---|
| 54 | for(i=0;i<nb_type_blocks;i++)   if (long_block[i]> j ) j=long_block[i]; | 
|---|
| 55 | printf(" taille maxi du block de telemesure = %d  //  on reserve %d octets par block \n", | 
|---|
| 56 | j,sizeof(block_type_modele)); | 
|---|
| 57 | if(j>sizeof(block_type_modele)) erreur("block_type_modele trops petit"); | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 | #define test_val(xx)    {if(octet_a_lire!=(xx)) {if(octet_a_lire==(debut_block_mesure&0xff)) tt->vi.a=1; else tt->vi.a=0;}} | 
|---|
| 63 |  | 
|---|
| 64 |  | 
|---|
| 65 | void lecture_fifo(void* tx)                                     // appellé directement pour acquisition en interuptions | 
|---|
| 66 | { | 
|---|
| 67 | register unsigned long RR; | 
|---|
| 68 | tmtc* tt=(tmtc*)tx; | 
|---|
| 69 | long lec_fifo=0;                //  compteur nombre de points lut en une fois dans la fifo | 
|---|
| 70 | int max_fifo; | 
|---|
| 71 |  | 
|---|
| 72 | if(acquisition_PCI)     max_fifo=4000;  //  3000  points maxi par interruption (10ms)  soit (3.3µs) | 
|---|
| 73 | else           max_fifo=200;   //  ((1000)faux )  points maxi par interruption (10ms)  soit  (20µs) | 
|---|
| 74 |  | 
|---|
| 75 | int max_buf=nb_byte_mot*tt->reglage.horloge.nb_mesures*nb_per_block; | 
|---|
| 76 | static long     num_block=0; | 
|---|
| 77 |  | 
|---|
| 78 | while(1) | 
|---|
| 79 | { | 
|---|
| 80 | if(acquisition_PCI)     {lit_carte;     if(rien_a_lire) break;}//  fifo vide  ->  retour  ->  sort du while | 
|---|
| 81 | lec_fifo++; | 
|---|
| 82 | //      tt->vi.bkb[tt->vi.a^3]=octet_a_lire;    // dans l'ordre: 3 2 1 0 7 6 5 4 11 10 9 8 ... | 
|---|
| 83 | tt->vi.bkb[tt->vi.a]=octet_a_lire;      // dans l'ordre: 3 2 1 0 7 6 5 4 11 10 9 8 ... | 
|---|
| 84 | tt->vi.a++; | 
|---|
| 85 | if(tt->vi.a>=max_buf) | 
|---|
| 86 | { | 
|---|
| 87 | num_block++; | 
|---|
| 88 | #ifdef  transmet_data_brute | 
|---|
| 89 | fabrique_block_type_data_brute(tt,num_block); | 
|---|
| 90 | #endif | 
|---|
| 91 | fabrique_block_type_une_periode(tt,num_block); | 
|---|
| 92 | fabrique_block_type_bolo(tt,num_block); | 
|---|
| 93 | tt->vi.a=0; | 
|---|
| 94 | } | 
|---|
| 95 | if(lec_fifo>max_fifo) break; | 
|---|
| 96 | } | 
|---|
| 97 | if(lec_fifo > tt->nb_lec_fofo_int)      tt->nb_lec_fofo_int=lec_fifo; | 
|---|
| 98 | if(!tt->val_con_fifo)           {tt->val_con_fifo=tt->nb_lec_fofo_int;tt->nb_lec_fofo_int=0;} | 
|---|
| 99 | } | 
|---|
| 100 |  | 
|---|
| 101 | //______________________________________________________________________________________________// | 
|---|
| 102 | //   je traite le block brut tel que recut de la bebo par le ctb                                // | 
|---|
| 103 | //      ce block contient    nbper   periodes de mesure                                         // | 
|---|
| 104 | //      Je rempli un block tm  en position      u=tt->tm.pos_ecrit                              // | 
|---|
| 105 | //      Le block s'ecrit:                       tt->tm.btm[u]                                   // | 
|---|
| 106 | //______________________________________________________________________________________________// | 
|---|
| 107 |  | 
|---|
| 108 |  | 
|---|
| 109 | #ifdef  transmet_data_brute | 
|---|
| 110 | void fabrique_block_type_data_brute(tmtc* tt,int num_block) | 
|---|
| 111 | { | 
|---|
| 112 | int i; | 
|---|
| 113 | block_type_data_brute  * blk    =  (block_type_data_brute*)   &(tt->vi.btt); | 
|---|
| 114 |  | 
|---|
| 115 | // pour 23 coups / demi-periode   et  nb_per=12  ( 2 bebo a 6 voies completes) | 
|---|
| 116 | //  on a 46 mesures par periode   et  276 mesures pour 6 periodes  et 552 mesures dans le block | 
|---|
| 117 | for(i=0;i<nb_per_block*tt->reglage.horloge.nb_mesures*nb_byte_mot;i++) | 
|---|
| 118 | { | 
|---|
| 119 | blk->data[i]=tt->vi.bkb[i]; | 
|---|
| 120 | } | 
|---|
| 121 |  | 
|---|
| 122 | valide_block((block_type_modele*)blk,block_data_brute,num_block); | 
|---|
| 123 | sauve_un_block(tt); | 
|---|
| 124 | } | 
|---|
| 125 | #endif | 
|---|
| 126 |  | 
|---|
| 127 |  | 
|---|
| 128 | void fabrique_block_type_une_periode(tmtc* tt,int num_block) | 
|---|
| 129 | { | 
|---|
| 130 | int i,k; | 
|---|
| 131 | block_type_une_periode  * blk   =  (block_type_une_periode*)   &(tt->vi.btt); | 
|---|
| 132 |  | 
|---|
| 133 | /* pour 23 coups / demi-periode   et  nb_per=12  ( 2 bebo a 6 voies completes)  */ | 
|---|
| 134 | /*  on a 46 mesures par periode   et  276 mesures pour 6 periodes  et 552 mesures dans le block         */ | 
|---|
| 135 | //for(k=0;k<nb_per_block;k++)           /* boucle sur les periodes entières   */ | 
|---|
| 136 | for(k=0;k<6;k++)                /* boucle sur les periodes entières   */ | 
|---|
| 137 | { | 
|---|
| 138 | /* spd vaut 1 durant les 6 premieres mesures    */ | 
|---|
| 139 | //      if( spd(k*reglage.horloge.nb_mesures) != (k<6)  )       blk->erreur_sync+=1000; | 
|---|
| 140 | for(i=0;i<tt->reglage.horloge.nb_mesures;i++) | 
|---|
| 141 | { | 
|---|
| 142 | blk->bol_per[k][i]=(0xff & tt->vi.bkb[nb_byte_mot*(k*tt->reglage.horloge.nb_mesures+i)+1]) | 
|---|
| 143 | | (0xff00 & ((tt->vi.bkb[nb_byte_mot*(k*tt->reglage.horloge.nb_mesures+i)+2])<<8)); | 
|---|
| 144 | //              if( (cpp(k*reglage.horloge.nb_mesures+i) != (i*2)/reglage.horloge.nb_mesures ) ) blk->erreur_sync++;*/ | 
|---|
| 145 | } | 
|---|
| 146 | } | 
|---|
| 147 | //for(i=0;i<max_buf;i++)        blk->data[i]=tt->vi.bkb[i]; | 
|---|
| 148 |  | 
|---|
| 149 | valide_block((block_type_modele*)blk,block_une_periode,num_block); | 
|---|
| 150 | sauve_un_block(tt); | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 |  | 
|---|
| 154 | void fabrique_block_type_bolo(tmtc* tt,int num_block) | 
|---|
| 155 | { | 
|---|
| 156 | int i,k; | 
|---|
| 157 | block_type_bolo  * blk  =  (block_type_bolo*)   &(tt->vi.btt); | 
|---|
| 158 |  | 
|---|
| 159 |  | 
|---|
| 160 | for(k=0;k<nb_per_block*2;k++)           /* boucle sur les demi entières   */ | 
|---|
| 161 | { | 
|---|
| 162 | for(i=0;i<nb_max_bolo;i++) | 
|---|
| 163 | { | 
|---|
| 164 | blk->data_bolo[i][k]= | 
|---|
| 165 | (0xff & tt->vi.bkb[nb_byte_mot*(k*tt->reglage.horloge.nb_mesures/2+i+1)+3]) | 
|---|
| 166 | | (0xff00 & (tt->vi.bkb[nb_byte_mot*(k*tt->reglage.horloge.nb_mesures/2+i+1)+4]<<8)) | 
|---|
| 167 | | (0x1f0000 & (tt->vi.bkb[nb_byte_mot*(k*tt->reglage.horloge.nb_mesures/2+i+1)+5]<<16)); | 
|---|
| 168 | } | 
|---|
| 169 | } | 
|---|
| 170 |  | 
|---|
| 171 |  | 
|---|
| 172 | valide_block((block_type_modele*)blk,block_bolo,num_block); | 
|---|
| 173 | sauve_un_block(tt); | 
|---|
| 174 | } | 
|---|
| 175 |  | 
|---|
| 176 |  | 
|---|
| 177 |  | 
|---|
| 178 | //______________________________________________________________________________________________// | 
|---|
| 179 | //   lit le block brut tel que recut par telemesure dans  tt->vi.btt                            // | 
|---|
| 180 | //      ce block contient  ??  periodes de mesure                                               // | 
|---|
| 181 | //      Je rempli un block tm  en position      u=tt->tm.pos_ecrit                              // | 
|---|
| 182 | //      Le block s'ecrit:                       tt->tm.btm[u]                                   // | 
|---|
| 183 | //______________________________________________________________________________________________// | 
|---|
| 184 |  | 
|---|
| 185 | void    sauve_un_block(tmtc* tt) | 
|---|
| 186 | { | 
|---|
| 187 | int u; | 
|---|
| 188 | u=tt->tm.pos_ecrit; | 
|---|
| 189 | tt->tm.btm[u].tmtrx=tt->vi.btt; | 
|---|
| 190 | u++; if(u>=longueur_table_tm) u=0; | 
|---|
| 191 | tt->tm.pos_ecrit=u; | 
|---|
| 192 | } | 
|---|
| 193 |  | 
|---|
| 194 | //***************************************************************************************** | 
|---|
| 195 | //                                                                                      *** | 
|---|
| 196 | #endif          //--------------------------------------------------------------------  *** | 
|---|
| 197 | #endif          //--------------------------------------------------------------------  *** | 
|---|
| 198 | //                                                                                      *** | 
|---|
| 199 | //***************************************************************************************** | 
|---|
| 200 |  | 
|---|
| 201 |  | 
|---|
| 202 |  | 
|---|
| 203 |  | 
|---|