[637] | 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 | // ***
|
---|
[639] | 15 | #ifdef _archeopsXX //--------- pour Archeops ----------------------- ***
|
---|
[637] | 16 | #ifndef _sans_transputer //--------- pour Archeops avec transputer ------------- ***
|
---|
| 17 | // ***
|
---|
| 18 | //*****************************************************************************************
|
---|
| 19 | //
|
---|
| 20 | //
|
---|
| 21 | // lit directement les blocks recut sur la fifo et les envoie au programme principal
|
---|
| 22 | //
|
---|
| 23 | //
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | //def_long_block
|
---|
| 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 | #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;}}
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | //*****************************************************************************************
|
---|
| 37 |
|
---|
| 38 | void init_tache(void)
|
---|
| 39 | {
|
---|
| 40 | tt->vi.a=0;
|
---|
| 41 | tt->vi.b=0;
|
---|
| 42 | tt->vi.c=0;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | #define max_fifo 4000
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 | void lecture_fifo(void* tx) // appellé directement pour acquisition en interruptions
|
---|
| 51 | {
|
---|
| 52 | register unsigned long RR;
|
---|
| 53 | tmtc* tt=(tmtc*)tx;
|
---|
| 54 | long lec_fifo=0; // compteur nombre de points lut en une fois dans la fifo
|
---|
| 55 | char* t_char=(char*)(&tt->vi.btt);
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | if(tt->PCI_actif==2) // simulation Archeops
|
---|
| 59 | {
|
---|
| 60 | static int numblock=0;
|
---|
| 61 | tt->vi.a++;
|
---|
| 62 | if(tt->vi.a>20) // ecrit un block toutes les 20 interruptions (soit 0.5 sec)
|
---|
| 63 | {
|
---|
| 64 | int i;
|
---|
| 65 | tt->vi.a=0;
|
---|
| 66 | numblock++;
|
---|
| 67 |
|
---|
| 68 | for(i=0;i<(taille_maxi_block_archeops/4);i++) tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);
|
---|
| 69 | valide_block(&tt->vi.btt,block_bolo,numblock);
|
---|
| 70 | sauve_un_block(tt);
|
---|
| 71 |
|
---|
| 72 | for(i=0;i<(taille_maxi_block_archeops/4);i++) tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);
|
---|
| 73 | valide_block(&tt->vi.btt,block_une_periode,numblock);
|
---|
| 74 | sauve_un_block(tt);
|
---|
| 75 |
|
---|
| 76 | for(i=0;i<(taille_maxi_block_archeops/4);i++) tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);
|
---|
| 77 | valide_block(&tt->vi.btt,block_dilution,numblock);
|
---|
| 78 | sauve_un_block(tt);
|
---|
| 79 |
|
---|
| 80 | // if((numblock%5)==0)
|
---|
| 81 | {
|
---|
| 82 | for(i=0;i<(taille_maxi_block_archeops/4);i++) tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);
|
---|
| 83 | valide_block(&tt->vi.btt,block_sst,numblock);
|
---|
| 84 | sauve_un_block(tt);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | else while(1)
|
---|
| 91 | {
|
---|
| 92 | lit_carte; if(rien_a_lire) break; // fifo vide -> retour -> sort du while
|
---|
| 93 | lec_fifo++;
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | //ecrit_erreur(err_sync_bebo);
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | if(tt->vi.b) // ecrit les mots pour b=[1....(sizeof(block_tm_trx)/4)-2]
|
---|
| 100 | {
|
---|
| 101 | t_char[tt->vi.b*4+3-tt->vi.c]=octet_a_lire; // dans l'ordre: 3 2 1 0 7 6 5 4 11 10 9 8 ...
|
---|
| 102 |
|
---|
| 103 | tt->vi.c++;
|
---|
| 104 | if(tt->vi.c>=4) // c est le compteur de cara
|
---|
| 105 | {
|
---|
| 106 | // ecrit_erreur(err_recut_un_block_ok);
|
---|
| 107 | tt->vi.c=0;
|
---|
| 108 | tt->vi.b++; // b est le compteur de mot long de 4 octets
|
---|
| 109 |
|
---|
| 110 | if (tt->vi.b>=4) // teste la longueur apres avoir lut 3 entiers long
|
---|
| 111 | {
|
---|
| 112 | int ll;
|
---|
| 113 | ll=longueur_block(&tt->vi.btt);
|
---|
| 114 | if(ll>sizeof(block_type_modele)) {tt->vi.a=0;tt->vi.b=0;ecrit_erreur(err_longueur_block);}
|
---|
| 115 | // if(ll>sizeof(block_type_gps)) {tt->vi.a=0;tt->vi.b=0;ecrit_erreur(err_lect_pci);}
|
---|
| 116 | if( tt->vi.b > ((ll/4)-1) ) {tt->vi.b=0;}
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | if(!tt->vi.b) // test et cherche debut
|
---|
| 122 | {
|
---|
| 123 | tt->vi.a++;
|
---|
| 124 | // ecrit_erreur(err_lect_pci);
|
---|
| 125 | switch(tt->vi.a)
|
---|
| 126 | {
|
---|
| 127 | case 1 : test_val(debut_block_mesure&0xff); break;
|
---|
| 128 | case 2 : test_val((debut_block_mesure>>8)&0xff); break;
|
---|
| 129 | case 3 : test_val((debut_block_mesure>>16)&0xff); break;
|
---|
| 130 | case 4 :
|
---|
| 131 | if(octet_a_lire!=((debut_block_mesure>>24)&0xff)) tt->vi.a=0;
|
---|
| 132 | else {
|
---|
| 133 | tt->vi.c=0; // pret pour la lecture de la suite du block
|
---|
| 134 | tt->vi.b=1; // déja lut debut du block: commence par mot b=1;
|
---|
| 135 | }
|
---|
| 136 | break;
|
---|
| 137 |
|
---|
| 138 | case 5 :
|
---|
| 139 | // ecrit_erreur(err_recut_un_block_ok);
|
---|
| 140 | sauve_un_block(tt); // le code de debut n'a pas été ecrit dans le block
|
---|
| 141 | default : tt->vi.a=0;break;
|
---|
| 142 | }
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | if(lec_fifo>max_fifo) break;
|
---|
| 146 | }
|
---|
| 147 | if(lec_fifo > tt->nb_lec_fofo_int) tt->nb_lec_fofo_int=lec_fifo;
|
---|
| 148 | if(!tt->nb_lec_fofo_ext) {tt->nb_lec_fofo_ext=tt->nb_lec_fofo_int;tt->nb_lec_fofo_int=0;}
|
---|
| 149 |
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 |
|
---|
| 154 | //______________________________________________________________________________________________//
|
---|
| 155 | // lit le block brut tel que recut par telemesure dans tt->vi.btt //
|
---|
| 156 | // ce block contient ?? periodes de mesure //
|
---|
| 157 | // Je rempli un block tm en position u=tt->tm.pos_ecrit //
|
---|
| 158 | // Le block s'ecrit: tt->tm.btm[u] //
|
---|
| 159 | //______________________________________________________________________________________________//
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 | void sauve_un_block(tmtc* tt)
|
---|
| 164 | {
|
---|
| 165 | int u;
|
---|
| 166 | u=tt->tm.pos_ecrit;
|
---|
| 167 | // le code de debut n'a pas été ecrit dans le block : il faut l'ecrire
|
---|
| 168 | tt->vi.btt.debut=debut_block_mesure;
|
---|
| 169 | tt->tm.btm[u].tmtrx=tt->vi.btt; // recopie le block courant dans la table
|
---|
| 170 | u++; if(u>=longueur_table_tm) u=0;
|
---|
| 171 | tt->tm.pos_ecrit=u;
|
---|
| 172 |
|
---|
| 173 | if(tt->tm.pos_ecrit==tt->tm.pos_lit) ecrit_erreur(err_pile_pleine);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | //*****************************************************************************************
|
---|
| 177 | // ***
|
---|
| 178 | #endif //-------------------------------------------------------------------- ***
|
---|
| 179 | #endif //-------------------------------------------------------------------- ***
|
---|
| 180 | // ***
|
---|
| 181 | //*****************************************************************************************
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 |
|
---|
| 185 |
|
---|