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

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

apres grenoble

File size: 5.3 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(boloTens2T)
108 else tsttoi(boloRawCN)
109 else tsttoi(sstDiode)
110 else tsttoi(sstChannel)
111 else tsttoi(sstDiodeCN)
112 else tsttoi(sstChannelCN)
113 else tsttoi(sstStarCnt)
114 else tsttoi(sstStarZ)
115 else tsttoi(sstStarF)
116 else tsttoi(sstStarT)
117 else tsttoi(gyroRaw)
118 else tsttoi(gyroTens)
119 else tsttoi(gyroSpeed)
120 else tsttoi(gpsTime)
121 else tsttoi(longitude)
122 else tsttoi(latitude)
123 else tsttoi(altitude)
124 else tsttoi(tsid)
125 else tsttoi(azimut)
126 else tsttoi(alphaAxis)
127 else tsttoi(deltaAxis)
128 else tsttoi(alphaSst)
129 else tsttoi(deltaSst)
130 else tsttoi(alphaBolo)
131 else tsttoi(deltaBolo)
132 else {
133 // cerr << "*Warning, unrecognized TOI " << line << endl;
134 return false;
135 }
136 if (kind == sampleNum || kind == mjd) notrig = true;
137 string toiname = keyw.substr(1);
138 while (args != "") {
139 if (args[0] == ' ') {
140 args = args.substr(args.find_first_not_of(' '));
141 if (args == "") break;
142 }
143 x = args.find(' ');
144 string opt = args.substr(0, x);
145 args = (x>0) ? args.substr(x) : string("");
146 if (opt[0]>='0' && opt[0]<='9') {
147 index = atoi(opt.c_str());
148 } else if (opt == "notrig") {
149 notrig = true;
150 } else if (opt == "repet") {
151 repet = true; interp = false;
152 } else if (opt == "interp") {
153 interp = true; repet = false;
154 } else if (opt == "flag") {
155 flag = true;
156 }
157 }
158 bool handled = processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
159 for (list<RequestHandler*>::iterator i = handlers.begin();
160 i != handlers.end(); i++) {
161 handled |= (*i)->processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
162 }
163 return handled;
164 }
165 return false;
166}
167
168
169bool TOISvr::processTOIReq(string /*line*/, string /*toiname*/, TOIKind kind, int index,
170 bool interp, bool /*repet*/, bool /*flag*/, bool notrig)
171{
172 if (index<0) index=0;
173 addInfo(kind, index, !notrig, interp);
174 return true;
175}
176
177bool TOISvr::processOption(string key, string arg)
178{
179 if (arg.length()>0 && arg[0] == ' ') {
180 arg = arg.substr(arg.find_first_not_of(' '));
181 }
182 if (key == "#TRANGE") {
183 double tmin, tmax;
184 sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
185 setTimeInterval(tmin, tmax);
186 } else if (key == "#PATH") {
187 setDirectory(arg);
188 } else if (key == "#FILE") {
189 addFile(arg);
190 } else if (key == "#RECORDER") {
191 onBoardRecorderFiles(true);
192 } else if (key == "#MJD0") {
193 double t0;
194 sscanf(arg.c_str(), "%lg", &t0);
195 archParam.acq.tBlock0 = t0;
196 } else if (key == "#PERECH") {
197 double t0;
198 sscanf(arg.c_str(), "%lg", &t0);
199 archParam.acq.perEch = t0;
200 } else if (key == "#ASIGPS") {
201 ASIGPS* gps = new ASIGPS(arg);
202 gps->FitsDump("GPSDump.fits");
203 useAuxGPS(gps);
204 } else {
205 // cerr << "*Warning, unrecognized option " << line << endl;
206 return false;
207 }
208 return true;
209}
Note: See TracBrowser for help on using the repository browser.