source: Sophya/trunk/Poubelle/archediab.old/archediab.sources/c/bolo.c@ 639

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

archediab 25

File size: 9.3 KB
Line 
1#include "diabolo.h"
2#include "bolo.h"
3#include "acqui.h"
4#include "fichier.h"
5#include "auto.h"
6#include "regul.h"
7#include "tm.h"
8
9
10int auto_tr[nb_max_bolo];
11int ib_efface[nb_max_bolo];
12
13
14//---------------------------------- fenetre : bolo -----------------------------------
15
16
17
18// le numero du bolometre dans fen (fenetres 1 à parametres.nb_bolo )
19
20void exec_bolo(int fen,int item,double valeur,...)
21{
22int a,c,i;
23int n=gg->reglage.horloge.nb_mesures;
24//if(fen > 5 ) return;
25if(item>1000) item-=1000; // pour appeler le case pour tous les cara d'un edit texte
26//controlemanip(0);
27//printf("execbolo avec fen=%d , item=%d \n",fen,item);
28switch(item)
29 {
30 case ouverture : ib_efface[fen-1]=0;
31 selectgra(fen);
32 graph->ymin=-18000;
33 graph->ymax=18000;
34 graph->ypas=9000;
35 graph->xmax=gg->reglage.horloge.nb_mesures;
36 graph->xpas=graph->xmax/4;
37 graph->grille=1;
38 graph->graduations=0;
39 graph->sans_image=1;
40 graph->avec_icones=0;
41 graph->aspect=0;
42 graph->xtitre[0]=0;
43 graph->ytitre[0]=0;
44// ecritD(fen,b_voy,fen+1);
45
46 ecritgain(fen);
47 break;
48
49
50 case tache_de_fond : // appellé par le programme d'acquisition pour tracer ---- la cadence est variable
51 n=gg->reglage.horloge.nb_mesures;
52 {
53 selectgra(fen);
54 graph->xmax=n; graph->xpas=n/4;
55 graph->ymin=-18000; graph->ymax=18000; graph->ypas=9000;
56 }
57 if(ib_efface[fen-1]--<0) { ib_efface[fen-1]=10; retrace(fen);}
58 c=1234;
59 effacecourbe(fen);
60// style(fen);
61 //tt->bololut[fen-1]=lecture_en_cours;
62
63 for(i=0;i<n;i++)
64 {
65 // 16 bit utiles dans gg->bol_per
66 trace(fen,i, ((double)((gg->bol_per[fen-1][i]&0x7fff)-0x4000)));
67 a=(gg->bol_per[fen-1][i]>>15)&1;
68 if(a!=c) {
69 c=a; if(a) modtrace(fen,1,bleu);
70 else modtrace(fen,1,rouge);
71 }
72 }
73 trace(fen,n, ((double)((gg->bol_per[fen-1][0]&0x7fff)-0x4000)));
74 if(gg->flag_tc_reduite) break; /* pas d'auto en local si en tc_reduites */
75 if( (litD(fen,b_auto,0L))!=0) auto_control(fen,auto_val);
76 if(auto_tr[fen-1]) {auto_transitoire(fen,auto_tr[fen-1]);auto_tr[fen-1]--;}
77
78 break;
79
80// reecrit les valeurs dans la fenetre pour appel par un autre programme
81 case b_carre : ecritD(fen,b_carre,(int)valeur); ecritgain(fen); break;
82 case b_tri : ecritD(fen,b_tri,(int)valeur); ecritgain(fen); break;
83 case b_trans : ecritD(fen,b_trans,(int)valeur); ecritgain(fen); break;
84 case b_lin : ecritD(fen,b_lin,(int)valeur); ecritgain(fen); break;
85 case b_gain : vg[fen-1]=0; ecritD(fen,b_gain,(int)valeur); ecritgain(fen); break;
86 case b_phase : ecritD(fen,b_phase,(int)valeur); ecritgain(fen); break;
87 case b_comm : ecritD(fen,b_comm,(int)valeur); ecritgain(fen); break;
88 case b_voie : ecritgain(fen); break;
89 case caseferme : //SizeWindow(ptf->ptwindow,210,105,1);MoveWindow(ptf->ptwindow,620,-20+fen*95,0);zoom(fen);
90 stop_exec(fen); break;
91
92 break;
93 case b_auto_trans: case b_auto_trans+1000 : auto_tr[fen-1]=20; break;
94 case b_auto_lin : case b_auto_lin+1000 : ecritD(fen,b_lin,2048); break;
95
96 case b_auto : ecritgain(fen);
97// if(valeur && (! gg->flag_tc_reduite) )
98 if(valeur) auto_control(fen,auto_force);
99 break;
100
101 default : break;
102 }
103}
104
105
106unsigned char codage_12_bit(int av,int an);
107unsigned char codage_12_bit(int av,int an)
108{
109int a=an-av;
110if( (a>0) && (a<64) ) a = 0x40 | a;
111 else if( (a<0) && (a>-64) ) a = -a;
112 else a=0x80 | ((an&0xfff)>>5) ;
113return(a);
114}
115
116
117void ecritgain(int fen) // ecrit gain, carre, triangle, .....gg->reglage.dac[...]
118{
119int carr,tri,lin,tran,i,j,gainbrut,phase,comm,voie;
120int gain_MLPA[16]={1,2,4,8,10,20,40,80,100,200,400,800,1000,2000,4000,8000};
121int gain_BEBO[4]={5,25,100,500}; /* gainbrut ampli 1 / 5 / 20 / 100 */
122int gain_BEDIF[3]={10,40,200}; /* gainbrut ampli 2 / 8 / 40 */
123int table_phase[4]={0,1,3,2};
124char bit[80];
125int b,ordre;
126char mot_tc[10];
127carr=litD(fen,b_carre,0L);
128tri=litD(fen,b_tri,0L);
129lin=litD(fen,b_lin,0L);
130tran=litD(fen,b_trans,0L);
131gainbrut=litD(fen,b_gain,0L);
132phase=litD(fen,b_phase,0L);
133comm=litD(fen,b_comm,0L);
134if(litD(fen,b_auto,0L)) voie=litD(fen,b_voie,0L); else voie=0;
135
136// verifie les gainsbrut en fonction de la boite utilisée
137switch(parametr.bolo[fen-1].bolo_bebo)
138 {
139 case 0: // ---------------------- programmation MLPA -------------------
140 break;
141 case 2:
142 case 3:
143 case 4: // ---------------------- programmation BEBO -------------------
144 if(gainbrut>3) {gainbrut=3;ecritD(fen,b_gain,3);}
145 gainbrut+=16; // pour une BEBO
146 break;
147
148 case 10: // ---------------------- programmation Bediff -------------------
149 if(gainbrut>2) {gainbrut=2;ecritD(fen,b_gain,2);}
150 gainbrut+=20; // pour une BEDIFF
151 if(phase>1) {phase=1;ecritD(fen,b_phase,1);}
152
153 default : break;
154 }
155
156
157
158// emission des telecommandes reduites au lieu des telecommandes completes
159
160if(gg->flag_tc_reduite)
161 {
162 if(carr!=dac_V(gg->reglage.bolo[fen-1]))
163 emission_tc_reduite(tc2_bolo_dacV,fen-1,codage_12_bit(dac_V(gg->reglage.bolo[fen-1]),carr));
164
165 if(tri!=dac_I(gg->reglage.bolo[fen-1]))
166 emission_tc_reduite(tc2_bolo_dacI,fen-1,codage_12_bit(dac_I(gg->reglage.bolo[fen-1]),tri));
167
168 if(tran!=dac_T(gg->reglage.bolo[fen-1]))
169 emission_tc_reduite(tc2_bolo_dacT,fen-1,codage_12_bit(dac_T(gg->reglage.bolo[fen-1]),tran));
170
171 if(lin!=dac_L(gg->reglage.bolo[fen-1]))
172 emission_tc_reduite(tc2_bolo_dacL,fen-1,codage_12_bit(dac_L(gg->reglage.bolo[fen-1]),lin));
173
174 if( (gainbrut!=gainbrut(gg->reglage.bolo[fen-1]))
175 ou (phase!=phase(gg->reglage.bolo[fen-1]))
176 ou (comm!=comm(gg->reglage.bolo[fen-1])) )
177 emission_tc_reduite(tc2_bolo_gain,fen-1,bolo_mot1(carr,tri,gainbrut,phase,comm));
178
179 if(voie!=voie(gg->reglage.bolo[fen-1]))
180 emission_tc_reduite(tc2_bolo_voie,fen-1,voie);
181 }
182
183else {
184 for(j=0;j<72;j++) bit[j]=0; // prepare 72 bits à envoyer en 9 mots de 8 bits
185
186 switch(parametr.bolo[fen-1].bolo_bebo)
187 {
188 case 0:
189 { // ---------------------- programmation MLPA -------------------
190 // printf("programmation MLPA: tri=%d car=%d \n",tri,carr);
191
192 mot_tc[0]=parametr.bolo[fen-1].bolo_num; // premier mot de 8 bit (code adresse bolometre)
193 // printf(" ecrit bolo %d \n",gg->bolo[fen-1].bolo_num);
194 bit[0]=table_phase[phase&3]>>1; bit[1]=table_phase[phase&3];
195 b=2;
196 for(i=11;i>=0;i--) {bit[b]=1; bit[b+1]=tran>>i; bit[b+2]=lin>>i; bit[b+3]=tri>>i; bit[b+4]=carr>>i;b+=5;}
197 bit[b]=1; bit[b+1]=gainbrut>>3; bit[b+2]=gainbrut>>2; bit[b+3]=gainbrut>>1; bit[b+4]=gainbrut;
198 ordre=0;
199 }
200 break;
201
202
203 case 2:
204 case 3:
205 case 4:
206 { // ---------------------- programmation BEBO -------------------
207 mot_tc[0]=8*parametr.bolo[fen-1].bolo_bebo + parametr.bolo[fen-1].bolo_num; // premier mot de 8 bit (code adresse bolometre)
208 // printf("programmation BEBO N° : tri=%d car=%d \n",mot_tc[0],tri,carr);
209
210 bit[0]=gainbrut>>1; bit[1]=gainbrut; bit[2]=table_phase[phase&3]>>1; bit[3]=table_phase[phase&3];
211 b=4;
212 for(i=11;i>=0;i--) bit[b++]=(tri>>i)&1;
213 for(i=11;i>=0;i--) bit[b++]=(carr>>i)&1;
214 for(i=11;i>=0;i--) bit[b++]=(tran>>i)&1;
215
216 ecritD(fen,b_lin,0);
217 ordre=0;
218 }
219 break;
220
221 case 10:
222 { // ---------------------- programmation Bediff -------------------
223 // --- les bits sortent dans l'autre sens : poid faible d'abord ----
224 // -- il faut donc retourner les bits des dacs
225 // lin=0;
226 // ecritD(fen,b_lin,lin); gg->reglage.dac[d_lin][fen-1]=lin; // pas de linearité
227 mot_tc[0]= parametr.bolo[fen-1].bolo_num; // premier mot de 8 bit (code adresse bolometre)
228 printf("programmation BEdiff N° %d: tri=%d car=%d \n",mot_tc[0],tri,carr);
229
230 bit[0]=gainbrut>>1; bit[1]=gainbrut; bit[2]=comm; bit[3]=phase;
231 b=4;
232 for(i=11;i>=0;i--) bit[b++]=(tri>>i)&1;
233 for(i=11;i>=0;i--) bit[b++]=(carr>>i)&1;
234 for(i=11;i>=0;i--) bit[b++]=(tran>>i)&1;
235 for(i=11;i>=0;i--) bit[b++]=(lin>>i)&1;
236 ordre=1;
237 }
238 break;
239
240
241 default : break;
242 }
243
244
245
246
247 if (ordre) // remet les bit par mot de 8 bit poid faible en premier
248 for(i=0;i<9;i++) mot_tc[i+1]=
249 ( ((bit[8*i]&1)) | ((bit[8*i+1]&1)<<1) | ((bit[8*i+2]&1)<<2) | ((bit[8*i+3]&1)<<3)
250 | ((bit[8*i+4]&1)<<4) | ((bit[8*i+5]&1)<<5) | ((bit[8*i+6]&1)<<6) | ((bit[8*i+7]&1)<<7 ) );
251
252 else // remet les bit par mot de 8 bit, poid fort en premier
253 for(i=0;i<9;i++) mot_tc[i+1]=
254 ( ((bit[8*i]&1)<<7) | ((bit[8*i+1]&1)<<6) | ((bit[8*i+2]&1)<<5) | ((bit[8*i+3]&1)<<4)
255 | ((bit[8*i+4]&1)<<3) | ((bit[8*i+5]&1)<<2) | ((bit[8*i+6]&1)<<1) | ((bit[8*i+7]&1) ) );
256
257 emission_telecommande(tc_dir_transputer,mot_tc);
258
259 gg->reglage.bolo[fen-1].mot1=bolo_mot1(carr,tri,gainbrut,phase,comm);
260 gg->reglage.bolo[fen-1].mot2=bolo_mot2(tran,lin,voie);
261
262 }
263mesures_bolo(fen,carr,tri,1); // mesure temperature, puissance,... pour les bolos
264
265tt->reglage=gg->reglage;
266
267fich_save_partiel(1);
268}
269
270
271/*
272
273void ecritpulseprisme(int per);
274
275void ecritpulseprisme(int per) // ecrit l'etat.bolo : gg->reglage.diode_dure
276{
277//int i;
278gg->reglage.diode_dure=per;
279per=per+1;
280//printf(" ecriture de per=%d \n",per);
281// lecture et ecriture carte du nopmbre de mesures
282if(per<1) per=1; if(per>31) per=31;
283//ecrit_nubus_dec(25); // valeur 2 * num_bolo +1 = 2*12 + 1 = 25
284//ecrit_nubus_dec(per & 31 ); // 5 bits ecriture
285//for(i=0;i<12;i++) ecrit_nubus_dec(0);
286fich_save_partiel(1);
287}
288*/
Note: See TracBrowser for help on using the repository browser.