source: Sophya/trunk/AddOn/TAcq/racqueth.h@ 3757

Last change on this file since 3757 was 3757, checked in by ansari, 15 years ago

Ajout classes de transfert DMA vers Ethernet et lecture ethernet, Reza 29/04/2010

File size: 4.3 KB
Line 
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
23using 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
48class PCIEToEthernet : public ZThread {
49public:
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
56protected:
57 BRParList par_; // Parametres divers d'acquisition
58
59 uint_8 nmaxpaq_; // Nombre maxi de paquets traites
60 BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
61 bool stop_;
62 unsigned int sizeFr_ ;
63 vector<PCIEWrapperInterface *> vec_pciw_;
64 vector<string> destname_;
65 int tcpportid_;
66 vector< vector<ClientSocket> > vvec_skt_;
67 uint_4 packSize_;
68 uint_4 packSizeInMgr_;
69 uint_4 nbDma_;
70
71};
72
73//------------------------------------------------------------------
74// Classe thread de lecture sur interface reseau (Ethernet)
75//------------------------------------------------------------------
76class EthernetReader : public ZThread {
77public:
78 EthernetReader(RAcqMemZoneMgr& mem, BRParList const& par, int portid=BRSPORTID, bool rdsamefc=false);
79 virtual void run();
80 inline void Stop() { stop_ = true; }
81 inline void STOP() { stop_ = true; }
82
83 inline int SetPrintLevel(int lev=0) { prtlev_=lev; return 0;}
84protected:
85 bool ReadNextAllFibers(); // Renvoie true si probleme
86 bool ReadNext(int fib); // Renvoie true si probleme
87 // Permet d'avancer d'un paquet dans la zone - renvoie true si probleme
88 inline bool MoveToNextTarget() {
89 if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
90 if (MZoneManage()) return true;
91 targ_npaq_++;
92 return false;
93 }
94 inline Byte* GetPaquetTarget(int numfib) {
95 if ((mmbufib_[numfib] == NULL )||(targ_npaq_ > max_targ_npaq)||(targ_npaq_ == 0)) return NULL;
96 Byte* rb=mmbufib_[numfib]+(targ_npaq_-1)*packsize_;
97 return rb;
98 }
99 bool MZoneManage(bool clean=false); // Renvoie true si probleme
100
101 RAcqMemZoneMgr& memgr_;
102 BRParList par_; // Parametres divers d'acquisition
103 int tcpportid_;
104 vector< Socket > vsok_; // Les sockets de lecture pour chaque fibre/lien
105 bool stop_;
106 bool rdsamefc_; // if true, read paquets with same value of FrameCounter on different fibers/link
107 uint_8 totnbytesrd_;
108 uint_8 totnpaqrd_;
109 uint_8 totsamefc_; // nombre total de paquets avec meme framecounter
110
111 vector<BRPaquet> vpaq_;
112 vector<BRPaqChecker> vpchk_;
113 vector<uint_8> curfc_; // Numeros des FrameCounter des paquets courants
114 vector<uint_8> totnpqrd_; // nombre total de paquets lus / lien
115 vector<uint_8> totnpqok_; // nombre total de paquets OK / lien
116
117 uint_4 packsize_;
118 int mid_; // Identificateur zone memoire
119 uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
120 uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
121 Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
122 Byte* mmbufib_[MAXANAFIB]; // Pointeurs zone memoire de chaque fibre rendu par RAcqMemZoneMgr
123
124 int prtlev_;
125};
126
127
128
129#endif
Note: See TracBrowser for help on using the repository browser.