source: Sophya/trunk/ArchTOIPipe/TestPipes/tstktoibad.cc@ 1735

Last change on this file since 1735 was 1735, checked in by cmv, 24 years ago

add FlagAround + enum FlagToiAll cmv 6/11/2001

File size: 3.7 KB
Line 
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
12void usage(void);
13void 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"
18 <<" -a lmaround"
19 <<" -p lp,sn1,sn2"
20 <<endl;
21}
22
23int main(int narg, char** arg)
24{
25 int_4 sdeb=0,sfin=-1;
26 int_4 lp=1,sn1=-1,sn2=-1;
27 uint_4 lg=3,lm=15,bupd=1000,lmaround=10;
28 r_8 nsg=5.;
29 char *label_bolomuv = "boloMuV";
30 int c;
31 while((c = getopt(narg,arg,"hs:g:b:a:p:")) != -1) {
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;
39 case 'a' :
40 sscanf(optarg,"%d",&lmaround);
41 break;
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
79 FlagAround flgaround(lm);
80 flgaround.Print();
81
82 // Creation des tuyaux et des connections associees
83 int taille = 8192;
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);
88
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);
93
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
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;
105 toi1->PrintStatus(cout);
106 toi2->PrintStatus(cout);
107 toiout->PrintStatus(cout);
108 cout<<"-----FlagGlitch ::PrintStatus() : -----"<<endl;
109 deglitch.PrintStatus(cout);
110 cout<<"-----FlagAround ::PrintStatus() : -----"<<endl;
111 flgaround.PrintStatus(cout);
112
113 // Lancement des taches
114
115 rfits.start();
116 wfits.start();
117 deglitch.start();
118 flgaround.start();
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}
Note: See TracBrowser for help on using the repository browser.