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

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

archediab 29

File size: 4.5 KB
Line 
1#include "diabolo.h"
2#include "fichier.h"
3
4
5block_type_modele bktm2; // memoire pour block local pour fabrication block
6block_type_bolo blk_bol;
7block_type_synchro_sol blk_sync;
8int index=0;
9int num_block=0;
10unsigned long temps_debut_arch;
11
12/*
13void valide_block(block_type_modele* blk,int type,int block_num)
14 {
15 int somme;
16 def_long_block
17 blk->debut = debut_block_mesure;
18 blk->code2 = (block_num & 0xffffff ) | ( (type<<24)&0xff000000 );
19 blk->mot[(long_block[type]/4)-4] = fin_block_mesure;
20 calcul_somme_block(blk,longueur);
21 blk->code1 = (long_block[type]<<16) | somme;
22 }
23
24*/
25
26
27
28void fabrique_block_type_param(void)
29{
30#define blk ((block_type_param*)(&bktm2)) // pointeur sur la memoire locale
31blk->param = parametr;
32
33valide_block(&bktm2,block_param,num_block);
34#undef blk
35ecrit_fichier_ARCH(&bktm2);
36}
37
38
39
40void fabrique_block_type_reglage(void)
41{
42#define blk ((block_type_reglage*)(&bktm2)) // pointeur sur la memoire locale
43blk->reglage = gg->reglage;
44
45valide_block(&bktm2,block_reglage,num_block);
46#undef blk
47ecrit_fichier_ARCH(&bktm2);
48}
49
50
51
52
53void fabrique_block_type_une_periode(void)
54{
55#define blk ((block_type_une_periode*)(&bktm2)) // pointeur sur la memoire locale
56
57// a ecrire boucle pour copier les periodes simples
58int j,i;
59for(j=0;j<nb_max_bolo;j++) for (i=0;i<nb_max_mes_per;i++)
60 blk->bol_per[j][i]=gg->bol_per[j][i]^0x7fff; // 16 bit -> 15 bit utile + phase
61 // change le signe des 15 bits utiles
62valide_block(&bktm2,block_une_periode,num_block);
63#undef blk
64ecrit_fichier_ARCH(&bktm2);
65}
66
67// short bol_per[nb_max_bolo][nb_max_mes_per];
68
69
70
71// cette fonction rempli un block coups par coups et l'ecrit quand il est plein
72
73void fabrique_block_type_bolo_synchro(void)
74{
75int j;
76int nb_coups,aa,s;
77static compt_block_reg=0;
78
79nb_coups= gg->reglage.horloge.nb_mesures/2 - gg->reglage.horloge.temp_mort;
80aa = (nb_coups<<14) + (nb_coups*190) ;
81if( index%2) s=1;else s=-1;
82//gg->don.don_bolo[j] = s*(((blk->data_bolo[j][i]-aa)<<1)/nb_coups)
83for(j=0;j<nb_max_bolo;j++) blk_bol.data_bolo[j][index]=aa+((gg->don.don_bolo[j]*s*nb_coups)>>1);
84for(j=0;j<nb_sync;j++) blk_sync.synchro[j][index]=gg->don.sync[j];
85
86index++;
87if( index < (nb_per_block*2) ) return;
88
89index=0;
90num_block++;
91
92valide_block( (block_type_modele*) &blk_sync,block_synchro_sol,num_block);
93ecrit_fichier_ARCH( (block_type_modele*) &blk_sync);
94
95
96valide_block( (block_type_modele*) &blk_bol,block_bolo,num_block);
97ecrit_fichier_ARCH( (block_type_modele*) &blk_bol);
98
99compt_block_reg++;
100if(compt_block_reg>20)
101 {
102 compt_block_reg=0;
103 fabrique_block_type_reglage();
104 }
105}
106
107
108
109
110
111//---------------------------------------------------------------------------------------
112//--------------- ecrit les fichiers ARCH -------------------------------
113//---------------------------------------------------------------------------------------
114
115
116void ecrit_fichier_ARCH(block_type_modele * bktp)
117{
118unsigned long ttx;
119int long_b=longueur_block(bktp);
120
121GetDateTime(&ttx);
122if(gg->scan_en_cours) temps_debut_arch=ttx;
123if( (!gg->scan_en_cours) && ( (ttx-temps_debut_arch) > 2*temps_max_fichier) )
124 {
125// printf(" fichier Archeops sans scan de plus de 10 minutes: fich_new \n");
126 GetDateTime(&temps_debut_arch); // pour ne pas le faire deux fois
127 fich_new(0,0); // pour limiter la duree des fichiers arch
128 }
129
130if(fenetre(fichier_arch_1))
131 {
132// position(fichier_arch_1,fin_f);
133 ecritF(fichier_arch_1,long_b,bktp);
134 }
135if(fenetre(fichier_arch_2))
136 {
137// position(fichier_arch_2,fin_f);
138 ecritF(fichier_arch_2,long_b,bktp);
139 }
140}
141
142
143
144void exec_ARCH(int fen,int item,double valeur,...) // exec du fichier lui_meme
145 // apellé pour les deux fichiers ARCH ouverts et fermés
146{
147switch(item)
148 {
149 case ouverture :
150 if( (fen!=fichier_arch_1) && (fen!=fichier_arch_2) )
151 {
152#ifdef _archeops
153 ouvre('ACTI',0,1,"lit_fichier_arch",exec_lit_fichier_ARCH,(void*)fen);
154#else
155 printf(" ne peut pas relire les fichiers archeops \n");
156 printf("il faut compiler avec archeops ou planck \n");
157#endif
158 break;
159 }
160//
161//*****************************************************************************************
162 printf("nouveau fichier archeops : %s \n",titre(fen));
163 gg->fichier_arch_ouvert=1;
164 GetDateTime(&temps_debut_arch);
165 fabrique_block_type_param();
166 fabrique_block_type_reglage();
167 break;
168
169
170 case fermeture :
171 gg->fichier_arch_ouvert=0;
172
173// if( (fen!=fichier_arch_1) && (fen!=fichier_arch_2) ) break;
174// fich_save_partiel(3);
175
176// litD(fenetre_fichier,f_comment,E->commentaires);
177// ecritD(fenetre_fichier,f_comment,"../..");
178 break;
179
180 }
181}
182
183
184
Note: See TracBrowser for help on using the repository browser.