source: Sophya/trunk/ArchTOIPipe/TestPipes/tstrztoi.cc@ 1437

Last change on this file since 1437 was 1437, checked in by ansari, 25 years ago

Protections diverses dans TOIProcessor et FITSTOIReader/Writer
Ajout d'un TOI (TOISeqBuffered) avec gestion d'un buffer entre put/get
Ajout de processeurs de test (RZTOIProc...) , programme test associe
et SMakefile (pour compil avec SOPHYA)

Reza 12/3/2001

File size: 5.4 KB
Line 
1#include <unistd.h>
2#include "toi.h"
3#include "toiprocessor.h"
4#include "fitstoirdr.h"
5#include "fitstoiwtr.h"
6#include "toisqfilter.h"
7#include "toimanager.h"
8#include "rztoi.h"
9#include "toiseqbuff.h"
10#include "timing.h"
11#include "sambainit.h"
12
13void Usage(bool fgerr)
14{
15 cout << endl;
16 if (fgerr) {
17 cout << " tstrztoi : Argument Error ! tstrztoi -h for usage " << endl;
18 exit(1);
19 }
20 else {
21 cout << "\n Usage : tstrztoi [-sproc] [-rwtoi] [-dbg] [-start snb] [-end sne] \n"
22 << " [-w1 sz] [-w2 sz] inFitsName outFitsName ppfFileName \n"
23 << " -sproc : Run RzSimpleTOIProc (default RzTOIProc) \n"
24 << " -rwtoi : Use Regular Window TOI (default TOISeqBuffered) \n"
25 << " -dbg : sets TOISeqBuffered debug level to 1 \n"
26 << " -start snb : sets the start sample num \n"
27 << " -end sne : sets the end sample num \n"
28 << " -w1 sz : sets main data window size (def= 8192)\n"
29 << " -w2 sz : sets secondary window size (def= 512) \n"
30 << endl;
31 exit(0);
32 }
33}
34
35int main(int narg, char** arg) {
36
37 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
38
39 cout << "tstrztoi starting - Decoding arguments " << " narg=" << narg << endl;
40
41 bool fgsimple = false;
42 bool fgrwtoi = false;
43 bool fgdbg = false;
44 int w1 = 8192;
45 int w2 = 512;
46 int nmax = 10;
47 int istart = 104121000+w1*5;
48 int iend = 0;
49 string infile;
50 string outfile;
51 string ppffile;
52
53 if (narg < 4) Usage(true);
54 int ko=1;
55 // decoding arguments
56 for(int ia=1; ia<narg; ia++) {
57 if (strcmp(arg[ia],"-start") == 0) {
58 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
59 istart = atoi(arg[ia+1]); ia++;
60 }
61 else if (strcmp(arg[ia],"-end") == 0) {
62 if (ia == narg-1) Usage(true);
63 iend = atoi(arg[ia+1]); ia++;
64 }
65 else if (strcmp(arg[ia],"-w1") == 0) {
66 if (ia == narg-1) Usage(true);
67 w1 = atoi(arg[ia+1]); ia++;
68 }
69 else if (strcmp(arg[ia],"-w2") == 0) {
70 if (ia == narg-1) Usage(true);
71 w2 = atoi(arg[ia+1]); ia++;
72 }
73 else if (strcmp(arg[ia],"-sproc") == 0) fgsimple = true;
74 else if (strcmp(arg[ia],"-rwtoi") == 0) fgrwtoi = true;
75 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
76
77 else { ko = ia; break; } // Debut des noms
78 }
79
80 if (iend < istart) iend = istart+w1*(nmax+5);
81 if ((narg-ko) < 3) Usage(true);
82 infile = arg[ko];
83 outfile = arg[ko+1];
84 ppffile = arg[ko+2];
85
86 cout << " Initializing SOPHYA ... " << endl;
87 SophyaInit();
88 InitTim();
89
90 cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile
91 << " ppfFile= " << ppffile << endl;
92 cout << ">>>> Window Size W1= " << w1 << " W2= " << w2
93 << " iStart= " << istart << " iEnd= " << iend << endl;
94 try {
95 TOIManager* mgr = TOIManager::getManager();
96
97 // mgr->setRequestedSample(11680920,11710584);
98 // mgr->setRequestedSample(104121000, 104946120);
99
100 mgr->setRequestedSample(istart, iend);
101
102 // FITSTOIReader r("/data/Archeops/bolo11.fits);
103 FITSTOIReader r(infile);
104 cout << "reader created" << endl;
105 // FITSTOIWriter w("/data/Archeops/rz.fits");
106 FITSTOIWriter w(outfile);
107 w.setOutFlags(true);
108 cout << "fits writer created" << endl;
109
110
111 char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
112 TOI* toitab[5];
113 TOI* toi2;
114 int kk;
115 if (fgrwtoi) {
116 cout << " Using TOIRegularWindow TOI's ... " << endl;
117 for(kk=0; kk<5; kk++) {
118 toitab[kk] = new TOIRegularWindow((string)"t_"+colname[kk]);
119 }
120 toi2 = new TOIRegularWindow("t2");
121 }
122 else {
123 cout << " Using TOISeqBuffered TOI's ... " << endl;
124 for(kk=0; kk<5; kk++) {
125 TOISeqBuffered * toisb = new TOISeqBuffered((string)"t_"+colname[kk], w1);
126 toitab[kk] = toisb;
127 if (fgdbg) toisb->setDebugLevel(1);
128 }
129 TOISeqBuffered * toisb = new TOISeqBuffered("t2", w1);
130 if (fgdbg) toisb->setDebugLevel(1);
131 toi2 = toisb;
132 }
133
134 // Connecting TOI to FITSTOIReader Processor
135 // for(kk=0; kk<5; kk++) {
136 // r.addOutput(colname[kk], toitab[kk]);
137 // }
138
139 kk = 2;
140 TOI* toi = toitab[kk];
141 r.addOutput(colname[kk], toi);
142 // toi->dbg=true;
143 // r.addOutput("boloMuV_11", toi);
144 cout << " connecting in/out to RzTOIProcessor ... " << endl;
145
146 // TOIProcessor * filt = NULL;
147
148 cout << " Creating Rz TOIProcessors: RzTOIProc () " << endl;
149 RzSimpleTOIProc rzs(2., 1000);
150 RzTOIProc rzp(w1, w2, nmax);
151 if (fgsimple) {
152 cout << " Using Simple TOIProcessor: RzSimpleTOIProc () " << endl;
153 rzs.addInput("signal", toi);
154 rzs.addOutput("sfout", toi2);
155 }
156 else {
157 cout << " Using Rz TOIProcessor: RzTOIProc () " << endl;
158 // rzp.setOutPPF("/data/Archeops/toto.ppf");
159 rzp.setOutPPF(ppffile);
160 rzp.addInput("signal", toi);
161 rzp.addOutput("sfout", toi2);
162 }
163
164
165 w.addInput("bolo_filtered", toi2);
166
167 PrtTim("starting threads");
168 r.start();
169 if (fgsimple) rzs.start();
170 else rzp.start();
171 w.start();
172
173 r.PrintStatus(cout);
174
175 for(int jj=0; jj<3; jj++) {
176 sleep(2);
177 cout << *toi;
178 }
179
180 mgr->joinAll();
181 PrtTim("End threads");
182 cout << " ------ toi and toi2 Status information ------- " << endl;
183 cout << *toi;
184 cout << *toi2;
185 }
186 catch (PThrowable & exc) {
187 cerr << "rztsttoi: Catched Exception \n" << (string)typeid(exc).name()
188 << " - Msg= " << exc.Msg() << endl;
189 }
190 catch (...) {
191 cerr << "rztsttoi: some other exception was caught ! " << endl;
192 }
193
194 return(0);
195}
Note: See TracBrowser for help on using the repository browser.