| 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 |  | 
|---|
| 25 | //------------------------------------------------------- | 
|---|
| 26 | // Classe thread de lecture PCI-Express | 
|---|
| 27 | //------------------------------------------------------- | 
|---|
| 28 |  | 
|---|
| 29 | class PCIEReader : public ZThread { | 
|---|
| 30 | public: | 
|---|
| 31 | PCIEReader( PCIEWrapperInterface &pciw , uint_4 sizeFrame,uint_4 paqSize ,RAcqMemZoneMgr& mem, | 
|---|
| 32 | uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll); | 
|---|
| 33 | virtual void run(); | 
|---|
| 34 | void Stop(); | 
|---|
| 35 | inline void STOP() { stop_ = true; } | 
|---|
| 36 |  | 
|---|
| 37 | protected: | 
|---|
| 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 |  | 
|---|
| 48 | RAcqMemZoneMgr& memgr; | 
|---|
| 49 | uint_4 nmax_;  // Nombre maxi de blocs MemZone traites | 
|---|
| 50 | BRDataFmtConv swapall_;  // select data swap/format conversion for BRPaquet | 
|---|
| 51 | bool stop_; | 
|---|
| 52 | unsigned int sizeFr_ ; | 
|---|
| 53 | PCIEWrapperInterface& 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 | 
|---|
| 60 | }; | 
|---|
| 61 |  | 
|---|
| 62 | //------------------------------------------------------- | 
|---|
| 63 | // Classe thread de sauvegarde sur fichiers | 
|---|
| 64 | //------------------------------------------------------- | 
|---|
| 65 |  | 
|---|
| 66 | class DataSaver : public ZThread { | 
|---|
| 67 | public: | 
|---|
| 68 | DataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true); | 
|---|
| 69 |  | 
|---|
| 70 | virtual void run(); | 
|---|
| 71 | void Stop(); | 
|---|
| 72 | inline void STOP() { stop_ = true; } | 
|---|
| 73 | protected: | 
|---|
| 74 | RAcqMemZoneMgr& memgr; | 
|---|
| 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 | 
|---|
| 79 | bool stop_; | 
|---|
| 80 | string path_; | 
|---|
| 81 | struct sigaction act; | 
|---|
| 82 |  | 
|---|
| 83 | }; | 
|---|
| 84 |  | 
|---|
| 85 | //------------------------------------------------------- | 
|---|
| 86 | // Classe thread de lecture PCI-Express + Check | 
|---|
| 87 | //------------------------------------------------------- | 
|---|
| 88 |  | 
|---|
| 89 | class PCIEReaderChecker : public ZThread { | 
|---|
| 90 | public: | 
|---|
| 91 | PCIEReaderChecker( PCIEWrapperInterface &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 | PCIEWrapperInterface& pciw_; | 
|---|
| 103 | uint_4 packSize_; | 
|---|
| 104 | }; | 
|---|
| 105 |  | 
|---|
| 106 | #endif | 
|---|