source: Sophya/trunk/Poubelle/archediab.old/archediab.sources/c/acquisition_archeops.c@ 649

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

archediab 28 vol

File size: 16.0 KB
Line 
1#define utilitaires_de_block_archeops
2
3#include "diabolo.h"
4#include "bolo.h"
5#include "acqui.h"
6#include "carte_acqui.h"
7#include "carte_pci.h"
8#include "trace.h"
9#include "corel.h"
10#include "montimer.h"
11#include "synchro.h"
12#include "fichier.h"
13#include "onde.h"
14#include "tm.h"
15#include "tache.h"
16#include "compress.h"
17#include "controle.h"
18#include "menu.h"
19
20
21
22
23//*****************************************************************************************
24// ***
25#ifdef _archeops //--------- pour Archeops ------------------------------ ***
26//--------------- lit block Archeops ------------------------------ ***
27// ***
28//*****************************************************************************************
29
30
31// la fonction litblock
32// 1 elle lit dans la table de telemesures
33// 2 elle teste le type de block et sa validité (somme des bits et code fin)
34// 3 elle appelle la fonction de traitement en lui fournissant un pointeur sur le block
35// 4 elle sauve le block dans le fichier
36// C'est la fonction acqui qui apelle lit_block qui avance le pointeur de la table de telemesures
37
38
39block_type_modele bktm; // memoire pour block local pour copie lors de la decompression
40
41block_type_synchro_sol blk_sync2; // block memoire pour les synchro sol qui seront traitées lors
42 // de la lecture du block bolo
43
44block_type_gyro blk_gyro2; // block memoire pour les gyros qui seront traitées lors
45 // de la lecture du block bolo
46
47
48
49#define blk_tm (&tt->tm.btm[tt->tm.pos_lit].tmtrx) // pointeur sur le block télémesure a lire)
50
51void lit_block_archeops(int err)
52{
53static char ss[1000];
54def_nom_block
55static int mon_num_block;
56
57if(!fenetre(fenetre_lecture_blocks)) nouveauT(fenetre_lecture_blocks,0,"lecture blocs");
58
59if(verifie_block_printf(blk_tm))
60 {
61 if((mon_num_block+1)==numero_block(blk_tm))
62 {
63 mon_num_block=numero_block(blk_tm);
64 if(!fenetre(fenetre_lecture_blocks)) nouveauT(fenetre_lecture_blocks,0,"lecture blocs");
65 ecritT(fenetre_lecture_blocks,fin_f,"%s\n",ss);
66 sprintf(ss,"%d ->",mon_num_block);
67 }
68 if(strlen(ss)<500) sprintf(ss+strlen(ss)," **%s ",nom_block[type_block(blk_tm)]);
69 ecrit_fichier_ARCH(blk_tm); // ecrit les fichiers en erreur sur le disque
70 return;
71 }
72
73 {
74 if(mon_num_block!=numero_block(blk_tm))
75 {
76 mon_num_block=numero_block(blk_tm);
77 if(!fenetre(fenetre_lecture_blocks)) nouveauT(fenetre_lecture_blocks,0,"lecture blocs");
78 ecritT(fenetre_lecture_blocks,fin_f,"%s\n",ss);
79 sprintf(ss,"%d ->",mon_num_block);
80 }
81 if(strlen(ss)<500) sprintf(ss+strlen(ss)," %s ",nom_block[type_block(blk_tm)]);
82 }
83
84switch(type_block(blk_tm))
85 {
86 case block_param : break;
87
88 case block_journal : traite_block_journal((block_type_journal*)blk_tm); break;
89
90 case block_reglage : traite_block_reglage((block_type_reglage*)blk_tm); break;
91
92 case block_dilution : traite_block_dilution((block_type_dilution*)blk_tm); break;
93
94 case block_gps : traite_block_gps((block_type_gps*)blk_tm); break;
95
96 case block_une_periode : traite_block_une_periode((block_type_une_periode*)blk_tm); break;
97
98 case block_bolo : traite_block_bolo((block_type_bolo*)blk_tm); break;
99 case block_bolo_comprime : traite_block_bolo_comprime((block_type_bolo_comprime*)blk_tm); break;
100
101 case block_sst : traite_block_sst((block_type_sst*)blk_tm);
102 traite_block_sst_brut((block_type_sst*)blk_tm); break;
103 case block_sst_comprime : traite_block_sst_comprime((block_type_sst_comprime*)blk_tm);
104 traite_block_sst_comprime_brut((block_type_sst_comprime*)blk_tm);break;
105
106 case block_gyro : traite_block_gyro((block_type_gyro*)blk_tm); break;
107 case block_gyro_comprime : traite_block_gyro_comprime((block_type_gyro_comprime*)blk_tm); break;
108
109 case block_synchro_sol : traite_block_synchro_sol((block_type_synchro_sol*)blk_tm); break;
110
111 case block_status_flash : printf("**** status flash recut **** nblock=%x - %d *** \n",((block_type_status_flash*)blk_tm)->status.nb_total_blocks,((block_type_status_flash*)blk_tm)->status.nb_total_blocks/256);break;
112
113#ifdef transmet_data_brute
114 case block_data_brute : traite_block_data_brute((block_type_data_brute*)blk_tm); break;
115#endif
116
117 default : {def_nom_block printf("block de type %s non traité par le programme \n",nom_block[type_block(blk_tm)]);}
118 break;
119 }
120
121ecrit_fichier_ARCH(blk_tm);
122
123}
124#undef blk_tm
125
126//*****************************************************************************************
127// ***
128// ------------------ traitement des blocks --------------- ***
129// ***
130//*****************************************************************************************
131
132
133
134
135//-----------------------------------------------------------------------------------------
136// ------------- block type 1 : lit le journal ------------------ ------------
137//-----------------------------------------------------------------------------------------
138void traite_block_journal(block_type_journal* blk)
139{
140long mothexa[5]; /* les 5 mots hexa de la telecommande */
141
142int i,code,blocknum;
143if(!fenetre(fenetre_journal)) nouveauT(fenetre_journal,0,"journal");
144
145//printf("ecrit une page du journal \n");
146for(i=0;i<long_page;i++)
147 {
148 code=type_block(&blk->jj[i]);
149 blocknum=numero_block(&blk->jj[i]);
150 if(code) break; // code vaut 1 pour vider une page de journal incomplete
151 mothexa[0]=blk->jj[i].mot[5]; /* 4 bit choix de commande */
152 mothexa[1]=blk->jj[i].mot[6]>>2; /* les 4 bits poid fort du code direction */
153 mothexa[2]=((blk->jj[i].mot[6]<<2)&0xc) + ((blk->jj[i].mot[7]>>6)&0x3);
154 mothexa[3]=(blk->jj[i].mot[7]>>2)&0xf;
155 mothexa[4]=(blk->jj[i].mot[7]&0x3);
156
157 if(blk->jj[i].mot[0])
158 {
159 ecritT(fenetre_journal,fin_f,"block_num= %d code %d ==> telecommande_OK : %d %d %d -> %x %x %x %x %x \n",
160 blocknum,code,blk->jj[4].mot[5],blk->jj[i].mot[6],blk->jj[i].mot[7]
161 ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]);
162 }
163 else
164 {
165 ecritT(fenetre_journal,fin_f,"block_num= %d code %d ==> erreur telecommande : %d %d %d -> %x %x %x %x %x \n",
166 blocknum,code,blk->jj[4].mot[5],blk->jj[i].mot[6],blk->jj[i].mot[7]
167 ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]);
168 }
169 }
170}
171
172
173
174
175//-----------------------------------------------------------------------------------------
176// ------------- block type 2 : block_reglage ------------------ ------------
177//-----------------------------------------------------------------------------------------
178void traite_block_reglage(block_type_reglage* blk)
179{
180
181//printf(" recut un block reglage *********************************** \n\n");
182
183gg->reglage=blk->reglage;
184tt->reglage=blk->reglage;
185rafraichis_fenetres();
186}
187
188
189//-----------------------------------------------------------------------------------------
190// --------------------- block type 3 : lit les data dilution ------------------------
191//-----------------------------------------------------------------------------------------
192//
193// fonction void traite_block_dilution(block_type_dilution*blk)
194//
195// la fonction est dans le module dilution.c
196
197
198
199//-----------------------------------------------------------------------------------------
200// --------------------- block type 4 : lit la chaine GPS ------------------------
201//-----------------------------------------------------------------------------------------
202void traite_block_gps(block_type_gps* blk)
203{
204int i;
205char c1;
206if(!fenetre(fenetre_GPS)) nouveauT(fenetre_GPS,0,"lecture GPS");
207
208//printf("ecrit une ligne GPS \n");
209
210if(blk->gps[0])
211 {
212 ecritT(fenetre_GPS,fin_f,"gps --> ");
213 for(i=0;i<80;i++)
214 {
215 c1=blk->gps[i];
216 if (c1) ecritT(fenetre_GPS,fin_f,"%c",c1&0x7f);
217 else i=80;
218 if(c1==13) i=80;
219 }
220 }
221}
222
223
224
225
226
227void traite_block_gyro_comprime(block_type_gyro_comprime* blk)
228{
229int i;
230block_type_gyro bk_gyro;
231block_type_gyro* blk2=& bk_gyro;
232if(!fenetre(fenetre_gyroscope)) return;
233//printf("*************** decompress data gyro \n");
234for(i=0;i<3;i++) decompress_7_2((long *)blk->gyro[i],blk2->gyro[i],nb_per_block*2);
235blk2->code1=blk->code1;
236blk2->code2=blk->code2;
237traite_block_gyro(blk2);
238}
239
240
241void traite_block_gyro(block_type_gyro* blk)
242{
243int k;
244double y[15];
245
246int temps_cntl;
247double secondes;
248blk_gyro2 = *blk;
249
250if(!fenetre(fenetre_gyroscope)) return;
251
252for(k=0;k<72;k++)
253 {
254 y[0]=20.*(blk->gyro[0][k]-32768)/32768.;
255 y[1]=20.*(blk->gyro[1][k]-32768)/32768.;
256 y[2]=20.*(blk->gyro[2][k]-32768)/32768.;
257
258// printf(" y = %g %g %g %g %g \n",y[0],y[1],y[2],y[3],y[4]);
259 temps_cntl =numero_block(blk)*nb_per_block*2+k;
260 secondes=gg->periode_echantillonage*(double)temps_cntl-gg->temps_origine;
261 tracen(fenetre_gyroscope,3,secondes,y);
262// printf("secondes=%g\n",secondes);
263 }
264}
265
266
267
268//-----------------------------------------------------------------------------------------
269// ------------- block type 5 : lit les courbes de bolos individuelles ------------
270// nb_per_block est le nombre de periodes entieres dans le block
271// --> le nombre de courbes lues est egal a nb_per_block qui doit etre <= nb_max_bolo
272//-----------------------------------------------------------------------------------------
273void traite_block_une_periode(block_type_une_periode* blk)
274{
275int j,i;
276for(j=0;j<nb_max_bolo;j++) for (i=0;i<gg->reglage.horloge.nb_mesures;i++)
277 gg->bol_per[j][i]=blk->bol_per[j][i]^0x7fff; // 16 bit -> 15 bit utile + phase
278 // change le signe des 15 bits utiles
279affi_bolo(); // affichage des bolo individuels
280}
281
282
283
284
285//-----------------------------------------------------------------------------------------
286// ------------- block type 6 : block_synchro_sol ------------------ ------------
287//-----------------------------------------------------------------------------------------
288void traite_block_synchro_sol(block_type_synchro_sol* blk)
289{
290blk_sync2 = *blk;
291// ne fait rien: le block synchro precede toujours le block bolo
292}
293
294
295
296
297//-----------------------------------------------------------------------------------------
298// --------------------- block type 12 : décomprime les données bolo ------------
299//-----------------------------------------------------------------------------------------
300void traite_block_bolo_comprime(block_type_bolo_comprime* blk)
301{
302int j,jc;
303#define blk2 ((block_type_bolo*)(&bktm)) // pointeur sur la memoire locale
304// maintenant, decomprime blk pour le reecrire dans blk2
305/*printf("comprime: ds1= %x , %x ds2= %x , %x ",
306 ( (blk->data_bolo[0][0] & 0xffff0000)>>11 ) & 0x001fffe0,
307 ( (blk->data_bolo[0][0] & 0x0000ffff)<<5 ) & 0x001fffe0,
308 ( (blk->data_bolo[1][0] & 0xffff0000)>>11 ) & 0x001fffe0,
309 ( (blk->data_bolo[1][0] & 0x0000ffff)<<5 ) & 0x001fffe0);
310*/
311/*
312for(j=0;j<nb_bolo_util;j++)
313 {
314 decompress_7_2((long *)blk->data_bolo[j],blk2->data_bolo[j],nb_per_block*2);
315 }
316*/
317jc=0;for(j=0;j<nb_max_bolo;j++) // jc = bolo_comprime // j=bolo normal
318 {
319 if( (parametr.bolo[j].bolo_code_util==bolo_normal_transmis) && (jc<nb_bolo_util) )
320 {
321 decompress_7_2((long *)blk->data_bolo[jc],blk2->data_bolo[j],nb_per_block*2);
322 jc++;
323 }
324 }
325/*printf("ds1= %x , %x ds2= %x , %x \n",
326 blk2->data_bolo[0][0],
327 blk2->data_bolo[0][1],
328 blk2->data_bolo[1][0],
329 blk2->data_bolo[1][1]);
330*/
331valide_block(&bktm,block_bolo,numero_block(blk)); // pour recopier le numero de block
332traite_block_bolo(blk2);
333}
334
335
336
337
338//-----------------------------------------------------------------------------------------
339// ------------- block type 8 : block_bolo ------------------ ------------
340//-----------------------------------------------------------------------------------------
341void traite_block_bolo(block_type_bolo* blk)
342{
343static num_block_local;
344int i,j,nb_coups,glitch;
345static ancien_don_bolo[nb_max_bolo];
346int secondes;
347
348glitch=litD(fenetre_acquisition,e_deglitch,0L);
349
350num_block_local++;
351if(num_block_local!=numero_block(blk)) {printf(" erreur numblock=%d\n",numero_block(blk));num_block_local=numero_block(blk);}
352
353secondes=(int) (gg->periode_echantillonage*(double)num_block_local*(double)nb_per_block*2.);
354//printf("numblock=%d sec=%d \n",num_block_local,secondes);
355ecritD(fenetre_controle,con_time,"%d",secondes);
356
357nb_coups= gg->reglage.horloge.nb_mesures/2 - gg->reglage.horloge.temp_mort;
358
359/*
360if( (num_block_local%10)==0) // impression des valeurs un block sur 10
361 {
362 int aa = (nb_coups<<14) + (nb_coups*190) ;
363 printf(" nb coups dans une somme : %d \n",nb_coups);
364 for(j=0;j<20;j+=2)
365 printf("ds1= %x , %x ds2= %x , %x ",
366 blk->data_bolo[0][j],
367 blk->data_bolo[0][j+1],
368 blk->data_bolo[1][j],
369 blk->data_bolo[1][j+1]);
370 printf("ds1= %8.1f , %8.1f ds2= %8.1f , %8.1f \n",
371 (double)(blk->data_bolo[0][j]- aa),
372 (double)(blk->data_bolo[0][j+1]- aa),
373 (double)(blk->data_bolo[1][j]- aa),
374 (double)(blk->data_bolo[1][j+1]- aa));
375 }
376*/
377
378// ------------- lit les valeur detection synchrone ------------------
379
380#define val_DS(j,i) (blk->data_bolo[j][i]&0x1fffff)
381//#define synchro_DS(j,i) ((blk->data_bolo[j][i]>>20)&1)
382
383for (i=0;i<nb_per_block*2;i++)
384 {
385 int aa,s;
386 aa = (nb_coups<<14) + (nb_coups*190) ;
387 if( i%2) s=1;else s=-1;
388
389 for(j=0;j<nb_max_bolo;j++)
390 {
391 gg->don.don_bolo[j]=0.5*(ancien_don_bolo[j]+s*(((val_DS(j,i)-aa)<<1)/nb_coups)); // copy bolos
392 ancien_don_bolo[j]=s*(((val_DS(j,i)-aa)<<1)/nb_coups);
393// if( (i==1) && (j==14) )
394// {
395// def_gains
396// printf(" brut=%d ofset=%d nbcoups=%d gg->don.don_bolo[j]=%d parametr.bolo[j].bolo_gain=%d gainampli=%g micro-volts=%g \n"
397// , val_DS(j,i) ,aa ,nb_coups ,(int)gg->don.don_bolo[j] ,parametr.bolo[j].bolo_gain ,gain_ampli(gg->reglage.bolo[j]) ,(double)xbolbrut(j));
398// }
399//
400 }
401
402 for(j=0;j<nb_sync;j++)
403 {
404 gg->don.sync[j]=blk_sync2.synchro[i][j];
405 }
406
407 gg->don.gyro[0]=20.*(blk_gyro2.gyro[0][i]-32768)/32768.;
408 gg->don.gyro[1]=20.*(blk_gyro2.gyro[1][i]-32768)/32768.;
409 gg->don.gyro[2]=20.*(blk_gyro2.gyro[2][i]-32768)/32768.;
410
411
412
413// gg->don.sync[j]=synchro_DS(j,i);
414
415 gg->temps_cntl=num_block_local*nb_per_block*2+i; // temps controlleur en demi-periodes
416// printf("gg->temps_cntl=%d \n",gg->temps_cntl);
417// exec_synchro(0,100,err); // en premier pour construire le flag scan_en_cours
418 exec_synchro(0,100,0); // en premier pour construire le flag scan_en_cours
419 // le trace ds et 1p est fait avec les points corelles du coups precedent !!!
420
421 GetDateTime(&gg->temps_mac);
422 if(gg->fichier_dia2_ouvert) ecrit_fichier_dia2(gg->don,gg->temps_cntl,gg->temps_mac); // ecrit les donnees dans le fichier
423
424 if(glitch) deglitch();
425 corel();
426
427 //if(gg->trace_ouvert&1) exec_trace_tout(fenetre_trace_tout,tache_de_fond,0);
428 for(j=0;j<8;j++) if(gg->trace_tout[j]) exec_trace_tout(gg->trace_tout[j],tache_de_fond,0);
429 if( (gg->trace_ouvert&16) && // trace carte et pas de select synchro
430 (! (gg->trace_ouvert&32))) trace_annexe(gg->corel);
431 if(gg->flag_fou) foufou();
432 if(gg->trace_ouvert&8) exec_ondelette(fenetre_ondelette,0,0);
433
434
435 }
436
437 // _____________ affichage numerique de la valeur d'un bolometre _______________
438j=litD(fenetre_acquisition,e_bolo,0L)-1;
439if( (j<0) ou (j>=nb_max_bolo) ) ecritD(fenetre_acquisition,e_valeur,"--");
440 else ecritD(fenetre_acquisition,e_valeur,"b%d=%g µV",j+1,xbol(j));
441
442
443}
444
445
446
447
448#ifdef transmet_data_brute
449//-----------------------------------------------------------------------------------------
450// ------------- block type 15 : lit data brute (block recut de l'EPLD) ------------ ------------
451// ------------- utilise uniquement pour la mise au point ------------
452//-----------------------------------------------------------------------------------------
453void traite_block_data_brute(block_type_data_brute* blk)
454{
455int i,k;
456static int qq=0;
457qq++;
458//if(qq>20)
459 {
460 qq=0;
461 printf(" data brutes : ");
462 for(k=0;k<10;k+=5) {printf(" ");for (i=0;i<5;i++) printf(" %x", (unsigned char) blk->data[k+i+1]);}
463 printf("\n");
464 for(k=0;k<nb_per_block;k++) printf("%d",(blk->data[k*tt->reglage.horloge.nb_mesures*nb_byte_mot+5]>>6)&0x3);
465 printf("\n");
466// for(k=0;k<2;k++)
467 {
468// printf("%d",(blk->data[k*tt->reglage.horloge.nb_mesures*nb_byte_mot+2]>>6)&0x3);
469 for(i=0;i<tt->reglage.horloge.nb_mesures;i++)
470 {
471// printf("%d",(blk->data[(k*tt->reglage.horloge.nb_mesures+i)*nb_byte_mot+5]>>6)&0x3);
472 }
473// printf("\n");
474 }
475
476 }
477}
478#endif
479
480
481
482
483#endif
484
Note: See TracBrowser for help on using the repository browser.