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