| 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) { | 
|---|
| 24 | cout<<"tsttoi2ring fitsin_phase fitsin_value fitsout_value fitsout_weight "; | 
|---|
| 25 | cout<<" Nsamples SN_begin SN_last Nring (all if SN_last<SN_begin)"<<endl; | 
|---|
| 26 | return; | 
|---|
| 27 | } | 
|---|
| 28 |  | 
|---|
| 29 | //////////////////////////////////////////////////////////////// | 
|---|
| 30 | int main(int narg, char** arg) { | 
|---|
| 31 |  | 
|---|
| 32 | TOIManager* mgr = TOIManager::getManager(); | 
|---|
| 33 |  | 
|---|
| 34 | //-- Decodage arguments | 
|---|
| 35 | bool fgsegmented = true; | 
|---|
| 36 | int wsize = 512; | 
|---|
| 37 | char *label_phase = "PHASE",  *label_bolomuv = "BOLOMUVC_26"; | 
|---|
| 38 | char *label_theta = "THETA",  *label_phi = "PHI"; | 
|---|
| 39 | bool snimplicit = false; | 
|---|
| 40 |  | 
|---|
| 41 | if(narg != 9) {usage(); exit(2);} | 
|---|
| 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]); | 
|---|
| 47 | int_8 sdeb               = atoi(arg[6]); | 
|---|
| 48 | int_8 sfin              = atoi(arg[7]); | 
|---|
| 49 | int_8 Nring             = atoi(arg[8]); | 
|---|
| 50 | cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl; | 
|---|
| 51 |  | 
|---|
| 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(); | 
|---|
| 75 | if(sfin>=sdeb) rfitsp.setRequestedSample(sdeb,sfin); | 
|---|
| 76 |  | 
|---|
| 77 | FITSTOIReader rfitsv(fitsin_value); | 
|---|
| 78 | if(snimplicit) rfitsv.setImplicitSN(); | 
|---|
| 79 | cout << "fits reader created"<<endl; | 
|---|
| 80 |  | 
|---|
| 81 | FITSRingWriter wfits(fitsout_value); | 
|---|
| 82 | FITSRingWriter wwfits(fitsout_weight); | 
|---|
| 83 | cout << "setAperture" << endl; | 
|---|
| 84 | wfits.setAperture(85.); | 
|---|
| 85 | wwfits.setAperture(85.); | 
|---|
| 86 | cout << "setNSamples" << endl; | 
|---|
| 87 | wfits.setNSamples(Nsamples); | 
|---|
| 88 | wwfits.setNSamples(Nsamples); | 
|---|
| 89 | wfits.setNRings(Nring); | 
|---|
| 90 | wwfits.setNRings(Nring); | 
|---|
| 91 |  | 
|---|
| 92 |  | 
|---|
| 93 |  | 
|---|
| 94 | // TOI Processor | 
|---|
| 95 | Toi2RING m2ring(Nsamples); | 
|---|
| 96 | cout<<"Toi2RING created"<<endl; | 
|---|
| 97 |  | 
|---|
| 98 | if(sfin>=sdeb) m2ring.setRequestedSample(sdeb,sfin); | 
|---|
| 99 |  | 
|---|
| 100 | // Definition des tuyaux | 
|---|
| 101 | cout << label_phase <<endl; | 
|---|
| 102 |  | 
|---|
| 103 | plombier.Connect(rfitsp,label_theta,m2ring,"Theta"); | 
|---|
| 104 | plombier.Connect(rfitsp,label_phi,m2ring,"Phi"); | 
|---|
| 105 | plombier.Connect(rfitsp,label_phase,m2ring,"Phase"); | 
|---|
| 106 | plombier.Connect(rfitsv,label_bolomuv,m2ring,"Value"); | 
|---|
| 107 | cout<<"file out "<<fitsout_value<< endl; | 
|---|
| 108 |  | 
|---|
| 109 | plombier.Connect(m2ring,"Rvalue",wfits,"signal"); | 
|---|
| 110 | plombier.Connect(m2ring,"WRvalue",wwfits,"signal"); | 
|---|
| 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 | } | 
|---|