#include "diabolo.h" #include "bolo.h" #include "synchro.h" #include "fichier.h" #include "trace.h" #include "menu.h" #define max_couleur 10 static int ds_bolo_coul[2*nb_max_bolo]; static int choix_DS=0; static int npt_DS=0; // nombre de points (periode) pour le calcul de la DS static double table_DS[2*max_points_DS]; // table de detection synchrone, dupliquer en double longueur static double norme_DS; static int raz_parasite=2; void montracen_ds(int fen,int n,double x,double *y); void exec_trace_DS_suite(int u); void trace_DS(double *y,int enregistre); void calcul_table_DS(double periode); #define degre(x) ((int)(x*180./3.14159)) // calcul ya pendant la periode , yb a cheval sur 2 periodes , yc= somme des deux void exec_trace_DS(int fen,int item,double valeur,...) { static int u=-1; static flag_err=0; int i; switch(item) { case ouverture : gg->trace_ouvert=gg->trace_ouvert | 4 ; graph->ymin=-20; graph->ymax=20; graph->ypas=5; graph->xmax=500; graph->xpas=50; graph->taille_graduations=7; // graph->flag_tracen=0; // for(j=0;jbolo_type[j]) graph->flag_tracen+=(1<flag_tracen+=(1<nb_max_bolo) ) ds_bolo_coul[i]=0; if (ds_bolo_coul[i]<=24) ds_bolo_coul[i+1]=ds_bolo_coul[i]+24; printf(" i=%d bolo=%d ",i,ds_bolo_coul[i]); } printf("\n"); calcul_table_DS(synchro_periode); break; case ds_raz_parasite : if (valeur) raz_parasite=1; // soustraction else raz_parasite=2; // plus de soustraction printf("remise a zero signal parasite \n"); break; case ds_raz : gg->temps_origine=gg->periode_echantillonage*(double)gg->temps_cntl; efface(fen); break; case ds_debut : if( (u<8*npt_DS/10) ou (u>15*npt_DS/10) ) { if(!flag_err) {printf("erreur periode \n");flag_err=20;} flag_err--; } else flag_err=0; while(u=0) && (utrace_ouvert=gg->trace_ouvert & (255-4); // enleve le 4 break; default : break; } } // le trace de la detection synchrone passe par un appel a chaque point avec u=0,1,2,.... , npt_DS-1 // // la commande de trace sera faite par exec_trace_DS_suite pour certaines valeures de u // pour une detection avec trois positions qui se suivent, le parametre supplementaire pernum // compte de 0 a 2. Il est remis a zero pour un appel de la fonction avec u=-1 (qui ne fait rien d'autre) // la detection est accumulée simultanement dans deux registres y1 et y2 qui sont plotte simultanement. // on a ainsi deux points par periode void exec_trace_DS_suite(int u) // appellé quoiqu'il arrive avec u=0,1,2,.... , npt_DS-1 { static double y[2*nb_max_bolo],y1[2*nb_max_bolo],y2[2*nb_max_bolo],bb[2*nb_max_bolo]; int j; static double phase_mesure[nb_max_bolo],confiance[nb_max_bolo],phase_memoire; //printf("suite avec u=%d \n"); switch(choix_DS) { case choix_DS_sinus_1f : for(j=0;j le cosinus bb[j]+= xbol(j)* (((double)(u%2))-0.5); // estimation du bruit } if(u==npt_DS-1) { for(j=0;jperiode_echantillonage*(double)gg->temps_cntl-gg->temps_origine; if(enregistre) { printf("traceDS avec enregistre=1\n"); ecritT(fenetre_enregistre_DS,fin_f," %9.3f ",x ); for(j=0;jtrace_ouvert&16) trace_annexe(yt); // données razparasite mais non filtrées raz_parasite=0; selectgra(fenetre_trace_DS); if(scan_ds != ( (gg->don.sync[sync_subscan]!=0) et (gg->don.sync[sync_scan]!=0) ) ) { if(scan_ds) rectangle(fenetre_trace_DS,x,graph->ymin,x,graph->ymax,rouge); // trace le segment x1,y1 - x2,y2 else rectangle(fenetre_trace_DS,x,graph->ymin,x,graph->ymax,bleu); // trace le segment x1,y1 - x2,y2 scan_ds = ( (gg->don.sync[sync_subscan]!=0) et (gg->don.sync[sync_scan]!=0) ) ; } moy=litD(fenetre_trace_DS,ds_moyenne,0L); if(moy>10) {moy=10;ecritD(fenetre_trace_DS,ds_moyenne,"10");} if(moy) { uf++; if(uf>=moy) uf=0; for(j=0;j<2*nb_max_bolo;j++) { for(k=0;kscroll_courbe) && litD(fenetre_trace_DS,ds_retour,0L) && ( (xxmin) ou (x>graph->xmax) )) { graph->xmax-=graph->xmin;graph->xmin=0; gg->temps_origine=gg->periode_echantillonage*(double)gg->temps_cntl; x=0; } //ecritD(fenetre_trace_DS,ds_bol1,"%gµV",yt[0]); //ecritD(fenetre_trace_DS,ds_bol2,"%gµV",yt[1]); } // fabrique une table double longueur pour ne pas poser de problèmes // la table de detection synchrone est deja dephase comme il faut void calcul_table_DS(double periode) { int i,v,tm,phase; npt_DS=(int)(periode+0.2); // synchro_periode est un double et npt_DS est un entier if (npt_DS>max_points_DS) npt_DS=max_points_DS; choix_DS=litD(fenetre_trace_DS,ds_choix_DS,0L); tm=litD(fenetre_trace_DS,ds_temps_mort,0L); phase=litD(fenetre_trace_DS,ds_phase,0L); norme_DS=0; switch(choix_DS) { case choix_DS_sinus_1f : npt_DS=2* (int) (npt_DS/2); // plus moins plus moins (hacheur) for(i=0 ;i=npt_DS) i=0; if(v=npt_DS) i=0; if(v=npt_DS) i=0; if(v=npt_DS) i=0; if(v=npt_DS) i=0; if(v=npt_DS) i=0; if(v=npt_DS) i=0; if(v=npt_DS) i=0; if(v=npt_DS) i=0; if(v