#include "diabolo.h" #include "bolo.h" #include "acqui.h" #include "fichier.h" #include "auto.h" #include "regul.h" #include "tm.h" int auto_tr[nb_max_bolo]; int ib_efface[nb_max_bolo]; //---------------------------------- fenetre : bolo ----------------------------------- // le numero du bolometre dans fen (fenetres 1 à parametres.nb_bolo ) void exec_bolo(int fen,int item,double valeur,...) { int a,c,i; int n=gg->reglage.horloge.nb_mesures; //if(fen > 5 ) return; if(item>1000) item-=1000; // pour appeler le case pour tous les cara d'un edit texte //controlemanip(0); //printf("execbolo avec fen=%d , item=%d \n",fen,item); switch(item) { case ouverture : ib_efface[fen-1]=0; selectgra(fen); graph->ymin=-18000; graph->ymax=18000; graph->ypas=9000; graph->xmax=gg->reglage.horloge.nb_mesures; graph->xpas=graph->xmax/4; graph->grille=1; graph->graduations=0; graph->sans_image=1; graph->avec_icones=0; graph->aspect=0; graph->xtitre[0]=0; graph->ytitre[0]=0; // ecritD(fen,b_voy,fen+1); ecritgain(fen); break; case tache_de_fond : // appellé par le programme d'acquisition pour tracer ---- la cadence est variable n=gg->reglage.horloge.nb_mesures; // printf(" nb mesure = %d \n",n); { selectgra(fen); graph->xmax=n; graph->xpas=n/4; graph->ymin=-18000; graph->ymax=18000; graph->ypas=9000; } if(ib_efface[fen-1]--<0) { ib_efface[fen-1]=10; retrace(fen);} c=1234; effacecourbe(fen); // style(fen); //tt->bololut[fen-1]=lecture_en_cours; for(i=0;ibol_per trace(fen,i, ((double)((gg->bol_per[fen-1][i]&0x7fff)-0x4000))); a=(gg->bol_per[fen-1][i]>>15)&1; if(a!=c) { c=a; if(a) modtrace(fen,1,bleu); else modtrace(fen,1,rouge); } } trace(fen,n, ((double)((gg->bol_per[fen-1][0]&0x7fff)-0x4000))); if(gg->flag_tc_reduite) break; /* pas d'auto en local si en tc_reduites */ if( (litD(fen,b_auto,0L))!=0) auto_control(fen,auto_val); if(auto_tr[fen-1]) {auto_transitoire(fen,auto_tr[fen-1]);auto_tr[fen-1]--;} break; // reecrit les valeurs dans la fenetre pour appel par un autre programme case b_carre : ecritD(fen,b_carre,(int)valeur); ecritgain(fen); break; case b_tri : ecritD(fen,b_tri,(int)valeur); ecritgain(fen); break; case b_trans : ecritD(fen,b_trans,(int)valeur); ecritgain(fen); break; case b_lin : ecritD(fen,b_lin,(int)valeur); ecritgain(fen); break; case b_gain : vg[fen-1]=0; ecritD(fen,b_gain,(int)valeur); ecritgain(fen); break; case b_phase : ecritD(fen,b_phase,(int)valeur); ecritgain(fen); break; case b_comm : ecritD(fen,b_comm,(int)valeur); ecritgain(fen); break; case b_voie : ecritgain(fen); break; case caseferme : //SizeWindow(ptf->ptwindow,210,105,1);MoveWindow(ptf->ptwindow,620,-20+fen*95,0);zoom(fen); stop_exec(fen); break; break; case b_auto_trans: case b_auto_trans+1000 : auto_tr[fen-1]=20; break; case b_auto_lin : case b_auto_lin+1000 : ecritD(fen,b_lin,2048); break; case b_auto : ecritgain(fen); // if(valeur && (! gg->flag_tc_reduite) ) if(valeur) auto_control(fen,auto_force); break; default : break; } } unsigned char codage_12_bit(int av,int an); unsigned char codage_12_bit(int av,int an) { int a=an-av; if( (a>0) && (a<64) ) a = 0x40 | a; else if( (a<0) && (a>-64) ) a = -a; else a=0x80 | ((an&0xfff)>>5) ; return(a); } void ecritgain(int fen) // ecrit gain, carre, triangle, .....gg->reglage.dac[...] { int carr,tri,lin,tran,i,j,gainbrut,phase,comm,voie; int gain_MLPA[16]={1,2,4,8,10,20,40,80,100,200,400,800,1000,2000,4000,8000}; int gain_BEBO[4]={5,25,100,500}; /* gainbrut ampli 1 / 5 / 20 / 100 */ int gain_BEDIF[3]={10,40,200}; /* gainbrut ampli 2 / 8 / 40 */ int table_phase[4]={0,1,3,2}; char bit[80]; int b,ordre; char mot_tc[10]; carr=litD(fen,b_carre,0L); tri=litD(fen,b_tri,0L); lin=litD(fen,b_lin,0L); tran=litD(fen,b_trans,0L); gainbrut=litD(fen,b_gain,0L); phase=litD(fen,b_phase,0L); comm=litD(fen,b_comm,0L); if(litD(fen,b_auto,0L)) voie=litD(fen,b_voie,0L); else voie=0; // verifie les gainsbrut en fonction de la boite utilisée switch(parametr.bolo[fen-1].bolo_bebo) { case 0: // ---------------------- programmation MLPA ------------------- break; case 2: case 3: case 4: // ---------------------- programmation BEBO ------------------- if(gainbrut>3) {gainbrut=3;ecritD(fen,b_gain,3);} gainbrut+=16; // pour une BEBO break; case 10: // ---------------------- programmation Bediff ------------------- if(gainbrut>2) {gainbrut=2;ecritD(fen,b_gain,2);} gainbrut+=20; // pour une BEDIFF if(phase>1) {phase=1;ecritD(fen,b_phase,1);} default : break; } // emission des telecommandes reduites au lieu des telecommandes completes if(gg->flag_tc_reduite) { if(carr!=dac_V(gg->reglage.bolo[fen-1])) emission_tc_reduite(tc2_bolo_dacV,fen-1,codage_12_bit(dac_V(gg->reglage.bolo[fen-1]),carr)); if(tri!=dac_I(gg->reglage.bolo[fen-1])) emission_tc_reduite(tc2_bolo_dacI,fen-1,codage_12_bit(dac_I(gg->reglage.bolo[fen-1]),tri)); if(tran!=dac_T(gg->reglage.bolo[fen-1])) emission_tc_reduite(tc2_bolo_dacT,fen-1,codage_12_bit(dac_T(gg->reglage.bolo[fen-1]),tran)); if(lin!=dac_L(gg->reglage.bolo[fen-1])) emission_tc_reduite(tc2_bolo_dacL,fen-1,codage_12_bit(dac_L(gg->reglage.bolo[fen-1]),lin)); if( (gainbrut!=gainbrut(gg->reglage.bolo[fen-1])) ou (phase!=phase(gg->reglage.bolo[fen-1])) ou (comm!=comm(gg->reglage.bolo[fen-1])) ) emission_tc_reduite(tc2_bolo_gain,fen-1,bolo_mot1(carr,tri,gainbrut,phase,comm)); if(voie!=voie(gg->reglage.bolo[fen-1])) emission_tc_reduite(tc2_bolo_voie,fen-1,voie); } else { for(j=0;j<72;j++) bit[j]=0; // prepare 72 bits à envoyer en 9 mots de 8 bits switch(parametr.bolo[fen-1].bolo_bebo) { case 0: { // ---------------------- programmation MLPA ------------------- // printf("programmation MLPA: tri=%d car=%d \n",tri,carr); mot_tc[0]=parametr.bolo[fen-1].bolo_num; // premier mot de 8 bit (code adresse bolometre) // printf(" ecrit bolo %d \n",gg->bolo[fen-1].bolo_num); bit[0]=table_phase[phase&3]>>1; bit[1]=table_phase[phase&3]; b=2; 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;} bit[b]=1; bit[b+1]=gainbrut>>3; bit[b+2]=gainbrut>>2; bit[b+3]=gainbrut>>1; bit[b+4]=gainbrut; ordre=0; } break; case 2: case 3: case 4: { // ---------------------- programmation BEBO ------------------- mot_tc[0]=8*parametr.bolo[fen-1].bolo_bebo + parametr.bolo[fen-1].bolo_num; // premier mot de 8 bit (code adresse bolometre) // printf("programmation BEBO N° : tri=%d car=%d \n",mot_tc[0],tri,carr); bit[0]=gainbrut>>1; bit[1]=gainbrut; bit[2]=table_phase[phase&3]>>1; bit[3]=table_phase[phase&3]; b=4; for(i=11;i>=0;i--) bit[b++]=(tri>>i)&1; for(i=11;i>=0;i--) bit[b++]=(carr>>i)&1; for(i=11;i>=0;i--) bit[b++]=(tran>>i)&1; ecritD(fen,b_lin,0); ordre=0; } break; case 10: { // ---------------------- programmation Bediff ------------------- // --- les bits sortent dans l'autre sens : poid faible d'abord ---- // -- il faut donc retourner les bits des dacs // lin=0; // ecritD(fen,b_lin,lin); gg->reglage.dac[d_lin][fen-1]=lin; // pas de linearité mot_tc[0]= parametr.bolo[fen-1].bolo_num; // premier mot de 8 bit (code adresse bolometre) printf("programmation BEdiff N° %d: tri=%d car=%d \n",mot_tc[0],tri,carr); bit[0]=gainbrut>>1; bit[1]=gainbrut; bit[2]=comm; bit[3]=phase; b=4; for(i=11;i>=0;i--) bit[b++]=(tri>>i)&1; for(i=11;i>=0;i--) bit[b++]=(carr>>i)&1; for(i=11;i>=0;i--) bit[b++]=(tran>>i)&1; for(i=11;i>=0;i--) bit[b++]=(lin>>i)&1; ordre=1; } break; default : break; } if (ordre) // remet les bit par mot de 8 bit poid faible en premier for(i=0;i<9;i++) mot_tc[i+1]= ( ((bit[8*i]&1)) | ((bit[8*i+1]&1)<<1) | ((bit[8*i+2]&1)<<2) | ((bit[8*i+3]&1)<<3) | ((bit[8*i+4]&1)<<4) | ((bit[8*i+5]&1)<<5) | ((bit[8*i+6]&1)<<6) | ((bit[8*i+7]&1)<<7 ) ); else // remet les bit par mot de 8 bit, poid fort en premier for(i=0;i<9;i++) mot_tc[i+1]= ( ((bit[8*i]&1)<<7) | ((bit[8*i+1]&1)<<6) | ((bit[8*i+2]&1)<<5) | ((bit[8*i+3]&1)<<4) | ((bit[8*i+4]&1)<<3) | ((bit[8*i+5]&1)<<2) | ((bit[8*i+6]&1)<<1) | ((bit[8*i+7]&1) ) ); emission_telecommande(tc_dir_transputer,mot_tc); gg->reglage.bolo[fen-1].mot1=bolo_mot1(carr,tri,gainbrut,phase,comm); gg->reglage.bolo[fen-1].mot2=bolo_mot2(tran,lin,voie); } mesures_bolo(fen,carr,tri,1); // mesure temperature, puissance,... pour les bolos tt->reglage=gg->reglage; fich_save_partiel(1); } /* void ecritpulseprisme(int per); void ecritpulseprisme(int per) // ecrit l'etat.bolo : gg->reglage.diode_dure { //int i; gg->reglage.diode_dure=per; per=per+1; //printf(" ecriture de per=%d \n",per); // lecture et ecriture carte du nopmbre de mesures if(per<1) per=1; if(per>31) per=31; //ecrit_nubus_dec(25); // valeur 2 * num_bolo +1 = 2*12 + 1 = 25 //ecrit_nubus_dec(per & 31 ); // 5 bits ecriture //for(i=0;i<12;i++) ecrit_nubus_dec(0); fich_save_partiel(1); } */