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

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

archediab 26

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