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

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

Suite debug des classes PCIEToEthernet et EthernetReader , Reza 30/04/2010

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