1 | #include "diabolo.h"
|
---|
2 | #include "fichier.h"
|
---|
3 | //#include "acqui.h"
|
---|
4 | #include "controle.h"
|
---|
5 |
|
---|
6 |
|
---|
7 | extern F_entete *E;
|
---|
8 | extern F_block_desc *BD;
|
---|
9 | extern F_block_param *BP;
|
---|
10 | extern F_donne * T; // tableau courant de donnee
|
---|
11 |
|
---|
12 | extern char * nom_du_fichier;
|
---|
13 |
|
---|
14 | unsigned long temps_debut_dia2;
|
---|
15 |
|
---|
16 |
|
---|
17 | //---------------------------------------------------------------------------------------
|
---|
18 | //--------------- ecrit les fichiers DIA2 -------------------------------
|
---|
19 | //---------------------------------------------------------------------------------------
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 | void ecrit_fichier_dia2(F_donne d,unsigned long temps_cntl,unsigned long temps_mac) // ecrit les valeurs bolo et synchro
|
---|
24 | {
|
---|
25 | int nl=BD->n_ligne_don;
|
---|
26 |
|
---|
27 | E->tempsfin=temps_mac; // comme ca bon a la fin du fichier
|
---|
28 | if(!E->tempsdebut) E->tempsdebut=temps_mac; // parceque mis a zero a l'ouverture du fichier
|
---|
29 |
|
---|
30 | T[nl]=d;
|
---|
31 | if(!nl) BP->temps_controleur_debut=temps_cntl;
|
---|
32 | BP->temps_controleur_fin=temps_cntl;
|
---|
33 | BD->n_ligne_don++; if (BD->n_ligne_don>=max_nb_donne) fich_save_partiel(0);
|
---|
34 | if( (nl%100)==0 ) ecritD(fenetre_fichier,f_bloc,"bloc %d : %d lignes",BD->n_blok+1,nl);
|
---|
35 |
|
---|
36 | if( (nl%100)==0 ) ecritD(fenetre_controle,con_fichier,"%s *",nom_du_fichier);
|
---|
37 | if( (nl%100)==50 ) ecritD(fenetre_controle,con_fichier,"%s ",nom_du_fichier);
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | void fich_save_partiel(int change) // change==3 -> fin de fichier sans changement de parametres
|
---|
43 | // change==1 -> change un parametre: nouveau block
|
---|
44 | // change==2 -> nouveau fichier, nouvelle serie de mesure
|
---|
45 | // change==0 -> meme fichier nouveau block avec memes parametres
|
---|
46 | {
|
---|
47 | unsigned long ttx;
|
---|
48 | int j,i,n=gg->reglage.horloge.nb_mesures;
|
---|
49 |
|
---|
50 | if((!fenetre(fichier_dia2_1)) && (!fenetre(fichier_dia2_2))) return;
|
---|
51 | if (change!=2)
|
---|
52 | {
|
---|
53 | for(j=0;j<nb_max_bolo;j++)
|
---|
54 | for(i=0;i<n;i++) BP->bol_per[j][i]=gg->bol_per[j][i];
|
---|
55 |
|
---|
56 | if(fenetre(fichier_dia2_1))
|
---|
57 | {
|
---|
58 | position(fichier_dia2_1,fin_f);
|
---|
59 | ecritF(fichier_dia2_1,sizeof(F_block_desc),BD); // ecrit l'entete partielle
|
---|
60 | ecritF(fichier_dia2_1,sizeof(F_block_param),BP); // ecrit l'entete partielle
|
---|
61 | ecritF(fichier_dia2_1,(long)E->long_donne*(long)BD->n_ligne_don,T); // ecrit le block de data
|
---|
62 | }
|
---|
63 | if(fenetre(fichier_dia2_2))
|
---|
64 | {
|
---|
65 | position(fichier_dia2_2,fin_f);
|
---|
66 | ecritF(fichier_dia2_2,sizeof(F_block_desc),BD); // ecrit l'entete partielle
|
---|
67 | ecritF(fichier_dia2_2,sizeof(F_block_param),BP); // ecrit l'entete partielle
|
---|
68 | ecritF(fichier_dia2_2,(long)E->long_donne*(long)BD->n_ligne_don,T);
|
---|
69 | }
|
---|
70 |
|
---|
71 | }
|
---|
72 | if( (change==0) ou (change==2) ) lit_data_telescope(); // debut fichier ou apres block complet
|
---|
73 |
|
---|
74 | BD->n_ligne_don=0;
|
---|
75 | BP->temps_controleur_debut=BP->temps_controleur_fin;
|
---|
76 |
|
---|
77 | BD->n_blok++;
|
---|
78 | BP->reglage=gg->reglage;
|
---|
79 | BD->change=change;
|
---|
80 | BD->bololut=0;
|
---|
81 |
|
---|
82 | if( (change==0) ou (change==1) )
|
---|
83 | {
|
---|
84 | GetDateTime(&ttx);
|
---|
85 | // printf(" temps debut fichier = %d temps courant=%d \n",E->tempsdebut,ttx);
|
---|
86 | if(gg->scan_en_cours) temps_debut_dia2=ttx;
|
---|
87 | if( (!gg->scan_en_cours) && ( (ttx-temps_debut_dia2) > temps_max_fichier) )
|
---|
88 | {
|
---|
89 | // printf(" fichier Diabolo sans scan de plus de 5 minutes: fich_new \n");
|
---|
90 | GetDateTime(&temps_debut_dia2); // pour etre sur de ne pas le faire deux fois
|
---|
91 | fich_new(0,0);
|
---|
92 | }
|
---|
93 | }
|
---|
94 | if(change==3) change=0;
|
---|
95 | BD->change=change;
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 |
|
---|
101 | void exec_DIA2(int fen,int item,double valeur,...) // exec du fichier lui_meme
|
---|
102 | // apellé pour les deux fichiers DIA2 ouverts et fermés
|
---|
103 | {
|
---|
104 | switch(item)
|
---|
105 | {
|
---|
106 | case ouverture :
|
---|
107 | if( (fen!=fichier_dia2_1) && (fen!=fichier_dia2_2) ) {lit_fichier_DIA2(fen);break;}
|
---|
108 | gg->fichier_dia2_ouvert=1;
|
---|
109 | E->tempsdebut=0; E->tempsfin=0; // temps de debut et fin de fichier
|
---|
110 | litD(fenetre_fichier,f_comment,E->commentaires); // commentaires à la main
|
---|
111 | ecritF(fen,(long)E->long_entete,E);
|
---|
112 | // printf("fabrique fichier : %s \n",titre(fen));
|
---|
113 | GetDateTime(&temps_debut_dia2);
|
---|
114 | break;
|
---|
115 |
|
---|
116 | case fermeture :
|
---|
117 | if( (fen!=fichier_dia2_1) && (fen!=fichier_dia2_2) ) break;
|
---|
118 | gg->fichier_dia2_ouvert=0;
|
---|
119 | fich_save_partiel(3);
|
---|
120 |
|
---|
121 | // litD(fenetre_fichier,f_comment,E->commentaires);
|
---|
122 | // ecritD(fenetre_fichier,f_comment,"../..");
|
---|
123 | break;
|
---|
124 |
|
---|
125 | }
|
---|
126 | }
|
---|
127 |
|
---|