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

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

vendredi soir...

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