[310] | 1 | #include "toiiter.h"
|
---|
[315] | 2 | #include "toiinterpolator.h"
|
---|
[310] | 3 | #include <dirent.h>
|
---|
[342] | 4 | #include <iostream.h>
|
---|
[310] | 5 |
|
---|
| 6 | // Format bloc GPS
|
---|
| 7 | // $GPGGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z,
|
---|
| 8 |
|
---|
| 9 | TOIIter::TOIIter() {
|
---|
| 10 | // Toutes les valeurs initialisees par defaut. Le TOISvr les positionnera,
|
---|
| 11 | // puis lancera l'initialisation
|
---|
| 12 |
|
---|
| 13 | file = NULL;
|
---|
| 14 | directory = "";
|
---|
| 15 | fileName = "";
|
---|
| 16 |
|
---|
[342] | 17 | files.clear();
|
---|
| 18 |
|
---|
| 19 | isOnBoardRecorder = false;
|
---|
| 20 |
|
---|
| 21 | imes=0;
|
---|
| 22 |
|
---|
[310] | 23 | tStart = -9.e99;
|
---|
[342] | 24 | tEnd = 9.e99;
|
---|
[310] | 25 |
|
---|
| 26 | tBlock0 = -1;
|
---|
[342] | 27 | perEch = -1;
|
---|
[315] | 28 |
|
---|
[342] | 29 | trigMask = 0;
|
---|
[315] | 30 | rawIter = NULL;
|
---|
| 31 | interp = NULL;
|
---|
| 32 | lastSample = -1;
|
---|
[342] | 33 | maxLookAhead = 10000;
|
---|
[310] | 34 |
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | TOIIter::TOIIter(TOIIter const& x) {
|
---|
| 38 | directory = x.directory;
|
---|
| 39 | fileName = x.fileName;
|
---|
| 40 | files = x.files;
|
---|
[342] | 41 | // curFile = x.curFile; // $CHECK$ DANGER !!
|
---|
| 42 | curFile = files.find(*(x.curFile));
|
---|
| 43 | isOnBoardRecorder = x.isOnBoardRecorder;
|
---|
[310] | 44 | imes = x.imes;
|
---|
| 45 | tStart = x.tStart;
|
---|
| 46 | tEnd = x.tEnd;
|
---|
| 47 | tBlock0 = x.tBlock0;
|
---|
[342] | 48 | perEch = x.perEch;
|
---|
[310] | 49 | trigMask = x.trigMask;
|
---|
| 50 | infos = x.infos;
|
---|
| 51 |
|
---|
[315] | 52 | if (x.file)
|
---|
| 53 | file = new ArcheopsFile(*x.file);
|
---|
| 54 | else
|
---|
| 55 | file = NULL;
|
---|
| 56 |
|
---|
| 57 | if (x.rawIter) {
|
---|
| 58 | rawIter = new TOIIter(*x.rawIter);
|
---|
| 59 | interp = new TOIInterpolator[infos.size()];
|
---|
| 60 | for (int i=0; i<infos.size(); i++)
|
---|
| 61 | interp[i] = x.interp[i];
|
---|
| 62 | } else {
|
---|
| 63 | rawIter = NULL;
|
---|
| 64 | interp = NULL;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | lastSample = x.lastSample;
|
---|
| 68 | maxLookAhead = x.maxLookAhead;
|
---|
[310] | 69 | }
|
---|
| 70 |
|
---|
| 71 | TOIIter::~TOIIter() {
|
---|
| 72 | delete file;
|
---|
[315] | 73 | delete rawIter;
|
---|
| 74 | delete[] interp;
|
---|
[310] | 75 | }
|
---|
| 76 |
|
---|
[342] | 77 | #ifdef __MWERKS__
|
---|
| 78 | #define filesep ':'
|
---|
| 79 | #else
|
---|
| 80 | #define filesep '/'
|
---|
| 81 | #endif
|
---|
| 82 |
|
---|
[310] | 83 | void TOIIter::Init() {
|
---|
[342] | 84 | // On a soit un repertoire, soit un fichier, soit une liste de fichiers....
|
---|
[310] | 85 | if (directory == "") {
|
---|
[342] | 86 | if (files.empty()) { // un seul fichier
|
---|
| 87 | file = new ArcheopsFile(fileName);
|
---|
| 88 | } else {
|
---|
| 89 | curFile = files.begin();
|
---|
| 90 | file = new ArcheopsFile((*curFile).c_str());
|
---|
| 91 | }
|
---|
| 92 | } else { // On a un repertoire a explorer
|
---|
| 93 | // On cherche soit les fichiers dans le repertoire donne, soit des fichiers
|
---|
| 94 | // dans un sous-repertoire "arch-YY_MM_DD". Les fichiers ont un nom en
|
---|
| 95 | // "hYY_MM_DD-hh_mm_ss".
|
---|
| 96 | // Pour l'enregistreur de vol, les fichiers ont un nom en ARKxxxxxx.DAT
|
---|
| 97 | if (directory[directory.length()-1] != filesep)
|
---|
| 98 | directory += filesep;
|
---|
[310] | 99 | DIR* dir = opendir(directory.c_str());
|
---|
| 100 | struct dirent* ent;
|
---|
| 101 | while ((ent = readdir(dir)) != NULL) {
|
---|
[342] | 102 | // si c'est un repertoire, avec un nom de jour, il faut l'explorer...
|
---|
| 103 | if (!strncmp(ent->d_name, "arch-", 5)) {
|
---|
| 104 | double mjd = ArcheopsFile::decodeMJD(ent->d_name+5) - 2./24.; // ENTIER + .5 en temps local!
|
---|
| 105 | if (mjd >= tStart - 1. && mjd <= tEnd) {
|
---|
| 106 | string direc2 = directory + ent->d_name + filesep;
|
---|
| 107 | DIR* dir2 = opendir(direc2.c_str());
|
---|
| 108 | struct dirent* ent2;
|
---|
| 109 | while ((ent2 = readdir(dir2)) != NULL) {
|
---|
| 110 | if (*ent2->d_name == 'h') {
|
---|
| 111 | double mjd2 = ArcheopsFile::decodeMJD(ent->d_name+1) - 2./24.;
|
---|
| 112 | if (mjd2 >= tStart - 1./24. && mjd2 <= tEnd) {
|
---|
| 113 | files.insert(direc2 + ent2->d_name);
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 | } else {
|
---|
| 119 | if (!isOnBoardRecorder && *ent->d_name == 'h') {
|
---|
| 120 | double mjd = ArcheopsFile::decodeMJD(ent->d_name+1) - 2./24.; // $CHECK$ UTCOffset
|
---|
| 121 | if (mjd >= tStart - 1./24. && mjd <= tEnd) {
|
---|
| 122 | files.insert(directory + ent->d_name);
|
---|
| 123 | }
|
---|
| 124 | } else if (isOnBoardRecorder) {
|
---|
| 125 | if (strncmp(ent->d_name, "ARK", 3)) continue;
|
---|
| 126 | char * sfx = ent->d_name + strlen(ent->d_name) - 4;
|
---|
| 127 | if (strcmp(sfx, ".DAT")) continue;
|
---|
| 128 | files.insert(directory + ent->d_name);
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
[310] | 131 | }
|
---|
| 132 | closedir(dir);
|
---|
| 133 | curFile = files.begin();
|
---|
| 134 | file = new ArcheopsFile((*curFile).c_str());
|
---|
| 135 | }
|
---|
| 136 |
|
---|
[342] | 137 | // On avance jusqu'a avoir au moins un bloc param et un bloc reglage,
|
---|
| 138 | // car on ne peut rien faire sans...
|
---|
| 139 | // Si on a des donnees de l'enregistreur de vol, pas de bloc param, et
|
---|
| 140 | // on en simule un
|
---|
| 141 | if (!file->lastParam()) {
|
---|
| 142 | if (isOnBoardRecorder) {
|
---|
| 143 | extern param_bolo parametr;
|
---|
| 144 | block_type_param block;
|
---|
| 145 | block.param = parametr;
|
---|
| 146 | valide_block((block_type_modele*)&block, block_param, 0);
|
---|
| 147 | file->forceBlock((block_type_modele*)&block);
|
---|
| 148 | } else {
|
---|
| 149 | file->nextBlock(block_param_mask);
|
---|
| 150 | }
|
---|
| 151 | }
|
---|
[310] | 152 | if (!file->lastReglage()) file->nextBlock(block_reglage_mask);
|
---|
| 153 |
|
---|
| 154 | // On cherche un bloc GPS pour avoir la correspondance timestamp/UTC.
|
---|
| 155 | // Pour le moment, on se fonde sur le premier bloc GPS. On pourra faire
|
---|
[342] | 156 | // mieux en prenant le min de tous les delta_T, a condition d'avoir un
|
---|
| 157 | // peu plus de details sur la facon dont le GPS est lu.
|
---|
[310] | 158 |
|
---|
[342] | 159 | if (tBlock0 < 0) {
|
---|
| 160 | tBlock0 = file->getStartMJD();
|
---|
[315] | 161 |
|
---|
[342] | 162 | file->pushMark();
|
---|
| 163 | if (file->lastGPS() || file->nextBlock(block_gps_mask)) {
|
---|
| 164 | // le temps du bloc courant, en secondes
|
---|
| 165 | double dt = file->blockNum() * file->perBlock();
|
---|
| 166 | tBlock0 = file->getGPSMJD() - dt/86400.;
|
---|
| 167 | } else { // pas de bloc GPS...
|
---|
| 168 | tBlock0 = file->getStartMJD();
|
---|
| 169 | }
|
---|
| 170 | file->popMark();
|
---|
[310] | 171 | }
|
---|
[342] | 172 |
|
---|
| 173 | if (perEch < 0)
|
---|
| 174 | perEch = file->perEchant();
|
---|
[315] | 175 |
|
---|
| 176 | bool hasInterp = false;
|
---|
[310] | 177 |
|
---|
| 178 | trigMask = 0;
|
---|
| 179 | for (vector<info>::iterator i = infos.begin(); i != infos.end(); i++) {
|
---|
[315] | 180 | if ((*i).interpolated) hasInterp = true;
|
---|
[310] | 181 | if ((*i).triggering) {
|
---|
| 182 | switch ((*i).kind) {
|
---|
| 183 | case boloTens:
|
---|
| 184 | case boloRaw:
|
---|
| 185 | trigMask |= block_bolo_mask;
|
---|
| 186 | break;
|
---|
[342] | 187 | case gpsTime:
|
---|
[310] | 188 | case longitude:
|
---|
| 189 | case latitude:
|
---|
[342] | 190 | case altitude:
|
---|
[310] | 191 | trigMask |= block_gps_mask;
|
---|
| 192 | break;
|
---|
| 193 | case azimut:
|
---|
[315] | 194 | file->needSSTProcessMask(SSTHandler::findPeriod);
|
---|
[310] | 195 | trigMask |= block_sst_mask;
|
---|
| 196 | break;
|
---|
[315] | 197 | case sstStarZ:
|
---|
| 198 | case sstStarF:
|
---|
| 199 | file->needSSTProcessMask(SSTHandler::findStars);
|
---|
[310] | 200 | trigMask |= block_sst_mask;
|
---|
| 201 | break;
|
---|
[315] | 202 | case sstSignal:
|
---|
| 203 | file->needSSTProcessMask(SSTHandler::rmveOffset);
|
---|
| 204 | trigMask |= block_sst_mask;
|
---|
| 205 | break;
|
---|
[342] | 206 | case sstRaw:
|
---|
| 207 | trigMask |= block_sst_mask;
|
---|
| 208 | break;
|
---|
| 209 | case gyroRaw:
|
---|
| 210 | trigMask |= block_gyro_mask;
|
---|
| 211 | break;
|
---|
[315] | 212 | case alphaAxis:
|
---|
| 213 | case deltaAxis:
|
---|
| 214 | case alphaBolo:
|
---|
| 215 | case deltaBolo:
|
---|
| 216 | file->needSSTProcessMask(SSTHandler::findAxis);
|
---|
| 217 | trigMask |= block_sst_mask;
|
---|
| 218 | break;
|
---|
[310] | 219 | }
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | if (trigMask & (block_bolo_mask | block_sst_mask)) {
|
---|
| 224 | imes = 9999;
|
---|
| 225 | } else {
|
---|
| 226 | imes = 0;
|
---|
| 227 | }
|
---|
[315] | 228 |
|
---|
| 229 | if (hasInterp) {
|
---|
| 230 | rawIter = new TOIIter(*this);
|
---|
| 231 | interp = new TOIInterpolator[infos.size()];
|
---|
| 232 | for (int i=0; i<infos.size(); i++) {
|
---|
| 233 | rawIter->infos[i].interpolated = false;
|
---|
| 234 | }
|
---|
| 235 | delete file; file = NULL; // on ne travaille plus sur le fichier directement...
|
---|
| 236 | }
|
---|
[310] | 237 | }
|
---|
| 238 |
|
---|
| 239 | bool TOIIter::NextFile() {
|
---|
[315] | 240 | if (rawIter)
|
---|
| 241 | return rawIter->NextFile();
|
---|
| 242 |
|
---|
[342] | 243 | if (files.empty()) {
|
---|
[310] | 244 | return false;
|
---|
| 245 | } else {
|
---|
| 246 | if (curFile == files.end()) return false;
|
---|
| 247 | curFile++;
|
---|
| 248 | if (curFile == files.end()) return false;
|
---|
[342] | 249 | cout << "opening file " << (*curFile).c_str() << endl;
|
---|
[310] | 250 | ArcheopsFile* newfile = new ArcheopsFile((*curFile).c_str());
|
---|
| 251 | newfile->grabLastBlocs(*file);
|
---|
| 252 | delete file;
|
---|
| 253 | file = newfile;
|
---|
| 254 | return true;
|
---|
| 255 | }
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | bool TOIIter::Next() {
|
---|
[315] | 259 | if (rawIter) { // Delegation pour interpolation
|
---|
| 260 | // Trouve prochain sample disponible
|
---|
| 261 | for (int k=0; k<2; k++) {
|
---|
| 262 | long smp = 2147483647L;
|
---|
| 263 | for (int i=0; i<infos.size(); i++) {
|
---|
| 264 | long ss = interp[i].nextSample(lastSample+1);
|
---|
| 265 | if (ss > 0 && ss < smp) smp=ss;
|
---|
| 266 | }
|
---|
| 267 | if (smp != 2147483647L) {
|
---|
| 268 | lastSample = smp;
|
---|
| 269 | break;
|
---|
| 270 | }
|
---|
| 271 | if (!fetchAhead()) // tout le monde etait en bout de course,
|
---|
| 272 | return false; // on lit un echantillon, ca suffit, d'ou le k<2
|
---|
| 273 | }
|
---|
| 274 | // Verifie que tous les interpolateurs ont assez de donnees pour
|
---|
| 275 | // trouver la valeur correspondante
|
---|
| 276 | for (int i=0; i<infos.size(); i++) {
|
---|
| 277 | //rif (infos[i].interpolated)
|
---|
| 278 | while (interp[i].needMoreDataFor(lastSample) &&
|
---|
| 279 | rawIter->getSampleIndex() - lastSample < maxLookAhead)
|
---|
| 280 | if (!fetchAhead()) return false;
|
---|
| 281 | }
|
---|
| 282 |
|
---|
| 283 | // On est pret...
|
---|
| 284 | return true;
|
---|
| 285 | }
|
---|
[310] | 286 |
|
---|
| 287 | // trigger sur info indexee dans bloc bolo ou bloc sst ?
|
---|
| 288 | if (trigMask & (block_bolo_mask | block_sst_mask)) {
|
---|
| 289 | imes++;
|
---|
| 290 | if (imes < file->nEchBlock()) return true;
|
---|
| 291 | imes = 0;
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | // soit pas d'info indexee, soit fin bloc courant...
|
---|
[315] | 295 | while (1) {
|
---|
| 296 | if (file->nextBlock(trigMask)) {
|
---|
| 297 | while (file->sameBlockNumAhead()) { // tant que meme numero de bloc, on lit
|
---|
| 298 | if (!file->nextBlock()) { // fin de fichier ?
|
---|
| 299 | if (NextFile()) file->nextBlock();
|
---|
| 300 | else break;
|
---|
| 301 | }
|
---|
| 302 | }
|
---|
| 303 | return true;
|
---|
| 304 | }
|
---|
| 305 | if (!NextFile()) return false;
|
---|
[310] | 306 | }
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[315] | 309 | /* double TOIIter::getTime() { // MJD
|
---|
[310] | 310 | // le temps du bloc courant, en secondes
|
---|
| 311 | double dt = file->blockNum() * file->perBlock();
|
---|
| 312 | return tBlock0 + dt/86400. + imes*file->perEchant()/86400.;
|
---|
| 313 | }
|
---|
[315] | 314 | */
|
---|
[310] | 315 |
|
---|
[315] | 316 | bool TOIIter::canGetValue(int column) {
|
---|
| 317 | if (column < 0 || column >= infos.size()) return false;
|
---|
| 318 | if (rawIter) {
|
---|
| 319 | return interp[column].canGet(lastSample);
|
---|
| 320 | }
|
---|
| 321 | TOIKind kind = infos[column].kind;
|
---|
| 322 | int index = infos[column].index;
|
---|
| 323 | switch (kind) {
|
---|
| 324 | case sampleNum:
|
---|
| 325 | case internalTime:
|
---|
| 326 | case utc:
|
---|
| 327 | return true;
|
---|
| 328 | case boloTens:
|
---|
[342] | 329 | if (imes==0 && file->llastBolo()==NULL) return false;
|
---|
| 330 | return file->lastBolo() != NULL;
|
---|
[315] | 331 | case boloRaw:
|
---|
| 332 | return file->lastBolo() != NULL;
|
---|
| 333 | case sstSignal:
|
---|
[342] | 334 | case sstRaw:
|
---|
[315] | 335 | return file->lastSST() != NULL;
|
---|
[342] | 336 | case sstStarZ:
|
---|
| 337 | case sstStarF:
|
---|
| 338 | return (file->lastSST() != NULL) && (file->getSSTStarZ(index, imes) >= 0);
|
---|
| 339 | case gyroRaw:
|
---|
| 340 | return (file->lastGyro() != NULL);
|
---|
| 341 | case gpsTime:
|
---|
| 342 | return file->hasGPSTime();
|
---|
[315] | 343 | case longitude:
|
---|
| 344 | case latitude:
|
---|
[342] | 345 | return file->hasGPSPos();
|
---|
| 346 | case altitude:
|
---|
| 347 | return file->hasGPSAlt();
|
---|
[315] | 348 | case azimut:
|
---|
| 349 | case alphaAxis:
|
---|
| 350 | case deltaAxis:
|
---|
| 351 | return (file->lastGPS() != NULL && file->lastSST() != NULL);
|
---|
| 352 | }
|
---|
| 353 | return false;
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | double TOIIter::getValue(int column) {
|
---|
[310] | 357 | if (column < 0 || column >= infos.size()) return -1;
|
---|
[315] | 358 | if (rawIter) {
|
---|
| 359 | if (infos[column].interpolated)
|
---|
| 360 | return interp[column].getIValue(lastSample);
|
---|
| 361 | else
|
---|
| 362 | return interp[column].getEValue(lastSample);
|
---|
| 363 | }
|
---|
[310] | 364 | TOIKind kind = infos[column].kind;
|
---|
| 365 | int index = infos[column].index;
|
---|
| 366 | switch (kind) {
|
---|
[315] | 367 | case sampleNum:
|
---|
| 368 | return file->blockNum() * file->nEchBlock() + imes;
|
---|
| 369 | case internalTime:
|
---|
[342] | 370 | //return (file->blockNum() * file->nEchBlock() + imes) * file->perEchant();
|
---|
| 371 | return (file->blockNum() * file->nEchBlock() + imes) * perEch;
|
---|
[315] | 372 | case utc:
|
---|
| 373 | /* printf("utc: %d %d %g %g %g\n",file->blockNum(),
|
---|
| 374 | (file->blockNum() * file->nEchBlock() + imes),
|
---|
| 375 | file->perEchant(),
|
---|
| 376 | (file->blockNum() * file->nEchBlock() + imes) * file->perEchant()/86400.,
|
---|
| 377 | tBlock0+(file->blockNum() * file->nEchBlock() + imes) * file->perEchant()/86400.); */
|
---|
[342] | 378 | //return tBlock0+(file->blockNum() * file->nEchBlock() + imes) * file->perEchant()/86400.;
|
---|
| 379 | return tBlock0+(file->blockNum() * file->nEchBlock() + imes) * perEch/86400.;
|
---|
[310] | 380 | case boloTens:
|
---|
| 381 | return file->getMuVBolo(index, imes);
|
---|
| 382 | case boloRaw:
|
---|
| 383 | return file->getRawBolo(index, imes);
|
---|
[315] | 384 | case sstSignal:
|
---|
| 385 | return file->getSSTSignal(index, imes);
|
---|
[342] | 386 | case sstRaw:
|
---|
| 387 | return file->getSSTRawSignal(index, imes);
|
---|
| 388 | case sstStarZ:
|
---|
| 389 | return file->getSSTStarZ(index, imes);
|
---|
| 390 | case sstStarF:
|
---|
| 391 | return file->getSSTStarF(index, imes);
|
---|
| 392 | case gyroRaw:
|
---|
| 393 | return file->getGyro(index, imes);
|
---|
| 394 | case gpsTime:
|
---|
| 395 | return file->getGPSUTC();
|
---|
[310] | 396 | case longitude:
|
---|
[342] | 397 | return file->getGPSLong();
|
---|
[310] | 398 | case latitude:
|
---|
[342] | 399 | return file->getGPSLat();
|
---|
| 400 | case altitude:
|
---|
| 401 | return file->getGPSAlt();
|
---|
[315] | 402 | case azimut:
|
---|
[310] | 403 | return file->getAzimut(imes);
|
---|
[315] | 404 | case alphaAxis:
|
---|
[310] | 405 | return file->getAlpha(imes);
|
---|
[315] | 406 | case deltaAxis:
|
---|
[310] | 407 | return file->getDelta(imes);
|
---|
| 408 | }
|
---|
| 409 | return -1;
|
---|
[315] | 410 | }
|
---|
[310] | 411 |
|
---|
[315] | 412 | bool TOIIter::newValue(int column) {
|
---|
[310] | 413 | if (column < 0 || column >= infos.size()) return false;
|
---|
[342] | 414 | if (rawIter) {
|
---|
| 415 | return interp[column].isNewValue(lastSample);
|
---|
| 416 | }
|
---|
[310] | 417 | TOIKind kind = infos[column].kind;
|
---|
| 418 | switch (kind) {
|
---|
[315] | 419 | case sampleNum:
|
---|
| 420 | case internalTime:
|
---|
| 421 | case utc:
|
---|
| 422 | return true;
|
---|
[310] | 423 | case boloTens:
|
---|
[315] | 424 | return file->blockNum() == file->getBoloBlockNum();
|
---|
[310] | 425 | case boloRaw:
|
---|
[315] | 426 | return file->blockNum() == file->getBoloBlockNum();
|
---|
[342] | 427 | case sstRaw:
|
---|
[315] | 428 | case sstSignal:
|
---|
[342] | 429 | case sstStarZ:
|
---|
| 430 | case sstStarF:
|
---|
[315] | 431 | return file->blockNum() == file->getSSTBlockNum();
|
---|
[342] | 432 | case gyroRaw:
|
---|
| 433 | return file->blockNum() == file->getGyroBlockNum();
|
---|
| 434 | case gpsTime:
|
---|
| 435 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
[310] | 436 | case longitude:
|
---|
[315] | 437 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
[310] | 438 | case latitude:
|
---|
[315] | 439 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
[342] | 440 | case altitude:
|
---|
| 441 | return file->blockNum() == file->getGPSBlockNum() && imes==0;
|
---|
[315] | 442 | case azimut:
|
---|
| 443 | return true; // $CHECK$ with SSTHandler
|
---|
| 444 | case alphaAxis:
|
---|
| 445 | return true; // $CHECK$ with SSTHandler
|
---|
| 446 | case deltaAxis:
|
---|
| 447 | return true; // $CHECK$ with SSTHandler
|
---|
[310] | 448 | }
|
---|
| 449 | return false;
|
---|
[315] | 450 | }
|
---|
[310] | 451 |
|
---|
[315] | 452 | bool TOIIter::extendValue(int column) {
|
---|
| 453 | return (!infos[column].interpolated && !newValue(column));
|
---|
| 454 | }
|
---|
[310] | 455 |
|
---|
[315] | 456 | bool TOIIter::interpValue(int column) {
|
---|
| 457 | return (infos[column].interpolated && !newValue(column));
|
---|
| 458 | }
|
---|
[342] | 459 |
|
---|
| 460 | bool TOIIter::isTrig(int column) {
|
---|
| 461 | if (column < 0 || column >= infos.size()) return false;
|
---|
| 462 | return infos[column].triggering;
|
---|
| 463 | }
|
---|
| 464 |
|
---|
[310] | 465 |
|
---|
[315] | 466 | TOIKind TOIIter::getKind(int column) {
|
---|
[310] | 467 | if (column < 0 || column >= infos.size()) return (TOIKind)-1;
|
---|
| 468 | return infos[column].kind;
|
---|
[315] | 469 | }
|
---|
[310] | 470 |
|
---|
[315] | 471 | int TOIIter::getIndex(int column) {
|
---|
[310] | 472 | if (column < 0 || column >= infos.size()) return (TOIKind)-1;
|
---|
| 473 | return infos[column].index;
|
---|
[315] | 474 | }
|
---|
| 475 |
|
---|
| 476 | int TOIIter::getColTOI(TOIKind kind, int index) {
|
---|
| 477 | for (int i=0; i<infos.size(); i++)
|
---|
| 478 | if (infos[i].kind == kind && infos[i].index == index)
|
---|
| 479 | return i;
|
---|
| 480 | return -1;
|
---|
| 481 | }
|
---|
| 482 |
|
---|
| 483 | bool TOIIter::canGetTOI(TOIKind kind, int index) {
|
---|
| 484 | int col = getColTOI(kind, index);
|
---|
| 485 | if (col<0) return false;
|
---|
| 486 | return canGetValue(col);
|
---|
| 487 | }
|
---|
| 488 |
|
---|
| 489 | double TOIIter::getTOI(TOIKind kind, int index) {
|
---|
| 490 | int col = getColTOI(kind, index);
|
---|
| 491 | if (col<0) return -9.e99;
|
---|
| 492 | return getValue(col);
|
---|
| 493 | }
|
---|
| 494 |
|
---|
[310] | 495 |
|
---|
[315] | 496 | int TOIIter::getBlockSampleIndex() {
|
---|
[310] | 497 | return imes;
|
---|
[315] | 498 | }
|
---|
| 499 |
|
---|
| 500 | int TOIIter::getSampleIndex() {
|
---|
[342] | 501 | if (file) {
|
---|
| 502 | return file->blockNum() * file->nEchBlock() + imes;
|
---|
| 503 | } else {
|
---|
| 504 | return lastSample;
|
---|
| 505 | }
|
---|
[315] | 506 | }
|
---|
| 507 |
|
---|
| 508 | bool TOIIter::fetchAhead() { // Seulement si delegation
|
---|
| 509 | if (!rawIter) return false;
|
---|
| 510 | if (!rawIter->Next()) return false;
|
---|
| 511 | long sample = rawIter->getSampleIndex();
|
---|
| 512 | for (int i=0; i<infos.size(); i++) {
|
---|
[342] | 513 | if (rawIter->canGetValue(i) && rawIter->newValue(i)) {
|
---|
[315] | 514 | interp[i].enterValue(rawIter->getValue(i), sample);
|
---|
[342] | 515 | }
|
---|
[315] | 516 | }
|
---|
| 517 | return true;
|
---|
| 518 | }
|
---|
| 519 |
|
---|
[342] | 520 | block_type_param* TOIIter::lastParam() {
|
---|
| 521 | if (file) return file->lastParam();
|
---|
| 522 | else return rawIter->lastParam();
|
---|
| 523 | }
|
---|
| 524 |
|
---|
| 525 |
|
---|