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"
|
---|
16 | #include "pciewrap.h"
|
---|
17 |
|
---|
18 | #include "brtypes.h"
|
---|
19 | #include "brpaqu.h"
|
---|
20 |
|
---|
21 | using namespace std;
|
---|
22 |
|
---|
23 |
|
---|
24 | // Quelques definitions globales
|
---|
25 | // Nombre maximum de fibres geres par les classes MultiReader / MultiDiskWriter
|
---|
26 | #define MAXNBFIB 4
|
---|
27 |
|
---|
28 | //-------------------------------------------------------
|
---|
29 | // Classe thread de lecture PCI-Express
|
---|
30 | //-------------------------------------------------------
|
---|
31 |
|
---|
32 | class PCIEReader : public ZThread {
|
---|
33 | public:
|
---|
34 | PCIEReader( PCIEWrapperInterface &pciw , uint_4 sizeFrame,uint_4 paqSize ,RAcqMemZoneMgr& mem,
|
---|
35 | uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
|
---|
36 | virtual void run();
|
---|
37 | void Stop();
|
---|
38 | inline void STOP() { stop_ = true; }
|
---|
39 |
|
---|
40 | protected:
|
---|
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 |
|
---|
51 | RAcqMemZoneMgr& memgr;
|
---|
52 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites
|
---|
53 | BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
|
---|
54 | bool stop_;
|
---|
55 | unsigned int sizeFr_ ;
|
---|
56 | PCIEWrapperInterface& pciw_;
|
---|
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
|
---|
63 | };
|
---|
64 |
|
---|
65 | //-------------------------------------------------------
|
---|
66 | // Classe thread de sauvegarde sur fichiers
|
---|
67 | //-------------------------------------------------------
|
---|
68 |
|
---|
69 | class DataSaver : public ZThread {
|
---|
70 | public:
|
---|
71 | DataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true);
|
---|
72 |
|
---|
73 | virtual void run();
|
---|
74 | void Stop();
|
---|
75 | inline void STOP() { stop_ = true; }
|
---|
76 | protected:
|
---|
77 | RAcqMemZoneMgr& memgr;
|
---|
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
|
---|
82 | bool stop_;
|
---|
83 | string path_;
|
---|
84 | struct sigaction act;
|
---|
85 |
|
---|
86 | };
|
---|
87 |
|
---|
88 | //-------------------------------------------------------
|
---|
89 | // Classe thread de lecture PCI-Express + Check
|
---|
90 | //-------------------------------------------------------
|
---|
91 |
|
---|
92 | class PCIEReaderChecker : public ZThread {
|
---|
93 | public:
|
---|
94 | PCIEReaderChecker( PCIEWrapperInterface &pciw , uint_4 sizeFrame,uint_4 paqSize, RAcqMemZoneMgr& mem,
|
---|
95 | uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
|
---|
96 | virtual void run();
|
---|
97 | void Stop();
|
---|
98 | inline void STOP() { stop_ = true; }
|
---|
99 | protected:
|
---|
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_ ;
|
---|
105 | PCIEWrapperInterface& pciw_;
|
---|
106 | uint_4 packSize_;
|
---|
107 | };
|
---|
108 | //------------------------------------------------------------------
|
---|
109 | // Classe thread de lecture PCI-Express multi fibre (ou multi DMA)
|
---|
110 | //------------------------------------------------------------------
|
---|
111 |
|
---|
112 | class PCIEMultiReader : public ZThread {
|
---|
113 | public:
|
---|
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 |
|
---|
120 | protected:
|
---|
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 |
|
---|
160 | class MultiDataSaver : public ZThread {
|
---|
161 | public:
|
---|
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; }
|
---|
167 | protected:
|
---|
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 |
|
---|
179 | #endif
|
---|