Changeset 3645 in Sophya for trunk/AddOn/TAcq/brproc.cc
- Timestamp:
- Jun 1, 2009, 10:24:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/brproc.cc
r3642 r3645 27 27 //--------------------------------------------------------------- 28 28 29 /* --Methode-- */ 29 30 BRProcARaw2C::BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, 30 uint_4 step, uint_4 nmax, bool fgnotrl)31 uint_4 nmax, bool fgnotrl, int card) 31 32 : memgr(mem) 32 33 { 33 34 nmax_ = nmax; 34 35 nmean_ = nmean; 35 step_ = step;36 36 stop_ = false; 37 37 path_ = path; 38 38 fgnotrl_ = fgnotrl; 39 } 40 39 card_ = card; 40 } 41 42 /* --Methode-- */ 41 43 void BRProcARaw2C::Stop() 42 44 { … … 49 51 { return (z.real()*z.real()+z.imag()*z.imag()); } 50 52 53 static inline string card2name_(int card) 54 { 55 if (card==2) return " (Chan3,4) "; 56 else return " (Chan1,2) "; 57 } 58 /* --Methode-- */ 51 59 void BRProcARaw2C::run() 52 60 { … … 61 69 62 70 cout << " BRProcARaw2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ 63 << " NMean=" << nmean_ << " Step=" << step_<< endl;71 << " NMean=" << nmean_ << card2name_(card_) << endl; 64 72 cout << " BRProcARaw2C::run()... - Output Data Path: " << path_ << endl; 65 73 char fname[512]; … … 106 114 } 107 115 108 for(uint_4 i=0; i<memgr.NbPaquets(); i+ =step_) {116 for(uint_4 i=0; i<memgr.NbPaquets(); i++) { 109 117 BRPaquet paq(NULL, buff+i*paqsz, paqsz); 110 118 if (!pcheck.Check(paq)) continue; // on ne traite que les paquets OK 111 119 112 120 // Traitement voie 1 113 114 121 for(sa_size_t j=0; j<vx.Size(); j++) 122 vx(j) = (r_4)(*(paq.Data1()+j))-127.5; 115 123 // fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz); 116 124 fftwf_execute(plan1); 117 125 // complex<r_4>* zp1 = (complex<r_4>*)(coeff1); 118 126 // ffts.FFTForward(vx, cfour1); … … 121 129 memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size()); 122 130 // Traitement voie 2 123 124 125 126 131 for(sa_size_t j=0; j<vx.Size(); j++) 132 vx(j) = (r_4)(*(paq.Data2()+j))-127.5; 133 134 fftwf_execute(plan2); 127 135 128 136 for(sa_size_t j=0; j<spectreV2.Size(); j++) … … 151 159 sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile); 152 160 POutPersist po(fname); 153 po << PPFNameTag("specV1") << spectreV1; 154 po << PPFNameTag("specV2") << spectreV2; 155 po << PPFNameTag("visiV12") << visiV12; 161 string tag1="specV1"; 162 string tag2="specV2"; 163 string tag12="visiV12"; 164 if (card_==2) { 165 tag1 = "specV3"; 166 tag2 = "specV4"; 167 tag12="visiV34"; 168 } 169 po << PPFNameTag(tag1) << spectreV1; 170 po << PPFNameTag(tag2) << spectreV2; 171 po << PPFNameTag(tag12) << visiV12; 156 172 } 157 173 spectreV1 = (r_4)(0.); … … 161 177 // ts.SetNow(); 162 178 // filog << ts << " : proc file " << fname << endl; 163 cout << " BRProcARaw2C::run() created file " << fname << endl;179 cout << " BRProcARaw2C::run() created file " << fname << card2name_(card_) << endl; 164 180 } 165 181 166 182 memgr.FreeMemZone(mid, MemZS_ProcA); 167 183 } // Fin de boucle sur les zones a traiter 168 cout << " ------------------ BRProcARaw2C::run() END ----------------- " << endl; 184 cout << " ------------ BRProcARaw2C::run() END " << card2name_(card_) 185 << " ------------ " << endl; 169 186 ts.SetNow(); 170 187 tm.SplitQ(); … … 173 190 << " ProcDataOut=" << totnbytesout/(1024*1024) << " MB" << endl; 174 191 cout << pcheck; 175 cout << " BRProcARaw2C::run()/Timing: \n";192 cout << " BRProcARaw2C::run()/Timing: " << card2name_(card_) << endl; 176 193 tm.Print(); 177 194 cout << " ---------------------------------------------------------- " << endl; … … 192 209 } 193 210 194 195 196 211 //--------------------------------------------------------------------- 212 // Classe thread de traitement 2 x 2 voies/frames (Apres BRProcARaw2C) 213 //--------------------------------------------------------------------- 214 215 /* --Methode-- */ 216 BRProcBRaw4C::BRProcBRaw4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2, 217 string& path, uint_4 nmean, uint_4 nmax, bool fgnotrl) 218 : memgr1(mem1), memgr2(mem2) 219 { 220 nmax_ = nmax; 221 nmean_ = nmean; 222 stop_ = false; 223 path_ = path; 224 fgnotrl_ = fgnotrl; 225 } 226 227 /* --Methode-- */ 228 void BRProcBRaw4C::Stop() 229 { 230 stop_=true; 231 // cout <<" BRProcBRaw4C::Stop ... > STOP " << endl; 232 } 233 234 235 /* --Methode-- */ 236 void BRProcBRaw4C::run() 237 { 238 setRC(1); 239 try { 240 Timer tm("BRProcBRaw4C", false); 241 TimeStamp ts; 242 BRPaqChecker pcheck1(~fgnotrl_); // Verification/comptage des paquets 243 BRPaqChecker pcheck2(~fgnotrl_); // Verification/comptage des paquets 244 245 size_t totnbytesout = 0; 246 size_t totnbytesproc = 0; 247 248 cout << " BRProcBRaw4C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ 249 << " NMean=" << nmean_ << endl; 250 cout << " BRProcBRaw4C::run()... - Output Data Path: " << path_ << endl; 251 252 uint_4 paqsz = memgr1.PaqSize(); 253 uint_4 procpaqsz = memgr1.ProcPaqSize(); 254 if ((paqsz != memgr2.PaqSize())||(procpaqsz!= memgr2.ProcPaqSize())) { 255 cout << "BRProcBRaw4C::run()/ERROR : different paquet size -> stop \n ...(PaqSz1=" 256 << paqsz << " Sz2=" << memgr2.PaqSize() << " ProcPaqSz1=" 257 << procpaqsz << " Sz2=" << memgr2.ProcPaqSize() << " )" << endl; 258 setRC(9); 259 return; 260 } 261 262 TVector< complex<r_4> > cfour; // composant TF 263 BRPaquet pq(NULL, NULL, paqsz); 264 TVector<r_4> vx(pq.DataSize()/2); 265 vx = (r_4)(0.); 266 FFTPackServer ffts; 267 ffts.FFTForward(vx, cfour); 268 269 TVector< complex<r_4> > visiV13( cfour.Size() ); 270 TVector< complex<r_4> > visiV14( cfour.Size() ); 271 TVector< complex<r_4> > visiV23( cfour.Size() ); 272 TVector< complex<r_4> > visiV24( cfour.Size() ); 273 274 uint_4 nzm = 0; 275 uint_4 totnoksfc = 0; 276 uint_4 totnokpaq = 0; 277 uint_4 totnpaq = 0; 278 uint_4 ifile = 0; 279 for (uint_4 kmz=0; kmz<nmax_; kmz++) { 280 uint_4 noksfc = 0; 281 uint_4 nokpaq = 0; 282 if (stop_) break; 283 int mid1 = memgr1.FindMemZoneId(MemZA_ProcB); 284 Byte* buff1 = memgr1.GetMemZone(mid1); 285 if (buff1 == NULL) { 286 cout << " BRProcBRaw4C::run()/ERROR memgr.GetMemZone(" << mid1 << ") -> NULL" << endl; 287 break; 288 } 289 Byte* procbuff1 = memgr1.GetProcMemZone(mid1); 290 if (procbuff1 == NULL) { 291 cout << " BRProcBRaw4C::run()/ERROR memgr.GetProcMemZone(" << mid1 << ") -> NULL" << endl; 292 break; 293 } 294 int mid2 = memgr2.FindMemZoneId(MemZA_ProcB); 295 Byte* buff2 = memgr2.GetMemZone(mid2); 296 if (buff1 == NULL) { 297 cout << " BRProcBRaw4C::run()/ERROR memgr.GetMemZone(" << mid2 << ") -> NULL" << endl; 298 break; 299 } 300 Byte* procbuff2 = memgr2.GetProcMemZone(mid2); 301 if (procbuff2 == NULL) { 302 cout << " BRProcBRaw4C::run()/ERROR memgr.GetProcMemZone(" << mid2 << ") -> NULL" << endl; 303 break; 304 } 305 uint_4 i1,i2; 306 i1=i2=0; 307 while((i1<memgr1.NbPaquets())&&(i2<memgr2.NbPaquets())) { 308 BRPaquet paq1(NULL, buff1+i1*paqsz, paqsz); 309 BRPaquet paq2(NULL, buff2+i2*paqsz, paqsz); 310 totnpaq++; 311 // cout << " DBG["<<kmz<<"] i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter() 312 //<<","<<paq2.FrameCounter()<<endl; 313 // on ne traite que les paquets OK 314 if (!pcheck1.Check(paq1)) { i1++; continue; } 315 if (!pcheck2.Check(paq2)) { i2++; continue; } 316 nokpaq++; 317 if (paq1.FrameCounter()<paq2.FrameCounter()) { i1++; continue; } 318 if (paq2.FrameCounter()<paq1.FrameCounter()) { i2++; continue; } 319 // cout << " DBG["<<kmz<<"]OKOK i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter() 320 // <<","<<paq2.FrameCounter()<<endl; 321 322 // Les deux framecounters sont identiques ... 323 noksfc++; 324 complex<r_4>* zp1 = (complex<r_4>*)(procbuff1+i1*procpaqsz); 325 complex<r_4>* zp2 = (complex<r_4>*)(procbuff1+i1*procpaqsz+procpaqsz/2); 326 complex<r_4>* zp3 = (complex<r_4>*)(procbuff2+i2*procpaqsz); 327 complex<r_4>* zp4 = (complex<r_4>*)(procbuff2+i2*procpaqsz+procpaqsz/2); 328 for(sa_size_t j=0; j<visiV13.Size(); j++) { 329 visiV13(j)+=zp1[j]*conj(zp3[j]); 330 visiV14(j)+=zp1[j]*conj(zp4[j]); 331 visiV23(j)+=zp2[j]*conj(zp3[j]); 332 visiV24(j)+=zp2[j]*conj(zp4[j]); 333 } 334 nzm++; i1++; i2++; 335 totnbytesproc += 2*paq1.DataSize(); 336 } // Fin de boucle sur les paquets d'une zone 337 if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) { 338 visiV13 /= complex<r_4>((r_4)nzm, 0.); 339 visiV14 /= complex<r_4>((r_4)nzm, 0.); 340 visiV23 /= complex<r_4>((r_4)nzm, 0.); 341 visiV24 /= complex<r_4>((r_4)nzm, 0.); 342 visiV13.Info()["NPaqMoy"] = nzm; 343 visiV14.Info()["NPaqMoy"] = nzm; 344 visiV23.Info()["NPaqMoy"] = nzm; 345 visiV24.Info()["NPaqMoy"] = nzm; 346 char fname[512]; 347 { 348 sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile); 349 POutPersist po(fname); 350 po << PPFNameTag("visiV13") << visiV13; 351 po << PPFNameTag("visiV14") << visiV14; 352 po << PPFNameTag("visiV23") << visiV23; 353 po << PPFNameTag("visiV24") << visiV24; 354 } 355 visiV13 = complex<r_4>(0., 0.); 356 visiV14 = complex<r_4>(0., 0.); 357 visiV23 = complex<r_4>(0., 0.); 358 visiV24 = complex<r_4>(0., 0.); 359 nzm = 0; 360 // ts.SetNow(); 361 // filog << ts << " : proc file " << fname << endl; 362 cout << " BRProcBRaw4C::run() created file " << fname << endl; 363 } 364 memgr1.FreeMemZone(mid1, MemZS_ProcB); 365 memgr2.FreeMemZone(mid2, MemZS_ProcB); 366 double okfrac = (nokpaq>1)?((double)noksfc/(double)nokpaq*100.):0.; 367 cout << "BRProcBRaw2C ["<<kmz<<"] NOKPaq=" << nokpaq << " NSameFC=" << noksfc 368 << " (" << okfrac << " %)" << endl; 369 totnokpaq += nokpaq; 370 totnoksfc += noksfc; 371 } // Fin de boucle sur les zones a traiter 372 cout << " ------------------ BRProcBRaw4C::run() END ----------------- " << endl; 373 ts.SetNow(); 374 tm.SplitQ(); 375 cout << " TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= " 376 << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s" << endl; 377 double totokfrac = (totnokpaq>1)?((double)totnoksfc/(double)totnokpaq*100.):0.; 378 cout << " NOkPaq1,2=" << totnokpaq << " /TotNPaq=" << totnpaq << " TotNSameFC=" 379 << totnoksfc << " (" << totokfrac << " %)" << endl; 380 // cout << pcheck1; 381 // cout << pcheck2; 382 cout << " BRProcBRaw4C::run()/Timing: \n"; 383 tm.Print(); 384 cout << " ---------------------------------------------------------- " << endl; 385 } 386 catch (PException& exc) { 387 cout << " BRProcBRaw4C::run()/catched PException " << exc.Msg() << endl; 388 setRC(3); 389 return; 390 } 391 catch(...) { 392 cout << " BRProcBRaw4C::run()/catched unknown ... exception " << endl; 393 setRC(4); 394 return; 395 } 396 setRC(0); 397 return; 398 } 399 400
Note:
See TracChangeset
for help on using the changeset viewer.