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

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

archediab 25

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