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