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

Last change on this file since 3755 was 3696, checked in by ansari, 16 years ago

correction et petites amelioration - Reza 03/12/2009

File size: 4.0 KB
RevLine 
[3683]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)
[3694]20 : memgr_(memgr), vpaq_(memgr.NbFibres()), vpchk_(memgr.NbFibres()), vfgok_(memgr.NbFibres()),
[3696]21 curfc_(memgr.NbFibres()), fcfirst_(memgr.NbFibres()), ttfirst_(memgr.NbFibres())
[3683]22{
[3686]23 stop_ = false;
[3683]24 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
[3696]25 fbuff_.push_back(NULL);
[3694]26 vpaq_[fib]=BRPaquet(NULL,memgr_.PaqSize());
27 vpchk_[fib]=BRPaqChecker(true,0);
28 vfgok_[fib]=true;
29 curfc_[fib]=0;
[3696]30 fcfirst_[fib]=0;
31 ttfirst_[fib]=0;
[3683]32 }
[3696]33 fgokallfibers_=true;
[3683]34 totprocnpaq_=0;
35}
36
37/* --Methode-- */
38void BRBaseProcessor::run()
39{
40 setRC(1);
41 int rc=0;
42 try {
43 cout << " BRBaseProcessor::run() - Starting " << " NFibers=" << memgr_.NbFibres()
44 << " NChan=" << 2*memgr_.NbFibres() << endl;
45
46 size_t paqsz=memgr_.PaqSize();
47 bool fgrun=true;
48 while (fgrun) {
49 if (stop_) break;
50 if (memgr_.GetRunState() == MemZR_Stopped) break;
51 int mid = memgr_.FindMemZoneId(MemZA_ProcA);
52 Byte* buffg = memgr_.GetMemZone(mid);
53 if (buffg == NULL) {
54 cout << "BRBaseProcessor::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
55 setRC(7); fgrun=false;
56 break;
57 }
[3696]58 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
59 fbuff_[fib] = memgr_.GetMemZone(mid,fib);
60 if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver
61 cout << "BRBaseProcessor::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
62 setRC(9); fgrun=false;
63 break;
64 }
65 }
[3683]66 for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone
67 fgokallfibers_=true;
68 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
[3696]69 vpaq_[fib].Set(fbuff_[fib]+jp*paqsz);
[3683]70 vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
71 if (!vfgok_[fib]) fgokallfibers_=false;
72 }
73 //--- Traitement
[3696]74 int rcp=0;
75 if (fgokallfibers_) {
76 if (totprocnpaq_==0) {
77 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
78 fcfirst_[fib]=curfc_[fib];
79 ttfirst_[fib]=vpaq_[fib].TimeTag();
80 }
81 }
82 rcp=Process();
83 totprocnpaq_++;
84 }
[3686]85 // if (rcp != 0) { fgrun=false; break; }
[3683]86 } // Fin de boucle sur les paquets
87 memgr_.FreeMemZone(mid, MemZS_ProcA);
88 } // Fin de boucle sur les zones a traiter
89 //------------------------------------
90 cout << " --------- END BRBaseProcessor::run() , TotNbProcPaq=" << totprocnpaq_ << endl;
[3686]91 /*
92 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) vpchk_[fib].Print();
93 cout << " ------------------------------------ " << endl;
94 */
[3683]95 }
96 catch (std::exception& exc) {
97 cout << " BRBaseProcessor::run()/catched std::exception " << exc.what() << endl;
98 setRC(98);
99 return;
100 }
101 catch(...) {
102 cout << " BRBaseProcessor::run()/catched unknown ... exception " << endl;
103 setRC(99);
104 return;
105 }
106
107}
108
109
110/* --Methode-- */
111int BRBaseProcessor::Process()
112{
113 // la methode par defaut ne fait rien
114 // if (fgokallfibers_) { faire le traitement }
[3696]115 // return 0;
116 /* Exemple de code test */
[3686]117 if ( totprocnpaq_ % 1000 == 0 ) {
118 cout << " BRVisibilityCalculator::Process() " << totprocnpaq_ << " FrameCnt=" ;
119 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)
120 cout << curfc_[fib] << "," ;
121 cout << endl;
122 cout << " TimeTag : " ;
123 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)
124 cout << vpaq_[fib].TimeTag()/125000000 << "," ;
125 cout << " seconds" << endl;
126 }
[3696]127 return 0;
[3683]128}
129
Note: See TracBrowser for help on using the repository browser.