source: Sophya/trunk/Poubelle/archTOI.old/toiiter.cc@ 433

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

en cours

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