[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);
|
---|
[1776] | 71 | cout<<"Resquested sampleNum: "<<sdeb<<" , "<<sfin<<endl;
|
---|
[1733] | 72 |
|
---|
[1776] | 73 |
|
---|
[1733] | 74 | //--------------------------------------------------------------------
|
---|
| 75 | try {
|
---|
| 76 | //--------------------------------------------------------------------
|
---|
| 77 |
|
---|
[1736] | 78 | ////// Lecteurs / ecriveurs FITS
|
---|
[1733] | 79 | // FITS reader
|
---|
| 80 | FITSTOIReader rfits(fitsin);
|
---|
| 81 | cout<<"Lecteur: created"<<endl;
|
---|
| 82 |
|
---|
[1736] | 83 | // FITS writer
|
---|
[1733] | 84 | FITSTOIWriter wfits(fitsout);
|
---|
| 85 | cout<<"Ecriveur: created"<<endl;
|
---|
| 86 |
|
---|
[1736] | 87 | ////// TOI processeurs
|
---|
| 88 | FlagOutOfRange flgout(vmin,vmax);
|
---|
| 89 | flgout.Print();
|
---|
| 90 |
|
---|
[1733] | 91 | FlagGlitch deglitch(lg,lm,nsg);
|
---|
| 92 | deglitch.SetBuffUpd(bupd);
|
---|
| 93 | deglitch.SetDebug(lp,sn1,sn2);
|
---|
| 94 | deglitch.Print();
|
---|
| 95 |
|
---|
[1736] | 96 | FlagAroundFlag flgaround(lm);
|
---|
| 97 | //flgaround.SetLimits(vmin,vmax);
|
---|
[1735] | 98 | flgaround.Print();
|
---|
| 99 |
|
---|
[1739] | 100 | DataSmooth dsmooth(lsmooth,sdeg);
|
---|
| 101 | dsmooth.Print();
|
---|
| 102 |
|
---|
[1736] | 103 | ////// Creation des tuyaux et des connections associees
|
---|
[1733] | 104 | int taille = 8192;
|
---|
[1736] | 105 |
|
---|
| 106 | // tuyau bolo pour entree processeur FlagOutOfRange
|
---|
| 107 | TOISegmented * toi0 = new TOISegmented("tuyau_bolo_0",taille);
|
---|
| 108 | rfits.addOutput(label_bolomuv,toi0);
|
---|
| 109 | flgout.addInput("DataIn",toi0);
|
---|
| 110 |
|
---|
[1735] | 111 | // tuyau bolo pour entree processeur FlagGlitch
|
---|
[1736] | 112 | TOISegmented * toi1 = new TOISegmented("tuyau_bolo_1",taille);
|
---|
| 113 | flgout.addOutput("DataOut",toi1);
|
---|
| 114 | deglitch.addInput("DataIn",toi1);
|
---|
[1733] | 115 |
|
---|
[1735] | 116 | // tuyau bolo pour entree processeur FlagAround
|
---|
[1736] | 117 | TOISegmented * toi2 = new TOISegmented("tuyau_bolo_2",taille);
|
---|
| 118 | deglitch.addOutput("DataOut",toi2);
|
---|
| 119 | flgaround.addInput("DataIn",toi2);
|
---|
[1733] | 120 |
|
---|
[1739] | 121 | // tuyau bolo pour smooth DataSmooth et fits writer
|
---|
[1736] | 122 | TOISegmented * toi3 = new TOISegmented("tuyau_bolo_3",taille);
|
---|
| 123 | flgaround.addOutput("DataOut",toi3);
|
---|
[1739] | 124 | dsmooth.addInput("DataIn",toi3);
|
---|
[1736] | 125 | wfits.addInput(label_bolomuv,toi3,true);
|
---|
[1735] | 126 |
|
---|
[1739] | 127 | // tuyau bolo pour entree fits writer
|
---|
| 128 | TOISegmented * toi31 = new TOISegmented("tuyau_bolo_31",taille);
|
---|
| 129 | dsmooth.addOutput("DataSmooth",toi31);
|
---|
| 130 | wfits.addInput("smbolo",toi31,true);
|
---|
| 131 |
|
---|
[1733] | 132 | // Print de status avant lancement des taches:
|
---|
| 133 | cout<<"----- FITSReaderTOI::PrintStatus() 1 : -----"<<endl;
|
---|
| 134 | rfits.PrintStatus(cout);
|
---|
| 135 | cout<<"----- FITSWriterTOI::PrintStatus() : -----"<<endl;
|
---|
| 136 | wfits.PrintStatus(cout);
|
---|
| 137 | cout<<"----- TOISegmented::PrintStatus() : -----"<<endl;
|
---|
[1736] | 138 | toi0->PrintStatus(cout);
|
---|
[1735] | 139 | toi1->PrintStatus(cout);
|
---|
| 140 | toi2->PrintStatus(cout);
|
---|
[1736] | 141 | toi3->PrintStatus(cout);
|
---|
[1739] | 142 | toi31->PrintStatus(cout);
|
---|
[1736] | 143 | cout<<"-----FlagOutOfRange ::PrintStatus() : -----"<<endl;
|
---|
| 144 | flgout.PrintStatus(cout);
|
---|
[1733] | 145 | cout<<"-----FlagGlitch ::PrintStatus() : -----"<<endl;
|
---|
| 146 | deglitch.PrintStatus(cout);
|
---|
[1735] | 147 | cout<<"-----FlagAround ::PrintStatus() : -----"<<endl;
|
---|
| 148 | flgaround.PrintStatus(cout);
|
---|
[1739] | 149 | cout<<"-----DataSmooth ::PrintStatus() : -----"<<endl;
|
---|
| 150 | dsmooth.PrintStatus(cout);
|
---|
[1733] | 151 |
|
---|
| 152 | // Lancement des taches
|
---|
| 153 |
|
---|
| 154 | rfits.start();
|
---|
| 155 | wfits.start();
|
---|
[1736] | 156 | flgout.start();
|
---|
[1733] | 157 | deglitch.start();
|
---|
[1735] | 158 | flgaround.start();
|
---|
[1739] | 159 | dsmooth.start();
|
---|
[1733] | 160 |
|
---|
| 161 | // Gestion de la re-connection des threads
|
---|
| 162 | mgr->joinAll();
|
---|
| 163 | cout<<"End threads"<<endl;
|
---|
| 164 |
|
---|
| 165 | //--------------------------------------------------------------------
|
---|
| 166 | // Que fait on avec les exceptions qui ont ete lancees ?
|
---|
| 167 | } catch (PThrowable & exc) { // Sophya exceptions
|
---|
| 168 | cout<<"\ntstktoibad: Catched Exception \n"<<(string)typeid(exc).name()
|
---|
| 169 | <<" - Msg= "<<exc.Msg()<<endl;
|
---|
| 170 | } catch (const std::exception & sex) { // Standard exceptions
|
---|
| 171 | cout<<"\ntstktoibad: Catched std::exception \n"
|
---|
| 172 | <<(string)typeid(sex).name()<<endl;
|
---|
| 173 | } catch (...) { // Other exceptions
|
---|
| 174 | cout<<"\ntstktoibad: some other exception was caught ! "<<endl;
|
---|
| 175 | }
|
---|
| 176 | //--------------------------------------------------------------------
|
---|
| 177 |
|
---|
| 178 | return(0);
|
---|
| 179 | }
|
---|