[3757] | 1 | #ifndef RACQUETH_H_SEEN
|
---|
| 2 | #define RACQUETH_H_SEEN
|
---|
| 3 |
|
---|
| 4 | //----------------------------------------------------------------
|
---|
| 5 | // ---- classes de threads pour lecture/ecriture des paquets (transfert DMA)
|
---|
| 6 | // et ecriture disque pour acquisition BAORadio -----
|
---|
| 7 | // LAL - R. Ansari - Juin/Juillet 2008
|
---|
| 8 | //----------------------------------------------------------------
|
---|
| 9 |
|
---|
| 10 | #include "racqumem.h"
|
---|
| 11 | #include <string>
|
---|
| 12 | #include <vector>
|
---|
| 13 | #include <iostream>
|
---|
| 14 | #include "sopnamsp.h"
|
---|
| 15 | #include "zthread.h"
|
---|
| 16 | #include "pciewrap.h"
|
---|
| 17 | #include "swrapsock.h"
|
---|
| 18 | #include "brtypes.h"
|
---|
| 19 | #include "brpaqu.h"
|
---|
| 20 | #include "brparam.h"
|
---|
| 21 | #include "minifits.h"
|
---|
| 22 |
|
---|
| 23 | using namespace std;
|
---|
| 24 |
|
---|
| 25 | // Quelques definitions globales
|
---|
| 26 | // Nombre maximum de fibres geres par les classes PCIEToEthernet ...
|
---|
| 27 | // ATTENTION cette definition (MAXANAFIB) se trouve dans plusieurs fichiers
|
---|
| 28 | #ifndef MAXNBFIB
|
---|
| 29 | #define MAXNBFIB 16
|
---|
| 30 | #endif
|
---|
| 31 | // ATTENTION cette definition (MAXANAFIB) se trouve dans plusieurs fichiers
|
---|
| 32 | #ifndef MAXANAFIB
|
---|
| 33 | #define MAXANAFIB 32
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
| 36 | #ifndef BRSPORTID
|
---|
| 37 | #define BRSPORTID 6912
|
---|
| 38 | #endif
|
---|
| 39 | #ifndef BRTCPMSGLEN
|
---|
| 40 | #define BRTCPMSGLEN 128
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | //----------------------------------------------------------------------------------
|
---|
| 45 | // Classe thread de lecture PCI-Express et recopie sur interface reseau (Ethernet)
|
---|
| 46 | //----------------------------------------------------------------------------------
|
---|
| 47 |
|
---|
| 48 | class PCIEToEthernet : public ZThread {
|
---|
| 49 | public:
|
---|
| 50 | PCIEToEthernet(vector<PCIEWrapperInterface*> vec_pciw , vector<string>& destname, BRParList const& par, int portid=BRSPORTID);
|
---|
| 51 | virtual ~PCIEToEthernet();
|
---|
| 52 | virtual void run();
|
---|
| 53 | void Stop();
|
---|
| 54 | inline void STOP() { stop_ = true; }
|
---|
| 55 |
|
---|
| 56 | protected:
|
---|
[3758] | 57 | virtual size_t SendToTargets(int fib, Byte* data, size_t len);
|
---|
| 58 |
|
---|
[3757] | 59 | BRParList par_; // Parametres divers d'acquisition
|
---|
| 60 |
|
---|
| 61 | uint_8 nmaxpaq_; // Nombre maxi de paquets traites
|
---|
| 62 | BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
|
---|
| 63 | bool stop_;
|
---|
| 64 | unsigned int sizeFr_ ;
|
---|
| 65 | vector<PCIEWrapperInterface *> vec_pciw_;
|
---|
| 66 | vector<string> destname_;
|
---|
| 67 | int tcpportid_;
|
---|
| 68 | vector< vector<ClientSocket> > vvec_skt_;
|
---|
| 69 | uint_4 packSize_;
|
---|
| 70 | uint_4 packSizeInMgr_;
|
---|
| 71 | uint_4 nbDma_;
|
---|
[3758] | 72 | uint_8 totrdsnd_;
|
---|
[3757] | 73 |
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | //------------------------------------------------------------------
|
---|
| 77 | // Classe thread de lecture sur interface reseau (Ethernet)
|
---|
| 78 | //------------------------------------------------------------------
|
---|
| 79 | class EthernetReader : public ZThread {
|
---|
| 80 | public:
|
---|
| 81 | EthernetReader(RAcqMemZoneMgr& mem, BRParList const& par, int portid=BRSPORTID, bool rdsamefc=false);
|
---|
| 82 | virtual void run();
|
---|
| 83 | inline void Stop() { stop_ = true; }
|
---|
| 84 | inline void STOP() { stop_ = true; }
|
---|
| 85 |
|
---|
| 86 | inline int SetPrintLevel(int lev=0) { prtlev_=lev; return 0;}
|
---|
| 87 | protected:
|
---|
| 88 | bool ReadNextAllFibers(); // Renvoie true si probleme
|
---|
| 89 | bool ReadNext(int fib); // Renvoie true si probleme
|
---|
| 90 | // Permet d'avancer d'un paquet dans la zone - renvoie true si probleme
|
---|
| 91 | inline bool MoveToNextTarget() {
|
---|
| 92 | if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
|
---|
| 93 | if (MZoneManage()) return true;
|
---|
| 94 | targ_npaq_++;
|
---|
| 95 | return false;
|
---|
| 96 | }
|
---|
| 97 | inline Byte* GetPaquetTarget(int numfib) {
|
---|
| 98 | if ((mmbufib_[numfib] == NULL )||(targ_npaq_ > max_targ_npaq)||(targ_npaq_ == 0)) return NULL;
|
---|
| 99 | Byte* rb=mmbufib_[numfib]+(targ_npaq_-1)*packsize_;
|
---|
| 100 | return rb;
|
---|
| 101 | }
|
---|
| 102 | bool MZoneManage(bool clean=false); // Renvoie true si probleme
|
---|
| 103 |
|
---|
| 104 | RAcqMemZoneMgr& memgr_;
|
---|
| 105 | BRParList par_; // Parametres divers d'acquisition
|
---|
| 106 | int tcpportid_;
|
---|
| 107 | vector< Socket > vsok_; // Les sockets de lecture pour chaque fibre/lien
|
---|
| 108 | bool stop_;
|
---|
| 109 | bool rdsamefc_; // if true, read paquets with same value of FrameCounter on different fibers/link
|
---|
| 110 | uint_8 totnbytesrd_;
|
---|
| 111 | uint_8 totnpaqrd_;
|
---|
| 112 | uint_8 totsamefc_; // nombre total de paquets avec meme framecounter
|
---|
| 113 |
|
---|
| 114 | vector<BRPaquet> vpaq_;
|
---|
| 115 | vector<BRPaqChecker> vpchk_;
|
---|
| 116 | vector<uint_8> curfc_; // Numeros des FrameCounter des paquets courants
|
---|
| 117 | vector<uint_8> totnpqrd_; // nombre total de paquets lus / lien
|
---|
| 118 | vector<uint_8> totnpqok_; // nombre total de paquets OK / lien
|
---|
| 119 |
|
---|
| 120 | uint_4 packsize_;
|
---|
| 121 | int mid_; // Identificateur zone memoire
|
---|
| 122 | uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
|
---|
| 123 | uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
|
---|
| 124 | Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
|
---|
| 125 | Byte* mmbufib_[MAXANAFIB]; // Pointeurs zone memoire de chaque fibre rendu par RAcqMemZoneMgr
|
---|
| 126 |
|
---|
| 127 | int prtlev_;
|
---|
| 128 | };
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 | #endif
|
---|