[3537] | 1 | #include "racquproc.h"
|
---|
| 2 |
|
---|
[3681] | 3 | /* ----------------------------------------
|
---|
| 4 | Projet BAORadio --- LAL
|
---|
| 5 | 2008 - 2010
|
---|
| 6 | ------------------------------------------- */
|
---|
| 7 |
|
---|
[3537] | 8 | #include <stdlib.h>
|
---|
| 9 | #include <unistd.h>
|
---|
| 10 | #include <fstream>
|
---|
[3623] | 11 | #include <signal.h>
|
---|
[3537] | 12 |
|
---|
| 13 | #include "pexceptions.h"
|
---|
| 14 | #include "tvector.h"
|
---|
| 15 | #include "fioarr.h"
|
---|
| 16 | #include "timestamp.h"
|
---|
| 17 | #include "fftpserver.h"
|
---|
| 18 | #include "fftwserver.h"
|
---|
[3683] | 19 | #include "histos.h"
|
---|
[3729] | 20 | #include "histos2.h"
|
---|
[3537] | 21 |
|
---|
| 22 | #include "FFTW/fftw3.h"
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | #include "pciewrap.h"
|
---|
| 26 | #include "brpaqu.h"
|
---|
| 27 | #include "minifits.h"
|
---|
| 28 |
|
---|
[3681] | 29 | /* Fonction, module^2 des nombres complexes */
|
---|
| 30 | static inline r_4 Zmod2(complex<r_4> z)
|
---|
| 31 | { return (z.real()*z.real()+z.imag()*z.imag()); }
|
---|
| 32 | static inline r_8 Zmod2(complex<r_8> z)
|
---|
| 33 | { return (z.real()*z.real()+z.imag()*z.imag()); }
|
---|
| 34 | static inline r_4 Zmod2(TwoByteComplex z)
|
---|
| 35 | { return ((r_4)z.realB()*(r_4)z.realB()+(r_4)z.imagB()*(r_4)z.imagB()); }
|
---|
| 36 |
|
---|
| 37 | //---------------------------------------------------------------------
|
---|
| 38 | // Classe thread de traitement/monitoring multifibre Raw/FFT
|
---|
| 39 | //---------------------------------------------------------------------
|
---|
| 40 | /* --Methode-- */
|
---|
| 41 | MonitorProc::MonitorProc(RAcqMemZoneMgr& mem)
|
---|
| 42 | : memgr(mem)
|
---|
| 43 | {
|
---|
| 44 | BRAcqConfig bpar;
|
---|
| 45 | par_.Set(bpar.GetParams());
|
---|
| 46 | nmax_ = par_.nmaxProc;
|
---|
| 47 | if (nmax_==0) nmax_=par_.MaxNbBlocs();
|
---|
| 48 | nmean_ = par_.nmeanProc;
|
---|
| 49 | step_ = par_.stepProc;
|
---|
| 50 | stop_ = false;
|
---|
| 51 | path_ = bpar.OutputDirectory();
|
---|
| 52 | nfiles_ = 0;
|
---|
| 53 | nblocproc_ = 0;
|
---|
| 54 | nprocpaq_=0;
|
---|
| 55 | npaqsamefc_=0;
|
---|
| 56 | totnprocpaq_=0;
|
---|
| 57 | totnpaqsamefc_=0;
|
---|
| 58 | curfc_.SetSize(memgr.NbFibres(), memgr.NbPaquets());
|
---|
| 59 | cpaqok_.SetSize(memgr.NbFibres(), memgr.NbPaquets());
|
---|
[3876] | 60 | SetMemZAction();
|
---|
[3681] | 61 | }
|
---|
| 62 |
|
---|
| 63 | /* --Methode-- */
|
---|
| 64 | MonitorProc::~MonitorProc()
|
---|
| 65 | {
|
---|
| 66 | // cout << " **** DBG ***** MonitorProc::~MonitorProc() " << endl;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | /* --Methode-- */
|
---|
[3876] | 70 | MemZStatus MonitorProc::SetMemZAction(MemZaction mmact)
|
---|
| 71 | {
|
---|
| 72 | mmact_=mmact;
|
---|
| 73 | mmsta_=MemZS_Proc;
|
---|
| 74 | switch (mmact) {
|
---|
| 75 | case MemZA_ProcA:
|
---|
| 76 | mmsta_=MemZS_ProcA;
|
---|
| 77 | break;
|
---|
| 78 | case MemZA_ProcB:
|
---|
| 79 | mmsta_=MemZS_ProcB;
|
---|
| 80 | break;
|
---|
| 81 | case MemZA_ProcC:
|
---|
| 82 | mmsta_=MemZS_ProcC;
|
---|
| 83 | break;
|
---|
| 84 | case MemZA_ProcD:
|
---|
| 85 | mmsta_=MemZS_ProcD;
|
---|
| 86 | break;
|
---|
| 87 | case MemZA_ProcE:
|
---|
| 88 | mmsta_=MemZS_ProcE;
|
---|
| 89 | break;
|
---|
| 90 | case MemZA_ProcF:
|
---|
| 91 | mmsta_=MemZS_ProcF;
|
---|
| 92 | break;
|
---|
| 93 | default:
|
---|
| 94 | mmact_=MemZA_Proc;
|
---|
| 95 | mmsta_=MemZS_Proc;
|
---|
| 96 | break;
|
---|
| 97 | }
|
---|
| 98 | return mmsta_;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /* --Methode-- */
|
---|
[3681] | 102 | void MonitorProc::Stop()
|
---|
| 103 | {
|
---|
| 104 | stop_=true;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | /* --Methode-- */
|
---|
| 108 | void MonitorProc::run()
|
---|
| 109 | {
|
---|
| 110 | setRC(1);
|
---|
| 111 | int rc=0;
|
---|
| 112 | try {
|
---|
| 113 | TimeStamp ts;
|
---|
| 114 | cout << " MonitorProc::run() - Starting " << ts << " NMaxMemZones=" << nmax_
|
---|
| 115 | << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
| 116 | cout << " MonitorProc::run()... - Output Data Path: " << path_ << endl;
|
---|
| 117 | char fname[512];
|
---|
| 118 | sprintf(fname,"%s/monproc.log",path_.c_str());
|
---|
| 119 | ofstream filog(fname);
|
---|
| 120 | filog << " MonitorProc::run() - starting log file " << ts << endl;
|
---|
| 121 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
| 122 | uint_4 paqsz = memgr.PaqSize();
|
---|
| 123 | BRPaquet pq(paqsz);
|
---|
| 124 | if (par_.fgsinglechannel) {
|
---|
| 125 | spectre_.SetSize(memgr.NbFibres(), pq.DataSize()/2);
|
---|
| 126 | for(int kc=0; kc<memgr.NbFibres(); kc++) nzm_.push_back(0);
|
---|
| 127 | rc=procData1C(filog);
|
---|
| 128 | }
|
---|
| 129 | else {
|
---|
| 130 | spectre_.SetSize(2*memgr.NbFibres(), pq.DataSize()/4);
|
---|
| 131 | for(int kc=0; kc<2*memgr.NbFibres(); kc++) nzm_.push_back(0);
|
---|
| 132 | rc=procData2C(filog);
|
---|
| 133 | }
|
---|
| 134 | cout << " ---- MonitorProc::run()/End NBlocProcessed=" << nblocproc_
|
---|
| 135 | << " NFiles=" << nfiles_ << " Rc=" << rc << endl;
|
---|
| 136 | ts.SetNow();
|
---|
| 137 | filog << " ---- MonitorProc::run()/End " << ts << endl;
|
---|
| 138 | filog << " --------- MonitorProc::run()/End NBlocProcessed=" << nblocproc_
|
---|
| 139 | << " NFiles=" << nfiles_ << " Rc=" << rc << endl;
|
---|
| 140 | }
|
---|
| 141 | catch (std::exception& exc) {
|
---|
| 142 | cout << " MonitorProc::run()/catched std::exception " << exc.what() << endl;
|
---|
| 143 | setRC(98);
|
---|
| 144 | return;
|
---|
| 145 | }
|
---|
| 146 | catch(...) {
|
---|
| 147 | cout << " MonitorProc::run()/catched unknown ... exception " << endl;
|
---|
| 148 | setRC(99);
|
---|
| 149 | return;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | setRC(rc);
|
---|
| 153 | return;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | /* --Methode-- */
|
---|
| 157 | int MonitorProc::procData1C(ofstream& logf)
|
---|
| 158 | {
|
---|
| 159 | cout << " MonitorProc::procData1C() - NOT IMPLEMENTED -> Rc=67" << endl;
|
---|
| 160 | logf << " MonitorProc::procData1C() - NOT IMPLEMENTED -> Rc=67" << endl;
|
---|
| 161 | return 67;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | /* --Methode-- */
|
---|
| 165 | int MonitorProc::procData2C(ofstream& filog)
|
---|
| 166 | {
|
---|
| 167 | BRPaqChecker pcheck[MAXNBFIB]; // Verification/comptage des paquets
|
---|
| 168 | // Initialisation pour calcul FFT
|
---|
| 169 | uint_4 paqsz = memgr.PaqSize();
|
---|
| 170 | BRPaquet pq(paqsz);
|
---|
| 171 | TVector<r_4> vx(pq.DataSize()/2);
|
---|
| 172 | vx = (r_4)(0.);
|
---|
| 173 | TVector< complex<r_4> > cfour(pq.DataSize()/4+1); // composant TF
|
---|
| 174 |
|
---|
| 175 | fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
|
---|
| 176 | (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE);
|
---|
[3683] | 177 |
|
---|
| 178 | // Histo pour valeurs des bytes dans les paquets
|
---|
[3918] | 179 | Histo* phist[2*MAXNBFIB];
|
---|
| 180 | Histo2D* ph2[2*MAXNBFIB];
|
---|
| 181 | Histo* phexp[2*MAXNBFIB];
|
---|
| 182 | TMatrix<r_4>* psatur[2*MAXNBFIB];
|
---|
[3920] | 183 | TVector<uint_4>* pvsatfreq[2*MAXNBFIB];
|
---|
[3918] | 184 | for(int ifib=0; ifib<2*MAXNBFIB; ifib++) {
|
---|
| 185 | phist[ifib]=NULL; ph2[ifib]=NULL; phexp[ifib]=NULL; psatur[ifib]=NULL;
|
---|
| 186 | }
|
---|
[3683] | 187 | if (par_.fgdatafft) { // data de type FFT
|
---|
[3729] | 188 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++) {
|
---|
[3683] | 189 | phist[lc] = new Histo(-128.5,+128.5,257);
|
---|
[3729] | 190 | ph2[lc] = new Histo2D(-128.5,+128.5,257, -128.5,+128.5,257);
|
---|
| 191 | phexp[lc] = new Histo(-128.5,+128.5,257);
|
---|
[3918] | 192 | psatur[lc] = new TMatrix<r_4>(3,3);
|
---|
[3920] | 193 | pvsatfreq[lc] = new TVector<uint_4>(spectre_.NCols());
|
---|
[3918] | 194 | *psatur[lc] = 0.;
|
---|
[3729] | 195 | }
|
---|
[3683] | 196 | }
|
---|
| 197 | else {
|
---|
| 198 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++)
|
---|
| 199 | phist[lc] = new Histo(-0.5,256.5,257);
|
---|
| 200 | }
|
---|
| 201 |
|
---|
[3681] | 202 | TimeStamp ts;
|
---|
| 203 | char fname[512];
|
---|
| 204 | nfiles_ = 0;
|
---|
| 205 | for (uint_4 kmz=0; kmz<nmax_; kmz++) {
|
---|
| 206 | if (stop_) break;
|
---|
| 207 | if (memgr.GetRunState() == MemZR_Stopped) break;
|
---|
| 208 |
|
---|
[3876] | 209 | int mid = memgr.FindMemZoneId(mmact_); // MemZA_Proc
|
---|
[3681] | 210 | Byte* buffg = memgr.GetMemZone(mid);
|
---|
| 211 | if (buffg == NULL) {
|
---|
| 212 | cout << " MonitorProc::procData2C()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
|
---|
| 213 | break;
|
---|
| 214 | }
|
---|
| 215 | if ((step_>1)&&(kmz%step_ != 0)) {
|
---|
[3876] | 216 | memgr.FreeMemZone(mid, mmsta_); // MemZS_Proc);
|
---|
[3681] | 217 | continue;
|
---|
| 218 | }
|
---|
| 219 | sa_size_t lc=0;
|
---|
| 220 | Byte* fbuff[MAXNBFIB];
|
---|
| 221 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) { // Boucle sur les fibres
|
---|
| 222 | fbuff[fib] = memgr.GetMemZone(mid,fib);
|
---|
| 223 | if (fbuff[fib] == NULL) { // cela ne devrait pas arriver
|
---|
| 224 | cout << " MonitorProc::procData2C()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
|
---|
| 225 | return 9;
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
[3918] | 228 |
|
---|
| 229 | // DBG-ATTENTION : freq 0 pour expo full FFT si reordonne
|
---|
| 230 | int idxexpo=(par_.fgfftshrink)?1023:0; // exposant FFT shrink 1024 freq, ou freq 0 pour full-FFT
|
---|
[3681] | 231 |
|
---|
| 232 | cpaqok_ = (uint_1)0;
|
---|
| 233 | curfc_ = (uint_8)0;
|
---|
| 234 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
|
---|
| 235 | for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
|
---|
| 236 | BRPaquet paq(fbuff[fib]+i*paqsz, paqsz);
|
---|
| 237 | bool pqok=pcheck[fib].Check(paq,curfc_(fib,i)); // Verification du paquet / FrameCounter
|
---|
| 238 | if (!pqok) continue;
|
---|
| 239 | cpaqok_(fib,i) = 1;
|
---|
| 240 | sa_size_t lc=2*fib;
|
---|
| 241 | if (par_.fgdatafft) { // Traitement data de type FFT
|
---|
| 242 | TwoByteComplex* tbcp=paq.Data1C();
|
---|
[3918] | 243 |
|
---|
| 244 | // exposant FFT
|
---|
| 245 | phexp[lc]->Add((r_4)tbcp[idxexpo].realD());
|
---|
| 246 |
|
---|
[3683] | 247 | for(sa_size_t j=1; j<spectre_.NCols(); j++) {
|
---|
| 248 | phist[lc]->Add((r_4)tbcp[j].realD());
|
---|
| 249 | phist[lc]->Add((r_4)tbcp[j].imagD());
|
---|
[3729] | 250 | ph2[lc]->Add((r_4)tbcp[j].realD(), (r_4)tbcp[j].imagD());
|
---|
[3918] | 251 | // comptage saturation
|
---|
| 252 | int sir=0, sii=0; // saturation partie reelle, partie imaginaire
|
---|
| 253 | if (tbcp[j].realI()==-128) sir=-1;
|
---|
| 254 | else if (tbcp[j].realI()==127) sir=1;
|
---|
| 255 | if (tbcp[j].imagI()==-128) sii=-1;
|
---|
| 256 | else if (tbcp[j].imagI()==127) sii=1;
|
---|
| 257 | (*psatur[lc])(sir+1,sii+1)+=1.;
|
---|
[3920] | 258 | if ((sir!=0)||(sii!=0)) (*pvsatfreq[lc])(j)+=1;
|
---|
[3681] | 259 | spectre_(lc,j) += Zmod2(tbcp[j]);
|
---|
[3683] | 260 | }
|
---|
[3682] | 261 | nzm_[lc]++;
|
---|
| 262 | tbcp=paq.Data2C(); lc++;
|
---|
[3918] | 263 | phexp[lc]->Add((r_4)tbcp[idxexpo].realD());
|
---|
[3683] | 264 | for(sa_size_t j=1; j<spectre_.NCols(); j++) {
|
---|
| 265 | phist[lc]->Add((r_4)tbcp[j].realD());
|
---|
| 266 | phist[lc]->Add((r_4)tbcp[j].imagD());
|
---|
[3729] | 267 | ph2[lc]->Add((r_4)tbcp[j].realD(), (r_4)tbcp[j].imagD());
|
---|
[3918] | 268 | // comptage saturation
|
---|
| 269 | int sir=0, sii=0; // saturation partie reelle, partie imaginaire
|
---|
| 270 | if (tbcp[j].realI()==-128) sir=-1;
|
---|
| 271 | else if (tbcp[j].realI()==127) sir=1;
|
---|
| 272 | if (tbcp[j].imagI()==-128) sii=-1;
|
---|
| 273 | else if (tbcp[j].imagI()==127) sii=1;
|
---|
| 274 | (*psatur[lc])(sir+1,sii+1)+=1.;
|
---|
[3920] | 275 | if ((sir!=0)||(sii!=0)) (*pvsatfreq[lc])(j)+=1;
|
---|
[3918] | 276 |
|
---|
[3681] | 277 | spectre_(lc,j) += Zmod2(tbcp[j]);
|
---|
[3683] | 278 | }
|
---|
[3682] | 279 | nzm_[lc]++;
|
---|
[3681] | 280 | }
|
---|
| 281 | else { // Traitement RawData
|
---|
[3683] | 282 | for(sa_size_t j=0; j<vx.Size(); j++) {
|
---|
| 283 | phist[lc]->Add((r_8)(*(paq.Data1()+j)));
|
---|
[3681] | 284 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
|
---|
[3683] | 285 | }
|
---|
[3681] | 286 | fftwf_execute(plan);
|
---|
| 287 | // ffts_.FFTForward(vx, cfour_);
|
---|
| 288 | for(sa_size_t j=0; j<spectre_.NCols(); j++)
|
---|
| 289 | spectre_(lc,j) += Zmod2(cfour(j+1));
|
---|
[3682] | 290 | nzm_[lc]++; lc++;
|
---|
[3683] | 291 | for(sa_size_t j=0; j<vx.Size(); j++) {
|
---|
| 292 | phist[lc]->Add((r_8)(*(paq.Data2()+j)));
|
---|
[3681] | 293 | vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
|
---|
[3683] | 294 | }
|
---|
[3681] | 295 | fftwf_execute(plan);
|
---|
| 296 | // ffts_.FFTForward(vx, cfour_);
|
---|
| 297 | for(sa_size_t j=0; j<spectre_.NCols(); j++)
|
---|
| 298 | spectre_(lc,j) += Zmod2(cfour(j+1));
|
---|
[3682] | 299 | nzm_[lc]++;
|
---|
[3681] | 300 | }
|
---|
| 301 | } // FIN de la boucle sur les paquets
|
---|
| 302 | } // Boucle sur les fibres
|
---|
[3876] | 303 | memgr.FreeMemZone(mid, mmsta_); // MemZS_Proc);
|
---|
[3681] | 304 | CheckFrameCounters();
|
---|
| 305 |
|
---|
| 306 | nblocproc_ ++;
|
---|
| 307 | totnprocpaq_ += memgr.NbPaquets(); nprocpaq_ += memgr.NbPaquets();
|
---|
| 308 | bool fgnzm=true;
|
---|
| 309 | for(int lc=0; lc<2*memgr.NbFibres(); lc++)
|
---|
| 310 | if (nzm_[lc]<nmean_) fgnzm=false;
|
---|
| 311 |
|
---|
| 312 | if (fgnzm) {
|
---|
| 313 | char buff[32];
|
---|
| 314 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++) {
|
---|
| 315 | spectre_.Row(lc) /= (r_4)nzm_[lc];
|
---|
| 316 | sprintf(buff,"NPaqMoy%d",(int)lc);
|
---|
| 317 | spectre_.Info()[buff] = nzm_[lc];
|
---|
| 318 | }
|
---|
| 319 | sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_);
|
---|
| 320 | nfiles_++;
|
---|
| 321 | POutPersist po(fname);
|
---|
[3683] | 322 | po << PPFNameTag("spectre") << spectre_;
|
---|
[3681] | 323 | spectre_ = (r_4)(0.);
|
---|
[3683] | 324 | char buftag[32];
|
---|
| 325 | for(int lc=0; lc<2*memgr.NbFibres(); lc++) {
|
---|
| 326 | sprintf(buftag,"hvalV%d",(int)lc);
|
---|
| 327 | po << PPFNameTag(buftag) << (*phist[lc]);
|
---|
| 328 | phist[lc]->Zero();
|
---|
[3729] | 329 | if (par_.fgdatafft) { // data de type FFT
|
---|
| 330 | sprintf(buftag,"h2dV%d",(int)lc);
|
---|
| 331 | po << PPFNameTag(buftag) << (*ph2[lc]);
|
---|
| 332 | ph2[lc]->Zero();
|
---|
| 333 | sprintf(buftag,"hexpV%d",(int)lc);
|
---|
| 334 | po << PPFNameTag(buftag) << (*phexp[lc]);
|
---|
| 335 | phexp[lc]->Zero();
|
---|
[3918] | 336 | sprintf(buftag,"saturV%d",(int)lc);
|
---|
| 337 | po << PPFNameTag(buftag) << (*psatur[lc]);
|
---|
| 338 | (*psatur[lc])=0.;
|
---|
[3920] | 339 | sprintf(buftag,"satfreqV%d",(int)lc);
|
---|
| 340 | po << PPFNameTag(buftag) << (*pvsatfreq[lc]);
|
---|
| 341 | (*pvsatfreq[lc])=0;
|
---|
[3729] | 342 | }
|
---|
[3683] | 343 | nzm_[lc]=0;
|
---|
| 344 | }
|
---|
[3681] | 345 | ts.SetNow();
|
---|
| 346 | // Calcul / impression fraction des paquets avec same-framecounter
|
---|
| 347 | int fracsame=0;
|
---|
| 348 | if (nprocpaq_>0) fracsame=100*npaqsamefc_/nprocpaq_;
|
---|
| 349 | int totfracsame=0;
|
---|
| 350 | if (totnprocpaq_>0) totfracsame=100*totnpaqsamefc_/totnprocpaq_;
|
---|
| 351 | filog << ts << " : proc file (meanspectra) " << fname << endl;
|
---|
| 352 | filog << " NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
|
---|
| 353 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ << " / " << nprocpaq_
|
---|
| 354 | << " -> " << fracsame << " % )" << endl;
|
---|
| 355 | cout << " MonitorProc::procData2C() " << ts << " : created file " << fname << endl;
|
---|
| 356 | cout << " NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
|
---|
| 357 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ << " / " << nprocpaq_
|
---|
| 358 | << " -> " << fracsame << " % )" << endl;
|
---|
| 359 | nprocpaq_=npaqsamefc_=0;
|
---|
| 360 | }
|
---|
| 361 | } // Fin de boucle sur les kmz ( bloc MemZoneMgr a traiter )
|
---|
| 362 |
|
---|
| 363 | bool fgnzm=false;
|
---|
| 364 | for(int lc=0; lc<2*memgr.NbFibres(); lc++)
|
---|
| 365 | if (nzm_[lc]>0) fgnzm=true;
|
---|
| 366 |
|
---|
| 367 | if (fgnzm) {
|
---|
| 368 | char buff[32];
|
---|
| 369 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++) {
|
---|
| 370 | if (nzm_[lc]>0) spectre_.Row(lc) /= (r_4)nzm_[lc];
|
---|
| 371 | sprintf(buff,"NPaqMoy%d",(int)lc);
|
---|
| 372 | spectre_.Info()[buff] = nzm_[lc];
|
---|
| 373 | }
|
---|
| 374 | sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_);
|
---|
| 375 | POutPersist po(fname);
|
---|
[3683] | 376 | po << PPFNameTag("spectre") << spectre_;
|
---|
[3681] | 377 | spectre_ = (r_4)(0.);
|
---|
[3683] | 378 | char buftag[32];
|
---|
| 379 | for(int lc=0; lc<2*memgr.NbFibres(); lc++) {
|
---|
| 380 | sprintf(buftag,"hvalV%d",(int)lc);
|
---|
| 381 | po << PPFNameTag(buftag) << (*phist[lc]);
|
---|
| 382 | delete phist[lc];
|
---|
[3729] | 383 | if (par_.fgdatafft) { // data de type FFT
|
---|
| 384 | sprintf(buftag,"h2dV%d",(int)lc);
|
---|
| 385 | po << PPFNameTag(buftag) << (*ph2[lc]);
|
---|
| 386 | delete ph2[lc];
|
---|
| 387 | sprintf(buftag,"hexpV%d",(int)lc);
|
---|
| 388 | po << PPFNameTag(buftag) << (*phexp[lc]);
|
---|
| 389 | delete phexp[lc];
|
---|
[3918] | 390 | sprintf(buftag,"saturV%d",(int)lc);
|
---|
| 391 | po << PPFNameTag(buftag) << (*psatur[lc]);
|
---|
[3920] | 392 | sprintf(buftag,"satfreqV%d",(int)lc);
|
---|
| 393 | po << PPFNameTag(buftag) << (*pvsatfreq[lc]);
|
---|
| 394 | delete psatur[lc];
|
---|
| 395 | delete pvsatfreq[lc];
|
---|
[3729] | 396 | }
|
---|
[3683] | 397 | nzm_[lc]=0;
|
---|
| 398 | }
|
---|
[3681] | 399 | ts.SetNow();
|
---|
| 400 | // Calcul / impression fraction des paquets avec same-framecounter
|
---|
| 401 | int fracsame=0;
|
---|
| 402 | if (nprocpaq_>0) fracsame=100*npaqsamefc_/nprocpaq_;
|
---|
| 403 | int totfracsame=0;
|
---|
| 404 | if (totnprocpaq_>0) totfracsame=100*totnpaqsamefc_/totnprocpaq_;
|
---|
| 405 | filog << ts << " : proc file (meanspectra) " << fname << endl;
|
---|
| 406 | filog << " NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
|
---|
| 407 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ << " / " << nprocpaq_
|
---|
| 408 | << " -> " << fracsame << " % )" << endl;
|
---|
| 409 | cout << " MonitorProc::procData2C() " << ts << " : created file " << fname << endl;
|
---|
| 410 | cout << " NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
|
---|
| 411 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ << " / " << nprocpaq_
|
---|
| 412 | << " -> " << fracsame << " % )" << endl;
|
---|
| 413 | }
|
---|
| 414 | return 0;
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | /* --Methode-- */
|
---|
| 418 | int MonitorProc::CheckFrameCounters()
|
---|
| 419 | {
|
---|
| 420 | if (memgr.NbFibres()<2) {
|
---|
| 421 | npaqsamefc_++; totnpaqsamefc_++;
|
---|
| 422 | return 99;
|
---|
| 423 | }
|
---|
| 424 | sa_size_t pidx[MAXNBFIB];
|
---|
| 425 | sa_size_t maxidx=curfc_.NCols();
|
---|
| 426 | uint_8 cfc=0;
|
---|
| 427 | for(uint_4 fib=0; fib<curfc_.NRows(); fib++) {
|
---|
| 428 | pidx[fib]=0;
|
---|
| 429 | while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++;
|
---|
| 430 | }
|
---|
| 431 |
|
---|
| 432 | bool fgsuite=true;
|
---|
| 433 | while (fgsuite) { // Boucle sur l'ensemble des paquets
|
---|
| 434 | for(uint_4 fib=0; fib<curfc_.NRows(); fib++) {
|
---|
| 435 | if ((pidx[fib]>=maxidx)||(cpaqok_(fib,pidx[fib])==0)) { fgsuite=false; break; }
|
---|
| 436 | }
|
---|
| 437 | if (!fgsuite) break;
|
---|
| 438 | cfc=curfc_(0,pidx[0]);
|
---|
| 439 | bool fgsame=true;
|
---|
| 440 | for(uint_4 fib=1; fib<curfc_.NRows(); fib++) {
|
---|
| 441 | if (curfc_(fib,pidx[fib])!=cfc) {
|
---|
| 442 | fgsame=false;
|
---|
| 443 | if (curfc_(fib,pidx[fib]) > cfc) cfc=curfc_(fib,pidx[fib]);
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 | if (fgsame) {
|
---|
| 447 | npaqsamefc_++; totnpaqsamefc_++;
|
---|
| 448 | for(uint_4 fib=0; fib<curfc_.NRows(); fib++) {
|
---|
| 449 | pidx[fib]++;
|
---|
| 450 | while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++;
|
---|
| 451 | }
|
---|
| 452 | } // fin if (fgsame)
|
---|
| 453 | else { // else !fgsame
|
---|
| 454 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
|
---|
| 455 | if (curfc_(fib,pidx[fib])<cfc) {
|
---|
| 456 | pidx[fib]++;
|
---|
| 457 | while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++;
|
---|
| 458 | }
|
---|
| 459 | }
|
---|
| 460 | } // fin de else !fgsame
|
---|
| 461 | } // Fin de while sur l'ensemble des paquets
|
---|
| 462 | return 0;
|
---|
| 463 | }
|
---|
| 464 |
|
---|
| 465 |
|
---|
| 466 | static struct sigaction act;
|
---|
[3537] | 467 | //-------------------------------------------------------
|
---|
[3623] | 468 | // Classe thread de traitement avec 1 voie par frame
|
---|
[3537] | 469 | //-------------------------------------------------------
|
---|
| 470 |
|
---|
[3623] | 471 | void DataProcSignal(int s)
|
---|
| 472 | {
|
---|
| 473 | cout <<"............................................... receive CtrlC" << endl;
|
---|
| 474 |
|
---|
| 475 | }
|
---|
| 476 |
|
---|
| 477 | DataProc::DataProc(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax)
|
---|
[3537] | 478 | : memgr(mem)
|
---|
| 479 | {
|
---|
| 480 | nmax_ = nmax;
|
---|
| 481 | nmean_ = nmean;
|
---|
[3623] | 482 | step_ = step;
|
---|
[3537] | 483 | stop_ = false;
|
---|
| 484 | path_ = path;
|
---|
[3623] | 485 | act.sa_handler=DataProcSignal;
|
---|
[3537] | 486 | }
|
---|
| 487 |
|
---|
| 488 |
|
---|
[3623] | 489 | void DataProc::Stop()
|
---|
| 490 | {
|
---|
| 491 | stop_=true;
|
---|
| 492 | // cout <<" DataProc::Stop ... > STOP " << endl;
|
---|
| 493 | }
|
---|
| 494 |
|
---|
[3537] | 495 | void DataProc::run()
|
---|
| 496 | {
|
---|
[3623] | 497 |
|
---|
| 498 | // sigaddset(&act.sa_mask,SIGINT); // pour proteger le transfert DMA
|
---|
| 499 | // sigaction(SIGINT,&act,NULL);
|
---|
[3537] | 500 | setRC(1);
|
---|
| 501 | try {
|
---|
| 502 | TimeStamp ts;
|
---|
[3623] | 503 | cout << " DataProc::run() - Starting " << ts << " NMaxMemZones=" << nmax_
|
---|
| 504 | << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
[3634] | 505 | cout << " DataProc::run()... - Output Data Path: " << path_ << endl;
|
---|
[3537] | 506 | char fname[512];
|
---|
| 507 | sprintf(fname,"%s/proc.log",path_.c_str());
|
---|
| 508 | ofstream filog(fname);
|
---|
| 509 | filog << " DataProc::run() - starting log file " << ts << endl;
|
---|
[3623] | 510 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
[3537] | 511 |
|
---|
| 512 | // Initialisation pour clcul FFT
|
---|
| 513 | TVector< complex<r_4> > cfour; // composant TF
|
---|
| 514 | uint_4 paqsz = memgr.PaqSize();
|
---|
| 515 | BRPaquet pq(NULL, NULL, paqsz);
|
---|
| 516 | TVector<r_4> vx(pq.DataSize());
|
---|
| 517 | vx = (r_4)(0.);
|
---|
| 518 | FFTPackServer ffts;
|
---|
| 519 | ffts.FFTForward(vx, cfour);
|
---|
| 520 | TVector<r_4> spectre;
|
---|
| 521 | spectre.ReSize(cfour.Size());
|
---|
| 522 |
|
---|
[3623] | 523 | fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
|
---|
| 524 | (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE);
|
---|
[3537] | 525 |
|
---|
| 526 | uint_4 ifile = 0;
|
---|
[3623] | 527 | uint_4 nzm = 0;
|
---|
[3537] | 528 | for (uint_4 kmz=0; kmz<nmax_; kmz++) {
|
---|
[3623] | 529 | if (stop_) break;
|
---|
[3537] | 530 | int mid = memgr.FindMemZoneId(MemZA_Proc);
|
---|
| 531 | Byte* buff = memgr.GetMemZone(mid);
|
---|
| 532 | if (buff == NULL) {
|
---|
| 533 | cout << " DataProc::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
|
---|
| 534 | setRC(2);
|
---|
| 535 | return;
|
---|
| 536 | }
|
---|
| 537 | BRPaquet paq0(NULL, buff, paqsz);
|
---|
[3623] | 538 | for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) {
|
---|
[3537] | 539 | BRPaquet paq(NULL, buff+i*paqsz, paqsz);
|
---|
| 540 | Byte min = 255;
|
---|
| 541 | Byte max = 0;
|
---|
| 542 |
|
---|
| 543 | for(sa_size_t j=0; j<vx.Size(); j++)
|
---|
[3623] | 544 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
|
---|
[3537] | 545 | fftwf_execute(plan);
|
---|
[3623] | 546 | // ffts_.FFTForward(vx, cfour_);
|
---|
[3537] | 547 | for(sa_size_t j=0; j<spectre.Size(); j++)
|
---|
| 548 | spectre(j) += Zmod2(cfour(j));
|
---|
| 549 | nzm++;
|
---|
| 550 | }
|
---|
[3623] | 551 | if ((nzm >= nmean_) ||(kmz==(nmax_-1))) {
|
---|
[3537] | 552 | spectre /= (r_4)(nzm);
|
---|
[3623] | 553 | spectre.Info()["NPaqMoy"] = nzm;
|
---|
[3537] | 554 | sprintf(fname,"%s/spectre%d.ppf",path_.c_str(),(int)ifile);
|
---|
| 555 | POutPersist po(fname);
|
---|
| 556 | po << spectre;
|
---|
| 557 | spectre = (r_4)(0.);
|
---|
| 558 | nzm = 0; ifile++;
|
---|
| 559 | ts.SetNow();
|
---|
| 560 | filog << ts << " : proc file " << fname << endl;
|
---|
| 561 | cout << " DataProc::run() " << ts << " : created file " << fname << endl;
|
---|
| 562 | }
|
---|
| 563 |
|
---|
| 564 | memgr.FreeMemZone(mid, MemZS_Proc);
|
---|
| 565 | }
|
---|
| 566 | }
|
---|
[3671] | 567 | catch (std::exception& exc) {
|
---|
| 568 | cout << " DataProc::run()/catched std::exception " << exc.what() << endl;
|
---|
[3537] | 569 | setRC(3);
|
---|
| 570 | return;
|
---|
| 571 | }
|
---|
| 572 | catch(...) {
|
---|
| 573 | cout << " DataProc::run()/catched unknown ... exception " << endl;
|
---|
| 574 | setRC(4);
|
---|
| 575 | return;
|
---|
| 576 | }
|
---|
| 577 | setRC(0);
|
---|
| 578 | return;
|
---|
| 579 | }
|
---|
[3623] | 580 |
|
---|
| 581 | //---------------------------------------------------------------
|
---|
| 582 | // Classe thread de traitement donnees ADC avec 2 voies par frame
|
---|
| 583 | //---------------------------------------------------------------
|
---|
| 584 |
|
---|
| 585 | DataProc2C::DataProc2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax)
|
---|
| 586 | : memgr(mem)
|
---|
| 587 | {
|
---|
| 588 | nmax_ = nmax;
|
---|
| 589 | nmean_ = nmean;
|
---|
| 590 | step_ = step;
|
---|
| 591 | stop_ = false;
|
---|
| 592 | path_ = path;
|
---|
| 593 | act.sa_handler=DataProcSignal;
|
---|
| 594 | }
|
---|
| 595 | void DataProc2C::Stop()
|
---|
| 596 | {
|
---|
| 597 | stop_=true;
|
---|
| 598 | // cout <<" DataProc2C::Stop ... > STOP " << endl;
|
---|
| 599 | }
|
---|
| 600 |
|
---|
| 601 | void DataProc2C::run()
|
---|
| 602 | {
|
---|
| 603 | // sigaction(SIGINT,&act,NULL);
|
---|
| 604 | setRC(1);
|
---|
| 605 | try {
|
---|
| 606 | TimeStamp ts;
|
---|
| 607 | cout << " DataProc2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
|
---|
| 608 | << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
[3634] | 609 | cout << " DataProc::run()... - Output Data Path: " << path_ << endl;
|
---|
[3623] | 610 | char fname[512];
|
---|
| 611 | sprintf(fname,"%s/proc.log",path_.c_str());
|
---|
| 612 | ofstream filog(fname);
|
---|
| 613 | filog << " DataProc2C::run() - starting log file " << ts << endl;
|
---|
| 614 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
| 615 |
|
---|
| 616 | // Initialisation pour clcul FFT
|
---|
| 617 | TVector< complex<r_4> > cfour; // composant TF
|
---|
| 618 | uint_4 paqsz = memgr.PaqSize();
|
---|
| 619 | BRPaquet pq(NULL, NULL, paqsz);
|
---|
| 620 | TVector<r_4> vx(pq.DataSize()/2);
|
---|
| 621 | vx = (r_4)(0.);
|
---|
| 622 | FFTPackServer ffts;
|
---|
| 623 | ffts.FFTForward(vx, cfour);
|
---|
| 624 | TVector<r_4> spectreV1, spectreV2;
|
---|
| 625 | spectreV1.ReSize(cfour.Size());
|
---|
| 626 | spectreV2.ReSize(cfour.Size());
|
---|
| 627 |
|
---|
| 628 | fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
|
---|
| 629 | (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE);
|
---|
| 630 |
|
---|
| 631 | uint_4 ifile = 0;
|
---|
| 632 | uint_4 nzm = 0;
|
---|
| 633 | for (uint_4 kmz=0; kmz<nmax_; kmz++) {
|
---|
| 634 | if (stop_) break;
|
---|
| 635 | int mid = memgr.FindMemZoneId(MemZA_Proc);
|
---|
| 636 | Byte* buff = memgr.GetMemZone(mid);
|
---|
| 637 | if (buff == NULL) {
|
---|
| 638 | cout << " DataProc2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
|
---|
| 639 | setRC(2);
|
---|
| 640 | return;
|
---|
| 641 | }
|
---|
| 642 | BRPaquet paq0(NULL, buff, paqsz);
|
---|
| 643 | for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) {
|
---|
| 644 | BRPaquet paq(NULL, buff+i*paqsz, paqsz);
|
---|
| 645 | Byte min = 255;
|
---|
| 646 | Byte max = 0;
|
---|
| 647 |
|
---|
| 648 | for(sa_size_t j=0; j<vx.Size(); j++)
|
---|
| 649 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
|
---|
| 650 | fftwf_execute(plan);
|
---|
| 651 | // ffts_.FFTForward(vx, cfour_);
|
---|
| 652 | for(sa_size_t j=0; j<spectreV1.Size(); j++)
|
---|
| 653 | spectreV1(j) += Zmod2(cfour(j));
|
---|
| 654 |
|
---|
| 655 | for(sa_size_t j=0; j<vx.Size(); j++)
|
---|
| 656 | vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
|
---|
| 657 | fftwf_execute(plan);
|
---|
| 658 | // ffts_.FFTForward(vx, cfour_);
|
---|
| 659 | for(sa_size_t j=0; j<spectreV2.Size(); j++)
|
---|
| 660 | spectreV2(j) += Zmod2(cfour(j));
|
---|
| 661 |
|
---|
| 662 | nzm++;
|
---|
| 663 | }
|
---|
| 664 | if ((nzm >= nmean_) ||(kmz==(nmax_-1))) {
|
---|
| 665 | spectreV1 /= (r_4)(nzm);
|
---|
| 666 | spectreV2 /= (r_4)(nzm);
|
---|
| 667 | spectreV1.Info()["NPaqMoy"] = nzm;
|
---|
| 668 | spectreV2.Info()["NPaqMoy"] = nzm;
|
---|
| 669 | {
|
---|
| 670 | sprintf(fname,"%s/spectre2C_%d.ppf",path_.c_str(),(int)ifile);
|
---|
| 671 | POutPersist po(fname);
|
---|
| 672 | po << PPFNameTag("specV1") << spectreV1;
|
---|
| 673 | po << PPFNameTag("specV2") << spectreV2;
|
---|
| 674 | }
|
---|
| 675 | spectreV1 = (r_4)(0.);
|
---|
| 676 | spectreV2 = (r_4)(0.);
|
---|
| 677 | nzm = 0; ifile++;
|
---|
| 678 | ts.SetNow();
|
---|
| 679 | filog << ts << " : proc file " << fname << endl;
|
---|
| 680 | cout << " DataProc2C::run() " << ts << " : created file " << fname << endl;
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | memgr.FreeMemZone(mid, MemZS_Proc);
|
---|
| 684 | }
|
---|
| 685 | }
|
---|
[3671] | 686 | catch (std::exception& exc) {
|
---|
| 687 | cout << " DataProc::run()/catched std::exception " << exc.what() << endl;
|
---|
[3623] | 688 | setRC(3);
|
---|
| 689 | return;
|
---|
| 690 | }
|
---|
| 691 | catch(...) {
|
---|
| 692 | cout << " DataProc2C::run()/catched unknown ... exception " << endl;
|
---|
| 693 | setRC(4);
|
---|
| 694 | return;
|
---|
| 695 | }
|
---|
| 696 | setRC(0);
|
---|
| 697 | return;
|
---|
| 698 | }
|
---|
| 699 |
|
---|
| 700 |
|
---|
| 701 |
|
---|
| 702 |
|
---|
| 703 | //---------------------------------------------------------------
|
---|
| 704 | // Classe thread de traitement donnees FFT avec 2 voies par frame
|
---|
| 705 | //---------------------------------------------------------------
|
---|
| 706 |
|
---|
| 707 | inline r_4 Zmod2TwoByte(TwoByteComplex z)
|
---|
| 708 | { return (z.realD()*z.realD()+z.imagD()*z.imagD()); }
|
---|
| 709 |
|
---|
| 710 | DataProcFFT2C::DataProcFFT2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax)
|
---|
| 711 | : memgr(mem)
|
---|
| 712 | {
|
---|
| 713 | nmax_ = nmax;
|
---|
| 714 | nmean_ = nmean;
|
---|
| 715 | step_ = step;
|
---|
| 716 | stop_ = false;
|
---|
| 717 | path_ = path;
|
---|
| 718 | act.sa_handler=DataProcSignal;
|
---|
| 719 | }
|
---|
| 720 | void DataProcFFT2C::Stop()
|
---|
| 721 | {
|
---|
| 722 | stop_=true;
|
---|
| 723 | // cout <<" DataProcFFT2C::Stop ... > STOP " << endl;
|
---|
| 724 | }
|
---|
| 725 |
|
---|
| 726 | void DataProcFFT2C::run()
|
---|
| 727 | {
|
---|
| 728 | // sigaction(SIGINT,&act,NULL);
|
---|
| 729 | setRC(1);
|
---|
| 730 | try {
|
---|
| 731 | TimeStamp ts;
|
---|
| 732 | cout << " DataProcFFT2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
|
---|
| 733 | << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
[3634] | 734 | cout << " DataProc::run()... - Output Data Path: " << path_ << endl;
|
---|
[3623] | 735 | char fname[512];
|
---|
| 736 | sprintf(fname,"%s/proc.log",path_.c_str());
|
---|
| 737 | ofstream filog(fname);
|
---|
| 738 | filog << " DataProcFFT2C::run() - starting log file " << ts << endl;
|
---|
| 739 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
| 740 |
|
---|
| 741 | // Initialisation pour clcul FFT
|
---|
| 742 | TVector< complex<r_4> > cfour; // composant TF
|
---|
| 743 | uint_4 paqsz = memgr.PaqSize();
|
---|
| 744 | BRPaquet pq(NULL, NULL, paqsz);
|
---|
| 745 |
|
---|
| 746 | TVector<r_4> spectreV1(pq.DataSize()/4+1), spectreV2(pq.DataSize()/4+1);
|
---|
| 747 |
|
---|
| 748 | uint_4 ifile = 0;
|
---|
| 749 | for (uint_4 kmz=0; kmz<nmax_; kmz++) {
|
---|
| 750 | if (stop_ ) break;
|
---|
| 751 | int mid = memgr.FindMemZoneId(MemZA_Proc);
|
---|
| 752 | Byte* buff = memgr.GetMemZone(mid);
|
---|
| 753 | if (buff == NULL) {
|
---|
| 754 | cout << " DataProcFFT2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
|
---|
| 755 | setRC(2);
|
---|
| 756 | return;
|
---|
| 757 | }
|
---|
| 758 | BRPaquet paq0(NULL, buff, paqsz);
|
---|
| 759 | uint_4 nzm = 0;
|
---|
| 760 | for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) {
|
---|
| 761 | BRPaquet paq(NULL, buff+i*paqsz, paqsz);
|
---|
| 762 | Byte min = 255;
|
---|
| 763 | Byte max = 0;
|
---|
| 764 |
|
---|
| 765 | TwoByteComplex* zz;
|
---|
| 766 | // Traitement Voie 1
|
---|
| 767 | zz = (TwoByteComplex*)paq.Data1();
|
---|
| 768 | spectreV1(0) += zz[0].realD()*zz[0].realD(); // Composante continue, partie reelle uniquement
|
---|
| 769 | for(sa_size_t j=1; j<spectreV1.Size()-1; j++) spectreV1(j) += Zmod2TwoByte(zz[j]);
|
---|
| 770 |
|
---|
| 771 | spectreV1(spectreV1.Size()-1) += zz[0].imagD()*zz[0].imagD(); // Freq. Nyquist a N/2
|
---|
| 772 |
|
---|
| 773 | // Traitement Voie 2
|
---|
| 774 | zz = (TwoByteComplex*)paq.Data2();
|
---|
| 775 | spectreV2(0) += zz[0].realD()*zz[0].realD(); // Composante continue, partie reelle uniquement
|
---|
| 776 | for(sa_size_t j=1; j<spectreV2.Size()-1; j++) spectreV2(j) += Zmod2TwoByte(zz[j]);
|
---|
| 777 |
|
---|
| 778 | spectreV2(spectreV2.Size()-1) += zz[0].imagD()*zz[0].imagD(); // Freq. Nyquist a N/2
|
---|
| 779 |
|
---|
| 780 | nzm++;
|
---|
| 781 | }
|
---|
| 782 | if ((nzm >= nmean_) ||(kmz==(nmax_-1))) {
|
---|
| 783 | spectreV1 /= (r_4)(nzm);
|
---|
| 784 | spectreV2 /= (r_4)(nzm);
|
---|
| 785 | spectreV1.Info()["NPaqMoy"] = nzm;
|
---|
| 786 | spectreV2.Info()["NPaqMoy"] = nzm;
|
---|
| 787 | {
|
---|
| 788 | sprintf(fname,"%s/spectreFFT2C_%d.ppf",path_.c_str(),(int)ifile);
|
---|
| 789 | POutPersist po(fname);
|
---|
| 790 | po << PPFNameTag("specV1") << spectreV1;
|
---|
| 791 | po << PPFNameTag("specV2") << spectreV2;
|
---|
| 792 | }
|
---|
| 793 | spectreV1 = (r_4)(0.);
|
---|
| 794 | spectreV2 = (r_4)(0.);
|
---|
| 795 | nzm = 0; ifile++;
|
---|
| 796 | ts.SetNow();
|
---|
| 797 | filog << ts << " : proc file " << fname << endl;
|
---|
| 798 | cout << " DataProcFFT2C::run() " << ts << " : created file " << fname << endl;
|
---|
| 799 | }
|
---|
| 800 |
|
---|
| 801 | memgr.FreeMemZone(mid, MemZS_Proc);
|
---|
| 802 | }
|
---|
| 803 | }
|
---|
[3671] | 804 | catch (std::exception& exc) {
|
---|
| 805 | cout << " DataProc::run()/catched std::exception " << exc.what() << endl;
|
---|
[3623] | 806 | setRC(3);
|
---|
| 807 | return;
|
---|
| 808 | }
|
---|
| 809 | catch(...) {
|
---|
| 810 | cout << " DataProcFFT2C::run()/catched unknown ... exception " << endl;
|
---|
| 811 | setRC(4);
|
---|
| 812 | return;
|
---|
| 813 | }
|
---|
| 814 | setRC(0);
|
---|
| 815 | return;
|
---|
| 816 | }
|
---|