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

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

archediab version 24 initial import

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