#include "diabolo.h" #include "carte_acqui.h" #include "carte_pci.h" #include "fenetres_diabolo.h" #include "acqui.h" #include "tm.h" #include "simulmission.h" #include "controle.h" // telecommande une chaine de 10 mots pour Diabolo // une chaine de 8 mots pour Archeops et Planck // pour les telecommandes reduites, seuls 4 mots sont utiles #define verif_bolo {bolo=tc[2];if(bolo>nb_max_bolo) {printf("erreur: telecommande pour bolo=%d >nb_max_bolo \n",bolo);return;}} void relit_telecommandes_reduites(unsigned char* tc); void relit_telecommandes_reduites(unsigned char* tc) { int bolo,a; if(tc[0]!=tc_reduite) return; printf("relit une telecommande reduite : "); switch(tc[1]) { case tc2_bolo_dacV: verif_bolo;a=dac_V(gg->reglage.bolo[bolo]); a=new_val_dac(a,tc[3]); gg->reglage.bolo[bolo].mot1=(gg->reglage.bolo[bolo].mot1&0xfff000ff) | (a<<8); printf(" nouvelle valeur dacV=%d \n",a); break; case tc2_bolo_dacI: verif_bolo;a=dac_I(gg->reglage.bolo[bolo]); a=new_val_dac(a,tc[3]); gg->reglage.bolo[bolo].mot1=(gg->reglage.bolo[bolo].mot1&0x000fffff) | (a<<20); printf(" nouvelle valeur dacI=%d \n",a); break; case tc2_bolo_gain: verif_bolo; gg->reglage.bolo[bolo].mot1=(gg->reglage.bolo[bolo].mot1&0xffffff00) | tc[3]; printf(" nouvelle valeur gain=%x \n",tc[3]); break; case tc2_bolo_dacT: verif_bolo;a=dac_T(gg->reglage.bolo[bolo]); a=new_val_dac(a,tc[3]); gg->reglage.bolo[bolo].mot2=(gg->reglage.bolo[bolo].mot2&0xfff000ff) | (a<<8); printf(" nouvelle valeur dacT=%d \n",a); break; case tc2_bolo_dacL: verif_bolo;a=dac_L(gg->reglage.bolo[bolo]); a=new_val_dac(a,tc[3]); gg->reglage.bolo[bolo].mot2=(gg->reglage.bolo[bolo].mot2&0x000fffff) | (a<<20); printf(" nouvelle valeur dacL=%d \n",a); break; case tc2_bolo_voie: verif_bolo; gg->reglage.bolo[bolo].mot2=(gg->reglage.bolo[bolo].mot2&0xffffff00) | tc[3]; printf(" nouvelle valeur voie=%d \n",tc[3]); break; case tc2_horloge: switch(tc[2]) { case tc3_periode : gg->reglage.horloge.periode=tc[3]; printf(" nouvelle valeur periode=%d \n",tc[3]); break; case tc3_nb_mesures : gg->reglage.horloge.nb_mesures=tc[3]; printf(" nouvelle valeur nb_mesures=%d \n",tc[3]); break; case tc3_temp_mort : gg->reglage.horloge.temp_mort=tc[3]; printf(" nouvelle valeur temp_mort=%d \n",tc[3]); break; case tc3_flag : gg->reglage.horloge.flag=tc[3]; printf(" nouvelle valeur flag=%d \n",tc[3]); break; default : // i=tc[2]-tc3_vitesse; // if( (i>=0) && (ireglage.vitesse[i]=tc[3]; // printf(" nouvelle valeur block%d vitesse %d \n",i,tc[3]); break; } case tc2_regul: { char * pt; printf(" tc reduite: ecrit regul val=%d pour position %d \n",tc[3],tc[2]); pt=(char*)(&(gg->reglage.regul[0])); pt=pt+tc[2]; if(tc[2]reglage.autom[0])); pt=pt+tc[2]; if(tc[2]reglage.dilu)); pt=pt+tc[2]; if(tc[2]>8);tc_char(x>>16);tc_char(x>>24);} //printf("telecommande: "); //***************************************************************************************** #ifdef _sans_transputer //--------- pour Archeops avec ctb ------------- *** //***************************************************************************************** if((mot[0]&0xff) == (tc_horloge&0xff) ) { printf("horloge tc_transputer sans transputer:\n"); mot[1]=83-mot[1]; // periode mot[2]=((mot[2]+5)-29 + 2* (((mot[2]+5)-1)/6) ); mot[2]=mot[2]+(mot[4]<<5); /* + les trois flags */ mot[4]=0; for(j=0;j<8;j++) { printf(" %x ",mot[j]&0xff); tc_char(mot[j]); } printf(" \n"); } else { printf("tc_bebo directe:"); for(j=0;j<8;j++) { printf(" %x ",mot[j]&0xff); tc_char(mot[j]); } printf(" \n"); } //***************************************************************************************** #else //--------- pour Archeops avec transputer ----------------------- *** //***************************************************************************************** switch(direction) { case tc_dir_transputer : //printf("tc_transputer:\n"); if( ((mot[0]&0xff)!=tc_reduite) && gg->flag_tc_reduite) { printf("attention: une telecommande normale non envoyée !!\n\n"); son(130); select(printf_ref); break; } // pour test en mode simulation sans le retour des blocks reglage du transputer if(tt->PCI_actif==2) { relit_telecommandes_reduites(tc); break; } else if(tt->PCI_actif==3) { simul_telecommandes_reduites(tc); } else {char ss[200]; static long t; #define tcl(iii) ((long)mot[iii]) long mothexa[5]; /* les 5 cara hexa envoyée */ /* on range les bit: bit 1 en poid fort de tout */ mothexa[0]=tcl(1); /* 4 bit choix de commande */ mothexa[1]=tcl(2)>>2; /* les 4 bits poid fort du code direction */ mothexa[2]=((tcl(2)<<2)&0xc) + ((tcl(3)>>6)&0x3); mothexa[3]=(tcl(3)>>2)&0xf; mothexa[4]=(tcl(3)&0x3) + 0x0C; printf("commande 18bit: %d %d %d -> %lx%lx%lx%lx%lx ",tcl(1),tcl(2),tcl(3) ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]); ecritD(fenetre_controle,con_subscan,"tc: %x %x %x %x %x ",mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]); tc_char(0x11); // synchro tc_int(debut_telecommande); for(j=0;j<4;j++) tc_char(mot[j]); tc_char(0x00); // synchro sprintf(ss,"S%X%X%X%X%X07WS%X%X%X%X%X07WS%X%X%X%X%X07W\r\n" ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]); /* sprintf(ss,"S%x%x%x%x%x07WS%x%x%x%x%x07WS%x%x%x%x%x07W\r\l" ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]);*/ if(ss[7]!='7') erreur("adresse not equal to 7"); if(ss[16]!='7') erreur("adresse not equal to 7"); if(ss[25]!='7') erreur("adresse not equal to 7"); while( (TickCount()>t) et (TickCount()<(t+60*15)) ) // 15sec { static int q; q++; son(130); if(q%10==0) printf("attente pour envoi de telecommande\n"); controlemanip(0); } son(133); printf(" envoi de la telecommande : %s \n",ss); ecritRS(0,ss,0); t=TickCount(); // 10 secondes (tick = 1/60 sec) } /* else { tc_char(0x11); // synchro tc_int(debut_telecommande); for(j=0;j<8;j++) tc_char(mot[j]); tc_int(fin_telecommande); tc_char(0x00);tc_char(0x00); // synchro } */ break; case tc_dir_reset_epld : //printf("tc_reset_epld:\n"); for(j=0;j<8;j++) tc_char(j); tc_char(1);tc_char(1); tc_char(0x00);tc_char(0x00); // synchro break; case tc_dir_reset_trp : //printf("tc_reset_epld:\n"); for(j=0;j<15;j++) tc_char(j); // reset epld+transputer tc_char(1);tc_char(1); tc_char(0x00);tc_char(0x00); // synchro break; default : break; } //***************************************************************************************** #endif //-------------------------------------------------------------------- *** //***************************************************************************************** // delai pour separer les télécommandes (archeops, transputer ou non) if(acquisition_PCI) delai(1000); #endif //-------------------------------------------------------------------- *** //***************************************************************************************** // *** #ifdef _diabolo //--------- pour Diabolo ------------------------------ *** // *** //***************************************************************************************** int q; // emission dans la table tc // la commande elle même est dans mot[0..9] // le parametre direction n'est pas utilisé if(!litD(fenetre_acquisition,e_tache_inter,0L) ) // ecriture forcée directe sur carte pci { for(j=0;j<5;j++) printf("."); printf(" ecriture forcée des données \n"); for(j=0;j<10;j++) ecrit_carte(mot[j]); son(1); } else { tt->tc.btc[tt->tc.pos_ecrit]=*((block_tc*)tc); tt->tc.pos_ecrit++; if(tt->tc.pos_ecrit>=longueur_table_tc) tt->tc.pos_ecrit=0; q=tt->tc.pos_ecrit-tt->tc.pos_lit; if (q<0) q+=longueur_table_tc; // printf(" liste de telecommande : %d chaines :",q); // printf(" %d %d %d %d %d %d %d %d %d %d\n",mot[0],mot[1],mot[2],mot[3],mot[4],mot[5],mot[6],mot[7],mot[8],mot[9]); // if(mot[0]==tc_regul) printf("telecommande regul: %d %d %d %d %d %d\n",mot[1],mot[2],mot[3],mot[4],mot[5],mot[6]); } //***************************************************************************************** // *** #endif //-------------------------------------------------------------------- *** // *** //***************************************************************************************** }