1 | #include <manip.h>
|
---|
2 | /*#include <stdio.h>
|
---|
3 | #include <malloc.h>
|
---|
4 | #include <stdlib.h>
|
---|
5 | #define utilitaires_de_block_archeops
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "choix_acquisition.h"
|
---|
9 | #include "archeops.h"
|
---|
10 | #include "bit_block.h"
|
---|
11 | #include "choix_param.h"
|
---|
12 | #include "structure.h"
|
---|
13 | #include "tm.h"
|
---|
14 | #include "tache.h"
|
---|
15 | #include "bolo.h"
|
---|
16 | #include "carte_acqui.h"
|
---|
17 | #include "carte_pci.h"
|
---|
18 |
|
---|
19 |
|
---|
20 | #define cadence_taux 16 // cadence de filtrage du taux d'occupation de telemetrie
|
---|
21 | #define mode_acquisition 0x00 //0xff en mode inverse, 0x00 en mode normal
|
---|
22 | unsigned long buffer;
|
---|
23 | int llgg,somme,type_du_block,numero;
|
---|
24 | int deb; /*deb vaut zero si aucun debut n'a encore ete trouve*/
|
---|
25 | int compteur;
|
---|
26 | int cpt_cherche_debut;
|
---|
27 | unsigned long taux;
|
---|
28 | unsigned long Nvide, Nplein;
|
---|
29 | def_long_block
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 | int lit_bit(block_type_modele *pbk)
|
---|
34 |
|
---|
35 | {
|
---|
36 | int i,m,bit;
|
---|
37 |
|
---|
38 | // unsigned char bit; /*c'est le bit lu*/
|
---|
39 |
|
---|
40 | bit=un_bit()^mode_acquisition;
|
---|
41 | switch(bit)
|
---|
42 | {
|
---|
43 | case bit_vide : return(lit_bit_vide);
|
---|
44 | case bit_un : buffer=(buffer>>1)|0x80000000; break;
|
---|
45 | case bit_zero : buffer=0x7fffffff & (buffer>>1); break;
|
---|
46 | default : ecrit_erreur_bit(erreur_bit_erreur);
|
---|
47 | buffer=buffer>>1;
|
---|
48 | break;
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | compteur++;
|
---|
53 | i=compteur%32;
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 | switch(deb)
|
---|
59 | {
|
---|
60 | case(1) :
|
---|
61 |
|
---|
62 | /*signifie qu'un debut a ete trouve precedemment*/
|
---|
63 |
|
---|
64 | if(i==31)
|
---|
65 | {
|
---|
66 | /*lecture du code 1*/
|
---|
67 | pbk->code1=buffer;
|
---|
68 | deb=2;
|
---|
69 | }
|
---|
70 | break;
|
---|
71 |
|
---|
72 | case(2) :
|
---|
73 |
|
---|
74 | /*lecture du code 2*/
|
---|
75 |
|
---|
76 | if(i==31)
|
---|
77 | {
|
---|
78 |
|
---|
79 | pbk->code2=buffer;
|
---|
80 | // type_du_block=((buffer>>24)&0xff);
|
---|
81 | // numero=(buffer&0xffffff);
|
---|
82 | deb=3;
|
---|
83 |
|
---|
84 | /*Quelques tests avant de continuer*/
|
---|
85 | llgg=longueur_block(pbk);
|
---|
86 | somme=somme_block(pbk);
|
---|
87 | type_du_block=type_block(pbk);
|
---|
88 | numero=numero_block(pbk);
|
---|
89 |
|
---|
90 | if((type_du_block<0) || (type_du_block>nb_type_blocks))
|
---|
91 | {
|
---|
92 | ecrit_erreur_bit(erreur_type);
|
---|
93 | deb=0; /*on va rechercher un nouveau debut*/
|
---|
94 | }
|
---|
95 |
|
---|
96 | if(llgg!=long_block[type_du_block])
|
---|
97 | {
|
---|
98 | ecrit_erreur_bit(erreur_longueur);
|
---|
99 | deb=0; /*on va rechercher un nouveau debut*/
|
---|
100 | }
|
---|
101 | // if(deb) ecrit_erreur_bit(bloc_correct);
|
---|
102 | }
|
---|
103 | break;
|
---|
104 |
|
---|
105 | case(3) :
|
---|
106 |
|
---|
107 | if(i==31)
|
---|
108 | {
|
---|
109 | m=(compteur+1)/32-4;
|
---|
110 | if( (m>(taille_maxi_block_archeops)/4) ou (m<0) )
|
---|
111 | {
|
---|
112 | ecrit_erreur_bit(erreur_longueur);
|
---|
113 | deb=0;
|
---|
114 | }
|
---|
115 | else
|
---|
116 | {
|
---|
117 | pbk->mot[m]=buffer;
|
---|
118 |
|
---|
119 | if(m==llgg/4-4) /*en principe, c'est le mot fin*/
|
---|
120 | {
|
---|
121 | if(pbk->mot[m] == fin_block_mesure)
|
---|
122 | {
|
---|
123 | /*
|
---|
124 | if(calcul_somme_block(pbk,llgg)!=somme)
|
---|
125 | {
|
---|
126 | ecrit_erreur_bit(erreur_somme);
|
---|
127 |
|
---|
128 |
|
---|
129 | }
|
---|
130 | */
|
---|
131 |
|
---|
132 | // else ecrit_erreur_bit(bloc_correct);
|
---|
133 |
|
---|
134 | deb=0;
|
---|
135 | Nplein=compteur+1;
|
---|
136 | compteur=0;
|
---|
137 | //Calcul du taux de remplissage
|
---|
138 | taux=taux+(((0xffff-taux)*Nplein)>>cadence_taux);
|
---|
139 | tt->val_con_donnee=((taux*1000)>>cadence_taux);
|
---|
140 | return(lit_bit_un_block);
|
---|
141 |
|
---|
142 | }
|
---|
143 | else
|
---|
144 | {
|
---|
145 | ecrit_erreur_bit(erreur_fin);
|
---|
146 |
|
---|
147 | /*ecrire ici une nouvelle recherche de debut dans pbk*/
|
---|
148 | deb=0;
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|
155 | }
|
---|
156 |
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | }
|
---|
161 | break;
|
---|
162 |
|
---|
163 |
|
---|
164 | default :
|
---|
165 |
|
---|
166 | if(compteur>1000)
|
---|
167 | {
|
---|
168 | Nvide=compteur;
|
---|
169 | compteur=0;
|
---|
170 | taux=taux-((taux*Nvide)>>cadence_taux);
|
---|
171 | tt->val_con_donnee=((taux*1000)>>cadence_taux);
|
---|
172 | }
|
---|
173 | if(buffer==debut_block_mesure)
|
---|
174 | {
|
---|
175 | deb=1;
|
---|
176 | Nvide=compteur-32;
|
---|
177 | compteur=31;
|
---|
178 | pbk->debut=buffer;
|
---|
179 | }
|
---|
180 | else
|
---|
181 | {
|
---|
182 | if( (cpt_cherche_debut++<0) ou (cpt_cherche_debut>10000) )
|
---|
183 | {
|
---|
184 | cpt_cherche_debut=0;
|
---|
185 | // ecrit_erreur_bit(cherche_debut);
|
---|
186 | }
|
---|
187 | }
|
---|
188 | break;
|
---|
189 |
|
---|
190 |
|
---|
191 | }
|
---|
192 |
|
---|
193 | return(lit_bit_OK);
|
---|
194 |
|
---|
195 | }
|
---|
196 |
|
---|
197 |
|
---|