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

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

archediab 28 vol

File size: 5.0 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#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);}
32void sauve_un_block(tmtc* tt);
33
34
35
36//*****************************************************************************************
37unsigned long N_total_bits,M;
38unsigned short Max,Min;
39
40void init_tache(void)
41{
42tt->vi.a=0;
43tt->vi.b=0;
44tt->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
55char un_bit()
56{
57static int i;
58static unsigned long RR;
59unsigned short Val;
60
61lit_carte; if(rien_a_lire) return(bit_vide); // fifo vide -> retour -> sort du while
62
63N_total_bits++;
64Val=((RR>>1) & 0x3f); //permet de lire les bits de temps dans RR
65
66//Calcul de la nouvelle moyenne glissee du temps
67M=M-(M>>16)+(Val<<8);
68
69
70//Calcul du Max
71if(N_total_bits==0) Max=Val; //initialisation au premier passage
72if(Val>Max) Max=Val; //changement de maximum
73if((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
80if(N_total_bits==0) Min=Val; //initialisation au premier passage
81if(Val<Min) Min=Val; //changement de minimum
82if((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
87if( RR & 1 ) return(bit_zero);
88else return(bit_un);
89
90#else
91
92if( RR & 1 ) return(bit_un);
93else return(bit_zero);
94
95#endif
96}
97
98
99
100void ecrit_erreur_bit(int e)
101{
102ecrit_erreur(e+20);
103}
104
105
106
107
108
109
110void lecture_fifo(void* tx) // appellé directement pour acquisition en interruptions
111{
112tmtc* tt=(tmtc*)tx;
113long lec_fifo=0; // compteur nombre de points lut en une fois dans la fifo
114char* t_char=(char*)(&tt->vi.btt);
115int i;
116
117
118if(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 }
142else 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 }
153else 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 }
162if(lec_fifo > tt->nb_lec_fofo_int) tt->nb_lec_fofo_int=lec_fifo;
163if(!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
178void sauve_un_block(tmtc* tt)
179{
180int u;
181//ecrit_erreur(err_recut_un_block_ok);
182
183u=tt->tm.pos_ecrit;
184// le code de debut n'a pas été ecrit dans le block : il faut l'ecrire
185tt->vi.btt.debut=debut_block_mesure;
186tt->tm.btm[u].tmtrx=tt->vi.btt; // recopie le block courant dans la table
187u++; if(u>=longueur_table_tm) u=0;
188tt->tm.pos_ecrit=u;
189
190if(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
Note: See TracBrowser for help on using the repository browser.