| [2316] | 1 | //#define TOISEQBUFFERED | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #include <unistd.h> | 
|---|
|  | 4 | #include "toi.h" | 
|---|
|  | 5 | #include "cgt.h" | 
|---|
|  | 6 | #include "toiprocessor.h" | 
|---|
|  | 7 | #include "fitstoirdr.h" | 
|---|
|  | 8 | #include "fitsringwtr.h" | 
|---|
|  | 9 | #include "toimanager.h" | 
|---|
|  | 10 | #ifdef TOISEQBUFFERED | 
|---|
|  | 11 | #include "toiseqbuff.h" | 
|---|
|  | 12 | #else | 
|---|
|  | 13 | #include "toisegment.h" | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include "sambainit.h" | 
|---|
|  | 17 | #include "toi2ring.h" | 
|---|
|  | 18 | #include "timing.h" | 
|---|
|  | 19 |  | 
|---|
|  | 20 | #include <stdexcept> | 
|---|
|  | 21 |  | 
|---|
|  | 22 | void usage(void); | 
|---|
|  | 23 | void usage(void) { | 
|---|
| [2329] | 24 | cout<<"tsttoi2ring fitsin_phase fitsin_value fitsout_value fitsout_weight "; | 
|---|
| [2355] | 25 | cout<<" Nsamples SN_begin SN_last Nring (all if SN_last<SN_begin)"<<endl; | 
|---|
| [2316] | 26 | return; | 
|---|
|  | 27 | } | 
|---|
|  | 28 |  | 
|---|
|  | 29 | //////////////////////////////////////////////////////////////// | 
|---|
|  | 30 | int main(int narg, char** arg) { | 
|---|
|  | 31 |  | 
|---|
|  | 32 | TOIManager* mgr = TOIManager::getManager(); | 
|---|
|  | 33 |  | 
|---|
|  | 34 | //-- Decodage arguments | 
|---|
| [2319] | 35 | bool fgsegmented = true; | 
|---|
| [2316] | 36 | int wsize = 512; | 
|---|
| [2319] | 37 | char *label_phase = "PHASE",  *label_bolomuv = "BOLOMUVC_26"; | 
|---|
|  | 38 | char *label_theta = "THETA",  *label_phi = "PHI"; | 
|---|
| [2316] | 39 | bool snimplicit = false; | 
|---|
|  | 40 |  | 
|---|
| [2355] | 41 | if(narg != 9) {usage(); exit(2);} | 
|---|
| [2316] | 42 | char * fitsin_phase    = arg[1]; | 
|---|
|  | 43 | char * fitsin_value    = arg[2]; | 
|---|
|  | 44 | char * fitsout_value   = arg[3]; | 
|---|
|  | 45 | char * fitsout_weight  = arg[4]; | 
|---|
|  | 46 | int    Nsamples        = atoi(arg[5]); | 
|---|
| [2329] | 47 | int_8 sdeb               = atoi(arg[6]); | 
|---|
|  | 48 | int_8 sfin              = atoi(arg[7]); | 
|---|
| [2355] | 49 | int_8 Nring             = atoi(arg[8]); | 
|---|
| [2329] | 50 | cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl; | 
|---|
|  | 51 |  | 
|---|
| [2316] | 52 |  | 
|---|
|  | 53 | cout<<">>>> tsttoi2ring:"<<endl | 
|---|
|  | 54 | <<"Fits OutFile "<<fitsout_value<<endl | 
|---|
|  | 55 | <<"Fits WOutFile "<<fitsout_weight<<endl; | 
|---|
|  | 56 | cout<<"Fits Infile Value "<<fitsin_value<<endl | 
|---|
|  | 57 | <<"  ...label_bolomuv "<<label_bolomuv<<endl; | 
|---|
|  | 58 | cout<<"Fits Infile Pointing "<<fitsin_phase<<endl | 
|---|
|  | 59 | <<"  ...label_phase "<<label_phase<<endl; | 
|---|
|  | 60 |  | 
|---|
|  | 61 |  | 
|---|
|  | 62 | SophyaInit(); | 
|---|
|  | 63 | InitTim(); | 
|---|
|  | 64 |  | 
|---|
|  | 65 | //-------------------------------------------------------------------- | 
|---|
|  | 66 | try { | 
|---|
|  | 67 | //-------------------------------------------------------------------- | 
|---|
|  | 68 |  | 
|---|
|  | 69 | CGT plombier(fgsegmented,wsize); | 
|---|
|  | 70 | plombier.SetDebugLevel(99); | 
|---|
|  | 71 |  | 
|---|
|  | 72 | // FITS reader et writer | 
|---|
|  | 73 | FITSTOIReader rfitsp(fitsin_phase); | 
|---|
|  | 74 | if(snimplicit) rfitsp.setImplicitSN(); | 
|---|
| [2329] | 75 | if(sfin>=sdeb) rfitsp.setRequestedSample(sdeb,sfin); | 
|---|
|  | 76 |  | 
|---|
| [2316] | 77 | FITSTOIReader rfitsv(fitsin_value); | 
|---|
|  | 78 | if(snimplicit) rfitsv.setImplicitSN(); | 
|---|
|  | 79 | cout << "fits reader created"<<endl; | 
|---|
|  | 80 |  | 
|---|
|  | 81 | FITSRingWriter wfits(fitsout_value); | 
|---|
| [2331] | 82 | FITSRingWriter wwfits(fitsout_weight); | 
|---|
| [2316] | 83 | cout << "setAperture" << endl; | 
|---|
|  | 84 | wfits.setAperture(85.); | 
|---|
| [2331] | 85 | wwfits.setAperture(85.); | 
|---|
| [2316] | 86 | cout << "setNSamples" << endl; | 
|---|
|  | 87 | wfits.setNSamples(Nsamples); | 
|---|
| [2331] | 88 | wwfits.setNSamples(Nsamples); | 
|---|
| [2355] | 89 | wfits.setNRings(Nring); | 
|---|
|  | 90 | wwfits.setNRings(Nring); | 
|---|
| [2316] | 91 |  | 
|---|
| [2329] | 92 |  | 
|---|
| [2316] | 93 |  | 
|---|
|  | 94 | // TOI Processor | 
|---|
|  | 95 | Toi2RING m2ring(Nsamples); | 
|---|
|  | 96 | cout<<"Toi2RING created"<<endl; | 
|---|
|  | 97 |  | 
|---|
| [2329] | 98 | if(sfin>=sdeb) m2ring.setRequestedSample(sdeb,sfin); | 
|---|
|  | 99 |  | 
|---|
| [2316] | 100 | // Definition des tuyaux | 
|---|
|  | 101 | cout << label_phase <<endl; | 
|---|
|  | 102 |  | 
|---|
| [2319] | 103 | plombier.Connect(rfitsp,label_theta,m2ring,"Theta"); | 
|---|
|  | 104 | plombier.Connect(rfitsp,label_phi,m2ring,"Phi"); | 
|---|
| [2316] | 105 | plombier.Connect(rfitsp,label_phase,m2ring,"Phase"); | 
|---|
|  | 106 | plombier.Connect(rfitsv,label_bolomuv,m2ring,"Value"); | 
|---|
|  | 107 | cout<<"file out "<<fitsout_value<< endl; | 
|---|
| [2319] | 108 |  | 
|---|
| [2316] | 109 | plombier.Connect(m2ring,"Rvalue",wfits,"signal"); | 
|---|
| [2355] | 110 | plombier.Connect(m2ring,"WRvalue",wwfits,"signal"); | 
|---|
| [2316] | 111 |  | 
|---|
|  | 112 | // Run | 
|---|
|  | 113 | cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl; | 
|---|
|  | 114 |  | 
|---|
|  | 115 | plombier.Start(); | 
|---|
|  | 116 | plombier.ListTOIs(cout, 1); | 
|---|
|  | 117 | cout << "Joining ..." << endl; | 
|---|
|  | 118 |  | 
|---|
|  | 119 | mgr->joinAll(); | 
|---|
|  | 120 | PrtTim("End threads"); | 
|---|
|  | 121 |  | 
|---|
|  | 122 | //-------------------------------------------------------------------- | 
|---|
|  | 123 | } catch (PThrowable & exc) { | 
|---|
|  | 124 | cout<<"\ntsttoi2ring: Catched Exception \n"<<(string)typeid(exc).name() | 
|---|
|  | 125 | <<" - Msg= "<<exc.Msg()<<endl; | 
|---|
|  | 126 | } catch (const std::exception & sex) { | 
|---|
|  | 127 | cout<<"\ntsttoi2ring: Catched std::exception \n" | 
|---|
|  | 128 | <<(string)typeid(sex).name()<<endl; | 
|---|
|  | 129 | } catch (...) { | 
|---|
|  | 130 | cout<<"\ntsttoi2ring: some other exception was caught ! "<<endl; | 
|---|
|  | 131 | } | 
|---|
|  | 132 | //-------------------------------------------------------------------- | 
|---|
|  | 133 |  | 
|---|
|  | 134 | exit(0); | 
|---|
|  | 135 | } | 
|---|