[1733] | 1 | #include <unistd.h>
|
---|
| 2 | #include "toi.h"
|
---|
| 3 | #include "toiprocessor.h"
|
---|
| 4 | #include "fitstoirdr.h"
|
---|
| 5 | #include "fitstoiwtr.h"
|
---|
| 6 | #include "toimanager.h"
|
---|
| 7 | #include "toisegment.h"
|
---|
| 8 | #include "sophyainit.h"
|
---|
| 9 | #include "ktoibad.h"
|
---|
[1739] | 10 | #include "smoothtoi.h"
|
---|
[1760] | 11 | #include <stdexcept>
|
---|
[1733] | 12 |
|
---|
| 13 | void usage(void);
|
---|
| 14 | void usage(void) {
|
---|
| 15 | cout<<"tstktoibad [-h] [options] fits_in fits_out"
|
---|
| 16 | <<" -s sdeb,sfin"
|
---|
| 17 | <<" -b label_bolomuv"
|
---|
[1736] | 18 | <<" -d vmin,vmax"
|
---|
[1733] | 19 | <<" -g lg,lm,nsg,bupd"
|
---|
[1735] | 20 | <<" -a lmaround"
|
---|
[1739] | 21 | <<" -S lsmooth,sdeg"
|
---|
[1733] | 22 | <<" -p lp,sn1,sn2"
|
---|
| 23 | <<endl;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | int main(int narg, char** arg)
|
---|
| 27 | {
|
---|
| 28 | int_4 sdeb=0,sfin=-1;
|
---|
| 29 | int_4 lp=1,sn1=-1,sn2=-1;
|
---|
[1735] | 30 | uint_4 lg=3,lm=15,bupd=1000,lmaround=10;
|
---|
[1739] | 31 | uint_4 lsmooth=1024,sdeg=2;
|
---|
[1733] | 32 | r_8 nsg=5.;
|
---|
[1736] | 33 | r_8 vmin=1.,vmax=-1.;
|
---|
[1733] | 34 | char *label_bolomuv = "boloMuV";
|
---|
| 35 | int c;
|
---|
[1739] | 36 | while((c = getopt(narg,arg,"hs:g:d:b:a:S:p:")) != -1) {
|
---|
[1733] | 37 | switch (c) {
|
---|
| 38 | case 's' :
|
---|
| 39 | sscanf(optarg,"%d,%d",&sdeb,&sfin);
|
---|
| 40 | break;
|
---|
[1736] | 41 | case 'd' :
|
---|
| 42 | sscanf(optarg,"%lf,%lf",&vmin,&vmax);
|
---|
| 43 | break;
|
---|
[1733] | 44 | case 'g' :
|
---|
| 45 | sscanf(optarg,"%d,%d,%lf,%d",&lg,&lm,&nsg,&bupd);
|
---|
| 46 | break;
|
---|
[1735] | 47 | case 'a' :
|
---|
| 48 | sscanf(optarg,"%d",&lmaround);
|
---|
| 49 | break;
|
---|
[1739] | 50 | case 'S' :
|
---|
| 51 | sscanf(optarg,"%d,%d",&lsmooth,&sdeg);
|
---|
| 52 | break;
|
---|
[1733] | 53 | case 'b' :
|
---|
| 54 | label_bolomuv = optarg;
|
---|
| 55 | break;
|
---|
| 56 | case 'p' :
|
---|
| 57 | sscanf(optarg,"%d,%d,%d",&lp,&sn1,&sn2);
|
---|
| 58 | break;
|
---|
| 59 | case 'h' :
|
---|
| 60 | default:
|
---|
| 61 | usage(); exit(1);
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | if(optind+1>=narg) {usage(); exit(2);}
|
---|
| 65 | char * fitsin = arg[optind];
|
---|
| 66 | char * fitsout = arg[optind+1];
|
---|
| 67 |
|
---|
| 68 | SophyaInit();
|
---|
| 69 | TOIManager* mgr = TOIManager::getManager();
|
---|
| 70 | if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
|
---|
| 71 |
|
---|
| 72 | //--------------------------------------------------------------------
|
---|
| 73 | try {
|
---|
| 74 | //--------------------------------------------------------------------
|
---|
| 75 |
|
---|
[1736] | 76 | ////// Lecteurs / ecriveurs FITS
|
---|
[1733] | 77 | // FITS reader
|
---|
| 78 | FITSTOIReader rfits(fitsin);
|
---|
| 79 | cout<<"Lecteur: created"<<endl;
|
---|
| 80 |
|
---|
[1736] | 81 | // FITS writer
|
---|
[1733] | 82 | FITSTOIWriter wfits(fitsout);
|
---|
| 83 | cout<<"Ecriveur: created"<<endl;
|
---|
| 84 |
|
---|
[1736] | 85 | ////// TOI processeurs
|
---|
| 86 | FlagOutOfRange flgout(vmin,vmax);
|
---|
| 87 | flgout.Print();
|
---|
| 88 |
|
---|
[1733] | 89 | FlagGlitch deglitch(lg,lm,nsg);
|
---|
| 90 | deglitch.SetBuffUpd(bupd);
|
---|
| 91 | deglitch.SetDebug(lp,sn1,sn2);
|
---|
| 92 | deglitch.Print();
|
---|
| 93 |
|
---|
[1736] | 94 | FlagAroundFlag flgaround(lm);
|
---|
| 95 | //flgaround.SetLimits(vmin,vmax);
|
---|
[1735] | 96 | flgaround.Print();
|
---|
| 97 |
|
---|
[1739] | 98 | DataSmooth dsmooth(lsmooth,sdeg);
|
---|
| 99 | dsmooth.Print();
|
---|
| 100 |
|
---|
[1736] | 101 | ////// Creation des tuyaux et des connections associees
|
---|
[1733] | 102 | int taille = 8192;
|
---|
[1736] | 103 |
|
---|
| 104 | // tuyau bolo pour entree processeur FlagOutOfRange
|
---|
| 105 | TOISegmented * toi0 = new TOISegmented("tuyau_bolo_0",taille);
|
---|
| 106 | rfits.addOutput(label_bolomuv,toi0);
|
---|
| 107 | flgout.addInput("DataIn",toi0);
|
---|
| 108 |
|
---|
[1735] | 109 | // tuyau bolo pour entree processeur FlagGlitch
|
---|
[1736] | 110 | TOISegmented * toi1 = new TOISegmented("tuyau_bolo_1",taille);
|
---|
| 111 | flgout.addOutput("DataOut",toi1);
|
---|
| 112 | deglitch.addInput("DataIn",toi1);
|
---|
[1733] | 113 |
|
---|
[1735] | 114 | // tuyau bolo pour entree processeur FlagAround
|
---|
[1736] | 115 | TOISegmented * toi2 = new TOISegmented("tuyau_bolo_2",taille);
|
---|
| 116 | deglitch.addOutput("DataOut",toi2);
|
---|
| 117 | flgaround.addInput("DataIn",toi2);
|
---|
[1733] | 118 |
|
---|
[1739] | 119 | // tuyau bolo pour smooth DataSmooth et fits writer
|
---|
[1736] | 120 | TOISegmented * toi3 = new TOISegmented("tuyau_bolo_3",taille);
|
---|
| 121 | flgaround.addOutput("DataOut",toi3);
|
---|
[1739] | 122 | dsmooth.addInput("DataIn",toi3);
|
---|
[1736] | 123 | wfits.addInput(label_bolomuv,toi3,true);
|
---|
[1735] | 124 |
|
---|
[1739] | 125 | // tuyau bolo pour entree fits writer
|
---|
| 126 | TOISegmented * toi31 = new TOISegmented("tuyau_bolo_31",taille);
|
---|
| 127 | dsmooth.addOutput("DataSmooth",toi31);
|
---|
| 128 | wfits.addInput("smbolo",toi31,true);
|
---|
| 129 |
|
---|
[1733] | 130 | // Print de status avant lancement des taches:
|
---|
| 131 | cout<<"----- FITSReaderTOI::PrintStatus() 1 : -----"<<endl;
|
---|
| 132 | rfits.PrintStatus(cout);
|
---|
| 133 | cout<<"----- FITSWriterTOI::PrintStatus() : -----"<<endl;
|
---|
| 134 | wfits.PrintStatus(cout);
|
---|
| 135 | cout<<"----- TOISegmented::PrintStatus() : -----"<<endl;
|
---|
[1736] | 136 | toi0->PrintStatus(cout);
|
---|
[1735] | 137 | toi1->PrintStatus(cout);
|
---|
| 138 | toi2->PrintStatus(cout);
|
---|
[1736] | 139 | toi3->PrintStatus(cout);
|
---|
[1739] | 140 | toi31->PrintStatus(cout);
|
---|
[1736] | 141 | cout<<"-----FlagOutOfRange ::PrintStatus() : -----"<<endl;
|
---|
| 142 | flgout.PrintStatus(cout);
|
---|
[1733] | 143 | cout<<"-----FlagGlitch ::PrintStatus() : -----"<<endl;
|
---|
| 144 | deglitch.PrintStatus(cout);
|
---|
[1735] | 145 | cout<<"-----FlagAround ::PrintStatus() : -----"<<endl;
|
---|
| 146 | flgaround.PrintStatus(cout);
|
---|
[1739] | 147 | cout<<"-----DataSmooth ::PrintStatus() : -----"<<endl;
|
---|
| 148 | dsmooth.PrintStatus(cout);
|
---|
[1733] | 149 |
|
---|
| 150 | // Lancement des taches
|
---|
| 151 |
|
---|
| 152 | rfits.start();
|
---|
| 153 | wfits.start();
|
---|
[1736] | 154 | flgout.start();
|
---|
[1733] | 155 | deglitch.start();
|
---|
[1735] | 156 | flgaround.start();
|
---|
[1739] | 157 | dsmooth.start();
|
---|
[1733] | 158 |
|
---|
| 159 | // Gestion de la re-connection des threads
|
---|
| 160 | mgr->joinAll();
|
---|
| 161 | cout<<"End threads"<<endl;
|
---|
| 162 |
|
---|
| 163 | //--------------------------------------------------------------------
|
---|
| 164 | // Que fait on avec les exceptions qui ont ete lancees ?
|
---|
| 165 | } catch (PThrowable & exc) { // Sophya exceptions
|
---|
| 166 | cout<<"\ntstktoibad: Catched Exception \n"<<(string)typeid(exc).name()
|
---|
| 167 | <<" - Msg= "<<exc.Msg()<<endl;
|
---|
| 168 | } catch (const std::exception & sex) { // Standard exceptions
|
---|
| 169 | cout<<"\ntstktoibad: Catched std::exception \n"
|
---|
| 170 | <<(string)typeid(sex).name()<<endl;
|
---|
| 171 | } catch (...) { // Other exceptions
|
---|
| 172 | cout<<"\ntstktoibad: some other exception was caught ! "<<endl;
|
---|
| 173 | }
|
---|
| 174 | //--------------------------------------------------------------------
|
---|
| 175 |
|
---|
| 176 | return(0);
|
---|
| 177 | }
|
---|