| 1 | #ifndef  BRBASEPROC_H_SEEN
 | 
|---|
| 2 | #define  BRBASEPROC_H_SEEN
 | 
|---|
| 3 | 
 | 
|---|
| 4 | //----------------------------------------------------------------
 | 
|---|
| 5 | // Projet BAORadio - (C) LAL/IRFU  2008-2011
 | 
|---|
| 6 | // Classes de threads de traitememt donnees BAORadio 
 | 
|---|
| 7 | //----------------------------------------------------------------
 | 
|---|
| 8 | 
 | 
|---|
| 9 | 
 | 
|---|
| 10 | #include "racqumem.h"
 | 
|---|
| 11 | #include <string>
 | 
|---|
| 12 | #include <vector>
 | 
|---|
| 13 | #include <iostream>
 | 
|---|
| 14 | 
 | 
|---|
| 15 | #include "brpaqu.h"
 | 
|---|
| 16 | #include "timestamp.h"  // include SOPHYA
 | 
|---|
| 17 | 
 | 
|---|
| 18 | using namespace std;
 | 
|---|
| 19 | 
 | 
|---|
| 20 | //---------------------------------------------------------------------
 | 
|---|
| 21 | // Classe de base pour l'analyse donnees (paquets acquisition) BAORadio 
 | 
|---|
| 22 | // Les classes de traitement des paquets BAORadio peuvent heriter de 
 | 
|---|
| 23 | // cette classe de base BRBaseProcessor en redefinissant la methode Process()
 | 
|---|
| 24 | //---------------------------------------------------------------------
 | 
|---|
| 25 | class BRBaseProcessor : public SOPHYA::ZThread {
 | 
|---|
| 26 | public: 
 | 
|---|
| 27 |   BRBaseProcessor(RAcqMemZoneMgr& memgr, MemZaction mmact=MemZA_ProcA);
 | 
|---|
| 28 |   
 | 
|---|
| 29 |   MemZStatus SetMemZAction(MemZaction mmact=MemZA_ProcA);
 | 
|---|
| 30 | 
 | 
|---|
| 31 |   virtual void run();
 | 
|---|
| 32 | 
 | 
|---|
| 33 |   inline void Stop() { stop_ = true; }  
 | 
|---|
| 34 |   inline void STOP() { stop_ = true; }  
 | 
|---|
| 35 | 
 | 
|---|
| 36 |   inline void setNameId(const char* nom, int id) 
 | 
|---|
| 37 |   { bpnom_=nom;   bpid_=id;  }
 | 
|---|
| 38 |   inline void setNameId(string const& nom, int id) 
 | 
|---|
| 39 |   { bpnom_=nom;   bpid_=id;  }
 | 
|---|
| 40 | 
 | 
|---|
| 41 |   // get Observation Time ( obtained from MemZoneMgr )
 | 
|---|
| 42 |   inline SOPHYA::TimeStamp& getObsTime()  { return cts_; }
 | 
|---|
| 43 |   // Attention : les methodes suivantes ne sont pas protegees pour le numero de fibre
 | 
|---|
| 44 |   // Renvoie le numero de frame-counter courant - si fgz=true, soustrait le FC du premier paquet 
 | 
|---|
| 45 |   inline uint_8 getCurFrameCounter(size_t fib=0, bool fgz=true) 
 | 
|---|
| 46 |   { if (fgz) return (curfc_[fib]-fcfirst_[fib]) ;  else return curfc_[fib]; }
 | 
|---|
| 47 |   // Renvoie le TimeTag courant (unite coups d'horloge) - si fgz=true, soustrait le TT du premier paquet 
 | 
|---|
| 48 |   inline uint_8 getCurTimeTag(size_t fib=0, bool fgz=true) 
 | 
|---|
| 49 |   { if (fgz) return (vpaq_[fib].TimeTag()-ttfirst_[fib]) ;  else return vpaq_[fib].TimeTag(); }
 | 
|---|
| 50 |   // Renvoie le TimeTag courant converti en secondes  - si fgz=true, soustrait le TT du premier paquet 
 | 
|---|
| 51 |   inline double getCurTimeTagSeconds(size_t fib=0, bool fgz=true) 
 | 
|---|
| 52 |   { 
 | 
|---|
| 53 |     if (fgz) return ((double)(vpaq_[fib].TimeTag()-ttfirst_[fib])/1.25e8) ;  
 | 
|---|
| 54 |     else return ((double)vpaq_[fib].TimeTag()/1.25e8); 
 | 
|---|
| 55 |   }
 | 
|---|
| 56 |   //---- niveau d'impression 
 | 
|---|
| 57 |   inline void SetPrintLevel(int lev=0, uint_8 prtmodulo=10) 
 | 
|---|
| 58 |     { prtlev_=lev;   prtmodulo_=prtmodulo;}
 | 
|---|
| 59 | 
 | 
|---|
| 60 | protected:
 | 
|---|
| 61 |   // Methode devant etre redefinie pour effectuer le traitement - appele pour chaque trigger  
 | 
|---|
| 62 |   virtual int Process();  // renvoie 0 si OK, sinon, arret traitement 
 | 
|---|
| 63 | 
 | 
|---|
| 64 |   RAcqMemZoneMgr& memgr_;
 | 
|---|
| 65 |   MemZaction mmact_;    // Definition de l'action sur les paquets (defaut=MemZA_ProcA)
 | 
|---|
| 66 |   MemZStatus mmsta_;    // Statut associe a mmact_ (defaut=MemZS_ProcA)
 | 
|---|
| 67 |   bool stop_;
 | 
|---|
| 68 |   vector<Byte*> fbuff_;      // Vecteur de pointeur de zone memoire pour chaque fibre 
 | 
|---|
| 69 |   vector<Byte*> fprocbuff_;   // Vecteur de pointeur de proc_zone_mem pour chaque fibre 
 | 
|---|
| 70 |   vector<BRPaquet> vpaq_;   // Vecteur de BRPaquet pour chaque fibre
 | 
|---|
| 71 |   vector<Byte*> vprocpaq_;  // Vecteur de pointeur de zone memoire pour donnees traitees de chaque paquet/fibre 
 | 
|---|
| 72 |   vector<BRPaqChecker> vpchk_;
 | 
|---|
| 73 |   vector<uint_8> vfgok_;    // Vecteur de flag si paquet OK pour chaque fibre
 | 
|---|
| 74 |   vector<uint_8> curfc_;    // Vecteur de numero de FrameCounter pour chaque fibre
 | 
|---|
| 75 |   vector<uint_8> fcfirst_;  // numero du FrameCounter pour le premier paquet 
 | 
|---|
| 76 |   vector<uint_8> ttfirst_;  // TimeTag pour le premier paquet 
 | 
|---|
| 77 |   bool fgokallfibers_;      // true -> paquets for all fibers OK
 | 
|---|
| 78 |   
 | 
|---|
| 79 |   uint_8 totprocnpaq_; 
 | 
|---|
| 80 |   SOPHYA::TimeStamp cts_;   // current time stamp, get from MemZoneMgr
 | 
|---|
| 81 | 
 | 
|---|
| 82 |   string bpnom_;    // nom du processeur
 | 
|---|
| 83 |   int bpid_;        // numero d'identificateur 
 | 
|---|
| 84 | 
 | 
|---|
| 85 |   int prtlev_;    // print level 
 | 
|---|
| 86 |   uint_8 prtmodulo_;   // print periodicity (modulo) 
 | 
|---|
| 87 | };
 | 
|---|
| 88 | 
 | 
|---|
| 89 | 
 | 
|---|
| 90 | 
 | 
|---|
| 91 | #endif
 | 
|---|