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 | /*!
|
---|
19 | \class PCIEWException
|
---|
20 | \ingroup TAcq
|
---|
21 |
|
---|
22 | \brief exception class for PCI-express operations.
|
---|
23 | */
|
---|
24 |
|
---|
25 | class PCIEWException {
|
---|
26 | public:
|
---|
27 | explicit PCIEWException(const char * m) { msg = m; }
|
---|
28 | explicit PCIEWException(const string& m) { msg = m; }
|
---|
29 | virtual ~PCIEWException() { }
|
---|
30 | virtual string const& Msg() const {return msg;}
|
---|
31 | virtual const char* what() {return msg.c_str(); }
|
---|
32 | private:
|
---|
33 | string msg;
|
---|
34 | };
|
---|
35 |
|
---|
36 |
|
---|
37 | // Classe definissant l'interface des operations transfert DMA/PCIExpress
|
---|
38 | class PCIEWrapperInterface {
|
---|
39 | public:
|
---|
40 | // Constructeur - fait l'initialisation
|
---|
41 | PCIEWrapperInterface();
|
---|
42 | // destructeur - libere la memoire allouee
|
---|
43 | virtual ~PCIEWrapperInterface();
|
---|
44 |
|
---|
45 | virtual UInt32 TransferSize() = 0;
|
---|
46 | virtual void StartTransfers() { return; };
|
---|
47 | virtual Byte* GetData() = 0;
|
---|
48 | virtual UInt64 TotTransferBytes() = 0;
|
---|
49 | virtual void PrintStatus(ostream& os) = 0;
|
---|
50 | // Identification de fibres / voies
|
---|
51 | inline void SetFiberNumId(int fibnum=1, int fibid=1)
|
---|
52 | { fiber_num_=fibnum; fiber_id_=fibid; }
|
---|
53 | inline int FiberNum() { return fiber_num_; }
|
---|
54 | inline int FiberId() { return fiber_id_; }
|
---|
55 | // Parametre de controle de la boucle d'attente de fin de DMA (en unite de 1000 pour maxkwedma)
|
---|
56 | virtual unsigned long SetMaxWaitEndDMA(unsigned int maxkwedma=1000, unsigned int nretry=3);
|
---|
57 | protected:
|
---|
58 | unsigned long maxwaitenddmaloop_; // Nombre d'iterations de la boucle d'attente de fin de DMA
|
---|
59 | unsigned int maxretryenddma_; // nombre maxi de tentatives pour terminer le DMA
|
---|
60 | int fiber_num_; // numero de fibre sur la machine
|
---|
61 | int fiber_id_; // identificateur de fibre - numero absolu sur l'ensemble des machines
|
---|
62 | };
|
---|
63 |
|
---|
64 | // Classe de test Implementant l'interface PCIEWrapper sans DMA
|
---|
65 | class TestPCIWrapperNODMA : public PCIEWrapperInterface {
|
---|
66 | public:
|
---|
67 | // lossrate_=partie_fractionnaire[lossrate], max_frcount_=partie entiere[lossrate]
|
---|
68 | TestPCIWrapperNODMA(UInt32 sz, double lossrate=0.);
|
---|
69 | virtual ~TestPCIWrapperNODMA();
|
---|
70 |
|
---|
71 | virtual UInt32 TransferSize() ;
|
---|
72 | virtual Byte* GetData() ;
|
---|
73 | virtual UInt64 TotTransferBytes() ;
|
---|
74 | virtual void PrintStatus(ostream& os) ;
|
---|
75 |
|
---|
76 | protected:
|
---|
77 | Byte* data_;
|
---|
78 | Byte* srcdata_;
|
---|
79 | UInt32 size_;
|
---|
80 | UInt32 frame_counter_;
|
---|
81 | UInt64 timetag_;
|
---|
82 | UInt64 tottransfer_;
|
---|
83 | double lossrate_;
|
---|
84 | UInt32 max_frcount_;
|
---|
85 | BRPaqChecker pchk_;
|
---|
86 | // FMTRandGen rg_;
|
---|
87 | SOPHYA::ThSDR48RandGen rg_;
|
---|
88 | };
|
---|
89 |
|
---|
90 | #endif
|
---|