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