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

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

add FlagOutOfRange cmv 7/11/2001

File size: 4.2 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 <<" -d vmin,vmax"
18 <<" -g lg,lm,nsg,bupd"
19 <<" -a lmaround"
20 <<" -p lp,sn1,sn2"
21 <<endl;
22}
23
24int main(int narg, char** arg)
25{
26 int_4 sdeb=0,sfin=-1;
27 int_4 lp=1,sn1=-1,sn2=-1;
28 uint_4 lg=3,lm=15,bupd=1000,lmaround=10;
29 r_8 nsg=5.;
30 r_8 vmin=1.,vmax=-1.;
31 char *label_bolomuv = "boloMuV";
32 int c;
33 while((c = getopt(narg,arg,"hs:g:d:b:a:p:")) != -1) {
34 switch (c) {
35 case 's' :
36 sscanf(optarg,"%d,%d",&sdeb,&sfin);
37 break;
38 case 'd' :
39 sscanf(optarg,"%lf,%lf",&vmin,&vmax);
40 break;
41 case 'g' :
42 sscanf(optarg,"%d,%d,%lf,%d",&lg,&lm,&nsg,&bupd);
43 break;
44 case 'a' :
45 sscanf(optarg,"%d",&lmaround);
46 break;
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
70 ////// Lecteurs / ecriveurs FITS
71 // FITS reader
72 FITSTOIReader rfits(fitsin);
73 cout<<"Lecteur: created"<<endl;
74
75 // FITS writer
76 FITSTOIWriter wfits(fitsout);
77 cout<<"Ecriveur: created"<<endl;
78
79 ////// TOI processeurs
80 FlagOutOfRange flgout(vmin,vmax);
81 flgout.Print();
82
83 FlagGlitch deglitch(lg,lm,nsg);
84 deglitch.SetBuffUpd(bupd);
85 deglitch.SetDebug(lp,sn1,sn2);
86 deglitch.Print();
87
88 FlagAroundFlag flgaround(lm);
89 //flgaround.SetLimits(vmin,vmax);
90 flgaround.Print();
91
92 ////// Creation des tuyaux et des connections associees
93 int taille = 8192;
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
100 // tuyau bolo pour entree processeur FlagGlitch
101 TOISegmented * toi1 = new TOISegmented("tuyau_bolo_1",taille);
102 flgout.addOutput("DataOut",toi1);
103 deglitch.addInput("DataIn",toi1);
104
105 // tuyau bolo pour entree processeur FlagAround
106 TOISegmented * toi2 = new TOISegmented("tuyau_bolo_2",taille);
107 deglitch.addOutput("DataOut",toi2);
108 flgaround.addInput("DataIn",toi2);
109
110 // tuyau bolo pour entree fits writer
111 TOISegmented * toi3 = new TOISegmented("tuyau_bolo_3",taille);
112 flgaround.addOutput("DataOut",toi3);
113 wfits.addInput(label_bolomuv,toi3,true);
114
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;
121 toi0->PrintStatus(cout);
122 toi1->PrintStatus(cout);
123 toi2->PrintStatus(cout);
124 toi3->PrintStatus(cout);
125 cout<<"-----FlagOutOfRange ::PrintStatus() : -----"<<endl;
126 flgout.PrintStatus(cout);
127 cout<<"-----FlagGlitch ::PrintStatus() : -----"<<endl;
128 deglitch.PrintStatus(cout);
129 cout<<"-----FlagAround ::PrintStatus() : -----"<<endl;
130 flgaround.PrintStatus(cout);
131
132 // Lancement des taches
133
134 rfits.start();
135 wfits.start();
136 flgout.start();
137 deglitch.start();
138 flgaround.start();
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}
Note: See TracBrowser for help on using the repository browser.