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

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

nouvelles toi

File size: 5.5 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
9TOISvr::TOISvr()
10{}
11
12// To avoid special copy constructor handling, we will not
13// register ourself to us... Special dealing in readReq.
14
15void TOISvr::setDirectory(string d) {
16 iter.directory = d;
17}
18
19void TOISvr::addFile(string f) {
20 iter.files.insert(f);
21}
22
23void TOISvr::useAuxGPS(AuxGPS* gps) {
24 if (iter.auxGPS) delete iter.auxGPS;
25 iter.auxGPS = gps;
26}
27
28
29void TOISvr::onBoardRecorderFiles(bool x) {
30 iter.isOnBoardRecorder = x;
31}
32
33
34void TOISvr::setTimeInterval(double tStart, double tEnd) {
35 if (tStart>0) iter.tStart = tStart;
36 if (tEnd>0) iter.tEnd = tEnd;
37}
38
39void TOISvr::addInfo(TOIKind kind, int index, bool triggering, bool interp) {
40 TOIIter::info i;
41 i.kind = kind;
42 i.index = index;
43 i.triggering = triggering;
44 i.interpolated= interp;
45 iter.infos.push_back(i);
46}
47
48void TOISvr::addInfo(TOIKind kind, bool triggering, bool interp) {
49 addInfo(kind,0,triggering,interp);
50}
51
52TOIIter TOISvr::doQuery() {
53 //iter.Init();
54 return iter;
55}
56
57void TOISvr::registerReqHandler(RequestHandler* h) {
58 handlers.push_back(h);
59}
60
61
62void TOISvr::readReq(istream& str) {
63 string line;
64 while (str) {
65 getline(str,line);
66 if (!str) break;
67 if (line.substr(0,4)=="#END") break;
68 if (line[0] != '@' && line[0] != '#') continue;
69 bool handled=processRequest(line);
70 if (!handled) {
71 cerr << "*Warning, unrecognized directive " << line << endl;
72 }
73 }
74}
75
76#define tsttoi(toi) if (keyw == "@"#toi) kind = toi;
77
78bool TOISvr::processRequest(string line) {
79 int x = line.find(' ');
80 string keyw = line.substr(0, x);
81 string args = (x>0) ? line.substr(x) : string("");
82 if (keyw[0] == '#') {
83 bool handled = processOption(keyw,args);
84 for (list<RequestHandler*>::iterator i = handlers.begin();
85 i != handlers.end(); i++) {
86 handled |= (*i)->processOption(keyw,args);
87 }
88 return handled;
89 }
90 if (keyw[0] == '@') {
91 // find TOI kind, index and options
92 TOIKind kind= (TOIKind)-1;
93 int index=-1;
94 bool interp=false;
95 bool repet =false;
96 bool flag =false;
97 bool notrig=false;
98 tsttoi(sampleNum)
99 else tsttoi(internalTime)
100 else tsttoi(mjd)
101 else tsttoi(boloTens)
102 else tsttoi(boloTens2)
103 else tsttoi(boloRaw)
104 else tsttoi(boloRes)
105 else tsttoi(boloTemp)
106 else tsttoi(boloGainAmpli)
107 else tsttoi(boloDACV)
108 else tsttoi(boloDACI)
109 else tsttoi(boloTens2T)
110 else tsttoi(boloRawCN)
111 else tsttoi(dilDAC)
112 else tsttoi(dilSwitch)
113 else tsttoi(sstDiode)
114 else tsttoi(sstChannel)
115 else tsttoi(sstDiodeCN)
116 else tsttoi(sstChannelCN)
117 else tsttoi(sstStarCnt)
118 else tsttoi(sstStarZ)
119 else tsttoi(sstStarF)
120 else tsttoi(sstStarT)
121 else tsttoi(gyroRaw)
122 else tsttoi(gyroTens)
123 else tsttoi(gyroSpeed)
124 else tsttoi(gpsTime)
125 else tsttoi(longitude)
126 else tsttoi(latitude)
127 else tsttoi(altitude)
128 else tsttoi(tsid)
129 else tsttoi(azimut)
130 else tsttoi(alphaAxis)
131 else tsttoi(deltaAxis)
132 else tsttoi(alphaSst)
133 else tsttoi(deltaSst)
134 else tsttoi(alphaBolo)
135 else tsttoi(deltaBolo)
136 else {
137 // cerr << "*Warning, unrecognized TOI " << line << endl;
138 return false;
139 }
140 if (kind == sampleNum || kind == mjd) notrig = true;
141 string toiname = keyw.substr(1);
142 while (args != "") {
143 if (args[0] == ' ') {
144 args = args.substr(args.find_first_not_of(' '));
145 if (args == "") break;
146 }
147 x = args.find(' ');
148 string opt = args.substr(0, x);
149 args = (x>0) ? args.substr(x) : string("");
150 if (opt[0]>='0' && opt[0]<='9') {
151 index = atoi(opt.c_str());
152 } else if (opt == "notrig") {
153 notrig = true;
154 } else if (opt == "repet") {
155 repet = true; interp = false;
156 } else if (opt == "interp") {
157 interp = true; repet = false;
158 } else if (opt == "flag") {
159 flag = true;
160 }
161 }
162 bool handled = processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
163 for (list<RequestHandler*>::iterator i = handlers.begin();
164 i != handlers.end(); i++) {
165 handled |= (*i)->processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
166 }
167 return handled;
168 }
169 return false;
170}
171
172
173bool TOISvr::processTOIReq(string /*line*/, string /*toiname*/, TOIKind kind, int index,
174 bool interp, bool /*repet*/, bool /*flag*/, bool notrig)
175{
176 if (index<0) index=0;
177 addInfo(kind, index, !notrig, interp);
178 return true;
179}
180
181bool TOISvr::processOption(string key, string arg)
182{
183 if (arg.length()>0 && arg[0] == ' ') {
184 arg = arg.substr(arg.find_first_not_of(' '));
185 }
186 if (key == "#TRANGE") {
187 double tmin, tmax;
188 sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
189 setTimeInterval(tmin, tmax);
190 } else if (key == "#PATH") {
191 setDirectory(arg);
192 } else if (key == "#FILE") {
193 addFile(arg);
194 } else if (key == "#RECORDER") {
195 onBoardRecorderFiles(true);
196 } else if (key == "#MJD0") {
197 double t0;
198 sscanf(arg.c_str(), "%lg", &t0);
199 archParam.acq.tBlock0 = t0;
200 } else if (key == "#PERECH") {
201 double t0;
202 sscanf(arg.c_str(), "%lg", &t0);
203 archParam.acq.perEch = t0;
204 } else if (key == "#ASIGPS") {
205 ASIGPS* gps = new ASIGPS(arg);
206 gps->FitsDump("GPSDump.fits");
207 useAuxGPS(gps);
208 } else if (key == "#INCLUDE") {
209 readReq(ifstream(arg.c_str()));
210 } else {
211 // cerr << "*Warning, unrecognized option " << line << endl;
212 return false;
213 }
214 return true;
215}
Note: See TracBrowser for help on using the repository browser.