// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: tgenw.cc,v 1.7 2001-11-13 16:01:39 aubourg Exp $ /* Test de GenWindowTOIProcessor (generic processor with window) ---------------- Exemple d'appel --------------------- csh> time ./tgenw -intoi bolo -start 1 -end 50000 -wgen 16,1,64 -wlcr 0,0,0 \ -dbg 0 toto.fits xx.fits */ #include "machdefs.h" #include #include "array.h" #include #include "toi.h" #include "toiprocessor.h" #include "fitstoirdr.h" #include "fitstoiwtr.h" #include "toimanager.h" #include "genwproc.h" #include "toiseqbuff.h" #include "timing.h" #include "sambainit.h" #include // ----- Classe de test heritant de GenWindowTOIProcessor ----- class TGenWProc : public GenWindowTOIProcessor { public: TGenWProc(int ntoiout, int wsz, int step, int wt); virtual void UserInit(int_8 kstart); virtual void UserProc(int_8 ks); virtual void UserEnd(int_8 kend); protected: int_8 SNRunning; }; TGenWProc::TGenWProc(int ntoiout,int wsz, int step, int wt) : GenWindowTOIProcessor(1,ntoiout,wsz,step,wt) { SNRunning = 1; } void TGenWProc::UserInit(int_8 kstart) { cout << "TGenWProc::UserInit(" << kstart << ")" << endl; } void TGenWProc::UserEnd(int_8 kend) { cout << "TGenWProc::UserEnd(" << kend << ")" << endl; } void TGenWProc::UserProc(int_8 ks) { if( ks==StartSampleNum() || ks>=EndSampleNum()-1 || ks%1000==0 ) cout<<"TGenWProc::UserProc("< 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false); cout << "tgenw starting - Decoding arguments " << " narg=" << narg << endl; bool fgdbg = false; bool fgsetstart = false; int dbglevel = 0; int wtoi = 8192; int wgen = 16; int stepgen = 1; int wgl = 0, wgc = 0, wgr = 0; int wtotgen = 0; int istart = 0; int iend = 0; string infile; string outfile = ""; string outppfname; string intoi = "boloMuV_27"; if (narg < 2) Usage(true); int ko=1; // decoding arguments for(int ia=1; ia> tgenw: Infile= " << infile << " outFile=" << outfile << endl; cout << ">>> Window Size WTOI= " << wtoi << " WGenSz= " << wgen << " StepGen=" << stepgen << " WTot=" << wtotgen << " Wglcr=" << wgl << "," << wgc << "," << wgr << endl; cout << ">>>> InTOIName= " << intoi << " iStart= " << istart << " iEnd= " << iend << endl; try { TOIManager* mgr = TOIManager::getManager(); // mgr->setRequestedSample(11680920,11710584); // mgr->setRequestedSample(104121000, 104946120); if (fgsetstart) mgr->setRequestedSample(istart, iend); FITSTOIReader r(infile); cout << "reader created" << endl; int ntoiout=0; FITSTOIWriter* w=NULL; if(outfile.size()>0) { ntoiout=1; w = new FITSTOIWriter(outfile); cout << "fits writer created" << endl; } TOISeqBuffered * toiin = new TOISeqBuffered("f2in", wtoi); if (fgdbg) toiin->setDebugLevel(1); TOISeqBuffered * toiout = NULL; if(w) { toiout = new TOISeqBuffered("genout", wtoi); if (fgdbg) toiout->setDebugLevel(1); } TGenWProc tgenp(ntoiout, wgen, stepgen, wtotgen); tgenp.SetWSizeLCR(wgl,wgc,wgr); tgenp.SetDbgLevel(dbglevel); cout << " Connecting to FitsReader ... " << endl; r.addOutput(intoi, toiin); if(w && toiout) { cout << " Connecting to FitsWriter ... " << endl; w->addInput("genout",toiout,true); } cout << " Connecting TGenWProc ... " << endl; tgenp.addInput("in0",toiin); if(toiout) tgenp.addOutput("out0",toiout); tgenp.PrintStatus(cout); PrtTim("starting threads"); r.start(); tgenp.start(); if(w) w->start(); /* for(int jj=0; jj<3; jj++) { cout << *toiin; if(toiout) cout << *toiout; sleep(1); } */ mgr->joinAll(); PrtTim("End threads"); // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl; // r.PrintStatus(cout); // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl; // w->PrintStatus(cout); cout << " ------ toiin, toiout Status information ------- " << endl; cout << *toiin; if(toiout) cout << *toiout; tgenp.PrintStatus(cout); // Fermeture du fitswriter if(w) delete w;; } catch (PThrowable & exc) { cerr << "\n tgenw: Catched Exception \n" << (string)typeid(exc).name() << " - Msg= " << exc.Msg() << endl; } catch (const std::exception & sex) { cerr << "\n tgenw: Catched std::exception \n" << (string)typeid(sex).name() << endl; } catch (...) { cerr << "\n tgenw: some other exception was caught ! " << endl; } return(0); }