1 | // toiiter.cc
|
---|
2 | // Eric Aubourg CEA/DAPNIA/SPP juillet 1999
|
---|
3 |
|
---|
4 | #ifndef nb_max_bolo
|
---|
5 | #define _archeops // Acquisition Archeops (avec transputer)
|
---|
6 | #define programme
|
---|
7 | extern "C" {
|
---|
8 | #include "archeops.h"
|
---|
9 | }
|
---|
10 | #endif
|
---|
11 |
|
---|
12 |
|
---|
13 | #include "toiiter.h"
|
---|
14 | #include "toiinterpolator.h"
|
---|
15 | #include "archparam.h"
|
---|
16 | #include <dirent.h>
|
---|
17 | #include <iostream.h>
|
---|
18 | #include "templocator.h"
|
---|
19 |
|
---|
20 | // Format bloc GPS
|
---|
21 | // $GPGGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z,
|
---|
22 |
|
---|
23 | TOIIter::TOIIter() {
|
---|
24 | // Toutes les valeurs initialisees par defaut. Le TOISvr les positionnera,
|
---|
25 | // puis lancera l'initialisation
|
---|
26 |
|
---|
27 | file = NULL;
|
---|
28 | directory = "";
|
---|
29 |
|
---|
30 | files.clear();
|
---|
31 |
|
---|
32 | isOnBoardRecorder = false;
|
---|
33 |
|
---|
34 | imes=0;
|
---|
35 |
|
---|
36 | tStart = -9.e99;
|
---|
37 | tEnd = 9.e99;
|
---|
38 |
|
---|
39 | //tBlock0 = -1;
|
---|
40 | // perEch = -1;
|
---|
41 | // Values for Trapani 99 = default values
|
---|
42 | //tBlock0 = 1376.8358818;
|
---|
43 | //perEch = 0.005836818076;
|
---|
44 |
|
---|
45 | trigMask = 0;
|
---|
46 | rawIter = NULL;
|
---|
47 | interp = NULL;
|
---|
48 | lastSample = -1;
|
---|
49 | maxLookAhead = 10000;
|
---|
50 |
|
---|
51 | auxGPS = NULL;
|
---|
52 |
|
---|
53 | initDone = false;
|
---|
54 | }
|
---|
55 |
|
---|
56 | TOIIter::TOIIter(TOIIter const& x) {
|
---|
57 | directory = x.directory;
|
---|
58 | files = x.files;
|
---|
59 | if (x.initDone && x.curFile != x.files.end()) curFile = files.find(*(x.curFile));
|
---|
60 | isOnBoardRecorder = x.isOnBoardRecorder;
|
---|
61 | imes = x.imes;
|
---|
62 | tStart = x.tStart;
|
---|
63 | tEnd = x.tEnd;
|
---|
64 | trigMask = x.trigMask;
|
---|
65 | infos = x.infos;
|
---|
66 |
|
---|
67 | if (x.file)
|
---|
68 | file = new ArcheopsFile(*x.file);
|
---|
69 | else
|
---|
70 | file = NULL;
|
---|
71 |
|
---|
72 | if (x.rawIter) {
|
---|
73 | rawIter = new TOIIter(*x.rawIter);
|
---|
74 | interp = new TOIInterpolator[infos.size()];
|
---|
75 | for (int i=0; i<infos.size(); i++)
|
---|
76 | interp[i] = x.interp[i];
|
---|
77 | } else {
|
---|
78 | rawIter = NULL;
|
---|
79 | interp = NULL;
|
---|
80 | }
|
---|
81 |
|
---|
82 | lastSample = x.lastSample;
|
---|
83 | maxLookAhead = x.maxLookAhead;
|
---|
84 |
|
---|
85 | auxGPS = x.auxGPS;
|
---|
86 | if (auxGPS) auxGPS = auxGPS->clone();
|
---|
87 |
|
---|
88 | initDone = x.initDone;
|
---|
89 | }
|
---|
90 |
|
---|
91 | TOIIter::~TOIIter() {
|
---|
92 | delete file;
|
---|
93 | delete rawIter;
|
---|
94 | delete[] interp;
|
---|
95 | delete auxGPS;
|
---|
96 | }
|
---|
97 |
|
---|
98 | #ifdef __MWERKS__
|
---|
99 | #define filesep ':'
|
---|
100 | #else
|
---|
101 | #define filesep '/'
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | void TOIIter::Init() {
|
---|
105 | if (initDone) return;
|
---|
106 | initDone = true;
|
---|
107 | // On a soit un repertoire, soit une liste de fichiers....
|
---|
108 | if (directory == "") {
|
---|
109 | if (files.empty()) { // Ni repertoire, ni fichiers
|
---|
110 | cerr << "toiiter : pas de repertoire, pas de fichiers" << endl;
|
---|
111 | exit(-1);
|
---|
112 | } else {
|
---|
113 | // On a deja une liste de fichiers
|
---|
114 | }
|
---|
115 | } else { // On a un repertoire a explorer
|
---|
116 | // On cherche soit les fichiers dans le repertoire donne, soit des fichiers
|
---|
117 | // dans un sous-repertoire "arch-YY_MM_DD". Les fichiers ont un nom en
|
---|
118 | // "hYY_MM_DD-hh_mm_ss".
|
---|
119 | // Pour l'enregistreur de vol, les fichiers ont un nom en ARKxxxxxx.DAT
|
---|
120 | if (directory[directory.length()-1] != filesep)
|
---|
121 | directory += filesep;
|
---|
122 | DIR* dir = opendir(directory.c_str());
|
---|
123 | struct dirent* ent;
|
---|
124 | while ((ent = readdir(dir)) != NULL) {
|
---|
125 | // si c'est un repertoire, avec un nom de jour, il faut l'explorer...
|
---|
126 | if (!strncmp(ent->d_name, "arch-", 5)) {
|
---|
127 | double mjd = ArcheopsFile::decodeMJD(ent->d_name+5) - 2./24.; // ENTIER + .5 en temps local!
|
---|
128 | if (mjd >= tStart - 1. && mjd <= tEnd) {
|
---|
129 | string direc2 = directory + ent->d_name + filesep;
|
---|
130 | DIR* dir2 = opendir(direc2.c_str());
|
---|
131 | struct dirent* ent2;
|
---|
132 | while ((ent2 = readdir(dir2)) != NULL) {
|
---|
133 | if (*ent2->d_name == 'h') {
|
---|
134 | double mjd2 = ArcheopsFile::decodeMJD(ent->d_name+1) - 2./24.;
|
---|
135 | if (mjd2 >= tStart - 1./24. && mjd2 <= tEnd) {
|
---|
136 | files.insert(direc2 + ent2->d_name);
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|
140 | }
|
---|
141 | } else {
|
---|
142 | if (!isOnBoardRecorder && *ent->d_name == 'h') {
|
---|
143 | double mjd = ArcheopsFile::decodeMJD(ent->d_name+1) - 2./24.; // $CHECK$ UTCOffset
|
---|
144 | if (mjd >= tStart - 1./24. && mjd <= tEnd) {
|
---|
145 | files.insert(directory + ent->d_name);
|
---|
146 | }
|
---|
147 | } else if (isOnBoardRecorder) {
|
---|
148 | if (strncmp(ent->d_name, "ARK", 3) && strncmp(ent->d_name, "ark", 3)) continue;
|
---|
149 | char * sfx = ent->d_name + strlen(ent->d_name) - 4;
|
---|
150 | if (strcmp(sfx, ".DAT") && strcmp(sfx, ".dat")) continue;
|
---|
151 | files.insert(directory + ent->d_name);
|
---|
152 | }
|
---|
153 | }
|
---|
154 | }
|
---|
155 | closedir(dir);
|
---|
156 | }
|
---|
157 |
|
---|
158 | ScanFiles();
|
---|
159 |
|
---|
160 | curFile = files.begin();
|
---|
161 | file = new ArcheopsFile((*curFile).c_str());
|
---|
162 | cout << "opening file " << (*curFile).c_str() << endl;
|
---|
163 |
|
---|
164 | // On avance jusqu'a avoir au moins un bloc param et un bloc reglage,
|
---|
165 | // car on ne peut rien faire sans...
|
---|
166 | // Si on a des donnees de l'enregistreur de vol, pas de bloc param, et
|
---|
167 | // on en simule un
|
---|
168 | double oldTStart = tStart;
|
---|
169 | tStart = -9.e99; // pour init, on accepte des blocs avant tstart....
|
---|
170 |
|
---|
171 | if (!file->lastParam()) {
|
---|
172 | if (isOnBoardRecorder) {
|
---|
173 | extern param_bolo parametr;
|
---|
174 | block_type_param block;
|
---|
175 | block.param = parametr;
|
---|
176 | valide_block((block_type_modele*)&block, block_param, 0);
|
---|
177 | file->forceBlock((block_type_modele*)&block);
|
---|
178 | } else {
|
---|
179 | file->nextBlock(block_param_mask);
|
---|
180 | }
|
---|
181 | }
|
---|
182 | if (!file->lastReglage()) file->nextBlock(block_reglage_mask);
|
---|
183 |
|
---|
184 | // On cherche un bloc GPS pour avoir la correspondance timestamp/UTC.
|
---|
185 | // Pour le moment, on se fonde sur le premier bloc GPS. On pourra faire
|
---|
186 | // mieux en prenant le min de tous les delta_T, a condition d'avoir un
|
---|
187 | // peu plus de details sur la facon dont le GPS est lu.
|
---|
188 |
|
---|
189 | if (archParam.acq.tBlock0 < 0) {
|
---|
190 | archParam.acq.tBlock0 = file->getStartMJD();
|
---|
191 |
|
---|
192 | file->pushMark();
|
---|
193 | if (file->lastGPS() || file->nextBlock(block_gps_mask)) {
|
---|
194 | // le temps du bloc courant, en secondes
|
---|
195 | double dt = file->blockNum() * file->perBlock();
|
---|
196 | archParam.acq.tBlock0 = file->getGPSMJD() - dt/86400.;
|
---|
197 | } else { // pas de bloc GPS...
|
---|
198 | archParam.acq.tBlock0 = file->getStartMJD();
|
---|
199 | }
|
---|
200 | file->popMark();
|
---|
201 | }
|
---|
202 | tStart = oldTStart; // on restaure
|
---|
203 |
|
---|
204 | if (archParam.acq.perEch < 0)
|
---|
205 | archParam.acq.perEch = file->perEchant();
|
---|
206 |
|
---|
207 | bool hasInterp = false;
|
---|
208 |
|
---|
209 | trigMask = 0;
|
---|
210 | for (vector<info>::iterator i = infos.begin(); i != infos.end(); i++) {
|
---|
211 | if ((*i).interpolated) hasInterp = true;
|
---|
212 | if ((*i).triggering) {
|
---|
213 | switch ((*i).kind) {
|
---|
214 | case boloTens:
|
---|
215 | case boloTens2:
|
---|
216 | case boloRaw:
|
---|
217 | case boloRawCN:
|
---|
218 | case boloTensCN:
|
---|
219 | trigMask |= block_bolo_mask;
|
---|
220 | break;
|
---|
221 | case boloTens2T:
|
---|
222 | case boloRes:
|
---|
223 | case boloTemp:
|
---|
224 | trigMask |= block_bolo_mask | block_reglage_mask;
|
---|
225 | break;
|
---|
226 | case dilDAC:
|
---|
227 | case dilSwitch:
|
---|
228 | trigMask |= block_dilution_mask;
|
---|
229 | case boloGainAmpli:
|
---|
230 | case boloDACV:
|
---|
231 | case boloDACI:
|
---|
232 | trigMask |= block_reglage_mask;
|
---|
233 | break;
|
---|
234 | case gpsTime:
|
---|
235 | case longitude:
|
---|
236 | case latitude:
|
---|
237 | case altitude:
|
---|
238 | trigMask |= block_gps_mask;
|
---|
239 | break;
|
---|
240 | case azimut:
|
---|
241 | trigMask |= block_bolo_mask;
|
---|
242 | //file->needSSTProcessMask(SSTHandler::findPeriod);
|
---|
243 | //trigMask |= block_sst_mask;
|
---|
244 | break;
|
---|
245 | case sstStarCnt:
|
---|
246 | case sstStarZ:
|
---|
247 | case sstStarF:
|
---|
248 | case sstStarT:
|
---|
249 | file->needSSTProcessMask(SSTHandler::findStars);
|
---|
250 | trigMask |= block_sst_mask;
|
---|
251 | break;
|
---|
252 | case sstDiode:
|
---|
253 | case sstDiodeCN:
|
---|
254 | file->needSSTProcessMask(SSTHandler::permDiode);
|
---|
255 | trigMask |= block_sst_mask;
|
---|
256 | break;
|
---|
257 | case sstChannel:
|
---|
258 | case sstChannelCN:
|
---|
259 | trigMask |= block_sst_mask;
|
---|
260 | break;
|
---|
261 | case gyroRaw:
|
---|
262 | case gyroTens:
|
---|
263 | trigMask |= block_gyro_mask;
|
---|
264 | break;
|
---|
265 | case gyroSpeed:
|
---|
266 | trigMask |= block_gyro_mask; // $CHECK$ + info to calibrate gyros
|
---|
267 | break;
|
---|
268 | case alphaAxis:
|
---|
269 | case deltaAxis:
|
---|
270 | case alphaSst:
|
---|
271 | case deltaSst:
|
---|
272 | case alphaBolo:
|
---|
273 | case deltaBolo:
|
---|
274 | trigMask |= block_bolo_mask;
|
---|
275 | //file->needSSTProcessMask(SSTHandler::findAxis);
|
---|
276 | //trigMask |= block_sst_mask;
|
---|
277 | break;
|
---|
278 | }
|
---|
279 | }
|
---|
280 | }
|
---|
281 |
|
---|
282 | if (trigMask & (block_bolo_mask | block_sst_mask)) {
|
---|
283 | imes = 9999;
|
---|
284 | } else {
|
---|
285 | imes = 0;
|
---|
286 | }
|
---|
287 |
|
---|
288 | if (hasInterp) {
|
---|
289 | rawIter = new TOIIter(*this);
|
---|
290 | interp = new TOIInterpolator[infos.size()];
|
---|
291 | for (int i=0; i<infos.size(); i++) {
|
---|
292 | rawIter->infos[i].interpolated = false;
|
---|
293 | }
|
---|
294 | delete file; file = NULL; // on ne travaille plus sur le fichier directement...
|
---|
295 | }
|
---|
296 | }
|
---|
297 |
|
---|
298 | void TOIIter::ScanFiles() {
|
---|
299 | file1stSamp.clear();
|
---|
300 | cout << "Scanning all files" << endl;
|
---|
301 | // Petite astuce pour les STL non conformes comme celles de digital
|
---|
302 | // qui ne supportent pas files.erase(i) suivi de i++....
|
---|
303 | set<string> copy = files;
|
---|
304 | for (set<string>::iterator i = copy.begin(); i != copy.end(); i++) {
|
---|
305 | ArcheopsFile fich((*i).c_str());
|
---|
306 | if (fich.nextBlock()) {
|
---|
307 | file1stSamp[*i] = fich.blockNum()*72; // premier numsample
|
---|
308 | cout << "File " << *i << " 1st sample = " << fich.blockNum()*72 << endl;
|
---|
309 | } else {
|
---|
310 | cout << "File " << *i << " unrecoverable, skipping" << endl;
|
---|
311 | files.erase(*i);
|
---|
312 | }
|
---|
313 | }
|
---|
314 | cout << "Scan done" << endl;
|
---|
315 |
|
---|
316 | // Et maintenant, on ne garde que ceux qui tombent dans l'intervalle...
|
---|
317 | copy = files;
|
---|
318 | string prev="";
|
---|
319 | for (set<string>::iterator i = copy.begin(); i != copy.end(); i++) {
|
---|
320 | double smp = file1stSamp[*i];
|
---|
321 | double t = archParam.acq.tBlock0 + smp * archParam.acq.perEch/86400.;
|
---|
322 | if (t>tEnd) { // premier echantillon apres tEnd
|
---|
323 | files.erase(*i);
|
---|
324 | prev = "";
|
---|
325 | continue;
|
---|
326 | }
|
---|
327 | if (t<tStart) { // premier echantillon avant tStart -> on vire le precedent si existe
|
---|
328 | if (prev != "") {
|
---|
329 | files.erase(prev);
|
---|
330 | }
|
---|
331 | }
|
---|
332 | prev = *i;
|
---|
333 | }
|
---|
334 | }
|
---|
335 |
|
---|
336 | bool TOIIter::NextFile() {
|
---|
337 | if (rawIter)
|
---|
338 | return rawIter->NextFile();
|
---|
339 |
|
---|
340 | if (files.empty()) {
|
---|
341 | return false;
|
---|
342 | } else {
|
---|
343 | if (curFile == files.end()) return false;
|
---|
344 | curFile++;
|
---|
345 | if (curFile == files.end()) return false;
|
---|
346 | cout << "opening file " << (*curFile).c_str() << endl;
|
---|
347 | ArcheopsFile* newfile = new ArcheopsFile((*curFile).c_str());
|
---|
348 | newfile->grabLastBlocs(*file);
|
---|
349 | delete file;
|
---|
350 | file = newfile;
|
---|
351 | return true;
|
---|
352 | }
|
---|
353 | }
|
---|
354 |
|
---|
355 |
|
---|
356 | bool TOIIter::Next() {
|
---|
357 | if (!initDone) Init();
|
---|
358 | while (1) {
|
---|
359 | if (!NextSample()) return false; // end of files
|
---|
360 | double t = getMJD();
|
---|
361 | if (t < tStart) continue;
|
---|
362 | if (t > tEnd) return false;
|
---|
363 | return true;
|
---|
364 | }
|
---|
365 | }
|
---|
366 |
|
---|
367 | bool TOIIter::NextSample() {
|
---|
368 | if (rawIter) { // Delegation pour interpolation
|
---|
369 | // Trouve prochain sample disponible
|
---|
370 | for (int k=0; k<2; k++) {
|
---|
371 | long smp = 2147483647L;
|
---|
372 | for (int i=0; i<infos.size(); i++) {
|
---|
373 | long ss = interp[i].nextSample(lastSample+1);
|
---|
374 | if (ss > 0 && ss < smp) smp=ss;
|
---|
375 | }
|
---|
376 | if (smp != 2147483647L) {
|
---|
377 | lastSample = smp;
|
---|
378 | break;
|
---|
379 | }
|
---|
380 | if (!fetchAhead()) // tout le monde etait en bout de course,
|
---|
381 | return false; // on lit un echantillon, ca suffit, d'ou le k<2
|
---|
382 | }
|
---|
383 | // Verifie que tous les interpolateurs ont assez de donnees pour
|
---|
384 | // trouver la valeur correspondante
|
---|
385 | for (int i=0; i<infos.size(); i++) {
|
---|
386 | //rif (infos[i].interpolated)
|
---|
387 | while (interp[i].needMoreDataFor(lastSample) &&
|
---|
388 | rawIter->getSampleIndex() - lastSample < maxLookAhead)
|
---|
389 | if (!fetchAhead()) return false;
|
---|
390 | }
|
---|
391 |
|
---|
392 | // On est pret...
|
---|
393 | return true;
|
---|
394 | }
|
---|
395 |
|
---|
396 | // trigger sur info indexee dans bloc bolo, bloc gyro ou bloc sst ?
|
---|
397 | if (trigMask & (block_bolo_mask | block_sst_mask | block_gyro_mask )) {
|
---|
398 | imes++;
|
---|
399 | if (imes < file->nEchBlock()) return true;
|
---|
400 | imes = 0;
|
---|
401 | }
|
---|
402 |
|
---|
403 | // soit pas d'info indexee, soit fin bloc courant...
|
---|
404 | while (1) {
|
---|
405 | if (file->nextBlock(trigMask)) {
|
---|
406 | while (file->sameBlockNumAhead()) { // tant que meme numero de bloc, on lit
|
---|
407 | if (!file->nextBlock()) { // fin de fichier ?
|
---|
408 | if (NextFile()) file->nextBlock(); // fichier suivant
|
---|
409 | else return false; // tout fini
|
---|
410 | }
|
---|
411 | }
|
---|
412 | return true;
|
---|
413 | }
|
---|
414 | if (!NextFile()) return false;
|
---|
415 | }
|
---|
416 | }
|
---|
417 |
|
---|
418 | /* double TOIIter::getTime() { // MJD
|
---|
419 | // le temps du bloc courant, en secondes
|
---|
420 | double dt = file->blockNum() * file->perBlock();
|
---|
421 | return tBlock0 + dt/86400. + imes*file->perEchant()/86400.;
|
---|
422 | }
|
---|
423 | */
|
---|
424 |
|
---|
425 | bool TOIIter::canGetValue(int column) {
|
---|
426 | if (!initDone) Init();
|
---|
427 | if (column < 0 || column >= infos.size()) return false;
|
---|
428 | TOIKind kind = infos[column].kind;
|
---|
429 | if (auxGPS &&
|
---|
430 | (kind == longitude || kind == latitude || kind == altitude || kind == tsid)) {
|
---|
431 | double dummy;
|
---|
432 | return auxGPS->getLocation(getMJD(), dummy, dummy, dummy) == 0;
|
---|
433 | }
|
---|
434 | if (rawIter) {
|
---|
435 | return interp[column].canGet(lastSample);
|
---|
436 | }
|
---|
437 | int index = infos[column].index;
|
---|
438 | switch (kind) {
|
---|
439 | case sampleNum:
|
---|
440 | case internalTime:
|
---|
441 | case mjd:
|
---|
442 | return true;
|
---|
443 | case boloTens:
|
---|
444 | case boloTens2:
|
---|
445 | case boloTens2T:
|
---|
446 | case boloRes:
|
---|
447 | case boloRawCN:
|
---|
448 | if (imes==0 && file->llastBolo()==NULL) return false;
|
---|
449 | return file->lastBolo() != NULL;
|
---|
450 | case boloTensCN:
|
---|
451 | case boloRaw:
|
---|
452 | return file->lastBolo() != NULL;
|
---|
453 | case boloGainAmpli:
|
---|
454 | case boloDACV:
|
---|
455 | case boloDACI:
|
---|
456 | return file->lastReglage() != NULL;
|
---|
457 | case dilDAC:
|
---|
458 | case dilSwitch:
|
---|
459 | return file->lastDilution() != NULL;
|
---|
460 | case sstDiode:
|
---|
461 | case sstChannel:
|
---|
462 | case sstDiodeCN:
|
---|
463 | case sstChannelCN:
|
---|
464 | return file->lastSST() != NULL;
|
---|
465 | case sstStarCnt:
|
---|
466 | case sstStarZ:
|
---|
467 | case sstStarF:
|
---|
468 | case sstStarT:{
|
---|
469 | if (file->lastSST() == NULL) return false;
|
---|
470 | int n = file->getNumbStar(imes);
|
---|
471 | return (n > 0 && index < n);
|
---|
472 | }
|
---|
473 | case gyroRaw:
|
---|
474 | case gyroTens:
|
---|
475 | case gyroSpeed:
|
---|
476 | return (file->lastGyro() != NULL);
|
---|
477 | case gpsTime:
|
---|
478 | return file->hasGPSTime();
|
---|
479 | case longitude:
|
---|
480 | case latitude:
|
---|
481 | return file->hasGPSPos();
|
---|
482 | case altitude:
|
---|
483 | return file->hasGPSAlt();
|
---|
484 | case tsid:
|
---|
485 | return file->hasGPSPos();
|
---|
486 | case azimut:
|
---|
487 | case alphaAxis:
|
---|
488 | case deltaAxis:
|
---|
489 | return true;
|
---|
490 | //return (file->lastGPS() != NULL && file->lastSST() != NULL);
|
---|
491 | case alphaSst:
|
---|
492 | case deltaSst:
|
---|
493 | case alphaBolo:
|
---|
494 | case deltaBolo:
|
---|
495 | return false;
|
---|
496 |
|
---|
497 | case boloTemp:
|
---|
498 | return false;
|
---|
499 | }
|
---|
500 | return false;
|
---|
501 | }
|
---|
502 |
|
---|
503 |
|
---|
504 | double TOIIter::getValue(int column) {
|
---|
505 | if (!initDone) Init();
|
---|
506 | if (column < 0 || column >= infos.size()) return -1;
|
---|
507 | TOIKind kind = infos[column].kind;
|
---|
508 | if (auxGPS &&
|
---|
509 | (kind == longitude || kind == latitude || kind == altitude || kind == tsid)) {
|
---|
510 | double lat,lon,alt;
|
---|
511 | if (auxGPS->getLocation(getMJD(), lat, lon, alt)) return -99999;
|
---|
512 | if (kind == longitude) return lon;
|
---|
513 | if (kind == latitude) return lat;
|
---|
514 | if (kind == altitude) return alt;
|
---|
515 | if (kind == tsid) {
|
---|
516 | tSid.setLongitude(lon);
|
---|
517 | return tSid.getLST(getMJD());
|
---|
518 | }
|
---|
519 | }
|
---|
520 | if (rawIter) {
|
---|
521 | if (infos[column].interpolated)
|
---|
522 | return interp[column].getIValue(lastSample);
|
---|
523 | else
|
---|
524 | return interp[column].getEValue(lastSample);
|
---|
525 | }
|
---|
526 | int index = infos[column].index;
|
---|
527 | switch (kind) {
|
---|
528 | case sampleNum:
|
---|
529 | return getSampleIndex();
|
---|
530 | case internalTime:
|
---|
531 | return getSampleIndex() * archParam.acq.perEch;
|
---|
532 | case mjd:
|
---|
533 | return getMJD();
|
---|
534 | case boloTens:
|
---|
535 | return file->getMuVBolo(index, imes);
|
---|
536 | case boloTens2:
|
---|
537 | return file->getMuVBolo2(index, imes);
|
---|
538 | case boloRaw:
|
---|
539 | return file->getRawBolo(index, imes);
|
---|
540 | case boloRawCN:
|
---|
541 | return file->getRawBoloCN(index, imes);
|
---|
542 | case boloTensCN:
|
---|
543 | return file->getMuVBoloCN(index, imes);
|
---|
544 | case boloGainAmpli:
|
---|
545 | return file->getGainAmpli(index);
|
---|
546 | case boloDACV:
|
---|
547 | return file->getDACV(index);
|
---|
548 | case boloDACI:
|
---|
549 | return file->getDACI(index);
|
---|
550 | case boloTens2T:
|
---|
551 | return file->getMuVBolo2T(index, imes);
|
---|
552 | case boloRes:
|
---|
553 | return file->getBoloRes(index, imes);
|
---|
554 | case dilDAC:
|
---|
555 | return file->getADCDil(index);
|
---|
556 | case dilSwitch:
|
---|
557 | return file->getSwitchDil();
|
---|
558 | case sstDiode:
|
---|
559 | return file->getSSTSignal(index, imes);
|
---|
560 | case sstChannel:
|
---|
561 | return file->getSSTRawSignal(index, imes);
|
---|
562 | case sstDiodeCN:
|
---|
563 | return file->getSSTSignalCN(index, imes);
|
---|
564 | case sstChannelCN:
|
---|
565 | return file->getSSTRawSignalCN(index, imes);
|
---|
566 | case sstStarCnt:
|
---|
567 | return file->getNumbStar(imes);
|
---|
568 | case sstStarZ:
|
---|
569 | return file->getSSTStarZ(index, imes);
|
---|
570 | case sstStarF:
|
---|
571 | return file->getSSTStarF(index, imes);
|
---|
572 | case sstStarT:
|
---|
573 | return file->getSSTStarT(index, imes);
|
---|
574 | case gyroRaw:
|
---|
575 | return file->getGyroRaw(index, imes);
|
---|
576 | case gyroTens:
|
---|
577 | return file->getGyroTens(index, imes);
|
---|
578 | case gyroSpeed:
|
---|
579 | return file->getGyroSpeed(index, imes);
|
---|
580 | case gpsTime:
|
---|
581 | return file->getGPSUTC();
|
---|
582 | case longitude:
|
---|
583 | return file->getGPSLong();
|
---|
584 | case latitude:
|
---|
585 | return file->getGPSLat();
|
---|
586 | case altitude:
|
---|
587 | return file->getGPSAlt();
|
---|
588 | case tsid:
|
---|
589 | tSid.setLongitude(file->getGPSLong());
|
---|
590 | return tSid.getLST(getMJD());
|
---|
591 | case azimut:
|
---|
592 | case alphaAxis:
|
---|
593 | case deltaAxis: {
|
---|
594 | double lat, lon;
|
---|
595 | if (auxGPS) {
|
---|
596 | double alti;
|
---|
597 | auxGPS->getLocation(getMJD(), lat, lon, alti);
|
---|
598 | } else {
|
---|
599 | lon = file->getGPSLong();
|
---|
600 | lat = file->getGPSLat();
|
---|
601 | }
|
---|
602 | tSid.setLongitude(lon);
|
---|
603 | double ts = tSid.getLST(getMJD());
|
---|
604 | tempLocator.setEarthPos(lon, lat);
|
---|
605 | tempLocator.setTSid(ts);
|
---|
606 | if ((kind) == alphaAxis) return tempLocator.getAlphaZenith();
|
---|
607 | if ((kind) == deltaAxis) return tempLocator.getDeltaZenith();
|
---|
608 | return 0;
|
---|
609 | }
|
---|
610 | }
|
---|
611 | return -1;
|
---|
612 | }
|
---|
613 |
|
---|
614 | bool TOIIter::newValue(int column) {
|
---|
615 | if (!initDone) Init();
|
---|
616 | if (column < 0 || column >= infos.size()) return false;
|
---|
617 | TOIKind kind = infos[column].kind;
|
---|
618 | if (auxGPS &&
|
---|
619 | (kind == longitude || kind == latitude || kind == altitude)) {
|
---|
620 | return true;
|
---|
621 | }
|
---|
622 | if (rawIter) {
|
---|
623 | return interp[column].isNewValue(lastSample);
|
---|
624 | }
|
---|
625 | switch (kind) {
|
---|
626 | case sampleNum:
|
---|
627 | case internalTime:
|
---|
628 | case mjd:
|
---|
629 | case tsid:
|
---|
630 | return true;
|
---|
631 | case boloTens:
|
---|
632 | case boloTens2:
|
---|
633 | case boloTens2T:
|
---|
634 | case boloRes:
|
---|
635 | return file->blockNum() == file->getBoloBlockNum();
|
---|
636 | case boloRaw:
|
---|
637 | case boloRawCN:
|
---|
638 | case boloTensCN:
|
---|
639 | return file->blockNum() == file->getBoloBlockNum();
|
---|
640 | case boloGainAmpli:
|
---|
641 | return file->blockNum() == file->getReglageBlockNum() && imes==0;
|
---|
642 | case boloDACI:
|
---|
643 | case boloDACV:
|
---|
644 | return file->blockNum() == file->getReglageBlockNum() && imes==0;
|
---|
645 | case dilDAC:
|
---|
646 | case dilSwitch:
|
---|
647 | return file->blockNum() == file->getDilutionBlockNum() && imes==0;
|
---|
648 | case sstChannel:
|
---|
649 | case sstDiode:
|
---|
650 | case sstStarCnt:
|
---|
651 | case sstStarZ:
|
---|
652 | case sstStarF:
|
---|
653 | case sstStarT:
|
---|
654 | return file->blockNum() == file->getSSTBlockNum();
|
---|
655 | case sstChannelCN:
|
---|
656 | case sstDiodeCN:
|
---|
657 | return file->blockNum() == file->getSSTCompBlockNum();
|
---|
658 | case gyroRaw:
|
---|
659 | case gyroTens:
|
---|
660 | case gyroSpeed:
|
---|
661 | return file->blockNum() == file->getGyroBlockNum();
|
---|
662 | case gpsTime:
|
---|
663 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
664 | case longitude:
|
---|
665 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
666 | case latitude:
|
---|
667 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
668 | case altitude:
|
---|
669 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
670 | case azimut:
|
---|
671 | return true; // $CHECK$ with SSTHandler
|
---|
672 | case alphaAxis:
|
---|
673 | return true; // $CHECK$ with SSTHandler
|
---|
674 | case deltaAxis:
|
---|
675 | return true; // $CHECK$ with SSTHandler
|
---|
676 | }
|
---|
677 | return false;
|
---|
678 | }
|
---|
679 |
|
---|
680 | bool TOIIter::extendValue(int column) {
|
---|
681 | return (!infos[column].interpolated && !newValue(column));
|
---|
682 | }
|
---|
683 |
|
---|
684 | bool TOIIter::interpValue(int column) {
|
---|
685 | return (infos[column].interpolated && !newValue(column));
|
---|
686 | }
|
---|
687 |
|
---|
688 | bool TOIIter::isTrig(int column) {
|
---|
689 | if (column < 0 || column >= infos.size()) return false;
|
---|
690 | return infos[column].triggering;
|
---|
691 | }
|
---|
692 |
|
---|
693 |
|
---|
694 | TOIKind TOIIter::getKind(int column) {
|
---|
695 | if (column < 0 || column >= infos.size()) return (TOIKind)-1;
|
---|
696 | return infos[column].kind;
|
---|
697 | }
|
---|
698 |
|
---|
699 | int TOIIter::getIndex(int column) {
|
---|
700 | if (column < 0 || column >= infos.size()) return (TOIKind)-1;
|
---|
701 | return infos[column].index;
|
---|
702 | }
|
---|
703 |
|
---|
704 | int TOIIter::getColTOI(TOIKind kind, int index) {
|
---|
705 | for (int i=0; i<infos.size(); i++)
|
---|
706 | if (infos[i].kind == kind && infos[i].index == index)
|
---|
707 | return i;
|
---|
708 | return -1;
|
---|
709 | }
|
---|
710 |
|
---|
711 | bool TOIIter::canGetTOI(TOIKind kind, int index) {
|
---|
712 | int col = getColTOI(kind, index);
|
---|
713 | if (col<0) return false;
|
---|
714 | return canGetValue(col);
|
---|
715 | }
|
---|
716 |
|
---|
717 | double TOIIter::getTOI(TOIKind kind, int index) {
|
---|
718 | int col = getColTOI(kind, index);
|
---|
719 | if (col<0) return -9.e99;
|
---|
720 | return getValue(col);
|
---|
721 | }
|
---|
722 |
|
---|
723 |
|
---|
724 | int TOIIter::getBlockSampleIndex() {
|
---|
725 | return imes;
|
---|
726 | }
|
---|
727 |
|
---|
728 | int TOIIter::getSampleIndex() {
|
---|
729 | if (!initDone) Init();
|
---|
730 | if (file) {
|
---|
731 | return file->blockNum() * file->nEchBlock() + imes;
|
---|
732 | } else {
|
---|
733 | return lastSample;
|
---|
734 | }
|
---|
735 | }
|
---|
736 |
|
---|
737 | double TOIIter::getMJD() {
|
---|
738 | if (!initDone) Init();
|
---|
739 | int sample = getSampleIndex();
|
---|
740 | return archParam.acq.tBlock0 + sample*archParam.acq.perEch/86400.;
|
---|
741 | }
|
---|
742 |
|
---|
743 | bool TOIIter::fetchAhead() { // Seulement si delegation
|
---|
744 | if (!rawIter) return false;
|
---|
745 | if (!rawIter->Next()) return false;
|
---|
746 | long sample = rawIter->getSampleIndex();
|
---|
747 | for (int i=0; i<infos.size(); i++) {
|
---|
748 | if (rawIter->canGetValue(i) && rawIter->newValue(i)) {
|
---|
749 | interp[i].enterValue(rawIter->getValue(i), sample);
|
---|
750 | }
|
---|
751 | }
|
---|
752 | return true;
|
---|
753 | }
|
---|
754 |
|
---|
755 | block_type_param* TOIIter::lastParam() {
|
---|
756 | if (!initDone) Init();
|
---|
757 | if (file) return file->lastParam();
|
---|
758 | else return rawIter->lastParam();
|
---|
759 | }
|
---|
760 |
|
---|
761 |
|
---|