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

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

Le DataSmooth cmv 8/11/2001

File size: 4.8 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#include "smoothtoi.h"
12
13void usage(void);
14void usage(void) {
15 cout<<"tstktoibad [-h] [options] fits_in fits_out"
16 <<" -s sdeb,sfin"
17 <<" -b label_bolomuv"
18 <<" -d vmin,vmax"
19 <<" -g lg,lm,nsg,bupd"
20 <<" -a lmaround"
21 <<" -S lsmooth,sdeg"
22 <<" -p lp,sn1,sn2"
23 <<endl;
24}
25
26int main(int narg, char** arg)
27{
28 int_4 sdeb=0,sfin=-1;
29 int_4 lp=1,sn1=-1,sn2=-1;
30 uint_4 lg=3,lm=15,bupd=1000,lmaround=10;
31 uint_4 lsmooth=1024,sdeg=2;
32 r_8 nsg=5.;
33 r_8 vmin=1.,vmax=-1.;
34 char *label_bolomuv = "boloMuV";
35 int c;
36 while((c = getopt(narg,arg,"hs:g:d:b:a:S:p:")) != -1) {
37 switch (c) {
38 case 's' :
39 sscanf(optarg,"%d,%d",&sdeb,&sfin);
40 break;
41 case 'd' :
42 sscanf(optarg,"%lf,%lf",&vmin,&vmax);
43 break;
44 case 'g' :
45 sscanf(optarg,"%d,%d,%lf,%d",&lg,&lm,&nsg,&bupd);
46 break;
47 case 'a' :
48 sscanf(optarg,"%d",&lmaround);
49 break;
50 case 'S' :
51 sscanf(optarg,"%d,%d",&lsmooth,&sdeg);
52 break;
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
76 ////// Lecteurs / ecriveurs FITS
77 // FITS reader
78 FITSTOIReader rfits(fitsin);
79 cout<<"Lecteur: created"<<endl;
80
81 // FITS writer
82 FITSTOIWriter wfits(fitsout);
83 cout<<"Ecriveur: created"<<endl;
84
85 ////// TOI processeurs
86 FlagOutOfRange flgout(vmin,vmax);
87 flgout.Print();
88
89 FlagGlitch deglitch(lg,lm,nsg);
90 deglitch.SetBuffUpd(bupd);
91 deglitch.SetDebug(lp,sn1,sn2);
92 deglitch.Print();
93
94 FlagAroundFlag flgaround(lm);
95 //flgaround.SetLimits(vmin,vmax);
96 flgaround.Print();
97
98 DataSmooth dsmooth(lsmooth,sdeg);
99 dsmooth.Print();
100
101 ////// Creation des tuyaux et des connections associees
102 int taille = 8192;
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
109 // tuyau bolo pour entree processeur FlagGlitch
110 TOISegmented * toi1 = new TOISegmented("tuyau_bolo_1",taille);
111 flgout.addOutput("DataOut",toi1);
112 deglitch.addInput("DataIn",toi1);
113
114 // tuyau bolo pour entree processeur FlagAround
115 TOISegmented * toi2 = new TOISegmented("tuyau_bolo_2",taille);
116 deglitch.addOutput("DataOut",toi2);
117 flgaround.addInput("DataIn",toi2);
118
119 // tuyau bolo pour smooth DataSmooth et fits writer
120 TOISegmented * toi3 = new TOISegmented("tuyau_bolo_3",taille);
121 flgaround.addOutput("DataOut",toi3);
122 dsmooth.addInput("DataIn",toi3);
123 wfits.addInput(label_bolomuv,toi3,true);
124
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
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;
136 toi0->PrintStatus(cout);
137 toi1->PrintStatus(cout);
138 toi2->PrintStatus(cout);
139 toi3->PrintStatus(cout);
140 toi31->PrintStatus(cout);
141 cout<<"-----FlagOutOfRange ::PrintStatus() : -----"<<endl;
142 flgout.PrintStatus(cout);
143 cout<<"-----FlagGlitch ::PrintStatus() : -----"<<endl;
144 deglitch.PrintStatus(cout);
145 cout<<"-----FlagAround ::PrintStatus() : -----"<<endl;
146 flgaround.PrintStatus(cout);
147 cout<<"-----DataSmooth ::PrintStatus() : -----"<<endl;
148 dsmooth.PrintStatus(cout);
149
150 // Lancement des taches
151
152 rfits.start();
153 wfits.start();
154 flgout.start();
155 deglitch.start();
156 flgaround.start();
157 dsmooth.start();
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}
Note: See TracBrowser for help on using the repository browser.