#include "racquproc.h" #include #include #include #include #include "pexceptions.h" #include "tvector.h" #include "fioarr.h" #include "timestamp.h" #include "fftpserver.h" #include "fftwserver.h" #include "FFTW/fftw3.h" #include "pciewrap.h" #include "brpaqu.h" #include "minifits.h" struct sigaction act; //------------------------------------------------------- // Classe thread de traitement avec 1 voie par frame //------------------------------------------------------- void DataProcSignal(int s) { cout <<"............................................... receive CtrlC" << endl; } DataProc::DataProc(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax) : memgr(mem) { nmax_ = nmax; nmean_ = nmean; step_ = step; stop_ = false; path_ = path; act.sa_handler=DataProcSignal; } static inline r_4 Zmod2(complex z) { return (z.real()*z.real()+z.imag()*z.imag()); } void DataProc::Stop() { stop_=true; // cout <<" DataProc::Stop ... > STOP " << endl; } void DataProc::run() { // sigaddset(&act.sa_mask,SIGINT); // pour proteger le transfert DMA // sigaction(SIGINT,&act,NULL); setRC(1); try { TimeStamp ts; cout << " DataProc::run() - Starting " << ts << " NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; cout << " DataProc::run()... - Output Data Path: " << path_ << endl; char fname[512]; sprintf(fname,"%s/proc.log",path_.c_str()); ofstream filog(fname); filog << " DataProc::run() - starting log file " << ts << endl; filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; // Initialisation pour clcul FFT TVector< complex > cfour; // composant TF uint_4 paqsz = memgr.PaqSize(); BRPaquet pq(NULL, NULL, paqsz); TVector vx(pq.DataSize()); vx = (r_4)(0.); FFTPackServer ffts; ffts.FFTForward(vx, cfour); TVector spectre; spectre.ReSize(cfour.Size()); fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); uint_4 ifile = 0; uint_4 nzm = 0; for (uint_4 kmz=0; kmz NULL" << endl; setRC(2); return; } BRPaquet paq0(NULL, buff, paqsz); for(uint_4 i=0; i= nmean_) ||(kmz==(nmax_-1))) { spectre /= (r_4)(nzm); spectre.Info()["NPaqMoy"] = nzm; sprintf(fname,"%s/spectre%d.ppf",path_.c_str(),(int)ifile); POutPersist po(fname); po << spectre; spectre = (r_4)(0.); nzm = 0; ifile++; ts.SetNow(); filog << ts << " : proc file " << fname << endl; cout << " DataProc::run() " << ts << " : created file " << fname << endl; } memgr.FreeMemZone(mid, MemZS_Proc); } } catch (PException& exc) { cout << " DataProc::run()/catched PException " << exc.Msg() << endl; setRC(3); return; } catch(...) { cout << " DataProc::run()/catched unknown ... exception " << endl; setRC(4); return; } setRC(0); return; } //--------------------------------------------------------------- // Classe thread de traitement donnees ADC avec 2 voies par frame //--------------------------------------------------------------- DataProc2C::DataProc2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax) : memgr(mem) { nmax_ = nmax; nmean_ = nmean; step_ = step; stop_ = false; path_ = path; act.sa_handler=DataProcSignal; } void DataProc2C::Stop() { stop_=true; // cout <<" DataProc2C::Stop ... > STOP " << endl; } void DataProc2C::run() { // sigaction(SIGINT,&act,NULL); setRC(1); try { TimeStamp ts; cout << " DataProc2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; cout << " DataProc::run()... - Output Data Path: " << path_ << endl; char fname[512]; sprintf(fname,"%s/proc.log",path_.c_str()); ofstream filog(fname); filog << " DataProc2C::run() - starting log file " << ts << endl; filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; // Initialisation pour clcul FFT TVector< complex > cfour; // composant TF uint_4 paqsz = memgr.PaqSize(); BRPaquet pq(NULL, NULL, paqsz); TVector vx(pq.DataSize()/2); vx = (r_4)(0.); FFTPackServer ffts; ffts.FFTForward(vx, cfour); TVector spectreV1, spectreV2; spectreV1.ReSize(cfour.Size()); spectreV2.ReSize(cfour.Size()); fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); uint_4 ifile = 0; uint_4 nzm = 0; for (uint_4 kmz=0; kmz NULL" << endl; setRC(2); return; } BRPaquet paq0(NULL, buff, paqsz); for(uint_4 i=0; i= nmean_) ||(kmz==(nmax_-1))) { spectreV1 /= (r_4)(nzm); spectreV2 /= (r_4)(nzm); spectreV1.Info()["NPaqMoy"] = nzm; spectreV2.Info()["NPaqMoy"] = nzm; { sprintf(fname,"%s/spectre2C_%d.ppf",path_.c_str(),(int)ifile); POutPersist po(fname); po << PPFNameTag("specV1") << spectreV1; po << PPFNameTag("specV2") << spectreV2; } spectreV1 = (r_4)(0.); spectreV2 = (r_4)(0.); nzm = 0; ifile++; ts.SetNow(); filog << ts << " : proc file " << fname << endl; cout << " DataProc2C::run() " << ts << " : created file " << fname << endl; } memgr.FreeMemZone(mid, MemZS_Proc); } } catch (PException& exc) { cout << " DataProc2C::run()/catched PException " << exc.Msg() << endl; setRC(3); return; } catch(...) { cout << " DataProc2C::run()/catched unknown ... exception " << endl; setRC(4); return; } setRC(0); return; } //--------------------------------------------------------------- // Classe thread de traitement donnees FFT avec 2 voies par frame //--------------------------------------------------------------- inline r_4 Zmod2TwoByte(TwoByteComplex z) { return (z.realD()*z.realD()+z.imagD()*z.imagD()); } DataProcFFT2C::DataProcFFT2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax) : memgr(mem) { nmax_ = nmax; nmean_ = nmean; step_ = step; stop_ = false; path_ = path; act.sa_handler=DataProcSignal; } void DataProcFFT2C::Stop() { stop_=true; // cout <<" DataProcFFT2C::Stop ... > STOP " << endl; } void DataProcFFT2C::run() { // sigaction(SIGINT,&act,NULL); setRC(1); try { TimeStamp ts; cout << " DataProcFFT2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; cout << " DataProc::run()... - Output Data Path: " << path_ << endl; char fname[512]; sprintf(fname,"%s/proc.log",path_.c_str()); ofstream filog(fname); filog << " DataProcFFT2C::run() - starting log file " << ts << endl; filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; // Initialisation pour clcul FFT TVector< complex > cfour; // composant TF uint_4 paqsz = memgr.PaqSize(); BRPaquet pq(NULL, NULL, paqsz); TVector spectreV1(pq.DataSize()/4+1), spectreV2(pq.DataSize()/4+1); uint_4 ifile = 0; for (uint_4 kmz=0; kmz NULL" << endl; setRC(2); return; } BRPaquet paq0(NULL, buff, paqsz); uint_4 nzm = 0; for(uint_4 i=0; i= nmean_) ||(kmz==(nmax_-1))) { spectreV1 /= (r_4)(nzm); spectreV2 /= (r_4)(nzm); spectreV1.Info()["NPaqMoy"] = nzm; spectreV2.Info()["NPaqMoy"] = nzm; { sprintf(fname,"%s/spectreFFT2C_%d.ppf",path_.c_str(),(int)ifile); POutPersist po(fname); po << PPFNameTag("specV1") << spectreV1; po << PPFNameTag("specV2") << spectreV2; } spectreV1 = (r_4)(0.); spectreV2 = (r_4)(0.); nzm = 0; ifile++; ts.SetNow(); filog << ts << " : proc file " << fname << endl; cout << " DataProcFFT2C::run() " << ts << " : created file " << fname << endl; } memgr.FreeMemZone(mid, MemZS_Proc); } } catch (PException& exc) { cout << " DataProcFFT2C::run()/catched PException " << exc.Msg() << endl; setRC(3); return; } catch(...) { cout << " DataProcFFT2C::run()/catched unknown ... exception " << endl; setRC(4); return; } setRC(0); return; }