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

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

nouvelles toi

File size: 20.0 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:
217 trigMask |= block_bolo_mask;
218 break;
[410]219 case boloTens2T:
220 case boloRes:
221 case boloTemp:
222 trigMask |= block_bolo_mask | block_reglage_mask;
223 break;
224 case dilDAC:
225 case dilSwitch:
226 trigMask |= block_dilution_mask;
[407]227 case boloGainAmpli:
[408]228 case boloDACV:
229 case boloDACI:
[407]230 trigMask |= block_reglage_mask;
231 break;
[400]232 case gpsTime:
233 case longitude:
234 case latitude:
235 case altitude:
[407]236 trigMask |= block_gps_mask;
237 break;
[400]238 case azimut:
[407]239 file->needSSTProcessMask(SSTHandler::findPeriod);
240 trigMask |= block_sst_mask;
241 break;
[400]242 case sstStarCnt:
243 case sstStarZ:
244 case sstStarF:
245 case sstStarT:
[407]246 file->needSSTProcessMask(SSTHandler::findStars);
247 trigMask |= block_sst_mask;
248 break;
[400]249 case sstDiode:
[407]250 case sstDiodeCN:
251 file->needSSTProcessMask(SSTHandler::permDiode);
252 trigMask |= block_sst_mask;
253 break;
[400]254 case sstChannel:
[407]255 case sstChannelCN:
256 trigMask |= block_sst_mask;
257 break;
[400]258 case gyroRaw:
[407]259 case gyroTens:
260 trigMask |= block_gyro_mask;
261 break;
262 case gyroSpeed:
263 trigMask |= block_gyro_mask; // $CHECK$ + info to calibrate gyros
264 break;
[400]265 case alphaAxis:
266 case deltaAxis:
[407]267 case alphaSst:
268 case deltaSst:
[400]269 case alphaBolo:
270 case deltaBolo:
[407]271 file->needSSTProcessMask(SSTHandler::findAxis);
272 trigMask |= block_sst_mask;
273 break;
[310]274 }
275 }
276 }
277
278 if (trigMask & (block_bolo_mask | block_sst_mask)) {
279 imes = 9999;
280 } else {
281 imes = 0;
282 }
[315]283
284 if (hasInterp) {
285 rawIter = new TOIIter(*this);
286 interp = new TOIInterpolator[infos.size()];
287 for (int i=0; i<infos.size(); i++) {
288 rawIter->infos[i].interpolated = false;
289 }
290 delete file; file = NULL; // on ne travaille plus sur le fichier directement...
291 }
[310]292}
293
[350]294void TOIIter::ScanFiles() {
295 file1stSamp.clear();
296 cout << "Scanning all files" << endl;
297 // Petite astuce pour les STL non conformes comme celles de digital
298 // qui ne supportent pas files.erase(i) suivi de i++....
299 set<string> copy = files;
300 for (set<string>::iterator i = copy.begin(); i != copy.end(); i++) {
301 ArcheopsFile fich((*i).c_str());
302 if (fich.nextBlock()) {
303 file1stSamp[*i] = fich.blockNum()*72; // premier numsample
304 cout << "File " << *i << " 1st sample = " << fich.blockNum()*72 << endl;
305 } else {
306 cout << "File " << *i << " unrecoverable, skipping" << endl;
307 files.erase(*i);
308 }
309 }
310 cout << "Scan done" << endl;
311
312 // Et maintenant, on ne garde que ceux qui tombent dans l'intervalle...
313 copy = files;
314 string prev="";
315 for (set<string>::iterator i = copy.begin(); i != copy.end(); i++) {
316 double smp = file1stSamp[*i];
[394]317 double t = archParam.acq.tBlock0 + smp * archParam.acq.perEch/86400.;
[350]318 if (t>tEnd) { // premier echantillon apres tEnd
319 files.erase(*i);
320 prev = "";
321 continue;
322 }
323 if (t<tStart) { // premier echantillon avant tStart -> on vire le precedent si existe
324 if (prev != "") {
325 files.erase(prev);
326 }
327 }
328 prev = *i;
329 }
330}
331
[310]332bool TOIIter::NextFile() {
[315]333 if (rawIter)
334 return rawIter->NextFile();
335
[342]336 if (files.empty()) {
[310]337 return false;
338 } else {
339 if (curFile == files.end()) return false;
340 curFile++;
341 if (curFile == files.end()) return false;
[342]342 cout << "opening file " << (*curFile).c_str() << endl;
[310]343 ArcheopsFile* newfile = new ArcheopsFile((*curFile).c_str());
344 newfile->grabLastBlocs(*file);
345 delete file;
346 file = newfile;
347 return true;
348 }
349}
350
[350]351
[310]352bool TOIIter::Next() {
[393]353 if (!initDone) Init();
[350]354 while (1) {
355 if (!NextSample()) return false; // end of files
[358]356 double t = getMJD();
[350]357 if (t < tStart) continue;
358 if (t > tEnd) return false;
359 return true;
360 }
361}
362
363bool TOIIter::NextSample() {
[315]364 if (rawIter) { // Delegation pour interpolation
365 // Trouve prochain sample disponible
366 for (int k=0; k<2; k++) {
367 long smp = 2147483647L;
368 for (int i=0; i<infos.size(); i++) {
369 long ss = interp[i].nextSample(lastSample+1);
370 if (ss > 0 && ss < smp) smp=ss;
371 }
372 if (smp != 2147483647L) {
373 lastSample = smp;
374 break;
375 }
376 if (!fetchAhead()) // tout le monde etait en bout de course,
377 return false; // on lit un echantillon, ca suffit, d'ou le k<2
378 }
379 // Verifie que tous les interpolateurs ont assez de donnees pour
380 // trouver la valeur correspondante
381 for (int i=0; i<infos.size(); i++) {
382 //rif (infos[i].interpolated)
383 while (interp[i].needMoreDataFor(lastSample) &&
384 rawIter->getSampleIndex() - lastSample < maxLookAhead)
385 if (!fetchAhead()) return false;
386 }
387
388 // On est pret...
389 return true;
390 }
[310]391
[406]392 // trigger sur info indexee dans bloc bolo, bloc gyro ou bloc sst ?
393 if (trigMask & (block_bolo_mask | block_sst_mask | block_gyro_mask )) {
[310]394 imes++;
395 if (imes < file->nEchBlock()) return true;
396 imes = 0;
397 }
398
399 // soit pas d'info indexee, soit fin bloc courant...
[315]400 while (1) {
401 if (file->nextBlock(trigMask)) {
402 while (file->sameBlockNumAhead()) { // tant que meme numero de bloc, on lit
403 if (!file->nextBlock()) { // fin de fichier ?
[393]404 if (NextFile()) file->nextBlock(); // fichier suivant
405 else return false; // tout fini
[315]406 }
407 }
408 return true;
409 }
410 if (!NextFile()) return false;
[310]411 }
412}
413
[315]414/* double TOIIter::getTime() { // MJD
[310]415 // le temps du bloc courant, en secondes
416 double dt = file->blockNum() * file->perBlock();
417 return tBlock0 + dt/86400. + imes*file->perEchant()/86400.;
418 }
[315]419 */
[310]420
[315]421bool TOIIter::canGetValue(int column) {
[393]422 if (!initDone) Init();
[315]423 if (column < 0 || column >= infos.size()) return false;
[358]424 TOIKind kind = infos[column].kind;
425 if (auxGPS &&
[363]426 (kind == longitude || kind == latitude || kind == altitude || kind == tsid)) {
[358]427 double dummy;
428 return auxGPS->getLocation(getMJD(), dummy, dummy, dummy) == 0;
429 }
[315]430 if (rawIter) {
431 return interp[column].canGet(lastSample);
432 }
433 int index = infos[column].index;
434 switch (kind) {
[400]435 case sampleNum:
436 case internalTime:
437 case mjd:
438 return true;
439 case boloTens:
[407]440 case boloTens2:
441 case boloTens2T:
442 case boloRes:
443 case boloRawCN:
[400]444 if (imes==0 && file->llastBolo()==NULL) return false;
445 return file->lastBolo() != NULL;
446 case boloRaw:
447 return file->lastBolo() != NULL;
[407]448 case boloGainAmpli:
[408]449 case boloDACV:
450 case boloDACI:
[407]451 return file->lastReglage() != NULL;
[410]452 case dilDAC:
453 case dilSwitch:
454 return file->lastDilution() != NULL;
[400]455 case sstDiode:
456 case sstChannel:
[407]457 case sstDiodeCN:
458 case sstChannelCN:
[400]459 return file->lastSST() != NULL;
460 case sstStarCnt:
461 case sstStarZ:
462 case sstStarF:
463 case sstStarT:{
464 if (file->lastSST() == NULL) return false;
465 int n = file->getNumbStar(imes);
466 return (n > 0 && index < n);
[315]467 }
[400]468 case gyroRaw:
[407]469 case gyroTens:
470 case gyroSpeed:
[400]471 return (file->lastGyro() != NULL);
472 case gpsTime:
473 return file->hasGPSTime();
474 case longitude:
475 case latitude:
476 return file->hasGPSPos();
477 case altitude:
478 return file->hasGPSAlt();
479 case tsid:
480 return file->hasGPSPos();
481 case azimut:
482 case alphaAxis:
483 case deltaAxis:
484 return false;
485 //return (file->lastGPS() != NULL && file->lastSST() != NULL);
486 case alphaSst:
487 case deltaSst:
488 case alphaBolo:
489 case deltaBolo:
490 return false;
491
492 case boloTemp:
493 return false;
494 }
[315]495 return false;
496}
[400]497
[407]498
[315]499double TOIIter::getValue(int column) {
[393]500 if (!initDone) Init();
[310]501 if (column < 0 || column >= infos.size()) return -1;
[358]502 TOIKind kind = infos[column].kind;
503 if (auxGPS &&
[363]504 (kind == longitude || kind == latitude || kind == altitude || kind == tsid)) {
[358]505 double lat,lon,alt;
506 if (auxGPS->getLocation(getMJD(), lat, lon, alt)) return -99999;
507 if (kind == longitude) return lon;
508 if (kind == latitude) return lat;
[363]509 if (kind == altitude) return alt;
510 if (kind == tsid) {
511 tSid.setLongitude(lon);
512 return tSid.getLST(getMJD());
513 }
[358]514 }
[315]515 if (rawIter) {
516 if (infos[column].interpolated)
517 return interp[column].getIValue(lastSample);
518 else
519 return interp[column].getEValue(lastSample);
520 }
[310]521 int index = infos[column].index;
522 switch (kind) {
[400]523 case sampleNum:
524 return getSampleIndex();
525 case internalTime:
526 return getSampleIndex() * archParam.acq.perEch;
527 case mjd:
528 return getMJD();
529 case boloTens:
530 return file->getMuVBolo(index, imes);
[408]531 case boloTens2:
532 return file->getMuVBolo2(index, imes);
[400]533 case boloRaw:
534 return file->getRawBolo(index, imes);
[407]535 case boloGainAmpli:
536 return file->getGainAmpli(index);
[408]537 case boloDACV:
538 return file->getDACV(index);
539 case boloDACI:
540 return file->getDACI(index);
[410]541 case boloTens2T:
542 return file->getMuVBolo2T(index, imes);
543 case boloRes:
544 return file->getBoloRes(index, imes);
545 case dilDAC:
546 return file->getADCDil(index);
547 case dilSwitch:
548 return file->getSwitchDil();
[400]549 case sstDiode:
550 return file->getSSTSignal(index, imes);
551 case sstChannel:
552 return file->getSSTRawSignal(index, imes);
[411]553 case sstDiodeCN:
554 return file->getSSTSignalCN(index, imes);
555 case sstChannelCN:
556 return file->getSSTRawSignalCN(index, imes);
[400]557 case sstStarCnt:
558 return file->getNumbStar(imes);
559 case sstStarZ:
560 return file->getSSTStarZ(index, imes);
561 case sstStarF:
562 return file->getSSTStarF(index, imes);
563 case sstStarT:
564 return file->getSSTStarT(index, imes);
565 case gyroRaw:
[407]566 return file->getGyroRaw(index, imes);
567 case gyroTens:
568 return file->getGyroTens(index, imes);
569 case gyroSpeed:
570 return file->getGyroSpeed(index, imes);
[400]571 case gpsTime:
572 return file->getGPSUTC();
573 case longitude:
574 return file->getGPSLong();
575 case latitude:
576 return file->getGPSLat();
577 case altitude:
578 return file->getGPSAlt();
579 case tsid:
580 tSid.setLongitude(file->getGPSLong());
581 return tSid.getLST(getMJD());
582 case azimut:
583 return file->getAzimut(imes);
584 case alphaAxis:
585 return file->getAlpha(imes);
586 case deltaAxis:
587 return file->getDelta(imes);
[310]588 }
589 return -1;
[315]590}
[310]591
[315]592bool TOIIter::newValue(int column) {
[393]593 if (!initDone) Init();
[310]594 if (column < 0 || column >= infos.size()) return false;
[358]595 TOIKind kind = infos[column].kind;
596 if (auxGPS &&
597 (kind == longitude || kind == latitude || kind == altitude)) {
598 return true;
599 }
[342]600 if (rawIter) {
601 return interp[column].isNewValue(lastSample);
602 }
[310]603 switch (kind) {
[315]604 case sampleNum:
605 case internalTime:
[350]606 case mjd:
[363]607 case tsid:
[315]608 return true;
[310]609 case boloTens:
[408]610 case boloTens2:
[410]611 case boloTens2T:
612 case boloRes:
[315]613 return file->blockNum() == file->getBoloBlockNum();
[310]614 case boloRaw:
[315]615 return file->blockNum() == file->getBoloBlockNum();
[407]616 case boloGainAmpli:
617 return file->blockNum() == file->getReglageBlockNum() && imes==0;
[408]618 case boloDACI:
619 case boloDACV:
620 return file->blockNum() == file->getReglageBlockNum() && imes==0;
[410]621 case dilDAC:
622 case dilSwitch:
623 return file->blockNum() == file->getDilutionBlockNum() && imes==0;
[350]624 case sstChannel:
625 case sstDiode:
[400]626 case sstStarCnt:
[342]627 case sstStarZ:
628 case sstStarF:
[394]629 case sstStarT:
[315]630 return file->blockNum() == file->getSSTBlockNum();
[342]631 case gyroRaw:
[407]632 case gyroTens:
633 case gyroSpeed:
[342]634 return file->blockNum() == file->getGyroBlockNum();
635 case gpsTime:
636 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[310]637 case longitude:
[315]638 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[310]639 case latitude:
[315]640 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[342]641 case altitude:
642 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[315]643 case azimut:
644 return true; // $CHECK$ with SSTHandler
645 case alphaAxis:
646 return true; // $CHECK$ with SSTHandler
647 case deltaAxis:
648 return true; // $CHECK$ with SSTHandler
[310]649 }
650 return false;
[315]651}
[310]652
[315]653bool TOIIter::extendValue(int column) {
654 return (!infos[column].interpolated && !newValue(column));
655}
[310]656
[315]657bool TOIIter::interpValue(int column) {
658 return (infos[column].interpolated && !newValue(column));
659}
[342]660
661bool TOIIter::isTrig(int column) {
662 if (column < 0 || column >= infos.size()) return false;
663 return infos[column].triggering;
664}
665
[310]666
[315]667TOIKind TOIIter::getKind(int column) {
[310]668 if (column < 0 || column >= infos.size()) return (TOIKind)-1;
669 return infos[column].kind;
[315]670}
[310]671
[315]672int TOIIter::getIndex(int column) {
[310]673 if (column < 0 || column >= infos.size()) return (TOIKind)-1;
674 return infos[column].index;
[315]675}
676
677int TOIIter::getColTOI(TOIKind kind, int index) {
678 for (int i=0; i<infos.size(); i++)
679 if (infos[i].kind == kind && infos[i].index == index)
680 return i;
681 return -1;
682}
683
684bool TOIIter::canGetTOI(TOIKind kind, int index) {
685 int col = getColTOI(kind, index);
686 if (col<0) return false;
687 return canGetValue(col);
688}
689
690double TOIIter::getTOI(TOIKind kind, int index) {
691 int col = getColTOI(kind, index);
692 if (col<0) return -9.e99;
693 return getValue(col);
694}
695
[310]696
[315]697int TOIIter::getBlockSampleIndex() {
[310]698 return imes;
[315]699}
700
701int TOIIter::getSampleIndex() {
[393]702 if (!initDone) Init();
[342]703 if (file) {
704 return file->blockNum() * file->nEchBlock() + imes;
705 } else {
706 return lastSample;
707 }
[315]708}
[358]709
710double TOIIter::getMJD() {
[393]711 if (!initDone) Init();
[358]712 int sample = getSampleIndex();
[394]713 return archParam.acq.tBlock0 + sample*archParam.acq.perEch/86400.;
[358]714}
[315]715
716bool TOIIter::fetchAhead() { // Seulement si delegation
717 if (!rawIter) return false;
718 if (!rawIter->Next()) return false;
719 long sample = rawIter->getSampleIndex();
720 for (int i=0; i<infos.size(); i++) {
[342]721 if (rawIter->canGetValue(i) && rawIter->newValue(i)) {
[315]722 interp[i].enterValue(rawIter->getValue(i), sample);
[342]723 }
[315]724 }
725 return true;
726}
727
[342]728block_type_param* TOIIter::lastParam() {
[393]729 if (!initDone) Init();
[342]730 if (file) return file->lastParam();
731 else return rawIter->lastParam();
732}
733
734
Note: See TracBrowser for help on using the repository browser.