| [3537] | 1 | #ifndef  PCIEWRAP_H_SEEN
 | 
|---|
 | 2 | #define  PCIEWRAP_H_SEEN
 | 
|---|
| [3623] | 3 | #include "brtypes.h"
 | 
|---|
| [3537] | 4 | #include "machdefs.h"
 | 
|---|
| [3623] | 5 | #include "racqumem.h"
 | 
|---|
 | 6 | #include "brpaqu.h"
 | 
|---|
| [3537] | 7 | #include <string>
 | 
|---|
| [3645] | 8 | #include "randr48.h"  // Generateur aleatoire SOPHYA pour simulation perte de paquets
 | 
|---|
| [3537] | 9 | 
 | 
|---|
 | 10 | /* 
 | 
|---|
 | 11 |    Classe interface aux fonctions d'I/O PCIExpress 
 | 
|---|
 | 12 |    pour la carte de reception optique BAORadio
 | 
|---|
 | 13 |    R. Ansari                        Juin 2008
 | 
|---|
 | 14 | */
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | using namespace std;
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | class PCIEWException {
 | 
|---|
 | 19 |   public:
 | 
|---|
 | 20 |   explicit PCIEWException(const char * m) { msg = m; }
 | 
|---|
 | 21 |   explicit PCIEWException(const string& m) { msg = m; }
 | 
|---|
| [3623] | 22 |   virtual ~PCIEWException() { }
 | 
|---|
| [3537] | 23 |   virtual string const& Msg() const  {return msg;}
 | 
|---|
 | 24 |   virtual const char* what() {return msg.c_str(); }
 | 
|---|
 | 25 |  private:
 | 
|---|
 | 26 |   string msg;
 | 
|---|
 | 27 | };
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | 
 | 
|---|
| [3623] | 30 | // Classe definissant l'interface des operations transfert DMA/PCIExpress 
 | 
|---|
| [3628] | 31 | class PCIEWrapperInterface {
 | 
|---|
| [3623] | 32 |  public:
 | 
|---|
 | 33 |   // Constructeur - fait l'initialisation
 | 
|---|
| [3909] | 34 |   PCIEWrapperInterface();
 | 
|---|
| [3623] | 35 |   // destructeur - libere la memoire allouee
 | 
|---|
| [3909] | 36 |   virtual ~PCIEWrapperInterface();
 | 
|---|
| [3537] | 37 | 
 | 
|---|
| [3623] | 38 |   virtual UInt32 TransferSize() = 0;
 | 
|---|
| [3643] | 39 |   virtual void   StartTransfers() { return; };
 | 
|---|
 | 40 |   virtual Byte*  GetData() = 0;
 | 
|---|
| [3623] | 41 |   virtual UInt64 TotTransferBytes() = 0;    
 | 
|---|
 | 42 |   virtual void PrintStatus(ostream& os) = 0;
 | 
|---|
| [3909] | 43 |   // Identification de fibres / voies 
 | 
|---|
 | 44 |   inline void SetFiberNumId(int fibnum=1, int fibid=1)
 | 
|---|
 | 45 |   { fiber_num_=fibnum;  fiber_id_=fibid; }
 | 
|---|
 | 46 |   inline int FiberNum() { return fiber_num_; }
 | 
|---|
 | 47 |   inline int FiberId() { return fiber_id_; }
 | 
|---|
 | 48 |   // Parametre de controle de la boucle d'attente de fin de DMA (en unite de 1000 pour maxkwedma)
 | 
|---|
 | 49 |   virtual unsigned long SetMaxWaitEndDMA(unsigned int maxkwedma=1000, unsigned int nretry=3);
 | 
|---|
 | 50 | protected:
 | 
|---|
 | 51 |   unsigned long maxwaitenddmaloop_;  // Nombre d'iterations de la boucle d'attente de fin de DMA
 | 
|---|
 | 52 |   unsigned int maxretryenddma_;      // nombre maxi de tentatives pour terminer le DMA 
 | 
|---|
 | 53 |   int fiber_num_;                    // numero de fibre sur la machine
 | 
|---|
 | 54 |   int fiber_id_;                     // identificateur de fibre - numero absolu sur l'ensemble des machines
 | 
|---|
| [3623] | 55 | };
 | 
|---|
| [3537] | 56 | 
 | 
|---|
| [3623] | 57 | // Classe de test Implementant l'interface PCIEWrapper sans DMA 
 | 
|---|
| [3628] | 58 | class TestPCIWrapperNODMA : public PCIEWrapperInterface {
 | 
|---|
| [3623] | 59 | public: 
 | 
|---|
| [3909] | 60 |   // lossrate_=partie_fractionnaire[lossrate], max_frcount_=partie entiere[lossrate]  
 | 
|---|
| [3645] | 61 |   TestPCIWrapperNODMA(UInt32 sz, double lossrate=0.);
 | 
|---|
| [3623] | 62 |   virtual ~TestPCIWrapperNODMA();
 | 
|---|
 | 63 | 
 | 
|---|
 | 64 |   virtual UInt32 TransferSize() ;
 | 
|---|
| [3643] | 65 |   virtual Byte*  GetData() ;
 | 
|---|
| [3623] | 66 |   virtual UInt64 TotTransferBytes() ;    
 | 
|---|
 | 67 |   virtual void PrintStatus(ostream& os) ;
 | 
|---|
 | 68 |   
 | 
|---|
 | 69 | protected:
 | 
|---|
 | 70 |   Byte* data_;
 | 
|---|
| [3631] | 71 |   Byte* srcdata_;
 | 
|---|
| [3623] | 72 |   UInt32 size_;
 | 
|---|
 | 73 |   UInt32 frame_counter_;
 | 
|---|
 | 74 |   UInt64 timetag_;      
 | 
|---|
 | 75 |   UInt64 tottransfer_;
 | 
|---|
| [3645] | 76 |   double lossrate_;
 | 
|---|
| [3909] | 77 |   UInt32 max_frcount_; 
 | 
|---|
| [3623] | 78 |   BRPaqChecker pchk_;
 | 
|---|
| [3645] | 79 | //  FMTRandGen rg_;
 | 
|---|
| [3683] | 80 |   SOPHYA::ThSDR48RandGen rg_;
 | 
|---|
| [3537] | 81 | };
 | 
|---|
 | 82 | 
 | 
|---|
 | 83 | #endif
 | 
|---|