source: Sophya/trunk/AddOn/TAcq/racqurw.h@ 3658

Last change on this file since 3658 was 3658, checked in by ansari, 16 years ago

1/ Gestion multi-fibre ds RAcqMemZoneMgr et les DMAReader/DiskWriter (brproc.cc)
2/ Possibilite d'ajout de mot cle ds l'entete FITS par la classe MiniFITSFile

Reza , 18/10/2009

File size: 6.2 KB
RevLine 
[3537]1#ifndef RACQURW_H_SEEN
2#define RACQURW_H_SEEN
3
4//----------------------------------------------------------------
5// ---- classes de threads pour lecture (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"
[3623]16#include "pciewrap.h"
[3537]17
18#include "brtypes.h"
[3623]19#include "brpaqu.h"
[3537]20
21using namespace std;
22
23
[3658]24// Quelques definitions globales
25// Nombre maximum de fibres geres par les classes MultiReader / MultiDiskWriter
26#define MAXNBFIB 4
[3537]27
28//-------------------------------------------------------
29// Classe thread de lecture PCI-Express
30//-------------------------------------------------------
31
32class PCIEReader : public ZThread {
33public:
[3628]34 PCIEReader( PCIEWrapperInterface &pciw , uint_4 sizeFrame,uint_4 paqSize ,RAcqMemZoneMgr& mem,
[3623]35 uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
[3537]36 virtual void run();
[3623]37 void Stop();
[3537]38 inline void STOP() { stop_ = true; }
[3623]39
[3537]40protected:
[3623]41 // Pour recuperer un pointeur sur la prochaine zone memoire devant recevoir un paquet
42 inline Byte* NextPaqTarget() {
43 if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
44 if (MZoneManage()) return NULL;
45 Byte* rb=mmbuf_+targ_npaq_*packSize_;
46 targ_npaq_++;
47 return rb;
48 }
49 bool MZoneManage(bool clean=false); // Renvoie true si probleme
50
[3537]51 RAcqMemZoneMgr& memgr;
52 uint_4 nmax_; // Nombre maxi de blocs MemZone traites
[3623]53 BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
[3537]54 bool stop_;
[3623]55 unsigned int sizeFr_ ;
[3628]56 PCIEWrapperInterface& pciw_;
[3623]57 uint_4 packSize_;
58 // Variables pour gerer la logique de NextPaqTarget() qui cache l'acces a RAcqMemZoneMgr
59 int mid_; // Identificateur zone memoire
60 uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
61 uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
62 Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
[3537]63};
64
65//-------------------------------------------------------
66// Classe thread de sauvegarde sur fichiers
67//-------------------------------------------------------
68
69class DataSaver : public ZThread {
70public:
[3623]71 DataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true);
72
[3537]73 virtual void run();
[3623]74 void Stop();
[3537]75 inline void STOP() { stop_ = true; }
76protected:
77 RAcqMemZoneMgr& memgr;
[3623]78 uint_4 nfiles_; // Nombre maxi de fichiers cree
79 uint_4 nblocperfile_; // Nombre de bloc (zone memoire) mis dans un fichier
80 uint_4 nmax_; // Nombre maxi de blocs MemZone traites = nfiles * nblocperfile_
81 bool savesig_; // Si false, pas d'ecriture des fichiers FITS du signal
[3537]82 bool stop_;
83 string path_;
[3623]84 struct sigaction act;
85
[3537]86};
87
[3623]88//-------------------------------------------------------
89// Classe thread de lecture PCI-Express + Check
90//-------------------------------------------------------
[3537]91
[3623]92class PCIEReaderChecker : public ZThread {
93public:
[3658]94 PCIEReaderChecker( PCIEWrapperInterface &pciw , uint_4 sizeFrame,uint_4 paqSize, RAcqMemZoneMgr& mem,
[3623]95 uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
96 virtual void run();
97 void Stop();
98 inline void STOP() { stop_ = true; }
99protected:
100 RAcqMemZoneMgr& memgr;
101 uint_4 nmax_; // Nombre maxi de blocs MemZone traites
102 BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
103 bool stop_;
104 unsigned int sizeFr_ ;
[3628]105 PCIEWrapperInterface& pciw_;
[3623]106 uint_4 packSize_;
107};
[3658]108//------------------------------------------------------------------
109// Classe thread de lecture PCI-Express multi fibre (ou multi DMA)
110//------------------------------------------------------------------
[3623]111
[3658]112class PCIEMultiReader : public ZThread {
113public:
114 PCIEMultiReader( vector<PCIEWrapperInterface*> vec_pciw , uint_4 sizeFrame,uint_4 paqSize, RAcqMemZoneMgr& mem,
115 uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll,int binMin=0, int nbBin=0);
116 virtual void run();
117 void Stop();
118 inline void STOP() { stop_ = true; }
119
120protected:
121 // Permet d'avancer d'un paquet dans la zone - renvoie true si probleme
122 inline bool MoveToNextTarget() {
123 if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
124 if (MZoneManage()) return true;
125 targ_npaq_++;
126 return false;
127 }
128 inline Byte* GetPaquetTarget(int numfib) {
129 if ((mmbufib_[numfib] == NULL )||(targ_npaq_ > max_targ_npaq)||(targ_npaq_ == 0)) return NULL;
130 Byte* rb=mmbufib_[numfib]+(targ_npaq_-1)*packSizeInMgr_;
131 return rb;
132 }
133 bool MZoneManage(bool clean=false); // Renvoie true si probleme
134
135 RAcqMemZoneMgr& memgr;
136 uint_4 nmax_; // Nombre maxi de blocs MemZone traites
137 BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
138 bool stop_;
139 unsigned int sizeFr_ ;
140 vector<PCIEWrapperInterface *> vec_pciw_;
141 uint_4 packSize_;
142 uint_4 packSizeInMgr_;
143 uint_4 nbDma_;
144 int nbBin_;
145 int binMin_;
146 int mid_; // Identificateur zone memoire
147 uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
148 uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
149 Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
150 Byte* mmbufib_[MAXNBFIB]; // Pointeurs zone memoire de chaque fibre rendu par RAcqMemZoneMgr
151
152};
153
154
155
156//----------------------------------------------------------------------------------------
157// Classe thread de sauvegarde sur fichiers - gerant plusieurs fibres dans RAcqMemZoneMgr
158//----------------------------------------------------------------------------------------
159
160class MultiDataSaver : public ZThread {
161public:
162 MultiDataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true);
163
164 virtual void run();
165 void Stop();
166 inline void STOP() { stop_ = true; }
167protected:
168 RAcqMemZoneMgr& memgr;
169 uint_4 nfiles_; // Nombre maxi de fichiers cree
170 uint_4 nblocperfile_; // Nombre de bloc (zone memoire) mis dans un fichier
171 uint_4 nmax_; // Nombre maxi de blocs MemZone traites = nfiles * nblocperfile_
172 bool savesig_; // Si false, pas d'ecriture des fichiers FITS du signal
173 bool stop_;
174 string path_;
175 struct sigaction act;
176
177};
178
[3537]179#endif
Note: See TracBrowser for help on using the repository browser.