1 | // toiiter.cc
|
---|
2 | // Eric Aubourg CEA/DAPNIA/SPP juillet 1999
|
---|
3 |
|
---|
4 | #ifndef nb_max_bolo
|
---|
5 | #define _archeops // Acquisition Archeops (avec transputer)
|
---|
6 | #define programme
|
---|
7 | extern "C" {
|
---|
8 | #include "archeops.h"
|
---|
9 | }
|
---|
10 | #endif
|
---|
11 |
|
---|
12 |
|
---|
13 | #include "toiiter.h"
|
---|
14 | #include "toiinterpolator.h"
|
---|
15 | #include "archparam.h"
|
---|
16 | #include <dirent.h>
|
---|
17 | #include <iostream.h>
|
---|
18 |
|
---|
19 | // Format bloc GPS
|
---|
20 | // $GPGGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z,
|
---|
21 |
|
---|
22 | TOIIter::TOIIter() {
|
---|
23 | // Toutes les valeurs initialisees par defaut. Le TOISvr les positionnera,
|
---|
24 | // puis lancera l'initialisation
|
---|
25 |
|
---|
26 | file = NULL;
|
---|
27 | directory = "";
|
---|
28 |
|
---|
29 | files.clear();
|
---|
30 |
|
---|
31 | isOnBoardRecorder = false;
|
---|
32 |
|
---|
33 | imes=0;
|
---|
34 |
|
---|
35 | tStart = -9.e99;
|
---|
36 | tEnd = 9.e99;
|
---|
37 |
|
---|
38 | //tBlock0 = -1;
|
---|
39 | // perEch = -1;
|
---|
40 | // Values for Trapani 99 = default values
|
---|
41 | //tBlock0 = 1376.8358818;
|
---|
42 | //perEch = 0.005836818076;
|
---|
43 |
|
---|
44 | trigMask = 0;
|
---|
45 | rawIter = NULL;
|
---|
46 | interp = NULL;
|
---|
47 | lastSample = -1;
|
---|
48 | maxLookAhead = 10000;
|
---|
49 |
|
---|
50 | auxGPS = NULL;
|
---|
51 |
|
---|
52 | initDone = false;
|
---|
53 | }
|
---|
54 |
|
---|
55 | TOIIter::TOIIter(TOIIter const& x) {
|
---|
56 | directory = x.directory;
|
---|
57 | files = x.files;
|
---|
58 | if (x.initDone && x.curFile != x.files.end()) curFile = files.find(*(x.curFile));
|
---|
59 | isOnBoardRecorder = x.isOnBoardRecorder;
|
---|
60 | imes = x.imes;
|
---|
61 | tStart = x.tStart;
|
---|
62 | tEnd = x.tEnd;
|
---|
63 | trigMask = x.trigMask;
|
---|
64 | infos = x.infos;
|
---|
65 |
|
---|
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;
|
---|
83 |
|
---|
84 | auxGPS = x.auxGPS;
|
---|
85 | if (auxGPS) auxGPS = auxGPS->clone();
|
---|
86 |
|
---|
87 | initDone = x.initDone;
|
---|
88 | }
|
---|
89 |
|
---|
90 | TOIIter::~TOIIter() {
|
---|
91 | delete file;
|
---|
92 | delete rawIter;
|
---|
93 | delete[] interp;
|
---|
94 | delete auxGPS;
|
---|
95 | }
|
---|
96 |
|
---|
97 | #ifdef __MWERKS__
|
---|
98 | #define filesep ':'
|
---|
99 | #else
|
---|
100 | #define filesep '/'
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | void TOIIter::Init() {
|
---|
104 | if (initDone) return;
|
---|
105 | initDone = true;
|
---|
106 | // On a soit un repertoire, soit une liste de fichiers....
|
---|
107 | if (directory == "") {
|
---|
108 | if (files.empty()) { // Ni repertoire, ni fichiers
|
---|
109 | cerr << "toiiter : pas de repertoire, pas de fichiers" << endl;
|
---|
110 | exit(-1);
|
---|
111 | } else {
|
---|
112 | // On a deja une liste de fichiers
|
---|
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;
|
---|
121 | DIR* dir = opendir(directory.c_str());
|
---|
122 | struct dirent* ent;
|
---|
123 | while ((ent = readdir(dir)) != NULL) {
|
---|
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) {
|
---|
147 | if (strncmp(ent->d_name, "ARK", 3) && strncmp(ent->d_name, "ark", 3)) continue;
|
---|
148 | char * sfx = ent->d_name + strlen(ent->d_name) - 4;
|
---|
149 | if (strcmp(sfx, ".DAT") && strcmp(sfx, ".dat")) continue;
|
---|
150 | files.insert(directory + ent->d_name);
|
---|
151 | }
|
---|
152 | }
|
---|
153 | }
|
---|
154 | closedir(dir);
|
---|
155 | }
|
---|
156 |
|
---|
157 | ScanFiles();
|
---|
158 |
|
---|
159 | curFile = files.begin();
|
---|
160 | file = new ArcheopsFile((*curFile).c_str());
|
---|
161 | cout << "opening file " << (*curFile).c_str() << endl;
|
---|
162 |
|
---|
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
|
---|
167 | double oldTStart = tStart;
|
---|
168 | tStart = -9.e99; // pour init, on accepte des blocs avant tstart....
|
---|
169 |
|
---|
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 | }
|
---|
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
|
---|
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.
|
---|
187 |
|
---|
188 | if (archParam.acq.tBlock0 < 0) {
|
---|
189 | archParam.acq.tBlock0 = file->getStartMJD();
|
---|
190 |
|
---|
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();
|
---|
195 | archParam.acq.tBlock0 = file->getGPSMJD() - dt/86400.;
|
---|
196 | } else { // pas de bloc GPS...
|
---|
197 | archParam.acq.tBlock0 = file->getStartMJD();
|
---|
198 | }
|
---|
199 | file->popMark();
|
---|
200 | }
|
---|
201 | tStart = oldTStart; // on restaure
|
---|
202 |
|
---|
203 | if (archParam.acq.perEch < 0)
|
---|
204 | archParam.acq.perEch = file->perEchant();
|
---|
205 |
|
---|
206 | bool hasInterp = false;
|
---|
207 |
|
---|
208 | trigMask = 0;
|
---|
209 | for (vector<info>::iterator i = infos.begin(); i != infos.end(); i++) {
|
---|
210 | if ((*i).interpolated) hasInterp = true;
|
---|
211 | if ((*i).triggering) {
|
---|
212 | switch ((*i).kind) {
|
---|
213 | case boloTens:
|
---|
214 | case boloTens2:
|
---|
215 | case boloRaw:
|
---|
216 | case boloRawCN:
|
---|
217 | case boloTensCN:
|
---|
218 | trigMask |= block_bolo_mask;
|
---|
219 | break;
|
---|
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;
|
---|
228 | case boloGainAmpli:
|
---|
229 | case boloDACV:
|
---|
230 | case boloDACI:
|
---|
231 | trigMask |= block_reglage_mask;
|
---|
232 | break;
|
---|
233 | case gpsTime:
|
---|
234 | case longitude:
|
---|
235 | case latitude:
|
---|
236 | case altitude:
|
---|
237 | trigMask |= block_gps_mask;
|
---|
238 | break;
|
---|
239 | case azimut:
|
---|
240 | file->needSSTProcessMask(SSTHandler::findPeriod);
|
---|
241 | trigMask |= block_sst_mask;
|
---|
242 | break;
|
---|
243 | case sstStarCnt:
|
---|
244 | case sstStarZ:
|
---|
245 | case sstStarF:
|
---|
246 | case sstStarT:
|
---|
247 | file->needSSTProcessMask(SSTHandler::findStars);
|
---|
248 | trigMask |= block_sst_mask;
|
---|
249 | break;
|
---|
250 | case sstDiode:
|
---|
251 | case sstDiodeCN:
|
---|
252 | file->needSSTProcessMask(SSTHandler::permDiode);
|
---|
253 | trigMask |= block_sst_mask;
|
---|
254 | break;
|
---|
255 | case sstChannel:
|
---|
256 | case sstChannelCN:
|
---|
257 | trigMask |= block_sst_mask;
|
---|
258 | break;
|
---|
259 | case gyroRaw:
|
---|
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;
|
---|
266 | case alphaAxis:
|
---|
267 | case deltaAxis:
|
---|
268 | case alphaSst:
|
---|
269 | case deltaSst:
|
---|
270 | case alphaBolo:
|
---|
271 | case deltaBolo:
|
---|
272 | file->needSSTProcessMask(SSTHandler::findAxis);
|
---|
273 | trigMask |= block_sst_mask;
|
---|
274 | break;
|
---|
275 | }
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 | if (trigMask & (block_bolo_mask | block_sst_mask)) {
|
---|
280 | imes = 9999;
|
---|
281 | } else {
|
---|
282 | imes = 0;
|
---|
283 | }
|
---|
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 | }
|
---|
293 | }
|
---|
294 |
|
---|
295 | void 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];
|
---|
318 | double t = archParam.acq.tBlock0 + smp * archParam.acq.perEch/86400.;
|
---|
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 |
|
---|
333 | bool TOIIter::NextFile() {
|
---|
334 | if (rawIter)
|
---|
335 | return rawIter->NextFile();
|
---|
336 |
|
---|
337 | if (files.empty()) {
|
---|
338 | return false;
|
---|
339 | } else {
|
---|
340 | if (curFile == files.end()) return false;
|
---|
341 | curFile++;
|
---|
342 | if (curFile == files.end()) return false;
|
---|
343 | cout << "opening file " << (*curFile).c_str() << endl;
|
---|
344 | ArcheopsFile* newfile = new ArcheopsFile((*curFile).c_str());
|
---|
345 | newfile->grabLastBlocs(*file);
|
---|
346 | delete file;
|
---|
347 | file = newfile;
|
---|
348 | return true;
|
---|
349 | }
|
---|
350 | }
|
---|
351 |
|
---|
352 |
|
---|
353 | bool TOIIter::Next() {
|
---|
354 | if (!initDone) Init();
|
---|
355 | while (1) {
|
---|
356 | if (!NextSample()) return false; // end of files
|
---|
357 | double t = getMJD();
|
---|
358 | if (t < tStart) continue;
|
---|
359 | if (t > tEnd) return false;
|
---|
360 | return true;
|
---|
361 | }
|
---|
362 | }
|
---|
363 |
|
---|
364 | bool TOIIter::NextSample() {
|
---|
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 | }
|
---|
392 |
|
---|
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 )) {
|
---|
395 | imes++;
|
---|
396 | if (imes < file->nEchBlock()) return true;
|
---|
397 | imes = 0;
|
---|
398 | }
|
---|
399 |
|
---|
400 | // soit pas d'info indexee, soit fin bloc courant...
|
---|
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 ?
|
---|
405 | if (NextFile()) file->nextBlock(); // fichier suivant
|
---|
406 | else return false; // tout fini
|
---|
407 | }
|
---|
408 | }
|
---|
409 | return true;
|
---|
410 | }
|
---|
411 | if (!NextFile()) return false;
|
---|
412 | }
|
---|
413 | }
|
---|
414 |
|
---|
415 | /* double TOIIter::getTime() { // MJD
|
---|
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 | }
|
---|
420 | */
|
---|
421 |
|
---|
422 | bool TOIIter::canGetValue(int column) {
|
---|
423 | if (!initDone) Init();
|
---|
424 | if (column < 0 || column >= infos.size()) return false;
|
---|
425 | TOIKind kind = infos[column].kind;
|
---|
426 | if (auxGPS &&
|
---|
427 | (kind == longitude || kind == latitude || kind == altitude || kind == tsid)) {
|
---|
428 | double dummy;
|
---|
429 | return auxGPS->getLocation(getMJD(), dummy, dummy, dummy) == 0;
|
---|
430 | }
|
---|
431 | if (rawIter) {
|
---|
432 | return interp[column].canGet(lastSample);
|
---|
433 | }
|
---|
434 | int index = infos[column].index;
|
---|
435 | switch (kind) {
|
---|
436 | case sampleNum:
|
---|
437 | case internalTime:
|
---|
438 | case mjd:
|
---|
439 | return true;
|
---|
440 | case boloTens:
|
---|
441 | case boloTens2:
|
---|
442 | case boloTens2T:
|
---|
443 | case boloRes:
|
---|
444 | case boloRawCN:
|
---|
445 | if (imes==0 && file->llastBolo()==NULL) return false;
|
---|
446 | return file->lastBolo() != NULL;
|
---|
447 | case boloTensCN:
|
---|
448 | case boloRaw:
|
---|
449 | return file->lastBolo() != NULL;
|
---|
450 | case boloGainAmpli:
|
---|
451 | case boloDACV:
|
---|
452 | case boloDACI:
|
---|
453 | return file->lastReglage() != NULL;
|
---|
454 | case dilDAC:
|
---|
455 | case dilSwitch:
|
---|
456 | return file->lastDilution() != NULL;
|
---|
457 | case sstDiode:
|
---|
458 | case sstChannel:
|
---|
459 | case sstDiodeCN:
|
---|
460 | case sstChannelCN:
|
---|
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);
|
---|
469 | }
|
---|
470 | case gyroRaw:
|
---|
471 | case gyroTens:
|
---|
472 | case gyroSpeed:
|
---|
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 | }
|
---|
497 | return false;
|
---|
498 | }
|
---|
499 |
|
---|
500 |
|
---|
501 | double TOIIter::getValue(int column) {
|
---|
502 | if (!initDone) Init();
|
---|
503 | if (column < 0 || column >= infos.size()) return -1;
|
---|
504 | TOIKind kind = infos[column].kind;
|
---|
505 | if (auxGPS &&
|
---|
506 | (kind == longitude || kind == latitude || kind == altitude || kind == tsid)) {
|
---|
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;
|
---|
511 | if (kind == altitude) return alt;
|
---|
512 | if (kind == tsid) {
|
---|
513 | tSid.setLongitude(lon);
|
---|
514 | return tSid.getLST(getMJD());
|
---|
515 | }
|
---|
516 | }
|
---|
517 | if (rawIter) {
|
---|
518 | if (infos[column].interpolated)
|
---|
519 | return interp[column].getIValue(lastSample);
|
---|
520 | else
|
---|
521 | return interp[column].getEValue(lastSample);
|
---|
522 | }
|
---|
523 | int index = infos[column].index;
|
---|
524 | switch (kind) {
|
---|
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);
|
---|
533 | case boloTens2:
|
---|
534 | return file->getMuVBolo2(index, imes);
|
---|
535 | case boloRaw:
|
---|
536 | return file->getRawBolo(index, imes);
|
---|
537 | case boloRawCN:
|
---|
538 | return file->getRawBoloCN(index, imes);
|
---|
539 | case boloTensCN:
|
---|
540 | return file->getMuVBoloCN(index, imes);
|
---|
541 | case boloGainAmpli:
|
---|
542 | return file->getGainAmpli(index);
|
---|
543 | case boloDACV:
|
---|
544 | return file->getDACV(index);
|
---|
545 | case boloDACI:
|
---|
546 | return file->getDACI(index);
|
---|
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();
|
---|
555 | case sstDiode:
|
---|
556 | return file->getSSTSignal(index, imes);
|
---|
557 | case sstChannel:
|
---|
558 | return file->getSSTRawSignal(index, imes);
|
---|
559 | case sstDiodeCN:
|
---|
560 | return file->getSSTSignalCN(index, imes);
|
---|
561 | case sstChannelCN:
|
---|
562 | return file->getSSTRawSignalCN(index, imes);
|
---|
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:
|
---|
572 | return file->getGyroRaw(index, imes);
|
---|
573 | case gyroTens:
|
---|
574 | return file->getGyroTens(index, imes);
|
---|
575 | case gyroSpeed:
|
---|
576 | return file->getGyroSpeed(index, imes);
|
---|
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);
|
---|
594 | }
|
---|
595 | return -1;
|
---|
596 | }
|
---|
597 |
|
---|
598 | bool TOIIter::newValue(int column) {
|
---|
599 | if (!initDone) Init();
|
---|
600 | if (column < 0 || column >= infos.size()) return false;
|
---|
601 | TOIKind kind = infos[column].kind;
|
---|
602 | if (auxGPS &&
|
---|
603 | (kind == longitude || kind == latitude || kind == altitude)) {
|
---|
604 | return true;
|
---|
605 | }
|
---|
606 | if (rawIter) {
|
---|
607 | return interp[column].isNewValue(lastSample);
|
---|
608 | }
|
---|
609 | switch (kind) {
|
---|
610 | case sampleNum:
|
---|
611 | case internalTime:
|
---|
612 | case mjd:
|
---|
613 | case tsid:
|
---|
614 | return true;
|
---|
615 | case boloTens:
|
---|
616 | case boloTens2:
|
---|
617 | case boloTens2T:
|
---|
618 | case boloRes:
|
---|
619 | return file->blockNum() == file->getBoloBlockNum();
|
---|
620 | case boloRaw:
|
---|
621 | case boloRawCN:
|
---|
622 | case boloTensCN:
|
---|
623 | return file->blockNum() == file->getBoloBlockNum();
|
---|
624 | case boloGainAmpli:
|
---|
625 | return file->blockNum() == file->getReglageBlockNum() && imes==0;
|
---|
626 | case boloDACI:
|
---|
627 | case boloDACV:
|
---|
628 | return file->blockNum() == file->getReglageBlockNum() && imes==0;
|
---|
629 | case dilDAC:
|
---|
630 | case dilSwitch:
|
---|
631 | return file->blockNum() == file->getDilutionBlockNum() && imes==0;
|
---|
632 | case sstChannel:
|
---|
633 | case sstDiode:
|
---|
634 | case sstStarCnt:
|
---|
635 | case sstStarZ:
|
---|
636 | case sstStarF:
|
---|
637 | case sstStarT:
|
---|
638 | return file->blockNum() == file->getSSTBlockNum();
|
---|
639 | case sstChannelCN:
|
---|
640 | case sstDiodeCN:
|
---|
641 | return file->blockNum() == file->getSSTCompBlockNum();
|
---|
642 | case gyroRaw:
|
---|
643 | case gyroTens:
|
---|
644 | case gyroSpeed:
|
---|
645 | return file->blockNum() == file->getGyroBlockNum();
|
---|
646 | case gpsTime:
|
---|
647 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
648 | case longitude:
|
---|
649 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
650 | case latitude:
|
---|
651 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
652 | case altitude:
|
---|
653 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
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
|
---|
660 | }
|
---|
661 | return false;
|
---|
662 | }
|
---|
663 |
|
---|
664 | bool TOIIter::extendValue(int column) {
|
---|
665 | return (!infos[column].interpolated && !newValue(column));
|
---|
666 | }
|
---|
667 |
|
---|
668 | bool TOIIter::interpValue(int column) {
|
---|
669 | return (infos[column].interpolated && !newValue(column));
|
---|
670 | }
|
---|
671 |
|
---|
672 | bool TOIIter::isTrig(int column) {
|
---|
673 | if (column < 0 || column >= infos.size()) return false;
|
---|
674 | return infos[column].triggering;
|
---|
675 | }
|
---|
676 |
|
---|
677 |
|
---|
678 | TOIKind TOIIter::getKind(int column) {
|
---|
679 | if (column < 0 || column >= infos.size()) return (TOIKind)-1;
|
---|
680 | return infos[column].kind;
|
---|
681 | }
|
---|
682 |
|
---|
683 | int TOIIter::getIndex(int column) {
|
---|
684 | if (column < 0 || column >= infos.size()) return (TOIKind)-1;
|
---|
685 | return infos[column].index;
|
---|
686 | }
|
---|
687 |
|
---|
688 | int 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 |
|
---|
695 | bool TOIIter::canGetTOI(TOIKind kind, int index) {
|
---|
696 | int col = getColTOI(kind, index);
|
---|
697 | if (col<0) return false;
|
---|
698 | return canGetValue(col);
|
---|
699 | }
|
---|
700 |
|
---|
701 | double 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 |
|
---|
707 |
|
---|
708 | int TOIIter::getBlockSampleIndex() {
|
---|
709 | return imes;
|
---|
710 | }
|
---|
711 |
|
---|
712 | int TOIIter::getSampleIndex() {
|
---|
713 | if (!initDone) Init();
|
---|
714 | if (file) {
|
---|
715 | return file->blockNum() * file->nEchBlock() + imes;
|
---|
716 | } else {
|
---|
717 | return lastSample;
|
---|
718 | }
|
---|
719 | }
|
---|
720 |
|
---|
721 | double TOIIter::getMJD() {
|
---|
722 | if (!initDone) Init();
|
---|
723 | int sample = getSampleIndex();
|
---|
724 | return archParam.acq.tBlock0 + sample*archParam.acq.perEch/86400.;
|
---|
725 | }
|
---|
726 |
|
---|
727 | bool 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++) {
|
---|
732 | if (rawIter->canGetValue(i) && rawIter->newValue(i)) {
|
---|
733 | interp[i].enterValue(rawIter->getValue(i), sample);
|
---|
734 | }
|
---|
735 | }
|
---|
736 | return true;
|
---|
737 | }
|
---|
738 |
|
---|
739 | block_type_param* TOIIter::lastParam() {
|
---|
740 | if (!initDone) Init();
|
---|
741 | if (file) return file->lastParam();
|
---|
742 | else return rawIter->lastParam();
|
---|
743 | }
|
---|
744 |
|
---|
745 |
|
---|