source: Sophya/trunk/Poubelle/archTOI.old/toisvr.cc@ 426

Last change on this file since 426 was 426, checked in by ansari, 26 years ago

alpha delta a partir croisement galax

File size: 6.7 KB
Line 
1// toisvr.cc
2// Eric Aubourg CEA/DAPNIA/SPP juillet 1999
3
4#include <iostream.h>
5#include "toisvr.h"
6#include "archparam.h"
7#include "asigps.h"
8
9
10
11TOISvr::TOISvr()
12{
13 initDone = false;
14}
15
16// To avoid special copy constructor handling, we will not
17// register ourself to us... Special dealing in readReq.
18
19void TOISvr::setDirectory(string d) {
20 iter.directory = d;
21}
22
23void TOISvr::addFile(string f) {
24 iter.files.insert(f);
25}
26
27void TOISvr::useAuxGPS(AuxGPS* gps) {
28 if (iter.auxGPS) delete iter.auxGPS;
29 iter.auxGPS = gps;
30}
31
32
33void TOISvr::onBoardRecorderFiles(bool x) {
34 iter.isOnBoardRecorder = x;
35}
36
37
38void TOISvr::setTimeInterval(double tStart, double tEnd) {
39 if (tStart>0) iter.tStart = tStart;
40 if (tEnd>0) iter.tEnd = tEnd;
41}
42
43void TOISvr::setUnderSample(int n) {
44 if (n<=1) n=1;
45 iter.underSample = n;
46}
47
48
49void TOISvr::addInfo(TOIKind kind, int index, bool triggering, bool interp) {
50 TOIIter::info i;
51 i.kind = kind;
52 i.index = index;
53 i.triggering = triggering;
54 i.interpolated= interp;
55 iter.infos.push_back(i);
56}
57
58void TOISvr::addInfo(TOIKind kind, bool triggering, bool interp) {
59 addInfo(kind,0,triggering,interp);
60}
61
62TOIIter TOISvr::doQuery() {
63 //iter.Init();
64 return iter;
65}
66
67void TOISvr::registerReqHandler(RequestHandler* h) {
68 handlers.push_back(h);
69}
70
71
72void TOISvr::readReq(istream& str) {
73 if (!initDone) defaultInclude();
74 string line;
75 while (str) {
76 getline(str,line);
77 if (!str) break;
78 if (line.substr(0,4)=="#END") break;
79 if (line[0] != '@' && line[0] != '#') continue;
80 bool handled=processRequest(line);
81 if (!handled) {
82 cerr << "*Warning, unrecognized directive " << line << endl;
83 }
84 }
85}
86
87#define tsttoi(toi) if (keyw == "@"#toi) kind = toi;
88
89bool TOISvr::processRequest(string line) {
90 int x = line.find(' ');
91 string keyw = line.substr(0, x);
92 string args = (x>0) ? line.substr(x) : string("");
93 if (keyw[0] == '#') {
94 bool handled = processOption(keyw,args);
95 for (list<RequestHandler*>::iterator i = handlers.begin();
96 i != handlers.end(); i++) {
97 handled |= (*i)->processOption(keyw,args);
98 }
99 return handled;
100 }
101 if (keyw[0] == '@') {
102 // find TOI kind, index and options
103 TOIKind kind= (TOIKind)-1;
104 int index=-1;
105 bool interp=false;
106 bool repet =false;
107 bool flag =false;
108 bool notrig=false;
109 tsttoi(sampleNum)
110 else tsttoi(internalTime)
111 else tsttoi(mjd)
112 else tsttoi(boloTens)
113 else tsttoi(boloTens2)
114 else tsttoi(boloRaw)
115 else tsttoi(boloRes)
116 else tsttoi(boloTemp)
117 else tsttoi(boloGainAmpli)
118 else tsttoi(boloDACV)
119 else tsttoi(boloDACI)
120 else tsttoi(boloTens2T)
121 else tsttoi(boloRawCN)
122 else tsttoi(boloTensCN)
123 else tsttoi(dilDAC)
124 else tsttoi(dilSwitch)
125 else tsttoi(sstDiode)
126 else tsttoi(sstChannel)
127 else tsttoi(sstDiodeCN)
128 else tsttoi(sstChannelCN)
129 else tsttoi(sstStarCnt)
130 else tsttoi(sstStarZ)
131 else tsttoi(sstStarF)
132 else tsttoi(sstStarT)
133 else tsttoi(gyroRaw)
134 else tsttoi(gyroTens)
135 else tsttoi(gyroSpeed)
136 else tsttoi(gpsTime)
137 else tsttoi(longitude)
138 else tsttoi(latitude)
139 else tsttoi(altitude)
140 else tsttoi(tsid)
141 else tsttoi(azimutBolo)
142 else tsttoi(alphaAxis)
143 else tsttoi(deltaAxis)
144 else tsttoi(alphaSst)
145 else tsttoi(deltaSst)
146 else tsttoi(alphaBolo)
147 else tsttoi(deltaBolo)
148 else {
149 // cerr << "*Warning, unrecognized TOI " << line << endl;
150 return false;
151 }
152 if (kind == sampleNum || kind == mjd) notrig = true;
153 string toiname = keyw.substr(1);
154 while (args != "") {
155 if (args[0] == ' ') {
156 args = args.substr(args.find_first_not_of(' '));
157 if (args == "") break;
158 }
159 x = args.find(' ');
160 string opt = args.substr(0, x);
161 args = (x>0) ? args.substr(x) : string("");
162 if (opt[0]>='0' && opt[0]<='9') {
163 index = atoi(opt.c_str());
164 } else if (opt == "notrig") {
165 notrig = true;
166 } else if (opt == "repet") {
167 repet = true; interp = false;
168 } else if (opt == "interp") {
169 interp = true; repet = false;
170 } else if (opt == "flag") {
171 flag = true;
172 }
173 }
174 bool handled = processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
175 for (list<RequestHandler*>::iterator i = handlers.begin();
176 i != handlers.end(); i++) {
177 handled |= (*i)->processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
178 }
179 return handled;
180 }
181 return false;
182}
183
184
185bool TOISvr::processTOIReq(string /*line*/, string /*toiname*/, TOIKind kind, int index,
186 bool interp, bool /*repet*/, bool /*flag*/, bool notrig)
187{
188 if (index<0) index=0;
189 addInfo(kind, index, !notrig, interp);
190 return true;
191}
192
193bool TOISvr::processOption(string key, string arg)
194{
195 if (arg.length()>0 && arg[0] == ' ') {
196 arg = arg.substr(arg.find_first_not_of(' '));
197 }
198 if (key == "#TRANGE") {
199 double tmin, tmax;
200 sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
201 setTimeInterval(tmin, tmax);
202 } else if (key == "#PATH") {
203 setDirectory(arg);
204 } else if (key == "#FILE") {
205 addFile(arg);
206 } else if (key == "#UNDERSAMPLE") {
207 setUnderSample(atoi(arg.c_str()));
208 } else if (key == "#RECORDER") {
209 onBoardRecorderFiles(true);
210 } else if (key == "#MJD0") {
211 double t0;
212 sscanf(arg.c_str(), "%lg", &t0);
213 archParam.acq.tBlock0 = t0;
214 } else if (key == "#PERECH") {
215 double t0;
216 sscanf(arg.c_str(), "%lg", &t0);
217 archParam.acq.perEch = t0;
218 } else if (key == "#ASIGPS") {
219 ASIGPS* gps = new ASIGPS(arg);
220 gps->FitsDump("GPSDump.fits");
221 useAuxGPS(gps);
222 } else if (key == "#INCLUDE") {
223 ifstream f(arg.c_str());
224 readReq(f);
225 } else {
226 // cerr << "*Warning, unrecognized option " << line << endl;
227 return false;
228 }
229 return true;
230}
231
232void TOISvr::defaultInclude() {
233 initDone = true;
234 processRequest("#REQVERSION V_230999");
235 processRequest("#MJD0 1376.8358818");
236 processRequest("#PERECH 0.005836818076");
237 processRequest("#ASIGPS ASI_GPS_archeops1999.ascii");
238 processRequest("#COMMENT Archtoi -- 23 september 1999 -- Eric Aubourg CEA/DAPNIA");
239 processRequest("#COMMENT ***WARNING***");
240 processRequest("#COMMENT ***SOME TOI'S ARE PRELIMINARY***");
241 processRequest("#COMMENT gyroSpeed is not calibrated");
242 processRequest("#COMMENT azimut/alpha/delta use galaxy crossings and ASI GPS data");
243 processRequest("#COMMENT and assume no pendulation");
244 processRequest("#COMMENT boloTens2 is not protected against glitches");
245 processRequest("#COMMENT sst software has not been updated to last DY code");
246 processRequest("#COMMENT trajectory info only while italian TM got GPS info");
247 processRequest("#COMMENT boloTemp is not implemented");
248
249}
Note: See TracBrowser for help on using the repository browser.