source: Sophya/trunk/AddOn/TAcq/brbaseproc.cc@ 3691

Last change on this file since 3691 was 3686, checked in by ansari, 16 years ago

Corrections diverses ds lecteur fits et processeur multi-fibres, Reza 27/11/2009

File size: 3.6 KB
Line 
1//----------------------------------------------------------------
2// Projet BAORadio - (C) LAL/IRFU 2008-2010
3// Classes de base pour les threads de traitememt donnees BAORadio
4//----------------------------------------------------------------
5
6#include <stdlib.h>
7#include <string.h>
8#include <unistd.h>
9#include <fstream>
10#include "brbaseproc.h"
11
12
13using namespace SOPHYA;
14//---------------------------------------------------------------------
15// Classe de traitement - calcul de visibilite pour n fibres
16//---------------------------------------------------------------------
17
18/* --Methode-- */
19BRBaseProcessor::BRBaseProcessor(RAcqMemZoneMgr& memgr)
20 : memgr_(memgr)
21{
22 stop_ = false;
23 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
24 vpaq_.push_back(BRPaquet(NULL,memgr_.PaqSize()));
25 vpchk_.push_back(BRPaqChecker(true,0));
26 vfgok_.push_back(true);
27 curfc_.push_back(0);
28 }
29 totprocnpaq_=0;
30}
31
32/* --Methode-- */
33void BRBaseProcessor::run()
34{
35 setRC(1);
36 int rc=0;
37 try {
38 cout << " BRBaseProcessor::run() - Starting " << " NFibers=" << memgr_.NbFibres()
39 << " NChan=" << 2*memgr_.NbFibres() << endl;
40
41 size_t paqsz=memgr_.PaqSize();
42 vector<Byte*> fbuff;
43 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) fbuff.push_back(NULL);
44 bool fgrun=true;
45 while (fgrun) {
46 if (stop_) break;
47 if (memgr_.GetRunState() == MemZR_Stopped) break;
48 int mid = memgr_.FindMemZoneId(MemZA_ProcA);
49 Byte* buffg = memgr_.GetMemZone(mid);
50 if (buffg == NULL) {
51 cout << "BRBaseProcessor::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
52 setRC(7); fgrun=false;
53 break;
54 }
55 for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone
56 fgokallfibers_=true;
57 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
58 fbuff[fib] = memgr_.GetMemZone(mid,fib);
59 if (fbuff[fib] == NULL) { // cela ne devrait pas arriver
60 cout << "BRBaseProcessor::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
61 setRC(9); fgrun=false;
62 break;
63 }
64 vpaq_[fib].Set(fbuff[fib]+jp*paqsz);
65 vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
66 if (!vfgok_[fib]) fgokallfibers_=false;
67 }
68 //--- Traitement
69 int rcp = Process();
70 totprocnpaq_++;
71 // if (rcp != 0) { fgrun=false; break; }
72 } // Fin de boucle sur les paquets
73 memgr_.FreeMemZone(mid, MemZS_ProcA);
74 } // Fin de boucle sur les zones a traiter
75 //------------------------------------
76 cout << " --------- END BRBaseProcessor::run() , TotNbProcPaq=" << totprocnpaq_ << endl;
77 /*
78 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) vpchk_[fib].Print();
79 cout << " ------------------------------------ " << endl;
80 */
81 }
82 catch (std::exception& exc) {
83 cout << " BRBaseProcessor::run()/catched std::exception " << exc.what() << endl;
84 setRC(98);
85 return;
86 }
87 catch(...) {
88 cout << " BRBaseProcessor::run()/catched unknown ... exception " << endl;
89 setRC(99);
90 return;
91 }
92
93}
94
95
96/* --Methode-- */
97int BRBaseProcessor::Process()
98{
99 // la methode par defaut ne fait rien
100 // if (fgokallfibers_) { faire le traitement }
101 return 0;
102 /* Exemple de code test
103 if ( totprocnpaq_ % 1000 == 0 ) {
104 cout << " BRVisibilityCalculator::Process() " << totprocnpaq_ << " FrameCnt=" ;
105 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)
106 cout << curfc_[fib] << "," ;
107 cout << endl;
108 cout << " TimeTag : " ;
109 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)
110 cout << vpaq_[fib].TimeTag()/125000000 << "," ;
111 cout << " seconds" << endl;
112 }
113
114 */
115}
116
Note: See TracBrowser for help on using the repository browser.