source: Sophya/trunk/Poubelle/archTOI.old/archeops.c@ 315

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

Archeops 24, gestion byte-swap

File size: 13.1 KB
Line 
1//#include "manip.h"
2#include <stdio.h>
3#include "archeops.h"
4
5
6/********** coefficients pour les mesures bolo ********************************/
7/* toutes les puissances en pW */
8/* -1- loi de reponse thermique des bolos avec R en ohms et T en Kelvin */
9/* */
10/* T = coef2 * ( ln ( R / coef1) ** ( -1 / coef0 ) */
11/* */
12/* -2- fuite thermique du bolo coef 3,4 */
13/* */
14/* Ptot = coef3 * ( (10*Tb) ** coef4 - (10*Tcryo) ** coef4 ) */
15/* */
16/* -3- calcul empirique de Pciel et de tau coef 5,6 */
17/* */
18/* Pciel = coef5 - Pelec coef5= I * Ai (tables xavier) */
19/* tau = - ln ( 1 + Pciel / coef6 ) coef6= I * Bi (tables xavier) */
20/* */
21/**************************************************************************************/
22
23
24/**************************************************************************************/
25/* */
26/* pour les MLPA : gain = 100 diviseur = 101 ou 330 */
27/* pour les bebodiff : gain = diviseur = 100Kohm / R preampli */
28/* pour les bebodiff : la capa est corrigee d'un facteur 0.868 */
29/* pour les cartes modifiees : mettre diviseur=0 */
30/* et capa = la resistance de chage en Megohm */
31/* */
32/**************************************************************************************/
33
34
35/* nom , on/off , 0 = MLPA , N° bolo , gain_pa , capa*1000 , diviseur , coef*10000
36/* , 0 ou 1 , 2..8 = BEBO , hard , , 4700 , 333 ,
37/* 10 = Bediff , , ,
38
39/* pour les bediff (code 10) le n° de bolo est N° de bebo*8 + numero dans la bebo
40/* soit : 1 2 3 4 5 6 .. 9 10 11 12 13 14 .. 17 18 19 20 21 22 .. etc
41
42
43/*debut_param*/
44/*---------------------------------- fenetre : -----------------------------------*/
45
46param_bolo parametr={24,24,36,88,18,
47
48{
49{ "v1-bedif1" , 1,10,1 , 200, 22000, 200, { 5000 , 123100 , 334200 } },
50{ "v1-bedif2" , 1,10,2 , 200, 22000, 200, { 5000 , 12.31 , 33.42 } },
51{ "v1-bedif3" , 1,10,3 , 200, 22000, 200, { 5000 , 50.0 , 14.0 } },
52{ "v1-bedif4" , 1,10,4 , 200, 22000, 200, { 5000 , 12.31 , 33.42 } },
53{ "v1-bedif5" , 1,10,5 , 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
54{ "v1-bedif6" , 1,10,6 , 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
55
56{ "v1-bedif7" , 1,10,9 , 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
57{ "v1-bedif8" , 1,10,10, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
58{ "v1-bedif9" , 1,10,11, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
59{ "v1-bedif10" , 1,10,12, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
60{ "v1-bedif11" , 1,10,13, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
61{ "v1-bedif12" , 1,10,14, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
62
63{ "v1-bedif13" , 1,10,17, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
64{ "v1-bedif14" , 1,10,18, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
65{ "germanium" , 3,10,19, 1000, 22000 , 0, { 5000 , 12.31 , 33.42 } },
66{ "therm_4k" , 3,10,20, 1000, 1000 , 0, { 5000 , 12.31 , 33.42 } },
67{ "therm_1.6k" , 3,10,21, 1000, 1000 , 0, { 5000 , 12.31 , 33.42 } },
68{ "therm_10k" , 3,10,22, 1000, 1000 , 0, { 5000 , 12.31 , 33.42 } },
69
70{ "v1-bedif19" , 2,10,25 , 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
71{ "v1-bedif20" , 2,10,26, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
72{ "v1-bedif21" , 2,10,27, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
73{ "v1-bedif22" , 2,10,28, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
74{ "v1-bedif23" , 2,10,29, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } },
75{ "v1-bedif24" , 2,10,30, 1000, 4700, 1000, { 5000 , 12.31 , 33.42 } }
76
77}
78};
79/*fin_param*/
80
81
82
83/* bolos campagne 1998-1999 */
84/*
85reg_NbSi.J, 1, 0, 1, 100, 4.7, 333, .5 ,519.6 , 8.286
86v1-231...L, 1, 0, 2, 100, 4.7, 333, .5 , 1.7 , 32.41 , 0.333 , 10 , 20.30 , 11.41
87v1-232...N, 1, 0, 3, 100, 4.7, 333,
88v1-237...E, 1, 0, 4, 100, 4.7, 333,
89
90reg_JamieO, 1, 0, 5, 100, 4.7, 101,
91
92V2-NbSi..H, 1, 0, 6, 100, 4.7, 101, .5 ,433.8 , 9.25
93V2-230...B, 1, 0, 7, 100, 4.7, 333, .5 , 8.26 , 26.61 , 5.10 , 7 , 9.354 , 1.026
94V2-205...Q, 1, 0, 8, 100, 4.7, 333, .518 , 81 , 25.2
95V2-208...P, 1, 0, 9, 100, 4.7, 333, .5 , 12.31 , 33.42 , 0.627 , 6.5 , 8.113 , 2.958
96
97*/
98/*bolos campagne 1997-1998 */
99/*
100
101v1-208...J, 1, 0, 1, 100, 4.7, 333, .5 , 12.31 , 33.42
102v1-232...L, 1, 0, 2, 100, 4.7, 333,
103v1-205...N, 1, 0, 3, 100, 4.7, 333, .518 , 81 , 25.2
104v1-NbSi..E, 1, 0, 4, 100, 4.7, 333, .5 ,519.6 , 8.286
105Jamie....O, 1, 0, 5, 100, 4.7, 101,
106V2-NbSi..H, 1, 0, 6, 100, 4.7, 101, .5 ,433.8 , 9.25
107V2-224...B, 1, 0, 7, 100, 4.7, 333, .5 ,3.43 , 26.6
108V2-230...Q, 1, 0, 8, 100, 4.7, 333, .5 , 8.26 , 26.61
109V2-231...P, 1, 0, 9, 100, 4.7, 333, .5 , 1.7 , 32.41
110
111*/
112
113
114
115
116
117/*debut_nom_reglage*/
118/* 0->aa*/
119/* 1->bb*/
120/* 2->cc*/
121/* 3->reglage 3 */
122/* 4->reglage 4 */
123/* 5->reglage 5 */
124/* 6->reglage 6 */
125/* 7->reglage 7 */
126/*fin_nom_reglage*/
127
128
129
130
131
132
133
134reglage_bolo reglage_standard[8]={{
135
136
137/*debut reglage 0 */
138{30,76,9,1},
139{0
140,10
141,1
142,3
143,10
144,2
145,0
146,0
147,1
148,0
149,0
150,0
151,0
152,0
153,0
154,0
155,0
156,0
157,0
158,0
159},{
160{22,100663296}
161,{-100646890,1}
162,{-100646890,1}
163,{22,0}
164,{-100638698,1}
165,{22,253952}
166,{-100646890,1}
167,{22,0}
168,{-100646890,1}
169,{-100646890,1}
170,{22,0}
171,{235388950,221185}
172,{20,0}
173,{20,0}
174,{16406,0}
175,{24598,0}
176,{22,0}
177,{24598,0}
178},{
179{1,22,0,1}
180,{0,20,0,1}
181,{0,20,0,1}
182,{0,20,0,1}
183,{0,20,0,1}
184,{0,20,0,1}
185},{
186{0,1,9,1,0,0,0}
187,{0,1,9,1,0,0,0}
188,{0,1,9,1,0,0,0}
189,{0,1,9,1,0,0,0}
190},{0,0,0,0,0,0,0,0}
191/*fin_reglage*/
192
193},{
194
195/*debut reglage 1 */
196{30,76,9,1},
197{0
198,10
199,1
200,3
201,10
202,2
203,0
204,0
205,1
206,0
207,0
208,0
209,0
210,0
211,0
212,0
213,0
214,0
215,0
216,0
217},{
218{22,100663296}
219,{-100646890,1}
220,{-100646890,1}
221,{22,0}
222,{-100638698,1}
223,{22,253952}
224,{-100646890,1}
225,{22,0}
226,{-100646890,1}
227,{-100646890,1}
228,{22,0}
229,{235388950,221185}
230,{20,0}
231,{20,0}
232,{16406,0}
233,{24598,0}
234,{22,0}
235,{24598,0}
236},{
237{1,22,0,1}
238,{0,20,0,1}
239,{0,20,0,1}
240,{0,20,0,1}
241,{0,20,0,1}
242,{0,20,0,1}
243},{
244{0,1,9,1,0,0,0}
245,{0,1,9,1,0,0,0}
246,{0,1,9,1,0,0,0}
247,{0,1,9,1,0,0,0}
248},{0,0,0,0,0,0,0,0}
249/*fin_reglage*/
250
251},{
252
253/*debut reglage 2 */
254{31,76,9,0},
255{0
256,-14
257,-31
258,-63
259,-83
260,-103
261,-122
262,127
263,1
264,97
265,14
266,-32
267,-93
268,-87
269,-72
270,-80
271,-101
272,-112
273,-113
274,-121
275},{
276{22,100663296}
277,{1040629782,204800}
278,{1040834582,221184}
279,{22,0}
280,{-100450282,2}
281,{22,253952}
282,{-100458474,2}
283,{22,0}
284,{-100442090,2}
285,{-100253674,253954}
286,{22,0}
287,{303013910,221184}
288,{20,0}
289,{20,0}
290,{9238,0}
291,{24598,301989888}
292,{22,0}
293,{24598,0}
294,{0,0}
295,{0,0}
296,{0,0}
297,{0,0}
298,{0,0}
299,{0,0}
300},{
301{-15,-9,-13,-38}
302,{-83,-109,-90,-68}
303,{-99,-101,-67,-61}
304,{-64,-60,-38,-19}
305,{-28,-57,-77,-75}
306,{-66,-55,-51,-68}
307},{
308{31,76,9,0,0,-35,-4643}
309,{-55,-77,-69,-55,-44,-43,-12336}
310,{-56,-85,-128,99,111,-116,-28030}
311,{105,107,101,101,106,111,31615}
312},{-102,-88,-94,-113,-126,101,73,70}
313/*fin_reglage*/
314
315},{
316
317/*debut reglage 3 */
318{31,76,9,0},
319{0
320,-14
321,-31
322,-63
323,-83
324,-103
325,-122
326,127
327,1
328,99
329,13
330,96
331,-93
332,-87
333,-72
334,-80
335,-101
336,-112
337,-113
338,-121
339},{
340{22,100663296}
341,{1040629782,204800}
342,{1040834582,221184}
343,{22,0}
344,{-100450282,2}
345,{22,253952}
346,{-100458474,2}
347,{22,0}
348,{-100442090,2}
349,{-100253674,253954}
350,{22,0}
351,{303013910,221184}
352,{20,0}
353,{20,0}
354,{9238,0}
355,{24598,301989888}
356,{22,0}
357,{24598,0}
358,{0,0}
359,{0,0}
360,{0,0}
361,{0,0}
362,{0,0}
363,{0,0}
364},{
365{-15,-9,-13,-38}
366,{-83,-109,-90,-68}
367,{-99,-101,-67,-61}
368,{-64,-60,-38,-19}
369,{-28,-57,-77,-75}
370,{-66,-55,-51,-68}
371},{
372{31,76,9,0,0,-35,-4643}
373,{-55,-77,-69,-55,-44,-43,-12336}
374,{-56,-85,-128,99,111,-116,-28030}
375,{105,107,101,101,106,111,31615}
376},{-102,-88,-94,-113,-126,101,73,70}
377/*fin_reglage*/
378
379},{
380
381/*debut reglage 4 */
382{31,76,9,0},
383{0
384,-14
385,-31
386,-63
387,-83
388,-103
389,-122
390,127
391,1
392,99
393,13
394,112
395,-93
396,-87
397,-72
398,-80
399,-101
400,-112
401,-113
402,-121
403},{
404{22,100663296}
405,{1040629782,204800}
406,{1040834582,221184}
407,{22,0}
408,{-100450282,2}
409,{22,253952}
410,{-100458474,2}
411,{22,0}
412,{-100442090,2}
413,{-100253674,253954}
414,{22,0}
415,{303013910,221184}
416,{20,0}
417,{20,0}
418,{9238,0}
419,{24598,301989888}
420,{22,0}
421,{24598,0}
422,{0,0}
423,{0,0}
424,{0,0}
425,{0,0}
426,{0,0}
427,{0,0}
428},{
429{-15,-9,-13,-38}
430,{-83,-109,-90,-68}
431,{-99,-101,-67,-61}
432,{-64,-60,-38,-19}
433,{-28,-57,-77,-75}
434,{-66,-55,-51,-68}
435},{
436{31,76,9,0,0,-35,-4643}
437,{-55,-77,-69,-55,-44,-43,-12336}
438,{-56,-85,-128,99,111,-116,-28030}
439,{105,107,101,101,106,111,31615}
440},{-102,-88,-94,-113,-126,101,73,70}
441/*fin_reglage*/
442
443},{
444
445/*debut reglage 5 */
446{31,76,9,0},
447{0
448,-14
449,-31
450,-63
451,-83
452,-103
453,-122
454,127
455,1
456,97
457,14
458,-80
459,-93
460,-87
461,-72
462,-80
463,-101
464,-112
465,-113
466,-121
467},{
468{22,100663296}
469,{1040629782,204800}
470,{1040834582,221184}
471,{22,0}
472,{-100450282,2}
473,{22,253952}
474,{-100458474,2}
475,{22,0}
476,{-100442090,2}
477,{-100253674,253954}
478,{22,0}
479,{303013910,221184}
480,{20,0}
481,{20,0}
482,{9238,0}
483,{24598,301989888}
484,{22,0}
485,{24598,0}
486,{0,0}
487,{0,0}
488,{0,0}
489,{0,0}
490,{0,0}
491,{0,0}
492},{
493{-15,-9,-13,-38}
494,{-83,-109,-90,-68}
495,{-99,-101,-67,-61}
496,{-64,-60,-38,-19}
497,{-28,-57,-77,-75}
498,{-66,-55,-51,-68}
499},{
500{31,76,9,0,0,-35,-4643}
501,{-55,-77,-69,-55,-44,-43,-12336}
502,{-56,-85,-128,99,111,-116,-28030}
503,{105,107,101,101,106,111,31615}
504},{-102,-88,-94,-113,-126,101,73,70}
505/*fin_reglage*/
506
507},{0
508
509/*debut reglage 6 */
510/*fin_reglage*/
511
512},{0
513
514/*debut reglage 7 */
515/*fin_reglage*/
516
517} };
518
519/* ------------------------------------ corps des fonctions ------------------------------ */
520/* -------------------------------------------------------------------------------------------- */
521
522
523
524unsigned long val_long(char x)
525{
526unsigned long a,xl;
527a=x-2; if(x<3) xl=x; else xl=((a&1) + 2)<<(a>>1);
528return(xl);
529}
530
531
532double val_double(char x)
533{
534unsigned long a,xl;
535if(x<0) x=-x; a=x; if(!a) xl=0; else xl=((a&1) + 2)<<(a>>1);
536if(x>0) return(1e-4*(double)xl); else return(-1e-4*(double)xl);
537}
538
539int new_val_dac(int a,char code)
540{
541if(code&0x80) a=(code&0x7f) <<5 ;
542else {
543 if(code&0x40) a+=code&0x3f;
544 else a-=code&0x3f;
545 }
546return(a);
547}
548
549
550
551
552int calcul_somme_block(block_type_modele* blk,int longueur)
553{
554int i,so=0;;
555for(i=0;i<(longueur/4-4);i++) so^=(int)blk->mot[i];
556/* somme sur tous les mots internes : on exclus le dbut, les codes et la fin */
557return((so^(so>>16))&0xffff);
558}
559
560
561
562
563void valide_block(block_type_modele* blk,int type,int block_num)
564{
565int somme,longueur;
566def_long_block
567longueur=long_block[type];
568/*printf("valide block adresse %x type %d numblock %d longueur=%d \n" */
569/* ,(unsigned)blk,type,block_num,longueur);*/
570blk->debut = debut_block_mesure;
571blk->code2 = (((long)block_num) & 0xffffff ) | ( (((long)type)<<24)&0xff000000 );
572
573blk->mot[longueur/4-4] = fin_block_mesure;
574somme=calcul_somme_block(blk,longueur);
575blk->code1 = (((long)longueur)<<16) | somme;
576}
577
578
579/* Quand on est sur une machine swappee, on ne cherche pas a verifier */
580/* le checksum, puisqu'on a modifie les blocs, sans swapper par exemple */
581/* les chars des noms de bolometres et des chaines GPS... */
582#ifdef __alpha
583#define SWAP
584#endif
585#if defined(Linux) || defined(linux)
586#define SWAP
587#endif
588
589int verifie_block(block_type_modele* blk)
590{
591int type,lg,som;
592def_long_block
593if(blk->debut != debut_block_mesure) return(block_debut_erreur);
594type=type_block(blk); if( (type<0) ||(type>=nb_type_blocks) ) return(block_type_inconnu);
595lg=longueur_block(blk); if( lg != long_block[type] ) return(block_longueur_erreur);
596if( blk->mot[(lg/4)-4] != fin_block_mesure) return(block_fin_erreur);
597#ifndef SWAP
598som=calcul_somme_block(blk,lg); if( som!= somme_block(blk)) return(block_somme_erreur);
599#endif
600return(block_correct);
601}
602
603
604int verifie_block_printf(block_type_modele* blk)
605{
606int type,lg,som;
607def_long_block
608def_nom_block
609if(blk->debut != debut_block_mesure)
610 {
611 printf(" erreur dans le code debut de block \n");
612 return(block_debut_erreur);
613 }
614
615type=type_block(blk);
616if( (type<0) || (type>nb_type_blocks) )
617 {
618 printf(" block de type %d inconnu\n",type);
619 return(block_type_inconnu);
620 }
621
622lg=longueur_block(blk);
623if( lg!=long_block[type] )
624 {
625 printf(" block type %s erreur de longueur (nominal=%d , dans le block=%d \n"
626 ,nom_block[type],long_block[type],lg);
627 return(block_longueur_erreur);
628 }
629
630som=calcul_somme_block(blk,lg);
631if( som!=somme_block(blk) )
632 {
633 printf(" block type %s : erreur de somme (calculee=%d , dans le block=%d \n"
634 ,nom_block[type],som,somme_block(blk) );
635 return(block_somme_erreur);
636 }
637
638if(blk->mot[(lg/4)-4] != fin_block_mesure)
639 {
640 printf(" block type %s erreur de code fin de block : trouve %x au lieu de %x \n"
641 ,nom_block[type],(int)blk->mot[(lg/4)-4],fin_block_mesure);
642 return(block_fin_erreur);
643 }
644
645return(block_correct);
646}
647
648
649
650
651
652
653
Note: See TracBrowser for help on using the repository browser.