| [637] | 1 | #include "diabolo.h" | 
|---|
|  | 2 | #include "carte_acqui.h" | 
|---|
|  | 3 | #include "carte_pci.h" | 
|---|
|  | 4 | #include "fenetres_diabolo.h" | 
|---|
|  | 5 | #include "acqui.h" | 
|---|
|  | 6 | #include "tm.h" | 
|---|
| [649] | 7 | #include "simulmission.h" | 
|---|
|  | 8 | #include "controle.h" | 
|---|
| [637] | 9 |  | 
|---|
|  | 10 |  | 
|---|
|  | 11 | // telecommande une chaine de 10 mots pour Diabolo | 
|---|
|  | 12 | //              une chaine de 8 mots pour Archeops et Planck | 
|---|
|  | 13 | //              pour les telecommandes reduites, seuls 4 mots sont utiles | 
|---|
|  | 14 |  | 
|---|
|  | 15 | #define verif_bolo {bolo=tc[2];if(bolo>nb_max_bolo) {printf("erreur: telecommande pour bolo=%d >nb_max_bolo \n",bolo);return;}} | 
|---|
|  | 16 |  | 
|---|
|  | 17 | void    relit_telecommandes_reduites(unsigned char* tc); | 
|---|
|  | 18 |  | 
|---|
|  | 19 |  | 
|---|
|  | 20 | void    relit_telecommandes_reduites(unsigned char* tc) | 
|---|
|  | 21 | { | 
|---|
| [643] | 22 | int bolo,a; | 
|---|
| [637] | 23 | if(tc[0]!=tc_reduite)   return; | 
|---|
|  | 24 | printf("relit une telecommande reduite :  "); | 
|---|
|  | 25 | switch(tc[1]) | 
|---|
|  | 26 | { | 
|---|
|  | 27 | case    tc2_bolo_dacV: | 
|---|
|  | 28 | verif_bolo;a=dac_V(gg->reglage.bolo[bolo]); | 
|---|
|  | 29 | a=new_val_dac(a,tc[3]); | 
|---|
|  | 30 | gg->reglage.bolo[bolo].mot1=(gg->reglage.bolo[bolo].mot1&0xfff000ff) | (a<<8); | 
|---|
|  | 31 | printf(" nouvelle valeur dacV=%d \n",a); | 
|---|
|  | 32 | break; | 
|---|
|  | 33 |  | 
|---|
|  | 34 | case    tc2_bolo_dacI: | 
|---|
|  | 35 | verif_bolo;a=dac_I(gg->reglage.bolo[bolo]); | 
|---|
|  | 36 | a=new_val_dac(a,tc[3]); | 
|---|
|  | 37 | gg->reglage.bolo[bolo].mot1=(gg->reglage.bolo[bolo].mot1&0x000fffff) | (a<<20); | 
|---|
|  | 38 | printf(" nouvelle valeur dacI=%d  \n",a); | 
|---|
|  | 39 | break; | 
|---|
|  | 40 |  | 
|---|
|  | 41 | case    tc2_bolo_gain: | 
|---|
|  | 42 | verif_bolo; | 
|---|
|  | 43 | gg->reglage.bolo[bolo].mot1=(gg->reglage.bolo[bolo].mot1&0xffffff00) | tc[3]; | 
|---|
|  | 44 |  | 
|---|
|  | 45 | printf(" nouvelle valeur gain=%x  \n",tc[3]); | 
|---|
|  | 46 | break; | 
|---|
|  | 47 |  | 
|---|
|  | 48 | case    tc2_bolo_dacT: | 
|---|
|  | 49 | verif_bolo;a=dac_T(gg->reglage.bolo[bolo]); | 
|---|
|  | 50 | a=new_val_dac(a,tc[3]); | 
|---|
|  | 51 | gg->reglage.bolo[bolo].mot2=(gg->reglage.bolo[bolo].mot2&0xfff000ff) | (a<<8); | 
|---|
|  | 52 | printf(" nouvelle valeur dacT=%d  \n",a); | 
|---|
|  | 53 | break; | 
|---|
|  | 54 |  | 
|---|
|  | 55 | case    tc2_bolo_dacL: | 
|---|
|  | 56 | verif_bolo;a=dac_L(gg->reglage.bolo[bolo]); | 
|---|
|  | 57 | a=new_val_dac(a,tc[3]); | 
|---|
|  | 58 | gg->reglage.bolo[bolo].mot2=(gg->reglage.bolo[bolo].mot2&0x000fffff) | (a<<20); | 
|---|
|  | 59 | printf(" nouvelle valeur dacL=%d  \n",a); | 
|---|
|  | 60 | break; | 
|---|
|  | 61 |  | 
|---|
|  | 62 | case    tc2_bolo_voie: | 
|---|
|  | 63 | verif_bolo; | 
|---|
|  | 64 | gg->reglage.bolo[bolo].mot2=(gg->reglage.bolo[bolo].mot2&0xffffff00) | tc[3]; | 
|---|
|  | 65 |  | 
|---|
|  | 66 | printf(" nouvelle valeur voie=%d  \n",tc[3]); | 
|---|
|  | 67 | break; | 
|---|
|  | 68 | case    tc2_horloge: | 
|---|
|  | 69 | switch(tc[2]) | 
|---|
|  | 70 | { | 
|---|
|  | 71 | case    tc3_periode     : | 
|---|
|  | 72 | gg->reglage.horloge.periode=tc[3]; | 
|---|
|  | 73 | printf(" nouvelle valeur periode=%d  \n",tc[3]); | 
|---|
|  | 74 | break; | 
|---|
|  | 75 | case    tc3_nb_mesures  :       gg->reglage.horloge.nb_mesures=tc[3]; | 
|---|
|  | 76 | printf(" nouvelle valeur nb_mesures=%d  \n",tc[3]); | 
|---|
|  | 77 | break; | 
|---|
|  | 78 | case    tc3_temp_mort   :       gg->reglage.horloge.temp_mort=tc[3]; | 
|---|
|  | 79 | printf(" nouvelle valeur temp_mort=%d  \n",tc[3]); | 
|---|
|  | 80 | break; | 
|---|
|  | 81 | case    tc3_flag        :       gg->reglage.horloge.flag=tc[3]; | 
|---|
|  | 82 | printf(" nouvelle valeur flag=%d  \n",tc[3]); | 
|---|
|  | 83 | break; | 
|---|
|  | 84 | default : | 
|---|
| [643] | 85 | //                                      i=tc[2]-tc3_vitesse; | 
|---|
|  | 86 | //                                      if( (i>=0) && (i<nb_type_blocks) ) | 
|---|
|  | 87 | //                                              gg->reglage.vitesse[i]=tc[3]; | 
|---|
|  | 88 | //                                      printf(" nouvelle valeur block%d vitesse %d \n",i,tc[3]); | 
|---|
| [637] | 89 | break; | 
|---|
|  | 90 | } | 
|---|
|  | 91 | case    tc2_regul: | 
|---|
|  | 92 | { | 
|---|
|  | 93 | char * pt; | 
|---|
|  | 94 | printf(" tc reduite: ecrit regul val=%d  pour position  %d \n",tc[3],tc[2]); | 
|---|
|  | 95 | pt=(char*)(&(gg->reglage.regul[0])); | 
|---|
|  | 96 | pt=pt+tc[2]; | 
|---|
|  | 97 | if(tc[2]<nombre_de_regul*sizeof(regul_bolo))    *pt=tc[3]; | 
|---|
|  | 98 | else            printf("erreur telecommande reduite tc2_regul \n"); | 
|---|
|  | 99 | } | 
|---|
|  | 100 | break; | 
|---|
|  | 101 |  | 
|---|
|  | 102 |  | 
|---|
|  | 103 |  | 
|---|
|  | 104 | case    tc2_auto_bolo: | 
|---|
|  | 105 | { | 
|---|
|  | 106 | char * pt; | 
|---|
|  | 107 | printf(" tc reduite: ecrit autobolo val=%d  pour position  %d \n",tc[3],tc[2]); | 
|---|
|  | 108 | pt=(char*)(&(gg->reglage.autom[0])); | 
|---|
|  | 109 | pt=pt+tc[2]; | 
|---|
|  | 110 | if(tc[2]<nombre_de_voies*sizeof(auto_bolo))     *pt=tc[3]; | 
|---|
|  | 111 | else            printf("erreur telecommande reduite tc2_auto_bolo \n"); | 
|---|
|  | 112 | } | 
|---|
|  | 113 | break; | 
|---|
|  | 114 |  | 
|---|
|  | 115 |  | 
|---|
|  | 116 | case    tc2_auto_dilu: | 
|---|
|  | 117 | { | 
|---|
|  | 118 | char * pt; | 
|---|
|  | 119 | printf(" tc reduite: ecrit auto_dilu val=%d  pour position  %d \n",tc[3],tc[2]); | 
|---|
|  | 120 | pt=(char*)(&(gg->reglage.dilu)); | 
|---|
|  | 121 | pt=pt+tc[2]; | 
|---|
|  | 122 | if(tc[2]<sizeof(auto_dilu))     *pt=tc[3]; | 
|---|
|  | 123 | else            printf("erreur telecommande reduite tc2_auto_bolo \n"); | 
|---|
|  | 124 | } | 
|---|
|  | 125 | break; | 
|---|
|  | 126 |  | 
|---|
|  | 127 |  | 
|---|
|  | 128 | default :       printf("telecommande reduite type inconnu \n\n"); | 
|---|
|  | 129 | son(130); | 
|---|
|  | 130 | break; | 
|---|
|  | 131 | } | 
|---|
|  | 132 | rafraichis_fenetres(); | 
|---|
|  | 133 | } | 
|---|
|  | 134 |  | 
|---|
|  | 135 |  | 
|---|
|  | 136 | void    emission_tc_reduite(unsigned char mot1,unsigned char mot2,unsigned char mot3) | 
|---|
|  | 137 | { | 
|---|
|  | 138 | unsigned char mot_tc[10]; | 
|---|
| [649] | 139 | { | 
|---|
|  | 140 | mot_tc[0]       =       tc_reduite; | 
|---|
|  | 141 | mot_tc[1]       =       mot1; | 
|---|
|  | 142 | mot_tc[2]       =       mot2; | 
|---|
|  | 143 | mot_tc[3]       =       mot3; | 
|---|
|  | 144 | emission_telecommande(tc_dir_transputer,mot_tc); | 
|---|
|  | 145 | } | 
|---|
| [637] | 146 | } | 
|---|
|  | 147 |  | 
|---|
|  | 148 |  | 
|---|
|  | 149 | void    emission_telecommande(int direction,void* tc) | 
|---|
|  | 150 | { | 
|---|
|  | 151 | char *mot=tc; | 
|---|
|  | 152 | int j; | 
|---|
|  | 153 |  | 
|---|
| [649] | 154 | if(!acquisition_avec_telecommande)  return; | 
|---|
|  | 155 |  | 
|---|
|  | 156 |  | 
|---|
| [637] | 157 | //***************************************************************************************** | 
|---|
|  | 158 | //                                                                                      *** | 
|---|
|  | 159 | #ifdef _archeops        //---------   pour  Archeops    ------------------------------  *** | 
|---|
|  | 160 | //                                                                                      *** | 
|---|
|  | 161 | //***************************************************************************************** | 
|---|
|  | 162 | //     direction  contient un octet de direction: bebo ou transputer | 
|---|
|  | 163 | //      la commande elle même est dans mot[0..7] | 
|---|
|  | 164 |  | 
|---|
|  | 165 | #define  delai(xx)      {long uu;for(uu=0;uu<(10000L*(long)xx);uu++){};} | 
|---|
| [649] | 166 | #define  tc_char(x)     {delai(40);if(acquisition_PCI) ecrit_carte((x)&0xff);} | 
|---|
| [637] | 167 | #define  tc_int(x)      {tc_char(x);tc_char(x>>8);tc_char(x>>16);tc_char(x>>24);} | 
|---|
|  | 168 | //printf("telecommande: "); | 
|---|
|  | 169 |  | 
|---|
|  | 170 |  | 
|---|
|  | 171 |  | 
|---|
|  | 172 | //***************************************************************************************** | 
|---|
|  | 173 | #ifdef _sans_transputer         //---------   pour  Archeops avec ctb    -------------  *** | 
|---|
|  | 174 | //***************************************************************************************** | 
|---|
|  | 175 | if((mot[0]&0xff) ==  (tc_horloge&0xff)  ) | 
|---|
|  | 176 |  | 
|---|
|  | 177 | { | 
|---|
|  | 178 | printf("horloge  tc_transputer sans transputer:\n"); | 
|---|
|  | 179 | mot[1]=83-mot[1];       // periode | 
|---|
|  | 180 | mot[2]=((mot[2]+5)-29 + 2* (((mot[2]+5)-1)/6) ); | 
|---|
|  | 181 | mot[2]=mot[2]+(mot[4]<<5); /* +   les trois flags               */ | 
|---|
|  | 182 |  | 
|---|
|  | 183 | mot[4]=0; | 
|---|
|  | 184 | for(j=0;j<8;j++) | 
|---|
|  | 185 | { | 
|---|
|  | 186 | printf(" %x ",mot[j]&0xff); | 
|---|
|  | 187 | tc_char(mot[j]); | 
|---|
|  | 188 | } | 
|---|
|  | 189 | printf(" \n"); | 
|---|
|  | 190 | } | 
|---|
|  | 191 |  | 
|---|
|  | 192 | else    { | 
|---|
|  | 193 | printf("tc_bebo directe:"); | 
|---|
|  | 194 | for(j=0;j<8;j++) | 
|---|
|  | 195 | { | 
|---|
|  | 196 | printf(" %x ",mot[j]&0xff); | 
|---|
|  | 197 | tc_char(mot[j]); | 
|---|
|  | 198 | } | 
|---|
|  | 199 | printf(" \n"); | 
|---|
|  | 200 | } | 
|---|
|  | 201 | //***************************************************************************************** | 
|---|
|  | 202 | #else           //---------   pour Archeops avec transputer    -----------------------  *** | 
|---|
|  | 203 | //***************************************************************************************** | 
|---|
|  | 204 | switch(direction) | 
|---|
|  | 205 | { | 
|---|
|  | 206 | case    tc_dir_transputer       :       //printf("tc_transputer:\n"); | 
|---|
|  | 207 | if( ((mot[0]&0xff)!=tc_reduite) && gg->flag_tc_reduite) | 
|---|
|  | 208 | { | 
|---|
| [649] | 209 | printf("attention: une telecommande normale non envoyée !!\n\n"); | 
|---|
| [637] | 210 | son(130); | 
|---|
|  | 211 | select(printf_ref); | 
|---|
| [649] | 212 | break; | 
|---|
| [637] | 213 | } | 
|---|
|  | 214 | //                      pour test en mode simulation sans le retour des blocks reglage du transputer | 
|---|
| [649] | 215 | if(tt->PCI_actif==2) | 
|---|
|  | 216 | { | 
|---|
|  | 217 | relit_telecommandes_reduites(tc); | 
|---|
|  | 218 | break; | 
|---|
|  | 219 | } | 
|---|
|  | 220 | else if(tt->PCI_actif==3) | 
|---|
|  | 221 | { | 
|---|
|  | 222 | simul_telecommandes_reduites(tc); | 
|---|
|  | 223 | } | 
|---|
|  | 224 | else    {char ss[200]; | 
|---|
|  | 225 | static long t; | 
|---|
|  | 226 |  | 
|---|
|  | 227 | #define tcl(iii)        ((long)mot[iii]) | 
|---|
|  | 228 |  | 
|---|
|  | 229 | long mothexa[5];        /* les 5 cara hexa envoyée  */ | 
|---|
|  | 230 | /*  on range les bit: bit 1 en poid fort de tout   */ | 
|---|
|  | 231 | mothexa[0]=tcl(1);      /* 4 bit choix de commande   */ | 
|---|
|  | 232 | mothexa[1]=tcl(2)>>2;   /* les 4 bits poid fort du code direction */ | 
|---|
|  | 233 | mothexa[2]=((tcl(2)<<2)&0xc)  + ((tcl(3)>>6)&0x3); | 
|---|
|  | 234 | mothexa[3]=(tcl(3)>>2)&0xf; | 
|---|
|  | 235 | mothexa[4]=(tcl(3)&0x3) + 0x0C; | 
|---|
|  | 236 | printf("commande 18bit:   %d %d %d -> %lx%lx%lx%lx%lx ",tcl(1),tcl(2),tcl(3) | 
|---|
|  | 237 | ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]); | 
|---|
|  | 238 | ecritD(fenetre_controle,con_subscan,"tc: %x %x %x %x %x ",mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]); | 
|---|
|  | 239 |  | 
|---|
| [637] | 240 | tc_char(0x11);  //  synchro | 
|---|
|  | 241 | tc_int(debut_telecommande); | 
|---|
| [649] | 242 | for(j=0;j<4;j++)        tc_char(mot[j]); | 
|---|
|  | 243 | tc_char(0x00);          //  synchro | 
|---|
|  | 244 | sprintf(ss,"S%X%X%X%X%X07WS%X%X%X%X%X07WS%X%X%X%X%X07W\r\n" | 
|---|
|  | 245 | ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] | 
|---|
|  | 246 | ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] | 
|---|
|  | 247 | ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]); | 
|---|
|  | 248 | /*                              sprintf(ss,"S%x%x%x%x%x07WS%x%x%x%x%x07WS%x%x%x%x%x07W\r\l" | 
|---|
|  | 249 | ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] | 
|---|
|  | 250 | ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4] | 
|---|
|  | 251 | ,mothexa[0],mothexa[1],mothexa[2],mothexa[3],mothexa[4]);*/ | 
|---|
|  | 252 | if(ss[7]!='7') erreur("adresse not equal to 7"); | 
|---|
|  | 253 | if(ss[16]!='7') erreur("adresse not equal to 7"); | 
|---|
|  | 254 | if(ss[25]!='7') erreur("adresse not equal to 7"); | 
|---|
| [651] | 255 | /*                              while( (TickCount()>t) et (TickCount()<(t+60*15)) )     // 15sec | 
|---|
| [649] | 256 | { | 
|---|
|  | 257 | static int q; | 
|---|
|  | 258 | q++; | 
|---|
|  | 259 | son(130); | 
|---|
|  | 260 | if(q%10==0) printf("attente pour envoi de telecommande\n"); | 
|---|
|  | 261 | controlemanip(0); | 
|---|
|  | 262 | } | 
|---|
| [651] | 263 | */                              son(133); | 
|---|
| [649] | 264 |  | 
|---|
|  | 265 | printf(" envoi de la telecommande : %s \n",ss); | 
|---|
|  | 266 | ecritRS(0,ss,0); | 
|---|
|  | 267 | t=TickCount();                  //  10 secondes  (tick = 1/60 sec) | 
|---|
|  | 268 | } | 
|---|
| [637] | 269 | break; | 
|---|
|  | 270 |  | 
|---|
|  | 271 | case    tc_dir_reset_epld       :       //printf("tc_reset_epld:\n"); | 
|---|
|  | 272 |  | 
|---|
| [649] | 273 | for(j=0;j<8;j++) tc_char(j); | 
|---|
|  | 274 | tc_char(1);tc_char(1); | 
|---|
|  | 275 | tc_char(0x00);tc_char(0x00);    //  synchro | 
|---|
|  | 276 |  | 
|---|
|  | 277 | break; | 
|---|
|  | 278 |  | 
|---|
|  | 279 | case    tc_dir_reset_trp        :       //printf("tc_reset_epld:\n"); | 
|---|
|  | 280 |  | 
|---|
| [645] | 281 | for(j=0;j<15;j++) tc_char(j);   // reset epld+transputer | 
|---|
| [637] | 282 | tc_char(1);tc_char(1); | 
|---|
|  | 283 | tc_char(0x00);tc_char(0x00);    //  synchro | 
|---|
|  | 284 |  | 
|---|
|  | 285 | break; | 
|---|
|  | 286 |  | 
|---|
|  | 287 | default :       break; | 
|---|
|  | 288 | } | 
|---|
|  | 289 |  | 
|---|
|  | 290 |  | 
|---|
|  | 291 | //***************************************************************************************** | 
|---|
|  | 292 | #endif          //--------------------------------------------------------------------  *** | 
|---|
|  | 293 | //***************************************************************************************** | 
|---|
|  | 294 |  | 
|---|
|  | 295 | //  delai pour separer les télécommandes (archeops, transputer ou non) | 
|---|
| [649] | 296 | if(acquisition_PCI) delai(1000); | 
|---|
| [637] | 297 |  | 
|---|
|  | 298 | #endif          //--------------------------------------------------------------------  *** | 
|---|
|  | 299 |  | 
|---|
|  | 300 |  | 
|---|
|  | 301 | //***************************************************************************************** | 
|---|
|  | 302 | //                                                                                      *** | 
|---|
|  | 303 | #ifdef _diabolo         //---------   pour  Diabolo    ------------------------------   *** | 
|---|
|  | 304 | //                                                                                      *** | 
|---|
|  | 305 | //***************************************************************************************** | 
|---|
|  | 306 |  | 
|---|
|  | 307 | int q; | 
|---|
|  | 308 |  | 
|---|
|  | 309 | //      emission dans la table tc | 
|---|
|  | 310 | //      la commande elle même est dans mot[0..9] | 
|---|
|  | 311 | //      le parametre direction n'est pas utilisé | 
|---|
|  | 312 |  | 
|---|
|  | 313 | if(!litD(fenetre_acquisition,e_tache_inter,0L) )    // ecriture forcée  directe sur carte pci | 
|---|
|  | 314 | { | 
|---|
|  | 315 | for(j=0;j<5;j++)   printf("."); | 
|---|
|  | 316 | printf(" ecriture forcée des données \n"); | 
|---|
|  | 317 | for(j=0;j<10;j++)       ecrit_carte(mot[j]); | 
|---|
|  | 318 | son(1); | 
|---|
|  | 319 | } | 
|---|
|  | 320 |  | 
|---|
|  | 321 |  | 
|---|
|  | 322 | else    { | 
|---|
|  | 323 | tt->tc.btc[tt->tc.pos_ecrit]=*((block_tc*)tc); | 
|---|
|  | 324 | tt->tc.pos_ecrit++; if(tt->tc.pos_ecrit>=longueur_table_tc) tt->tc.pos_ecrit=0; | 
|---|
|  | 325 | q=tt->tc.pos_ecrit-tt->tc.pos_lit;      if (q<0) q+=longueur_table_tc; | 
|---|
|  | 326 |  | 
|---|
|  | 327 | //      printf(" liste de telecommande : %d chaines :",q); | 
|---|
|  | 328 | //      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]); | 
|---|
|  | 329 | //      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]); | 
|---|
|  | 330 | } | 
|---|
|  | 331 |  | 
|---|
|  | 332 |  | 
|---|
|  | 333 |  | 
|---|
|  | 334 | //***************************************************************************************** | 
|---|
|  | 335 | //                                                                                      *** | 
|---|
|  | 336 | #endif          //--------------------------------------------------------------------  *** | 
|---|
|  | 337 | //                                                                                      *** | 
|---|
|  | 338 | //***************************************************************************************** | 
|---|
|  | 339 |  | 
|---|
|  | 340 | } | 
|---|
|  | 341 |  | 
|---|
|  | 342 |  | 
|---|