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

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

nouvelles toi

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