| 1 | #include "diabolo.h" | 
|---|
| 2 | #include "fichier.h" | 
|---|
| 3 |  | 
|---|
| 4 |  | 
|---|
| 5 | block_type_modele       bktm2;          // memoire pour block local pour fabrication block | 
|---|
| 6 | block_type_bolo         blk_bol; | 
|---|
| 7 | block_type_synchro_sol  blk_sync; | 
|---|
| 8 | int                     index=0; | 
|---|
| 9 | int                     num_block=0; | 
|---|
| 10 | unsigned long           temps_debut_arch; | 
|---|
| 11 |  | 
|---|
| 12 | /* | 
|---|
| 13 | void  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 |  | 
|---|
| 28 | void    fabrique_block_type_param(void) | 
|---|
| 29 | { | 
|---|
| 30 | #define blk  ((block_type_param*)(&bktm2))      // pointeur sur la memoire locale | 
|---|
| 31 | blk->param      =       parametr; | 
|---|
| 32 |  | 
|---|
| 33 | valide_block(&bktm2,block_param,num_block); | 
|---|
| 34 | #undef blk | 
|---|
| 35 | ecrit_fichier_ARCH(&bktm2); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 |  | 
|---|
| 40 | void    fabrique_block_type_reglage(void) | 
|---|
| 41 | { | 
|---|
| 42 | #define blk  ((block_type_reglage*)(&bktm2))    // pointeur sur la memoire locale | 
|---|
| 43 | blk->reglage    =       gg->reglage; | 
|---|
| 44 |  | 
|---|
| 45 | valide_block(&bktm2,block_reglage,num_block); | 
|---|
| 46 | #undef blk | 
|---|
| 47 | ecrit_fichier_ARCH(&bktm2); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 | void    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 | 
|---|
| 58 | int j,i; | 
|---|
| 59 | for(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 | 
|---|
| 62 | valide_block(&bktm2,block_une_periode,num_block); | 
|---|
| 63 | #undef blk | 
|---|
| 64 | ecrit_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 |  | 
|---|
| 73 | void    fabrique_block_type_bolo_synchro(void) | 
|---|
| 74 | { | 
|---|
| 75 | int j; | 
|---|
| 76 | int nb_coups,aa,s; | 
|---|
| 77 | static compt_block_reg=0; | 
|---|
| 78 |  | 
|---|
| 79 | nb_coups= gg->reglage.horloge.nb_mesures/2 - gg->reglage.horloge.temp_mort; | 
|---|
| 80 | aa = (nb_coups<<14) + (nb_coups*190) ; | 
|---|
| 81 | if( index%2) s=1;else   s=-1; | 
|---|
| 82 | //gg->don.don_bolo[j] =  s*(((blk->data_bolo[j][i]-aa)<<1)/nb_coups) | 
|---|
| 83 | for(j=0;j<nb_max_bolo;j++)      blk_bol.data_bolo[j][index]=aa+((gg->don.don_bolo[j]*s*nb_coups)>>1); | 
|---|
| 84 | for(j=0;j<nb_sync;j++)          blk_sync.synchro[j][index]=gg->don.sync[j]; | 
|---|
| 85 |  | 
|---|
| 86 | index++; | 
|---|
| 87 | if( index < (nb_per_block*2) ) return; | 
|---|
| 88 |  | 
|---|
| 89 | index=0; | 
|---|
| 90 | num_block++; | 
|---|
| 91 |  | 
|---|
| 92 | valide_block( (block_type_modele*) &blk_sync,block_synchro_sol,num_block); | 
|---|
| 93 | ecrit_fichier_ARCH( (block_type_modele*) &blk_sync); | 
|---|
| 94 |  | 
|---|
| 95 |  | 
|---|
| 96 | valide_block( (block_type_modele*) &blk_bol,block_bolo,num_block); | 
|---|
| 97 | ecrit_fichier_ARCH( (block_type_modele*) &blk_bol); | 
|---|
| 98 |  | 
|---|
| 99 | compt_block_reg++; | 
|---|
| 100 | if(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 |  | 
|---|
| 116 | void    ecrit_fichier_ARCH(block_type_modele * bktp) | 
|---|
| 117 | { | 
|---|
| 118 | unsigned long ttx; | 
|---|
| 119 | int long_b=longueur_block(bktp); | 
|---|
| 120 |  | 
|---|
| 121 | GetDateTime(&ttx); | 
|---|
| 122 | if(gg->scan_en_cours)   temps_debut_arch=ttx; | 
|---|
| 123 | if( (!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 |  | 
|---|
| 130 | if(fenetre(fichier_arch_1)) | 
|---|
| 131 | { | 
|---|
| 132 | //      position(fichier_arch_1,fin_f); | 
|---|
| 133 | ecritF(fichier_arch_1,long_b,bktp); | 
|---|
| 134 | } | 
|---|
| 135 | if(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 |  | 
|---|
| 144 | void 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 | { | 
|---|
| 147 | switch(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 |  | 
|---|