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

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

intro deglitcheur FlagGlitch et prog de test cmv 5/11/2001

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