1 | #ifndef PCIEWRAP_H_SEEN
|
---|
2 | #define PCIEWRAP_H_SEEN
|
---|
3 | #include "brtypes.h"
|
---|
4 | #include "machdefs.h"
|
---|
5 | #include "racqumem.h"
|
---|
6 | #include "brpaqu.h"
|
---|
7 | #include <string>
|
---|
8 | #include "randr48.h" // Generateur aleatoire SOPHYA pour simulation perte de paquets
|
---|
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; }
|
---|
22 | virtual ~PCIEWException() { }
|
---|
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 |
|
---|
30 | // Classe definissant l'interface des operations transfert DMA/PCIExpress
|
---|
31 | class PCIEWrapperInterface {
|
---|
32 | public:
|
---|
33 | // Constructeur - fait l'initialisation
|
---|
34 | PCIEWrapperInterface();
|
---|
35 | // destructeur - libere la memoire allouee
|
---|
36 | virtual ~PCIEWrapperInterface();
|
---|
37 |
|
---|
38 | virtual UInt32 TransferSize() = 0;
|
---|
39 | virtual void StartTransfers() { return; };
|
---|
40 | virtual Byte* GetData() = 0;
|
---|
41 | virtual UInt64 TotTransferBytes() = 0;
|
---|
42 | virtual void PrintStatus(ostream& os) = 0;
|
---|
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
|
---|
55 | };
|
---|
56 |
|
---|
57 | // Classe de test Implementant l'interface PCIEWrapper sans DMA
|
---|
58 | class TestPCIWrapperNODMA : public PCIEWrapperInterface {
|
---|
59 | public:
|
---|
60 | // lossrate_=partie_fractionnaire[lossrate], max_frcount_=partie entiere[lossrate]
|
---|
61 | TestPCIWrapperNODMA(UInt32 sz, double lossrate=0.);
|
---|
62 | virtual ~TestPCIWrapperNODMA();
|
---|
63 |
|
---|
64 | virtual UInt32 TransferSize() ;
|
---|
65 | virtual Byte* GetData() ;
|
---|
66 | virtual UInt64 TotTransferBytes() ;
|
---|
67 | virtual void PrintStatus(ostream& os) ;
|
---|
68 |
|
---|
69 | protected:
|
---|
70 | Byte* data_;
|
---|
71 | Byte* srcdata_;
|
---|
72 | UInt32 size_;
|
---|
73 | UInt32 frame_counter_;
|
---|
74 | UInt64 timetag_;
|
---|
75 | UInt64 tottransfer_;
|
---|
76 | double lossrate_;
|
---|
77 | UInt32 max_frcount_;
|
---|
78 | BRPaqChecker pchk_;
|
---|
79 | // FMTRandGen rg_;
|
---|
80 | SOPHYA::ThSDR48RandGen rg_;
|
---|
81 | };
|
---|
82 |
|
---|
83 | #endif
|
---|