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

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

archediab 29

File size: 16.1 KB
RevLine 
[637]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
[649]44block_type_gyro blk_gyro2; // block memoire pour les gyros qui seront traitées lors
45 // de la lecture du block bolo
[637]46
47
[649]48
[637]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{
[649]53static char ss[1000];
54def_nom_block
55static int mon_num_block;
[637]56
[649]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
[643]73 {
74 if(mon_num_block!=numero_block(blk_tm))
75 {
76 mon_num_block=numero_block(blk_tm);
[649]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);
[643]80 }
[649]81 if(strlen(ss)<500) sprintf(ss+strlen(ss)," %s ",nom_block[type_block(blk_tm)]);
[643]82 }
[637]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;
[643]99 case block_bolo_comprime : traite_block_bolo_comprime((block_type_bolo_comprime*)blk_tm); break;
[637]100
[649]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;
[643]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;
[637]108
109 case block_synchro_sol : traite_block_synchro_sol((block_type_synchro_sol*)blk_tm); break;
110
[649]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;
[643]112
[637]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{
[649]140long mothexa[5]; /* les 5 mots hexa de la telecommande */
141
[637]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
[649]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 }
[637]169 }
170}
171
[649]172
173
174
[637]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
[649]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
[637]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
[639]296
[637]297//-----------------------------------------------------------------------------------------
298// --------------------- block type 12 : décomprime les données bolo ------------
299//-----------------------------------------------------------------------------------------
300void traite_block_bolo_comprime(block_type_bolo_comprime* blk)
301{
[643]302int j,jc;
[637]303#define blk2 ((block_type_bolo*)(&bktm)) // pointeur sur la memoire locale
304// maintenant, decomprime blk pour le reecrire dans blk2
[639]305/*printf("comprime: ds1= %x , %x ds2= %x , %x ",
[637]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);
[639]310*/
[643]311/*
[637]312for(j=0;j<nb_bolo_util;j++)
313 {
[639]314 decompress_7_2((long *)blk->data_bolo[j],blk2->data_bolo[j],nb_per_block*2);
[637]315 }
[643]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 }
[639]325/*printf("ds1= %x , %x ds2= %x , %x \n",
[637]326 blk2->data_bolo[0][0],
327 blk2->data_bolo[0][1],
328 blk2->data_bolo[1][0],
329 blk2->data_bolo[1][1]);
[639]330*/
[637]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//-----------------------------------------------------------------------------------------
[651]341#define temps_UT(block) (8.0609925+0.00011673636*(double)(block))
342
[637]343void traite_block_bolo(block_type_bolo* blk)
344{
345static num_block_local;
346int i,j,nb_coups,glitch;
347static ancien_don_bolo[nb_max_bolo];
348int secondes;
349
350glitch=litD(fenetre_acquisition,e_deglitch,0L);
351
352num_block_local++;
353if(num_block_local!=numero_block(blk)) {printf(" erreur numblock=%d\n",numero_block(blk));num_block_local=numero_block(blk);}
354
355secondes=(int) (gg->periode_echantillonage*(double)num_block_local*(double)nb_per_block*2.);
356//printf("numblock=%d sec=%d \n",num_block_local,secondes);
357ecritD(fenetre_controle,con_time,"%d",secondes);
[651]358ecritD(fenetre_controle,con_time,"%6.3f",temps_UT(num_block_local));
[637]359
360nb_coups= gg->reglage.horloge.nb_mesures/2 - gg->reglage.horloge.temp_mort;
361
362/*
363if( (num_block_local%10)==0) // impression des valeurs un block sur 10
364 {
365 int aa = (nb_coups<<14) + (nb_coups*190) ;
366 printf(" nb coups dans une somme : %d \n",nb_coups);
367 for(j=0;j<20;j+=2)
368 printf("ds1= %x , %x ds2= %x , %x ",
369 blk->data_bolo[0][j],
370 blk->data_bolo[0][j+1],
371 blk->data_bolo[1][j],
372 blk->data_bolo[1][j+1]);
373 printf("ds1= %8.1f , %8.1f ds2= %8.1f , %8.1f \n",
374 (double)(blk->data_bolo[0][j]- aa),
375 (double)(blk->data_bolo[0][j+1]- aa),
376 (double)(blk->data_bolo[1][j]- aa),
377 (double)(blk->data_bolo[1][j+1]- aa));
378 }
379*/
380
381// ------------- lit les valeur detection synchrone ------------------
382
383#define val_DS(j,i) (blk->data_bolo[j][i]&0x1fffff)
[639]384//#define synchro_DS(j,i) ((blk->data_bolo[j][i]>>20)&1)
[637]385
386for (i=0;i<nb_per_block*2;i++)
387 {
388 int aa,s;
389 aa = (nb_coups<<14) + (nb_coups*190) ;
390 if( i%2) s=1;else s=-1;
391
392 for(j=0;j<nb_max_bolo;j++)
393 {
394 gg->don.don_bolo[j]=0.5*(ancien_don_bolo[j]+s*(((val_DS(j,i)-aa)<<1)/nb_coups)); // copy bolos
395 ancien_don_bolo[j]=s*(((val_DS(j,i)-aa)<<1)/nb_coups);
[649]396// if( (i==1) && (j==14) )
397// {
398// def_gains
399// 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"
400// , 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));
401// }
402//
[637]403 }
404
[639]405 for(j=0;j<nb_sync;j++)
406 {
407 gg->don.sync[j]=blk_sync2.synchro[i][j];
408 }
409
[649]410 gg->don.gyro[0]=20.*(blk_gyro2.gyro[0][i]-32768)/32768.;
411 gg->don.gyro[1]=20.*(blk_gyro2.gyro[1][i]-32768)/32768.;
412 gg->don.gyro[2]=20.*(blk_gyro2.gyro[2][i]-32768)/32768.;
413
414
[639]415
416// gg->don.sync[j]=synchro_DS(j,i);
[637]417
418 gg->temps_cntl=num_block_local*nb_per_block*2+i; // temps controlleur en demi-periodes
419// printf("gg->temps_cntl=%d \n",gg->temps_cntl);
420// exec_synchro(0,100,err); // en premier pour construire le flag scan_en_cours
421 exec_synchro(0,100,0); // en premier pour construire le flag scan_en_cours
422 // le trace ds et 1p est fait avec les points corelles du coups precedent !!!
423
424 GetDateTime(&gg->temps_mac);
425 if(gg->fichier_dia2_ouvert) ecrit_fichier_dia2(gg->don,gg->temps_cntl,gg->temps_mac); // ecrit les donnees dans le fichier
426
427 if(glitch) deglitch();
428 corel();
429
430 //if(gg->trace_ouvert&1) exec_trace_tout(fenetre_trace_tout,tache_de_fond,0);
431 for(j=0;j<8;j++) if(gg->trace_tout[j]) exec_trace_tout(gg->trace_tout[j],tache_de_fond,0);
432 if( (gg->trace_ouvert&16) && // trace carte et pas de select synchro
433 (! (gg->trace_ouvert&32))) trace_annexe(gg->corel);
434 if(gg->flag_fou) foufou();
435 if(gg->trace_ouvert&8) exec_ondelette(fenetre_ondelette,0,0);
436
437
438 }
439
440 // _____________ affichage numerique de la valeur d'un bolometre _______________
441j=litD(fenetre_acquisition,e_bolo,0L)-1;
442if( (j<0) ou (j>=nb_max_bolo) ) ecritD(fenetre_acquisition,e_valeur,"--");
443 else ecritD(fenetre_acquisition,e_valeur,"b%d=%g µV",j+1,xbol(j));
444
445
446}
447
448
449
450
451#ifdef transmet_data_brute
452//-----------------------------------------------------------------------------------------
453// ------------- block type 15 : lit data brute (block recut de l'EPLD) ------------ ------------
454// ------------- utilise uniquement pour la mise au point ------------
455//-----------------------------------------------------------------------------------------
456void traite_block_data_brute(block_type_data_brute* blk)
457{
458int i,k;
459static int qq=0;
460qq++;
461//if(qq>20)
462 {
463 qq=0;
464 printf(" data brutes : ");
465 for(k=0;k<10;k+=5) {printf(" ");for (i=0;i<5;i++) printf(" %x", (unsigned char) blk->data[k+i+1]);}
466 printf("\n");
467 for(k=0;k<nb_per_block;k++) printf("%d",(blk->data[k*tt->reglage.horloge.nb_mesures*nb_byte_mot+5]>>6)&0x3);
468 printf("\n");
469// for(k=0;k<2;k++)
470 {
471// printf("%d",(blk->data[k*tt->reglage.horloge.nb_mesures*nb_byte_mot+2]>>6)&0x3);
472 for(i=0;i<tt->reglage.horloge.nb_mesures;i++)
473 {
474// printf("%d",(blk->data[(k*tt->reglage.horloge.nb_mesures+i)*nb_byte_mot+5]>>6)&0x3);
475 }
476// printf("\n");
477 }
478
479 }
480}
481#endif
482
483
484
485
486#endif
487
Note: See TracBrowser for help on using the repository browser.