| [637] | 1 | #include "manip.h"
 | 
|---|
 | 2 | #include "choix_acquisition.h"
 | 
|---|
 | 3 | #include "archeops.h"
 | 
|---|
 | 4 | #include "choix_param.h"
 | 
|---|
 | 5 | #include "structure.h"
 | 
|---|
 | 6 | #include "tm.h"
 | 
|---|
 | 7 | #include "tache.h"
 | 
|---|
 | 8 | #include "bolo.h"
 | 
|---|
 | 9 | #include "carte_acqui.h"
 | 
|---|
 | 10 | #include "carte_pci.h"
 | 
|---|
 | 11 | 
 | 
|---|
| [649] | 12 | #include "simulmission.h"
 | 
|---|
| [637] | 13 | 
 | 
|---|
 | 14 | //*****************************************************************************************
 | 
|---|
 | 15 | //                                                                                      ***
 | 
|---|
| [639] | 16 | #ifdef _archeopsXX              //---------   pour  Archeops    ----------------------- ***
 | 
|---|
| [637] | 17 | #ifndef _sans_transputer        //---------   pour  Archeops avec transputer    -------------   ***
 | 
|---|
 | 18 | //                                                                                      ***
 | 
|---|
 | 19 | //*****************************************************************************************
 | 
|---|
 | 20 | //
 | 
|---|
 | 21 | //
 | 
|---|
 | 22 | //   lit directement les blocks recut sur la fifo et les envoie au programme principal
 | 
|---|
 | 23 | //
 | 
|---|
 | 24 | //
 | 
|---|
 | 25 | 
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | //def_long_block
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | #define avance_erreur  {tt->te.pos_ecrit++; if(tt->te.pos_ecrit>=long_table_err) tt->te.pos_ecrit=0;}
 | 
|---|
 | 31 | #define ecrit_erreur(xx)        {avance_erreur;tt->te.err[tt->te.pos_ecrit]=900+(xx);}
 | 
|---|
 | 32 | void    sauve_un_block(tmtc* tt);
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | #define test_val(xx)    {if(octet_a_lire!=(xx)) {if(octet_a_lire==(debut_block_mesure&0xff)) tt->vi.a=1; else tt->vi.a=0;}}
 | 
|---|
 | 35 |         
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | //*****************************************************************************************
 | 
|---|
 | 38 | 
 | 
|---|
 | 39 | void init_tache(void)
 | 
|---|
 | 40 | {
 | 
|---|
 | 41 | tt->vi.a=0;
 | 
|---|
 | 42 | tt->vi.b=0;
 | 
|---|
 | 43 | tt->vi.c=0;
 | 
|---|
 | 44 | }
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | #define max_fifo  4000
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 | void lecture_fifo(void* tx)     // appellé directement pour acquisition en interruptions
 | 
|---|
 | 52 | {
 | 
|---|
 | 53 | register unsigned long RR;
 | 
|---|
 | 54 | tmtc* tt=(tmtc*)tx;
 | 
|---|
 | 55 | long lec_fifo=0;                //  compteur nombre de points lut en une fois dans la fifo
 | 
|---|
 | 56 | char*   t_char=(char*)(&tt->vi.btt);
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | if(tt->PCI_actif==2)    // simulation Archeops
 | 
|---|
 | 60 |         {
 | 
|---|
 | 61 |         static int numblock=0;
 | 
|---|
 | 62 |         tt->vi.a++;
 | 
|---|
 | 63 |         if(tt->vi.a>20) // ecrit un block toutes les 20 interruptions (soit 0.5 sec)
 | 
|---|
 | 64 |                 {
 | 
|---|
 | 65 |                 int i;
 | 
|---|
 | 66 |                 tt->vi.a=0;
 | 
|---|
 | 67 |                 numblock++;
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 |                 for(i=0;i<(taille_maxi_block_archeops/4);i++)   tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);   
 | 
|---|
 | 70 |                 valide_block(&tt->vi.btt,block_bolo,numblock);
 | 
|---|
 | 71 |                 sauve_un_block(tt);
 | 
|---|
 | 72 | 
 | 
|---|
 | 73 |                 for(i=0;i<(taille_maxi_block_archeops/4);i++)   tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);   
 | 
|---|
 | 74 |                 valide_block(&tt->vi.btt,block_une_periode,numblock);
 | 
|---|
 | 75 |                 sauve_un_block(tt);
 | 
|---|
 | 76 | 
 | 
|---|
 | 77 |                 for(i=0;i<(taille_maxi_block_archeops/4);i++)   tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);   
 | 
|---|
 | 78 |                 valide_block(&tt->vi.btt,block_dilution,numblock);
 | 
|---|
 | 79 |                 sauve_un_block(tt);
 | 
|---|
 | 80 |                 
 | 
|---|
 | 81 | //              if((numblock%5)==0)
 | 
|---|
 | 82 |                         {
 | 
|---|
 | 83 |                         for(i=0;i<(taille_maxi_block_archeops/4);i++)   tt->vi.btt.mot[i]=(int)((random(0)-0.5)*256.*256.*256.*256.);   
 | 
|---|
 | 84 |                         valide_block(&tt->vi.btt,block_sst,numblock);
 | 
|---|
 | 85 |                         sauve_un_block(tt);
 | 
|---|
 | 86 |                         }
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 |                 }
 | 
|---|
 | 89 |         }
 | 
|---|
| [649] | 90 | else if (tt->PCI_actif==3)      // simulation donnees mission
 | 
|---|
| [637] | 91 |         {
 | 
|---|
| [649] | 92 |                 // EA + JD
 | 
|---|
 | 93 |                 // Lecture d'un block depuis le simulateur
 | 
|---|
 | 94 |                 
 | 
|---|
 | 95 |                 if (SimulMissionBloc(tt)) {
 | 
|---|
 | 96 |                 
 | 
|---|
 | 97 |                   // Sauvegarde du bloc dans la file d'attente
 | 
|---|
 | 98 |                   sauve_un_block(tt);
 | 
|---|
 | 99 |                 }
 | 
|---|
 | 100 |         }
 | 
|---|
 | 101 | else    while(1)                //  case 1 et 4  
 | 
|---|
 | 102 |         {
 | 
|---|
| [637] | 103 |         lit_carte;      if(rien_a_lire)         break;                          //  fifo vide  ->  retour  ->  sort du while
 | 
|---|
 | 104 |         lec_fifo++;
 | 
|---|
 | 105 |         
 | 
|---|
 | 106 |         
 | 
|---|
 | 107 | //ecrit_erreur(err_sync_bebo);  
 | 
|---|
 | 108 | 
 | 
|---|
 | 109 |         
 | 
|---|
 | 110 |         if(tt->vi.b)     // ecrit les mots pour b=[1....(sizeof(block_tm_trx)/4)-2]
 | 
|---|
 | 111 |                 {
 | 
|---|
 | 112 |                 t_char[tt->vi.b*4+3-tt->vi.c]=octet_a_lire;     // dans l'ordre: 3 2 1 0 7 6 5 4 11 10 9 8 ...
 | 
|---|
 | 113 |                 
 | 
|---|
 | 114 |                 tt->vi.c++;
 | 
|---|
 | 115 |                 if(tt->vi.c>=4)                         //  c est le compteur de cara  
 | 
|---|
 | 116 |                         {
 | 
|---|
 | 117 | //                      ecrit_erreur(err_recut_un_block_ok);
 | 
|---|
 | 118 |                         tt->vi.c=0;
 | 
|---|
 | 119 |                         tt->vi.b++;                     //  b est le compteur de mot long de 4 octets
 | 
|---|
 | 120 |                         
 | 
|---|
 | 121 |                         if (tt->vi.b>=4)        // teste la longueur apres avoir lut 3 entiers long
 | 
|---|
 | 122 |                                 {
 | 
|---|
 | 123 |                                 int ll;
 | 
|---|
 | 124 |                                 ll=longueur_block(&tt->vi.btt);
 | 
|---|
 | 125 |                                 if(ll>sizeof(block_type_modele))  {tt->vi.a=0;tt->vi.b=0;ecrit_erreur(err_longueur_block);}
 | 
|---|
 | 126 | //                              if(ll>sizeof(block_type_gps))  {tt->vi.a=0;tt->vi.b=0;ecrit_erreur(err_lect_pci);}
 | 
|---|
 | 127 |                                 if( tt->vi.b > ((ll/4)-1) )      {tt->vi.b=0;}
 | 
|---|
 | 128 |                                 }
 | 
|---|
 | 129 |                         }  
 | 
|---|
 | 130 |                 }
 | 
|---|
 | 131 | 
 | 
|---|
 | 132 |         if(!tt->vi.b)    // test et cherche debut
 | 
|---|
 | 133 |                 {
 | 
|---|
 | 134 |                 tt->vi.a++;
 | 
|---|
 | 135 | //              ecrit_erreur(err_lect_pci);                     
 | 
|---|
 | 136 |                 switch(tt->vi.a)
 | 
|---|
 | 137 |                         {
 | 
|---|
 | 138 |                         case 1  :       test_val(debut_block_mesure&0xff);              break;
 | 
|---|
 | 139 |                         case 2  :       test_val((debut_block_mesure>>8)&0xff);         break;
 | 
|---|
 | 140 |                         case 3  :       test_val((debut_block_mesure>>16)&0xff);        break;
 | 
|---|
 | 141 |                         case 4  :               
 | 
|---|
 | 142 |                                         if(octet_a_lire!=((debut_block_mesure>>24)&0xff)) tt->vi.a=0;
 | 
|---|
 | 143 |                                         else    {
 | 
|---|
 | 144 |                                                 tt->vi.c=0;             //  pret pour la lecture de la suite du block
 | 
|---|
 | 145 |                                                 tt->vi.b=1;             //  déja lut debut du block: commence par mot b=1;
 | 
|---|
 | 146 |                                                 }
 | 
|---|
 | 147 |                                          break; 
 | 
|---|
 | 148 |                                          
 | 
|---|
 | 149 |                         case 5  :       
 | 
|---|
 | 150 | //                                      ecrit_erreur(err_recut_un_block_ok);
 | 
|---|
 | 151 |                                         sauve_un_block(tt);     //  le code de debut n'a pas été ecrit dans le block
 | 
|---|
 | 152 |                         default :       tt->vi.a=0;break;
 | 
|---|
 | 153 |                         }
 | 
|---|
 | 154 |                 }
 | 
|---|
 | 155 |         
 | 
|---|
 | 156 |         if(lec_fifo>max_fifo) break;
 | 
|---|
 | 157 |         }
 | 
|---|
 | 158 | if(lec_fifo > tt->nb_lec_fofo_int)      tt->nb_lec_fofo_int=lec_fifo;
 | 
|---|
| [649] | 159 | if(!tt->val_con_fifo)           {tt->val_con_fifo=tt->nb_lec_fofo_int;tt->nb_lec_fofo_int=0;}
 | 
|---|
| [637] | 160 | 
 | 
|---|
 | 161 | }
 | 
|---|
 | 162 | 
 | 
|---|
 | 163 | 
 | 
|---|
 | 164 | 
 | 
|---|
 | 165 | //______________________________________________________________________________________________//
 | 
|---|
 | 166 | //   lit le block brut tel que recut par telemesure dans  tt->vi.btt                            //
 | 
|---|
 | 167 | //      ce block contient  ??  periodes de mesure                                               // 
 | 
|---|
 | 168 | //      Je rempli un block tm  en position      u=tt->tm.pos_ecrit                              //
 | 
|---|
 | 169 | //      Le block s'ecrit:                       tt->tm.btm[u]                                   //
 | 
|---|
 | 170 | //______________________________________________________________________________________________//
 | 
|---|
 | 171 | 
 | 
|---|
 | 172 | 
 | 
|---|
 | 173 | 
 | 
|---|
 | 174 | void    sauve_un_block(tmtc* tt)
 | 
|---|
 | 175 | {
 | 
|---|
 | 176 | int u;
 | 
|---|
 | 177 | u=tt->tm.pos_ecrit;
 | 
|---|
 | 178 | //  le code de debut n'a pas été ecrit dans le block : il faut l'ecrire
 | 
|---|
 | 179 | tt->vi.btt.debut=debut_block_mesure;
 | 
|---|
 | 180 | tt->tm.btm[u].tmtrx=tt->vi.btt; // recopie le block courant dans la table
 | 
|---|
 | 181 | u++; if(u>=longueur_table_tm) u=0;
 | 
|---|
 | 182 | tt->tm.pos_ecrit=u;
 | 
|---|
 | 183 | 
 | 
|---|
 | 184 | if(tt->tm.pos_ecrit==tt->tm.pos_lit)  ecrit_erreur(err_pile_pleine);
 | 
|---|
 | 185 | }
 | 
|---|
 | 186 | 
 | 
|---|
 | 187 | //*****************************************************************************************
 | 
|---|
 | 188 | //                                                                                      ***
 | 
|---|
 | 189 | #endif          //--------------------------------------------------------------------  ***
 | 
|---|
 | 190 | #endif          //--------------------------------------------------------------------  ***
 | 
|---|
 | 191 | //                                                                                      ***
 | 
|---|
 | 192 | //*****************************************************************************************
 | 
|---|
 | 193 | 
 | 
|---|
 | 194 | 
 | 
|---|
 | 195 | 
 | 
|---|
 | 196 | 
 | 
|---|