| 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 recut 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 |
|
|---|
| 37 | void init_tache(void)
|
|---|
| 38 | {
|
|---|
| 39 | tt->vi.a=0;
|
|---|
| 40 | tt->vi.b=0;
|
|---|
| 41 | tt->vi.c=0;
|
|---|
| 42 | //init_lit_bit();
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | #define max_fifo 4000
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | // un bit pour 8 bit en parallele dans la fifo
|
|---|
| 50 | /*
|
|---|
| 51 | char un_bit(void)
|
|---|
| 52 | {
|
|---|
| 53 | static int i;
|
|---|
| 54 | static unsigned long RR;
|
|---|
| 55 | i++;
|
|---|
| 56 | if( (i<0) ou (i>7) )
|
|---|
| 57 | {
|
|---|
| 58 | lit_carte; if(rien_a_lire) return(bit_vide); // fifo vide -> retour -> sort du while
|
|---|
| 59 | i=0;
|
|---|
| 60 | }
|
|---|
| 61 | if( (RR>>i) & 1 ) return(bit_un);
|
|---|
| 62 | else return(bit_zero);
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | */
|
|---|
| 66 |
|
|---|
| 67 | // un bit pour fifo avec un seul bit (bit0) et la valeur de la periode en bit 1..6 (37 ou 38)
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | char un_bit(void)
|
|---|
| 72 | {
|
|---|
| 73 | static int i;
|
|---|
| 74 | static unsigned long RR;
|
|---|
| 75 | lit_carte; if(rien_a_lire) return(bit_vide); // fifo vide -> retour -> sort du while
|
|---|
| 76 | //if( RR & 1 ) return(bit_un);
|
|---|
| 77 | //else return(bit_zero);
|
|---|
| 78 | if( RR & 1 ) return(bit_zero);
|
|---|
| 79 | else return(bit_un);
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | void ecrit_erreur_bit(int e)
|
|---|
| 85 | {
|
|---|
| 86 | ecrit_erreur(e+20);
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 | void lecture_fifo(void* tx) // appellé directement pour acquisition en interruptions
|
|---|
| 95 | {
|
|---|
| 96 | tmtc* tt=(tmtc*)tx;
|
|---|
| 97 | long lec_fifo=0; // compteur nombre de points lut en une fois dans la fifo
|
|---|
| 98 | char* t_char=(char*)(&tt->vi.btt);
|
|---|
| 99 | int i;
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | if(tt->PCI_actif==2) // simulation Archeops
|
|---|
| 103 | {
|
|---|
| 104 | static int numblock=0;
|
|---|
| 105 | tt->vi.a++;
|
|---|
| 106 | if(tt->vi.a>20) // ecrit un block toutes les 20 interruptions (soit 0.5 sec)
|
|---|
| 107 | {
|
|---|
| 108 | int i;
|
|---|
| 109 | tt->vi.a=0;
|
|---|
| 110 | numblock++;
|
|---|
| 111 |
|
|---|
| 112 | for(i=0;i<(taille_maxi_block_archeops/4);i++) tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);
|
|---|
| 113 | valide_block(&tt->vi.btt,block_bolo,numblock);
|
|---|
| 114 | sauve_un_block(tt);
|
|---|
| 115 |
|
|---|
| 116 | for(i=0;i<(taille_maxi_block_archeops/4);i++) tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);
|
|---|
| 117 | valide_block(&tt->vi.btt,block_une_periode,numblock);
|
|---|
| 118 | sauve_un_block(tt);
|
|---|
| 119 |
|
|---|
| 120 | for(i=0;i<(taille_maxi_block_archeops/4);i++) tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);
|
|---|
| 121 | valide_block(&tt->vi.btt,block_dilution,numblock);
|
|---|
| 122 | sauve_un_block(tt);
|
|---|
| 123 |
|
|---|
| 124 | }
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | else while(1)
|
|---|
| 128 | {
|
|---|
| 129 | i=lit_bit(&tt->vi.btt);
|
|---|
| 130 | if(i==lit_bit_vide) break;
|
|---|
| 131 | if(i==lit_bit_un_block) sauve_un_block(tt);
|
|---|
| 132 |
|
|---|
| 133 | lec_fifo++;
|
|---|
| 134 | if(lec_fifo>max_fifo*8) break; // parceque compte les bit et non les octets
|
|---|
| 135 | }
|
|---|
| 136 | if(lec_fifo > tt->nb_lec_fofo_int) tt->nb_lec_fofo_int=lec_fifo;
|
|---|
| 137 | if(!tt->nb_lec_fofo_ext) {tt->nb_lec_fofo_ext=tt->nb_lec_fofo_int;tt->nb_lec_fofo_int=0;}
|
|---|
| 138 |
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | //______________________________________________________________________________________________//
|
|---|
| 144 | // lit le block brut tel que recut par telemesure dans tt->vi.btt //
|
|---|
| 145 | // ce block contient ?? periodes de mesure //
|
|---|
| 146 | // Je rempli un block tm en position u=tt->tm.pos_ecrit //
|
|---|
| 147 | // Le block s'ecrit: tt->tm.btm[u] //
|
|---|
| 148 | //______________________________________________________________________________________________//
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 | void sauve_un_block(tmtc* tt)
|
|---|
| 153 | {
|
|---|
| 154 | int u;
|
|---|
| 155 | //ecrit_erreur(err_recut_un_block_ok);
|
|---|
| 156 |
|
|---|
| 157 | u=tt->tm.pos_ecrit;
|
|---|
| 158 | // le code de debut n'a pas été ecrit dans le block : il faut l'ecrire
|
|---|
| 159 | tt->vi.btt.debut=debut_block_mesure;
|
|---|
| 160 | tt->tm.btm[u].tmtrx=tt->vi.btt; // recopie le block courant dans la table
|
|---|
| 161 | u++; if(u>=longueur_table_tm) u=0;
|
|---|
| 162 | tt->tm.pos_ecrit=u;
|
|---|
| 163 |
|
|---|
| 164 | if(tt->tm.pos_ecrit==tt->tm.pos_lit) ecrit_erreur(err_pile_pleine);
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | //*****************************************************************************************
|
|---|
| 168 | // ***
|
|---|
| 169 | #endif //-------------------------------------------------------------------- ***
|
|---|
| 170 | #endif //-------------------------------------------------------------------- ***
|
|---|
| 171 | // ***
|
|---|
| 172 | //*****************************************************************************************
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|