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