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

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

correction toi temperatures

File size: 8.6 KB
RevLine 
[350]1// toisvr.cc
2// Eric Aubourg CEA/DAPNIA/SPP juillet 1999
3
[407]4#include <iostream.h>
[310]5#include "toisvr.h"
[407]6#include "archparam.h"
7#include "asigps.h"
[310]8
[417]9
10
[310]11TOISvr::TOISvr()
[416]12{
[417]13 initDone = false;
[416]14}
[310]15
[407]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) {
[310]20 iter.directory = d;
21}
22
[407]23void TOISvr::addFile(string f) {
[342]24 iter.files.insert(f);
25}
26
[407]27void TOISvr::useAuxGPS(AuxGPS* gps) {
[358]28 if (iter.auxGPS) delete iter.auxGPS;
29 iter.auxGPS = gps;
30}
31
32
[407]33void TOISvr::onBoardRecorderFiles(bool x) {
[342]34 iter.isOnBoardRecorder = x;
35}
36
[310]37
[432]38void TOISvr::setMJDInterval(double tStart, double tEnd) {
[342]39 if (tStart>0) iter.tStart = tStart;
40 if (tEnd>0) iter.tEnd = tEnd;
[310]41}
[426]42
[432]43void TOISvr::setUTCInterval(double tStart, double tEnd) {
44 if (tStart>0) iter.utcStart = tStart;
45 if (tEnd>0) iter.utcEnd = tEnd;
46}
47
48void TOISvr::setSNInterval(long tStart, long tEnd) {
49 if (tStart>0) iter.sStart = tStart;
50 if (tEnd>0) iter.sEnd = tEnd;
51}
52
53
[426]54void TOISvr::setUnderSample(int n) {
55 if (n<=1) n=1;
56 iter.underSample = n;
57}
58
[310]59
[407]60void TOISvr::addInfo(TOIKind kind, int index, bool triggering, bool interp) {
[310]61 TOIIter::info i;
62 i.kind = kind;
63 i.index = index;
64 i.triggering = triggering;
65 i.interpolated= interp;
66 iter.infos.push_back(i);
67}
68
[407]69void TOISvr::addInfo(TOIKind kind, bool triggering, bool interp) {
70 addInfo(kind,0,triggering,interp);
[310]71}
72
[407]73TOIIter TOISvr::doQuery() {
[393]74 //iter.Init();
[310]75 return iter;
76}
[407]77
78void TOISvr::registerReqHandler(RequestHandler* h) {
79 handlers.push_back(h);
80}
81
82
83void TOISvr::readReq(istream& str) {
[417]84 if (!initDone) defaultInclude();
[407]85 string line;
86 while (str) {
87 getline(str,line);
88 if (!str) break;
89 if (line.substr(0,4)=="#END") break;
90 if (line[0] != '@' && line[0] != '#') continue;
91 bool handled=processRequest(line);
92 if (!handled) {
93 cerr << "*Warning, unrecognized directive " << line << endl;
94 }
95 }
96}
97
98#define tsttoi(toi) if (keyw == "@"#toi) kind = toi;
99
100bool TOISvr::processRequest(string line) {
101 int x = line.find(' ');
102 string keyw = line.substr(0, x);
103 string args = (x>0) ? line.substr(x) : string("");
104 if (keyw[0] == '#') {
105 bool handled = processOption(keyw,args);
106 for (list<RequestHandler*>::iterator i = handlers.begin();
107 i != handlers.end(); i++) {
108 handled |= (*i)->processOption(keyw,args);
109 }
110 return handled;
111 }
112 if (keyw[0] == '@') {
113 // find TOI kind, index and options
114 TOIKind kind= (TOIKind)-1;
115 int index=-1;
116 bool interp=false;
117 bool repet =false;
118 bool flag =false;
119 bool notrig=false;
120 tsttoi(sampleNum)
121 else tsttoi(internalTime)
122 else tsttoi(mjd)
[432]123 else tsttoi(mutc)
124 else tsttoi(boloMuV)
125 else tsttoi(boloMuV2)
126 else tsttoi(boloRawMuV)
[407]127 else tsttoi(boloRes)
128 else tsttoi(boloTemp)
129 else tsttoi(boloGainAmpli)
[408]130 else tsttoi(boloDACV)
131 else tsttoi(boloDACI)
[432]132 else tsttoi(boloMuV2T)
133 else tsttoi(boloRawMuVCN)
[410]134 else tsttoi(dilDAC)
135 else tsttoi(dilSwitch)
[432]136 else tsttoi(serviceTemp)
[407]137 else tsttoi(sstDiode)
138 else tsttoi(sstChannel)
139 else tsttoi(sstDiodeCN)
140 else tsttoi(sstChannelCN)
141 else tsttoi(sstStarCnt)
142 else tsttoi(sstStarZ)
143 else tsttoi(sstStarF)
144 else tsttoi(sstStarT)
145 else tsttoi(gyroRaw)
[432]146 else tsttoi(gyroV)
[407]147 else tsttoi(gyroSpeed)
148 else tsttoi(gpsTime)
149 else tsttoi(longitude)
150 else tsttoi(latitude)
151 else tsttoi(altitude)
152 else tsttoi(tsid)
[432]153 else tsttoi(azimuthBolo)
154 else tsttoi(alphaRotAxis)
155 else tsttoi(deltaRotAxis)
[407]156 else tsttoi(alphaSst)
157 else tsttoi(deltaSst)
[432]158 else tsttoi(alphaZenith)
159 else tsttoi(deltaZenith)
160 else tsttoi(alphaFPAxis)
161 else tsttoi(deltaFPAxis)
[407]162 else tsttoi(alphaBolo)
163 else tsttoi(deltaBolo)
[465]164 else tsttoi(voyantEVO)
165 else tsttoi(voyantEVF)
166 else tsttoi(commandeEV0)
167 else tsttoi(commandeEVF)
168 else tsttoi(commandeEVB)
169 else tsttoi(commandeEVV)
170 else tsttoi(pressEnt3He)
171 else tsttoi(debit3He)
172 else tsttoi(pressSor3He)
173 else tsttoi(pressEnt4He)
174 else tsttoi(debit4He)
175 else tsttoi(pressSor4He)
176 else tsttoi(pressAirVanne)
177 else tsttoi(pressPompChar)
178 else tsttoi(pressMembrane)
179 else tsttoi(pressExterne)
180 else tsttoi(tensPile10T)
181 else tsttoi(tensPileP18D)
182 else tsttoi(tensPileM18D)
183 else tsttoi(tensPile10B)
184 else tsttoi(tensPileP18B)
185 else tsttoi(tensPileM18B)
186 else tsttoi(tensPileCh)
187 else tsttoi(swPile5)
188 else tsttoi(swPile15)
189 else tsttoi(tempCaissH1)
190 else tsttoi(tempCaissH2)
191 else tsttoi(tempCaissB1)
192 else tsttoi(tempCaissB2)
193 else tsttoi(tempCaissTHe)
194 else tsttoi(tempCaissPiles)
195 else tsttoi(tempCaissDrv)
196 else tsttoi(pressHeBain)
197 else tsttoi(pressPirani)
[407]198 else {
199 // cerr << "*Warning, unrecognized TOI " << line << endl;
200 return false;
201 }
[432]202 if (kind == sampleNum || kind == mjd || kind == mutc) notrig = true;
[407]203 string toiname = keyw.substr(1);
204 while (args != "") {
205 if (args[0] == ' ') {
[432]206 x = args.find_first_not_of(' ');
207 if (x==string::npos) break;
208 args = args.substr(x);
[407]209 if (args == "") break;
210 }
211 x = args.find(' ');
212 string opt = args.substr(0, x);
213 args = (x>0) ? args.substr(x) : string("");
214 if (opt[0]>='0' && opt[0]<='9') {
215 index = atoi(opt.c_str());
216 } else if (opt == "notrig") {
217 notrig = true;
218 } else if (opt == "repet") {
219 repet = true; interp = false;
220 } else if (opt == "interp") {
221 interp = true; repet = false;
222 } else if (opt == "flag") {
223 flag = true;
224 }
225 }
226 bool handled = processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
227 for (list<RequestHandler*>::iterator i = handlers.begin();
228 i != handlers.end(); i++) {
229 handled |= (*i)->processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
230 }
231 return handled;
232 }
233 return false;
234}
235
236
237bool TOISvr::processTOIReq(string /*line*/, string /*toiname*/, TOIKind kind, int index,
238 bool interp, bool /*repet*/, bool /*flag*/, bool notrig)
239{
240 if (index<0) index=0;
241 addInfo(kind, index, !notrig, interp);
242 return true;
243}
244
245bool TOISvr::processOption(string key, string arg)
246{
247 if (arg.length()>0 && arg[0] == ' ') {
248 arg = arg.substr(arg.find_first_not_of(' '));
249 }
[432]250 if (key == "#MJDRANGE") {
[407]251 double tmin, tmax;
252 sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
[432]253 setMJDInterval(tmin, tmax);
254 } else if (key == "#UTCRANGE") {
255 double tmin, tmax;
256 sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
257 setUTCInterval(tmin, tmax);
258 } else if (key == "#SNRANGE") {
259 long tmin, tmax;
260 sscanf(arg.c_str(), "%ld %ld", &tmin, &tmax);
261 setSNInterval(tmin, tmax);
[407]262 } else if (key == "#PATH") {
263 setDirectory(arg);
264 } else if (key == "#FILE") {
265 addFile(arg);
[426]266 } else if (key == "#UNDERSAMPLE") {
267 setUnderSample(atoi(arg.c_str()));
[407]268 } else if (key == "#RECORDER") {
269 onBoardRecorderFiles(true);
270 } else if (key == "#MJD0") {
271 double t0;
272 sscanf(arg.c_str(), "%lg", &t0);
273 archParam.acq.tBlock0 = t0;
[432]274 } else if (key == "#UTCORIGIN") {
275 double t0;
276 sscanf(arg.c_str(), "%lg", &t0);
277 archParam.acq.utcOrigin = t0;
[407]278 } else if (key == "#PERECH") {
279 double t0;
280 sscanf(arg.c_str(), "%lg", &t0);
281 archParam.acq.perEch = t0;
282 } else if (key == "#ASIGPS") {
283 ASIGPS* gps = new ASIGPS(arg);
284 gps->FitsDump("GPSDump.fits");
285 useAuxGPS(gps);
[408]286 } else if (key == "#INCLUDE") {
[414]287 ifstream f(arg.c_str());
288 readReq(f);
[407]289 } else {
290 // cerr << "*Warning, unrecognized option " << line << endl;
291 return false;
292 }
293 return true;
294}
[416]295
296void TOISvr::defaultInclude() {
[417]297 initDone = true;
[443]298 processRequest("#REQVERSION V_270999");
[416]299 processRequest("#MJD0 1376.8358818");
300 processRequest("#PERECH 0.005836818076");
[432]301 processRequest("#UTCORIGIN 1376.5");
[420]302 processRequest("#ASIGPS ASI_GPS_archeops1999.ascii");
[443]303 processRequest("#COMMENT Archtoi -- 27 september 1999 -- Eric Aubourg CEA/DAPNIA");
[416]304 processRequest("#COMMENT ***WARNING***");
305 processRequest("#COMMENT ***SOME TOI'S ARE PRELIMINARY***");
306 processRequest("#COMMENT gyroSpeed is not calibrated");
[426]307 processRequest("#COMMENT azimut/alpha/delta use galaxy crossings and ASI GPS data");
[443]308 processRequest("#COMMENT and assume no pendulation");
309 processRequest("#COMMENT Focal plane center elevation found at 41.5 deg");
310 processRequest("#COMMENT with Jupiter");
311 processRequest("#COMMENT boloMuV2 is not protected against glitches");
[426]312 processRequest("#COMMENT sst software has not been updated to last DY code");
313 processRequest("#COMMENT trajectory info only while italian TM got GPS info");
[416]314
315}
Note: See TracBrowser for help on using the repository browser.