[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 |
|
---|
| 21 | using namespace std;
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | //-------------------------------------------------------
|
---|
| 26 | // Classe thread de lecture PCI-Express
|
---|
| 27 | //-------------------------------------------------------
|
---|
| 28 |
|
---|
| 29 | class PCIEReader : public ZThread {
|
---|
| 30 | public:
|
---|
[3623] | 31 | PCIEReader( PCIEWrapper &pciw , uint_4 sizeFrame,uint_4 paqSize ,RAcqMemZoneMgr& mem,
|
---|
| 32 | uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
|
---|
[3537] | 33 | virtual void run();
|
---|
[3623] | 34 | void Stop();
|
---|
[3537] | 35 | inline void STOP() { stop_ = true; }
|
---|
[3623] | 36 |
|
---|
[3537] | 37 | protected:
|
---|
[3623] | 38 | // Pour recuperer un pointeur sur la prochaine zone memoire devant recevoir un paquet
|
---|
| 39 | inline Byte* NextPaqTarget() {
|
---|
| 40 | if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
|
---|
| 41 | if (MZoneManage()) return NULL;
|
---|
| 42 | Byte* rb=mmbuf_+targ_npaq_*packSize_;
|
---|
| 43 | targ_npaq_++;
|
---|
| 44 | return rb;
|
---|
| 45 | }
|
---|
| 46 | bool MZoneManage(bool clean=false); // Renvoie true si probleme
|
---|
| 47 |
|
---|
[3537] | 48 | RAcqMemZoneMgr& memgr;
|
---|
| 49 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites
|
---|
[3623] | 50 | BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
|
---|
[3537] | 51 | bool stop_;
|
---|
[3623] | 52 | unsigned int sizeFr_ ;
|
---|
| 53 | PCIEWrapper& pciw_;
|
---|
| 54 | uint_4 packSize_;
|
---|
| 55 | // Variables pour gerer la logique de NextPaqTarget() qui cache l'acces a RAcqMemZoneMgr
|
---|
| 56 | int mid_; // Identificateur zone memoire
|
---|
| 57 | uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
|
---|
| 58 | uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
|
---|
| 59 | Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
|
---|
[3537] | 60 | };
|
---|
| 61 |
|
---|
| 62 | //-------------------------------------------------------
|
---|
| 63 | // Classe thread de sauvegarde sur fichiers
|
---|
| 64 | //-------------------------------------------------------
|
---|
| 65 |
|
---|
| 66 | class DataSaver : public ZThread {
|
---|
| 67 | public:
|
---|
[3623] | 68 | DataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true);
|
---|
| 69 |
|
---|
[3537] | 70 | virtual void run();
|
---|
[3623] | 71 | void Stop();
|
---|
[3537] | 72 | inline void STOP() { stop_ = true; }
|
---|
| 73 | protected:
|
---|
| 74 | RAcqMemZoneMgr& memgr;
|
---|
[3623] | 75 | uint_4 nfiles_; // Nombre maxi de fichiers cree
|
---|
| 76 | uint_4 nblocperfile_; // Nombre de bloc (zone memoire) mis dans un fichier
|
---|
| 77 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites = nfiles * nblocperfile_
|
---|
| 78 | bool savesig_; // Si false, pas d'ecriture des fichiers FITS du signal
|
---|
[3537] | 79 | bool stop_;
|
---|
| 80 | string path_;
|
---|
[3623] | 81 | struct sigaction act;
|
---|
| 82 |
|
---|
[3537] | 83 | };
|
---|
| 84 |
|
---|
[3623] | 85 | //-------------------------------------------------------
|
---|
| 86 | // Classe thread de lecture PCI-Express + Check
|
---|
| 87 | //-------------------------------------------------------
|
---|
[3537] | 88 |
|
---|
[3623] | 89 | class PCIEReaderChecker : public ZThread {
|
---|
| 90 | public:
|
---|
| 91 | PCIEReaderChecker( PCIEWrapper &pciw , uint_4 sizeFrame,uint_4 paqSize ,RAcqMemZoneMgr& mem,
|
---|
| 92 | uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
|
---|
| 93 | virtual void run();
|
---|
| 94 | void Stop();
|
---|
| 95 | inline void STOP() { stop_ = true; }
|
---|
| 96 | protected:
|
---|
| 97 | RAcqMemZoneMgr& memgr;
|
---|
| 98 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites
|
---|
| 99 | BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
|
---|
| 100 | bool stop_;
|
---|
| 101 | unsigned int sizeFr_ ;
|
---|
| 102 | PCIEWrapper& pciw_;
|
---|
| 103 | uint_4 packSize_;
|
---|
| 104 | };
|
---|
| 105 |
|
---|
[3537] | 106 | #endif
|
---|