source: Sophya/trunk/ArchTOIPipe/TestPipes/mesovh2.cc@ 2016

Last change on this file since 2016 was 2000, checked in by ansari, 23 years ago

Corrections diverses et introduction d'une classe de calcul de ligne de
base par ajustement glissant d'un polynome (SimpleOffsetEstimator)
avec son programme test - Reza 14/5/2002

File size: 5.6 KB
RevLine 
[1995]1// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
2// Eric Aubourg
3// Christophe Magneville
4// Reza Ansari
[2000]5// $Id: mesovh2.cc,v 1.2 2002-05-14 13:06:58 ansari Exp $
[1995]6/* mesure de performance de l'architecture
7
8---------------- Exemple d'appel ---------------------
9csh> mesovh2 -start 104385384 -end 104399964
10 -intoi boloMuV_27 -wtoi 8192 -wnoop 4096 inputbolo.fits
11*/
12
13
14
15#include "machdefs.h"
16#include <math.h>
17#include <unistd.h>
18#include "cgt.h"
19#include "fitstoirdr.h"
20#include "toimanager.h"
21#include "nooppr.h"
22#include "timing.h"
23#include <stdexcept>
24
25void Usage(bool fgerr)
26{
27 cout << endl;
28 if (fgerr) {
29 cout << " mesovh2 : Argument Error ! mesovh2 -h for usage " << endl;
30 exit(1);
31 }
32 else {
33 cout << "\n Usage : mesovh2 [-dbg] [-start snb] [-end sne] \n"
34 << " [-intoi name] [-wtoi sz] [-wnoop sz] [-bipro] \n"
35 << " [-intoi2 name] [-prstat] [-useseqbuff] inFitsName \n"
36 << " -dbg : sets CGT class debug level to 1 \n"
37 << " -dbg2 : sets CGT class debug level to 2 \n"
38 << " -start snb : sets the start sample num \n"
39 << " -end sne : sets the end sample num \n"
40 << " -intoi toiName : select input TOI name (def bolo)\n"
41 << " -wtoi sz : sets TOISeqBuff/TOISegmented buffer size (def= 1024)\n"
42 << " -wnoop sz : sets NoOpProcessor window size \n"
43 << " -bipro : chain 2 processors \n"
44 << " -intoi2 toiName : chaine 2 procs with toi2->in2\n"
45 << " -prstat : PrintStat with ProcSampleCounter \n"
[2000]46 << " -useseqbuff : Use TOISeqBuffered TOI's (default: TOISegmented) \n"
[1995]47 << endl;
48 exit(0);
49 }
50}
51
52int main(int narg, char** arg) {
53
54 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
55
56 cout << "mesovh2 starting - Decoding arguments " << " narg=" << narg << endl;
57
58 // --------- Decoding command line parameters
59 bool fgbipro = false;
60 bool fgsetstart = false;
61 bool fgprstat = false;
62 bool fgsegmented = true;
63 int dbglev = 0;
64 int wtoi = 1024;
65 int wnoop = 0;
66 int keepfft = 0;
67 int nmax = 10;
68 int istart = 0;
69 int iend = 0;
70 string infile;
71 string intoi = "bolo";
72 bool fgtoi2 = false;
73 string intoi2;
74
75 if (narg < 4) Usage(true);
76 int ko=1;
77 // decoding arguments
78 for(int ia=1; ia<narg; ia++) {
79 if (strcmp(arg[ia],"-start") == 0) {
80 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
81 istart = atoi(arg[ia+1]); ia++;
82 fgsetstart = true;
83 }
84 else if (strcmp(arg[ia],"-end") == 0) {
85 if (ia == narg-1) Usage(true);
86 iend = atoi(arg[ia+1]); ia++;
87 }
88 else if (strcmp(arg[ia],"-wtoi") == 0) {
89 if (ia == narg-1) Usage(true);
90 wtoi = atoi(arg[ia+1]); ia++;
91 }
92 else if (strcmp(arg[ia],"-wnoop") == 0) {
93 if (ia == narg-1) Usage(true);
94 wnoop = atoi(arg[ia+1]); ia++;
95 }
96 else if (strcmp(arg[ia],"-intoi") == 0) {
97 if (ia == narg-1) Usage(true);
98 intoi = arg[ia+1]; ia++;
99 }
100 else if (strcmp(arg[ia],"-intoi2") == 0) {
101 if (ia == narg-1) Usage(true);
102 fgbipro = fgtoi2 = true;
103 intoi2 = arg[ia+1]; ia++;
104 }
105 else if (strcmp(arg[ia],"-bipro") == 0) fgbipro = true;
106 else if (strcmp(arg[ia],"-dbg") == 0) dbglev = 1;
107 else if (strcmp(arg[ia],"-dbg2") == 0) dbglev = 2;
108 else if (strcmp(arg[ia],"-prstat") == 0) fgprstat = true;
109 else if (strcmp(arg[ia],"-useseqbuff") == 0) fgsegmented = false;
110
111 else { ko = ia; break; } // Debut des noms
112 }
113
114 if (iend < istart) iend = istart+wtoi*(nmax+5);
115 if ((narg-ko) < 1) Usage(true);
116 infile = arg[ko];
117
118 InitTim();
119
120 cout << ">>>> mesovh2: Infile= " << infile << " outFile=" << endl;
121 cout << ">>>> Window Size WTOI= " << wtoi << " WNOOP= " << wnoop
122 << " iStart= " << istart << " iEnd= " << iend << endl;
123 cout << ">>>> InTOIName= " << intoi << endl;
124
125 try {
126 // --------- Setting up the pipe
127 TOIManager* mgr = TOIManager::getManager();
128 if (fgsetstart)
129 mgr->setRequestedSample(istart, iend);
130
131 CGT plombier(fgsegmented, wtoi);
132 plombier.SetDebugLevel(dbglev);
133
134 FITSTOIReader r(infile);
135 cout << "> FITSTOIReader reader created" << endl;
136 NoOpProcessor noop(wnoop);
137 NoOpProcessor noop2(wnoop);
138 cout << "> NoOpProcessor noop noop2 created" << endl;
139
140 cout << "> Connecting to Processors through plombier ... " << endl;
141 string inname = "in";
142 plombier.Connect(r, intoi, noop, inname);
143
144 if (fgtoi2) {
145 int w2 = (wnoop > 0) ? wtoi+wnoop : wtoi;
146 inname = "in2";
147 plombier.Connect(r, intoi2, noop, inname, "", w2);
148 }
149 if (fgbipro) {
150 plombier.Connect(noop, "out", noop2, "in");
151 if (fgtoi2) plombier.Connect(noop, "out2", noop2, "in2");
152 }
153
154 cout << "> Plombier status before start" << endl;
155 cout << plombier ;
156
157 PrtTim("starting processors");
158 plombier.Start();
159
160 if (fgprstat) {
161 // --------------- Impression continu de stat -------------------
162 ProcSampleCounter<NoOpProcessor> stats(noop);
163 stats.InfoMessage() = "mesovh2/Info";
164 stats.PrintStats();
165 // --------------------------------------------------------------
166 }
167
168
169 mgr->joinAll();
170 PrtTim("End threads");
171
172 cout << noop ;
173 if (fgbipro) cout << noop2 ;
174 }
175 catch (PThrowable & exc) {
176 cerr << "\n mesovh2: Catched Exception \n" << (string)typeid(exc).name()
177 << " - Msg= " << exc.Msg() << endl;
178 }
179 catch (const std::exception & sex) {
180 cerr << "\n mesovh2: Catched std::exception \n"
181 << (string)typeid(sex).name() << endl;
182 }
183 catch (...) {
184 cerr << "\n mesovh2: some other exception was caught ! " << endl;
185 }
186
187 return(0);
188}
Note: See TracBrowser for help on using the repository browser.