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