| 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 | #include "bit_block.h" | 
|---|
| 12 |  | 
|---|
| 13 |  | 
|---|
| 14 | #include "simulmission.h" | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 |  | 
|---|
| 18 | //***************************************************************************************** | 
|---|
| 19 | //                                                                                      *** | 
|---|
| 20 | #ifdef _archeops                //---------   pour  Archeops    ----------------------- *** | 
|---|
| 21 | #ifndef _sans_transputer        //---------   pour  Archeops avec transputer    -------------   *** | 
|---|
| 22 | //                                                                                      *** | 
|---|
| 23 | //***************************************************************************************** | 
|---|
| 24 | // | 
|---|
| 25 | // | 
|---|
| 26 | //   lit directement les blocks recus sur la fifo et les envoie au programme principal | 
|---|
| 27 | // | 
|---|
| 28 |  | 
|---|
| 29 |  | 
|---|
| 30 | #define avance_erreur  {tt->te.pos_ecrit++; if(tt->te.pos_ecrit>=long_table_err) tt->te.pos_ecrit=0;} | 
|---|
| 31 | #define ecrit_erreur(xx)        {avance_erreur;tt->te.err[tt->te.pos_ecrit]=900+(xx);} | 
|---|
| 32 | void    sauve_un_block(tmtc* tt); | 
|---|
| 33 |  | 
|---|
| 34 |  | 
|---|
| 35 |  | 
|---|
| 36 | //***************************************************************************************** | 
|---|
| 37 | unsigned long   N_total_bits,M; | 
|---|
| 38 | unsigned short  Max,Min; | 
|---|
| 39 |  | 
|---|
| 40 | void init_tache(void) | 
|---|
| 41 | { | 
|---|
| 42 | tt->vi.a=0; | 
|---|
| 43 | tt->vi.b=0; | 
|---|
| 44 | tt->vi.c=0; | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | #define max_fifo  4000 | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 | //              un bit pour  fifo avec un seul bit (bit0) et la valeur de la periode en bit 1..6  (37 ou 38) | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 |  | 
|---|
| 55 | char    un_bit() | 
|---|
| 56 | { | 
|---|
| 57 | static int i; | 
|---|
| 58 | static unsigned long RR; | 
|---|
| 59 | unsigned short  Val; | 
|---|
| 60 |  | 
|---|
| 61 | lit_carte;      if(rien_a_lire)         return(bit_vide);       //  fifo vide  ->  retour  ->  sort du while | 
|---|
| 62 |  | 
|---|
| 63 | N_total_bits++; | 
|---|
| 64 | Val=((RR>>1) & 0x3f);   //permet de lire les bits de temps dans RR | 
|---|
| 65 |  | 
|---|
| 66 | //Calcul de la nouvelle moyenne glissee du temps | 
|---|
| 67 | M=M-(M>>16)+(Val<<8); | 
|---|
| 68 |  | 
|---|
| 69 |  | 
|---|
| 70 | //Calcul du Max | 
|---|
| 71 | if(N_total_bits==0) Max=Val;    //initialisation au premier passage | 
|---|
| 72 | if(Val>Max) Max=Val;    //changement de maximum | 
|---|
| 73 | if((N_total_bits%60000)==0) | 
|---|
| 74 | { | 
|---|
| 75 | Max=Max-1;      //Diminution tous les 60000 bits | 
|---|
| 76 | N_total_bits=0; | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | //Calcul du Min | 
|---|
| 80 | if(N_total_bits==0) Min=Val;    //initialisation au premier passage | 
|---|
| 81 | if(Val<Min) Min=Val;    //changement de minimum | 
|---|
| 82 | if((N_total_bits%60000)==0) Min=Min+1;  //Augmentation tous les 60000 bits | 
|---|
| 83 | //tt->nb_lec_fofo_ext=M; | 
|---|
| 84 |  | 
|---|
| 85 | #ifdef signe_inverse | 
|---|
| 86 |  | 
|---|
| 87 | if( RR & 1 )  return(bit_zero); | 
|---|
| 88 | else            return(bit_un); | 
|---|
| 89 |  | 
|---|
| 90 | #else | 
|---|
| 91 |  | 
|---|
| 92 | if( RR & 1 )    return(bit_un); | 
|---|
| 93 | else            return(bit_zero); | 
|---|
| 94 |  | 
|---|
| 95 | #endif | 
|---|
| 96 | } | 
|---|
| 97 |  | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 | void    ecrit_erreur_bit(int e) | 
|---|
| 101 | { | 
|---|
| 102 | ecrit_erreur(e+20); | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 |  | 
|---|
| 106 |  | 
|---|
| 107 |  | 
|---|
| 108 |  | 
|---|
| 109 |  | 
|---|
| 110 | void lecture_fifo(void* tx)     // appellé directement pour acquisition en interruptions | 
|---|
| 111 | { | 
|---|
| 112 | tmtc* tt=(tmtc*)tx; | 
|---|
| 113 | long lec_fifo=0;                //  compteur nombre de points lut en une fois dans la fifo | 
|---|
| 114 | char*   t_char=(char*)(&tt->vi.btt); | 
|---|
| 115 | int i; | 
|---|
| 116 |  | 
|---|
| 117 |  | 
|---|
| 118 | if(tt->PCI_actif==2)    // simulation Archeops | 
|---|
| 119 | { | 
|---|
| 120 | static int numblock=0; | 
|---|
| 121 | tt->vi.a++; | 
|---|
| 122 | if(tt->vi.a>20) // ecrit un block toutes les 20 interruptions (soit 0.5 sec) | 
|---|
| 123 | { | 
|---|
| 124 | int i; | 
|---|
| 125 | tt->vi.a=0; | 
|---|
| 126 | numblock++; | 
|---|
| 127 |  | 
|---|
| 128 | for(i=0;i<(taille_maxi_block_archeops/4);i++)   tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.); | 
|---|
| 129 | valide_block(&tt->vi.btt,block_bolo,numblock); | 
|---|
| 130 | sauve_un_block(tt); | 
|---|
| 131 |  | 
|---|
| 132 | for(i=0;i<(taille_maxi_block_archeops/4);i++)   tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.); | 
|---|
| 133 | valide_block(&tt->vi.btt,block_une_periode,numblock); | 
|---|
| 134 | sauve_un_block(tt); | 
|---|
| 135 |  | 
|---|
| 136 | for(i=0;i<(taille_maxi_block_archeops/4);i++)   tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.); | 
|---|
| 137 | valide_block(&tt->vi.btt,block_dilution,numblock); | 
|---|
| 138 | sauve_un_block(tt); | 
|---|
| 139 |  | 
|---|
| 140 | } | 
|---|
| 141 | } | 
|---|
| 142 | else if (tt->PCI_actif==3)      // simulation donnees mission | 
|---|
| 143 | { | 
|---|
| 144 | // EA + JD | 
|---|
| 145 | // Lecture d'un block depuis le simulateur | 
|---|
| 146 |  | 
|---|
| 147 | if (SimulMissionBloc(tt)) { | 
|---|
| 148 |  | 
|---|
| 149 | // Sauvegarde du bloc dans la file d'attente | 
|---|
| 150 | sauve_un_block(tt); | 
|---|
| 151 | } | 
|---|
| 152 | } | 
|---|
| 153 | else    while(1)                //  case 1 et 4 | 
|---|
| 154 | { | 
|---|
| 155 | i=lit_bit(&tt->vi.btt); | 
|---|
| 156 | if(i==lit_bit_vide)     break; | 
|---|
| 157 | if(i==lit_bit_un_block) sauve_un_block(tt); | 
|---|
| 158 |  | 
|---|
| 159 | lec_fifo++; | 
|---|
| 160 | if(lec_fifo>max_fifo*8)         break;          // parceque compte les bit et non les octets | 
|---|
| 161 | } | 
|---|
| 162 | if(lec_fifo > tt->nb_lec_fofo_int)      tt->nb_lec_fofo_int=lec_fifo; | 
|---|
| 163 | if(!tt->val_con_fifo)           {tt->val_con_fifo=tt->nb_lec_fofo_int;tt->nb_lec_fofo_int=0;} | 
|---|
| 164 |  | 
|---|
| 165 | } | 
|---|
| 166 |  | 
|---|
| 167 |  | 
|---|
| 168 |  | 
|---|
| 169 | //______________________________________________________________________________________________// | 
|---|
| 170 | //   lit le block brut tel que recut par telemesure dans  tt->vi.btt                            // | 
|---|
| 171 | //      ce block contient  ??  periodes de mesure                                               // | 
|---|
| 172 | //      Je rempli un block tm  en position      u=tt->tm.pos_ecrit                              // | 
|---|
| 173 | //      Le block s'ecrit:                       tt->tm.btm[u]                                   // | 
|---|
| 174 | //______________________________________________________________________________________________// | 
|---|
| 175 |  | 
|---|
| 176 |  | 
|---|
| 177 |  | 
|---|
| 178 | void    sauve_un_block(tmtc* tt) | 
|---|
| 179 | { | 
|---|
| 180 | int u; | 
|---|
| 181 | //ecrit_erreur(err_recut_un_block_ok); | 
|---|
| 182 |  | 
|---|
| 183 | u=tt->tm.pos_ecrit; | 
|---|
| 184 | //  le code de debut n'a pas été ecrit dans le block : il faut l'ecrire | 
|---|
| 185 | tt->vi.btt.debut=debut_block_mesure; | 
|---|
| 186 | tt->tm.btm[u].tmtrx=tt->vi.btt; // recopie le block courant dans la table | 
|---|
| 187 | u++; if(u>=longueur_table_tm) u=0; | 
|---|
| 188 | tt->tm.pos_ecrit=u; | 
|---|
| 189 |  | 
|---|
| 190 | if(tt->tm.pos_ecrit==tt->tm.pos_lit)  ecrit_erreur(err_pile_pleine); | 
|---|
| 191 | } | 
|---|
| 192 |  | 
|---|
| 193 | //***************************************************************************************** | 
|---|
| 194 | //                                                                                      *** | 
|---|
| 195 | #endif          //--------------------------------------------------------------------  *** | 
|---|
| 196 | #endif          //--------------------------------------------------------------------  *** | 
|---|
| 197 | //                                                                                      *** | 
|---|
| 198 | //***************************************************************************************** | 
|---|
| 199 |  | 
|---|
| 200 |  | 
|---|
| 201 |  | 
|---|
| 202 |  | 
|---|