source: Sophya/trunk/Poubelle/archediab.old/archediab.sources/c/tache_archeops_bit2.c@ 645

Last change on this file since 645 was 645, checked in by ansari, 26 years ago

archediab 27

File size: 5.1 KB
Line 
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);}
31void sauve_un_block(tmtc* tt);
32
33
34
35//*****************************************************************************************
36unsigned long N_total_bits,M;
37unsigned short Max,Min;
38
39void init_tache(void)
40{
41tt->vi.a=0;
42tt->vi.b=0;
43tt->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/*
53char un_bit(void)
54{
55static int i;
56static unsigned long RR;
57i++;
58if( (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 }
63if( (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
73char un_bit()
74{
75static int i;
76static unsigned long RR;
77unsigned short Val;
78
79lit_carte; if(rien_a_lire) return(bit_vide); // fifo vide -> retour -> sort du while
80
81N_total_bits++;
82Val=((RR>>1) & 0x3f); //permet de lire les bits de temps dans RR
83
84//Calcul de la nouvelle moyenne glissee du temps
85M=M-(M>>16)+(Val<<8);
86
87
88//Calcul du Max
89if(N_total_bits==0) Max=Val; //initialisation au premier passage
90if(Val>Max) Max=Val; //changement de maximum
91if((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
98if(N_total_bits==0) Min=Val; //initialisation au premier passage
99if(Val<Min) Min=Val; //changement de minimum
100if((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);
107if( RR & 1 ) return(bit_zero);
108else return(bit_un);
109
110}
111
112
113
114void ecrit_erreur_bit(int e)
115{
116ecrit_erreur(e+20);
117}
118
119
120
121
122
123
124void lecture_fifo(void* tx) // appellé directement pour acquisition en interruptions
125{
126tmtc* tt=(tmtc*)tx;
127long lec_fifo=0; // compteur nombre de points lut en une fois dans la fifo
128char* t_char=(char*)(&tt->vi.btt);
129int i;
130
131
132if(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
157else 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 }
166if(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
182void sauve_un_block(tmtc* tt)
183{
184int u;
185//ecrit_erreur(err_recut_un_block_ok);
186
187u=tt->tm.pos_ecrit;
188// le code de debut n'a pas été ecrit dans le block : il faut l'ecrire
189tt->vi.btt.debut=debut_block_mesure;
190tt->tm.btm[u].tmtrx=tt->vi.btt; // recopie le block courant dans la table
191u++; if(u>=longueur_table_tm) u=0;
192tt->tm.pos_ecrit=u;
193
194if(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
Note: See TracBrowser for help on using the repository browser.