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
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>
[419]18#include "templocator.h"
[310]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
[342]30 files.clear();
31
32 isOnBoardRecorder = false;
33
34 imes=0;
35
[310]36 tStart = -9.e99;
[342]37 tEnd = 9.e99;
[432]38 utcStart = -9.e99;
39 utcEnd = 9.e99;
[310]40
[432]41 sStart = -999999999;
42 sEnd = 999999999;
43
[394]44 //tBlock0 = -1;
45 // perEch = -1;
[350]46 // Values for Trapani 99 = default values
[394]47 //tBlock0 = 1376.8358818;
48 //perEch = 0.005836818076;
[315]49
[342]50 trigMask = 0;
[315]51 rawIter = NULL;
52 interp = NULL;
53 lastSample = -1;
[342]54 maxLookAhead = 10000;
[358]55
56 auxGPS = NULL;
[393]57
58 initDone = false;
[426]59
60 underSample = 1;
[310]61}
62
63TOIIter::TOIIter(TOIIter const& x) {
64 directory = x.directory;
65 files = x.files;
[401]66 if (x.initDone && x.curFile != x.files.end()) curFile = files.find(*(x.curFile));
[342]67 isOnBoardRecorder = x.isOnBoardRecorder;
[432]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
[310]77 trigMask = x.trigMask;
78 infos = x.infos;
79
[315]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;
[358]97
98 auxGPS = x.auxGPS;
99 if (auxGPS) auxGPS = auxGPS->clone();
[393]100
101 initDone = x.initDone;
[426]102 underSample = x.underSample;
[310]103}
104
105TOIIter::~TOIIter() {
106 delete file;
[315]107 delete rawIter;
108 delete[] interp;
[358]109 delete auxGPS;
[310]110}
111
[342]112#ifdef __MWERKS__
113#define filesep ':'
114#else
115#define filesep '/'
116#endif
117
[310]118void TOIIter::Init() {
[393]119 if (initDone) return;
120 initDone = true;
[432]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 }
[350]129 // On a soit un repertoire, soit une liste de fichiers....
[310]130 if (directory == "") {
[350]131 if (files.empty()) { // Ni repertoire, ni fichiers
132 cerr << "toiiter : pas de repertoire, pas de fichiers" << endl;
133 exit(-1);
[342]134 } else {
[350]135 // On a deja une liste de fichiers
[342]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;
[310]144 DIR* dir = opendir(directory.c_str());
145 struct dirent* ent;
146 while ((ent = readdir(dir)) != NULL) {
[342]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) {
[350]170 if (strncmp(ent->d_name, "ARK", 3) && strncmp(ent->d_name, "ark", 3)) continue;
[342]171 char * sfx = ent->d_name + strlen(ent->d_name) - 4;
[350]172 if (strcmp(sfx, ".DAT") && strcmp(sfx, ".dat")) continue;
[342]173 files.insert(directory + ent->d_name);
174 }
175 }
[310]176 }
177 closedir(dir);
178 }
[350]179
180 ScanFiles();
181
182 curFile = files.begin();
183 file = new ArcheopsFile((*curFile).c_str());
184 cout << "opening file " << (*curFile).c_str() << endl;
[310]185
[342]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
[350]190 double oldTStart = tStart;
191 tStart = -9.e99; // pour init, on accepte des blocs avant tstart....
192
[342]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 }
[310]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
[342]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.
[310]210
[394]211 if (archParam.acq.tBlock0 < 0) {
212 archParam.acq.tBlock0 = file->getStartMJD();
[315]213
[342]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();
[394]218 archParam.acq.tBlock0 = file->getGPSMJD() - dt/86400.;
[342]219 } else { // pas de bloc GPS...
[394]220 archParam.acq.tBlock0 = file->getStartMJD();
[342]221 }
222 file->popMark();
[310]223 }
[350]224 tStart = oldTStart; // on restaure
[342]225
[394]226 if (archParam.acq.perEch < 0)
227 archParam.acq.perEch = file->perEchant();
[315]228
229 bool hasInterp = false;
[310]230
231 trigMask = 0;
232 for (vector<info>::iterator i = infos.begin(); i != infos.end(); i++) {
[315]233 if ((*i).interpolated) hasInterp = true;
[310]234 if ((*i).triggering) {
235 switch ((*i).kind) {
[432]236 case boloMuV:
237 case boloMuV2:
238 case boloRawMuV:
239 case boloRawMuVCN:
[407]240 trigMask |= block_bolo_mask;
241 break;
[432]242 case boloMuV2T:
[410]243 case boloRes:
244 case boloTemp:
245 trigMask |= block_bolo_mask | block_reglage_mask;
246 break;
[432]247 case dilDAC:
[410]248 case dilSwitch:
249 trigMask |= block_dilution_mask;
[407]250 case boloGainAmpli:
[408]251 case boloDACV:
252 case boloDACI:
[407]253 trigMask |= block_reglage_mask;
254 break;
[400]255 case gpsTime:
256 case longitude:
257 case latitude:
258 case altitude:
[407]259 trigMask |= block_gps_mask;
260 break;
[432]261 case azimuthBolo:
[419]262 trigMask |= block_bolo_mask;
263 //file->needSSTProcessMask(SSTHandler::findPeriod);
264 //trigMask |= block_sst_mask;
[407]265 break;
[400]266 case sstStarCnt:
267 case sstStarZ:
268 case sstStarF:
269 case sstStarT:
[407]270 file->needSSTProcessMask(SSTHandler::findStars);
271 trigMask |= block_sst_mask;
272 break;
[400]273 case sstDiode:
[407]274 case sstDiodeCN:
275 file->needSSTProcessMask(SSTHandler::permDiode);
276 trigMask |= block_sst_mask;
277 break;
[400]278 case sstChannel:
[407]279 case sstChannelCN:
280 trigMask |= block_sst_mask;
281 break;
[400]282 case gyroRaw:
[432]283 case gyroV:
[407]284 trigMask |= block_gyro_mask;
285 break;
286 case gyroSpeed:
287 trigMask |= block_gyro_mask; // $CHECK$ + info to calibrate gyros
288 break;
[432]289 case alphaRotAxis:
290 case deltaRotAxis:
[407]291 case alphaSst:
292 case deltaSst:
[432]293 case alphaFPAxis:
294 case deltaFPAxis:
[400]295 case alphaBolo:
296 case deltaBolo:
[419]297 trigMask |= block_bolo_mask;
298 //file->needSSTProcessMask(SSTHandler::findAxis);
299 //trigMask |= block_sst_mask;
[407]300 break;
[432]301 case alphaZenith:
302 case deltaZenith:
303 trigMask |= block_gps_mask;
304 break;
[310]305 }
306 }
307 }
308
309 if (trigMask & (block_bolo_mask | block_sst_mask)) {
310 imes = 9999;
311 } else {
312 imes = 0;
313 }
[315]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 }
[310]323}
324
[350]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];
[394]348 double t = archParam.acq.tBlock0 + smp * archParam.acq.perEch/86400.;
[432]349 if (t>tEnd || smp>sEnd) { // premier echantillon apres tEnd
[350]350 files.erase(*i);
351 prev = "";
352 continue;
353 }
[432]354 if (t<tStart || smp<sStart) { // premier echantillon avant tStart -> on vire le precedent si existe
[350]355 if (prev != "") {
356 files.erase(prev);
357 }
358 }
359 prev = *i;
360 }
361}
362
[310]363bool TOIIter::NextFile() {
[315]364 if (rawIter)
365 return rawIter->NextFile();
366
[342]367 if (files.empty()) {
[310]368 return false;
369 } else {
370 if (curFile == files.end()) return false;
371 curFile++;
372 if (curFile == files.end()) return false;
[342]373 cout << "opening file " << (*curFile).c_str() << endl;
[310]374 ArcheopsFile* newfile = new ArcheopsFile((*curFile).c_str());
375 newfile->grabLastBlocs(*file);
376 delete file;
377 file = newfile;
378 return true;
379 }
380}
381
[426]382bool TOIIter::Next() {
383 for (int ii=0; ii<underSample; ii++)
384 if (!Next1()) return false;
385 return true;
386}
[350]387
[426]388bool TOIIter::Next1() {
[393]389 if (!initDone) Init();
[350]390 while (1) {
391 if (!NextSample()) return false; // end of files
[358]392 double t = getMJD();
[350]393 if (t < tStart) continue;
394 if (t > tEnd) return false;
395 return true;
396 }
397}
398
399bool TOIIter::NextSample() {
[315]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 }
[310]427
[406]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 )) {
[310]430 imes++;
431 if (imes < file->nEchBlock()) return true;
432 imes = 0;
433 }
434
435 // soit pas d'info indexee, soit fin bloc courant...
[315]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 ?
[393]440 if (NextFile()) file->nextBlock(); // fichier suivant
441 else return false; // tout fini
[315]442 }
443 }
444 return true;
445 }
446 if (!NextFile()) return false;
[310]447 }
448}
449
[315]450/* double TOIIter::getTime() { // MJD
[310]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 }
[315]455 */
[310]456
[315]457bool TOIIter::canGetValue(int column) {
[393]458 if (!initDone) Init();
[315]459 if (column < 0 || column >= infos.size()) return false;
[358]460 TOIKind kind = infos[column].kind;
461 if (auxGPS &&
[432]462 (kind == longitude || kind == latitude || kind == altitude || kind == tsid ||
463 kind == alphaZenith || kind == deltaZenith)) {
[358]464 double dummy;
465 return auxGPS->getLocation(getMJD(), dummy, dummy, dummy) == 0;
466 }
[315]467 if (rawIter) {
468 return interp[column].canGet(lastSample);
469 }
470 int index = infos[column].index;
471 switch (kind) {
[400]472 case sampleNum:
473 case internalTime:
474 case mjd:
[432]475 case mutc:
[400]476 return true;
[432]477 case boloMuV:
478 case boloMuV2:
479 case boloMuV2T:
[407]480 case boloRes:
[432]481 case boloRawMuVCN:
[400]482 if (imes==0 && file->llastBolo()==NULL) return false;
483 return file->lastBolo() != NULL;
[432]484 case boloRawMuV:
[400]485 return file->lastBolo() != NULL;
[407]486 case boloGainAmpli:
[408]487 case boloDACV:
488 case boloDACI:
[407]489 return file->lastReglage() != NULL;
[410]490 case dilDAC:
491 case dilSwitch:
492 return file->lastDilution() != NULL;
[400]493 case sstDiode:
494 case sstChannel:
[407]495 case sstDiodeCN:
496 case sstChannelCN:
[400]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);
[315]505 }
[400]506 case gyroRaw:
[432]507 case gyroV:
[407]508 case gyroSpeed:
[400]509 return (file->lastGyro() != NULL);
510 case gpsTime:
511 return file->hasGPSTime();
512 case longitude:
513 case latitude:
[432]514 case alphaZenith:
515 case deltaZenith:
[400]516 return file->hasGPSPos();
517 case altitude:
518 return file->hasGPSAlt();
519 case tsid:
520 return file->hasGPSPos();
[432]521 case azimuthBolo:
522 case alphaRotAxis:
523 case deltaRotAxis:
524 case alphaFPAxis:
525 case deltaFPAxis:
[426]526 case alphaBolo:
527 case deltaBolo:
[419]528 return true;
[400]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 }
[315]537 return false;
538}
[400]539
[407]540
[315]541double TOIIter::getValue(int column) {
[393]542 if (!initDone) Init();
[310]543 if (column < 0 || column >= infos.size()) return -1;
[358]544 TOIKind kind = infos[column].kind;
545 if (auxGPS &&
[363]546 (kind == longitude || kind == latitude || kind == altitude || kind == tsid)) {
[358]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;
[363]551 if (kind == altitude) return alt;
552 if (kind == tsid) {
553 tSid.setLongitude(lon);
554 return tSid.getLST(getMJD());
555 }
[432]556
[358]557 }
[315]558 if (rawIter) {
559 if (infos[column].interpolated)
560 return interp[column].getIValue(lastSample);
561 else
562 return interp[column].getEValue(lastSample);
563 }
[310]564 int index = infos[column].index;
565 switch (kind) {
[400]566 case sampleNum:
567 return getSampleIndex();
568 case internalTime:
569 return getSampleIndex() * archParam.acq.perEch;
570 case mjd:
571 return getMJD();
[432]572 case mutc:
573 return (getMJD()-archParam.acq.utcOrigin)*24.;
574 case boloMuV:
[400]575 return file->getMuVBolo(index, imes);
[432]576 case boloMuV2:
[408]577 return file->getMuVBolo2(index, imes);
[432]578 case boloRawMuV:
[400]579 return file->getRawBolo(index, imes);
[432]580 case boloRawMuVCN:
[416]581 return file->getMuVBoloCN(index, imes);
[407]582 case boloGainAmpli:
583 return file->getGainAmpli(index);
[408]584 case boloDACV:
585 return file->getDACV(index);
586 case boloDACI:
587 return file->getDACI(index);
[432]588 case boloMuV2T:
[410]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();
[400]596 case sstDiode:
597 return file->getSSTSignal(index, imes);
598 case sstChannel:
599 return file->getSSTRawSignal(index, imes);
[411]600 case sstDiodeCN:
601 return file->getSSTSignalCN(index, imes);
602 case sstChannelCN:
603 return file->getSSTRawSignalCN(index, imes);
[400]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:
[407]613 return file->getGyroRaw(index, imes);
[432]614 case gyroV:
[407]615 return file->getGyroTens(index, imes);
616 case gyroSpeed:
617 return file->getGyroSpeed(index, imes);
[400]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());
[432]629 case azimuthBolo:
630 case alphaRotAxis:
631 case deltaRotAxis:
632 case alphaFPAxis:
633 case deltaFPAxis:
634 case alphaZenith:
635 case deltaZenith:
[426]636 case alphaBolo:
637 case deltaBolo: {
[419]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);
[432]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);
[426]655 if ((kind) == alphaBolo) return tempLocator.getAlphaBolo(getSampleIndex(),index);
656 if ((kind) == deltaBolo) return tempLocator.getDeltaBolo(getSampleIndex(),index);
[432]657 if ((kind) == alphaFPAxis) return tempLocator.getAlphaCenter(getSampleIndex());
658 if ((kind) == deltaFPAxis) return tempLocator.getDeltaCenter(getSampleIndex());
[419]659 return 0;
660 }
[310]661 }
662 return -1;
[315]663}
[310]664
[315]665bool TOIIter::newValue(int column) {
[393]666 if (!initDone) Init();
[310]667 if (column < 0 || column >= infos.size()) return false;
[358]668 TOIKind kind = infos[column].kind;
669 if (auxGPS &&
670 (kind == longitude || kind == latitude || kind == altitude)) {
671 return true;
672 }
[342]673 if (rawIter) {
674 return interp[column].isNewValue(lastSample);
675 }
[310]676 switch (kind) {
[315]677 case sampleNum:
678 case internalTime:
[350]679 case mjd:
[432]680 case mutc:
[363]681 case tsid:
[315]682 return true;
[432]683 case boloMuV:
684 case boloMuV2:
685 case boloMuV2T:
[410]686 case boloRes:
[315]687 return file->blockNum() == file->getBoloBlockNum();
[432]688 case boloRawMuV:
689 case boloRawMuVCN:
[315]690 return file->blockNum() == file->getBoloBlockNum();
[407]691 case boloGainAmpli:
692 return file->blockNum() == file->getReglageBlockNum() && imes==0;
[408]693 case boloDACI:
694 case boloDACV:
695 return file->blockNum() == file->getReglageBlockNum() && imes==0;
[410]696 case dilDAC:
697 case dilSwitch:
698 return file->blockNum() == file->getDilutionBlockNum() && imes==0;
[350]699 case sstChannel:
700 case sstDiode:
[400]701 case sstStarCnt:
[342]702 case sstStarZ:
703 case sstStarF:
[394]704 case sstStarT:
[315]705 return file->blockNum() == file->getSSTBlockNum();
[413]706 case sstChannelCN:
707 case sstDiodeCN:
708 return file->blockNum() == file->getSSTCompBlockNum();
[342]709 case gyroRaw:
[432]710 case gyroV:
[407]711 case gyroSpeed:
[342]712 return file->blockNum() == file->getGyroBlockNum();
713 case gpsTime:
714 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[310]715 case longitude:
[315]716 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[310]717 case latitude:
[315]718 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[342]719 case altitude:
720 return file->blockNum() == file->getGPSBlockNum() && imes==0;
[432]721 case azimuthBolo:
[426]722 case alphaBolo:
723 case deltaBolo:
[432]724 case alphaZenith:
725 case deltaZenith:
726 case alphaFPAxis:
727 case deltaFPAxis:
[315]728 return true; // $CHECK$ with SSTHandler
[432]729 case alphaRotAxis:
[315]730 return true; // $CHECK$ with SSTHandler
[432]731 case deltaRotAxis:
[315]732 return true; // $CHECK$ with SSTHandler
[310]733 }
734 return false;
[315]735}
[310]736
[315]737bool TOIIter::extendValue(int column) {
738 return (!infos[column].interpolated && !newValue(column));
739}
[310]740
[315]741bool TOIIter::interpValue(int column) {
742 return (infos[column].interpolated && !newValue(column));
743}
[342]744
745bool TOIIter::isTrig(int column) {
746 if (column < 0 || column >= infos.size()) return false;
747 return infos[column].triggering;
748}
749
[310]750
[315]751TOIKind TOIIter::getKind(int column) {
[310]752 if (column < 0 || column >= infos.size()) return (TOIKind)-1;
753 return infos[column].kind;
[315]754}
[310]755
[315]756int TOIIter::getIndex(int column) {
[310]757 if (column < 0 || column >= infos.size()) return (TOIKind)-1;
758 return infos[column].index;
[315]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
[310]780
[315]781int TOIIter::getBlockSampleIndex() {
[310]782 return imes;
[315]783}
784
[426]785int TOIIter::getUnderSampling() {
786 return underSample;
787}
788
[315]789int TOIIter::getSampleIndex() {
[393]790 if (!initDone) Init();
[342]791 if (file) {
792 return file->blockNum() * file->nEchBlock() + imes;
793 } else {
794 return lastSample;
795 }
[315]796}
[358]797
798double TOIIter::getMJD() {
[393]799 if (!initDone) Init();
[358]800 int sample = getSampleIndex();
[394]801 return archParam.acq.tBlock0 + sample*archParam.acq.perEch/86400.;
[358]802}
[315]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++) {
[342]809 if (rawIter->canGetValue(i) && rawIter->newValue(i)) {
[315]810 interp[i].enterValue(rawIter->getValue(i), sample);
[342]811 }
[315]812 }
813 return true;
814}
815
[342]816block_type_param* TOIIter::lastParam() {
[393]817 if (!initDone) Init();
[342]818 if (file) return file->lastParam();
819 else return rawIter->lastParam();
820}
821
822
Note: See TracBrowser for help on using the repository browser.