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