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

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

petites optimisations et corrections, Reza 01/12/2009

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