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