Changeset 315 in Sophya for trunk/Poubelle
- Timestamp:
- Jun 15, 1999, 3:53:04 PM (26 years ago)
- Location:
- trunk/Poubelle/archTOI.old
- Files:
-
- 7 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Poubelle/archTOI.old/archeopsfile.cc
r310 r315 1 1 #define utilitaires_de_block_archeops 2 2 #include "archeopsfile.h" 3 extern "C" { 3 4 #include "compress.h" 5 } 4 6 #include <iostream.h> 7 8 // BlockSet is the current "state" of the file reader automate. 9 // It contains the last blocks of each kind, the current block and 10 // the look-ahead block. 5 11 6 12 class BlockSet { … … 27 33 block_type_gyro_comprime* lastGyroComp; 28 34 block_type_sst_comprime* lastSSTComp; 35 36 block_type_modele curBlock; 37 block_type_modele peekBlock; 38 39 SSTHandler sstHandler; 29 40 }; 30 41 … … 45 56 lastGyroComp = NULL; 46 57 lastSSTComp = NULL; 58 59 memset(&curBlock,0,sizeof(block_type_modele)); 60 memset(&peekBlock,0,sizeof(block_type_modele)); 47 61 } 48 62 … … 65 79 } 66 80 67 BlockSet::BlockSet(BlockSet const& x) { 81 BlockSet::BlockSet(BlockSet const& x) 82 : sstHandler(x.sstHandler) 83 { 68 84 lastParam = NULL; 69 85 lastJournal = NULL; … … 81 97 lastGyroComp = NULL; 82 98 lastSSTComp = NULL; 99 83 100 if (x.lastParam) { 84 101 lastParam = new block_type_param; … … 141 158 *lastSSTComp = *x.lastSSTComp; 142 159 } 160 161 memcpy(&curBlock,&x.curBlock,sizeof(block_type_modele)); 162 memcpy(&peekBlock,&x.peekBlock,sizeof(block_type_modele)); 163 143 164 } 144 165 … … 232 253 fseek(f,0,SEEK_END); 233 254 fLen = ftell(f); 234 curPos = 0; 255 curPos = -1; 256 peekPos = -1; 235 257 curKind = -1; 236 258 curRawKind = -1; … … 256 278 } 257 279 258 curBlock = x.curBlock;280 //curBlock = x.curBlock; 259 281 curKind = x.curKind; 260 282 curRawKind = x.curRawKind; 261 283 curPos = x.curPos; 284 peekPos = x.peekPos; 262 285 fLen = x.fLen; 263 286 fn = x.fn; … … 275 298 delete blockSet; 276 299 blockSet = new BlockSet(*oldFile.blockSet); 300 //curBlock = oldFile.curBlock; 301 //peekBlock = oldFile.peekBlock; 302 peekPos = 0; 277 303 setUTCOffset(oldFile.utcOffset); 278 304 } … … 282 308 283 309 bool ArcheopsFile::nextBlock() { 284 //if (curPos>0) saveCurBlock(); 285 //if (curPos<0) curPos = 0; 286 if (curPos+12 > fLen) return false; 287 fseek(f,curPos,SEEK_SET); 288 size_t read = fread(&curBlock,1,sizeof(curBlock),f); 289 if (read < longueur_block(&curBlock)) return false; 290 if (verifie_block(&curBlock) != block_correct) { 310 // si pas de peek, alors en lire un pour commencer... 311 if (peekPos<0) { 312 peekPos=0; if (!nextBlock()) return false; 313 } 314 block_type_modele* curBlock=currentBlock(); 315 block_type_modele* peekBlock=aheadBlock(); 316 317 memcpy(curBlock, peekBlock, sizeof(block_type_modele)); 318 319 if (peekPos+12 > fLen) return false; 320 fseek(f,peekPos,SEEK_SET); 321 size_t read = fread(peekBlock,1,sizeof(block_type_modele),f); 322 swapEntete(peekBlock); 323 if (read < longueur_block(peekBlock)) return false; 324 swapContent(peekBlock); 325 if (verifie_block(peekBlock) != block_correct) { 291 326 printf("block invalide\n"); throw ArchExc("invalid block"); 292 327 } 293 curRawKind = curKind = type_block(&curBlock); 294 curPos += longueur_block(&curBlock); 328 peekPos += longueur_block(peekBlock); 329 if (curPos < 0) { 330 curPos = 0; return true; 331 } 332 curPos += longueur_block(curBlock); 333 curRawKind = curKind = type_block(curBlock); 295 334 //printf("block %d : %s \n",numero_block(&curBlock),nom_block[curKind]); 296 335 postProcessBlock(); … … 316 355 317 356 int ArcheopsFile::blockNum() { 318 return numero_block( &curBlock);357 return numero_block(currentBlock()); 319 358 } 320 359 … … 348 387 349 388 block_type_modele* ArcheopsFile::currentBlock() { 350 if (curPos<0) return NULL; 351 return &curBlock; 352 } 389 //if (curPos<0) return NULL; 390 return &blockSet->curBlock; 391 } 392 393 block_type_modele* ArcheopsFile::aheadBlock() { 394 //if (peekPos<0) return NULL; 395 return &blockSet->peekBlock; 396 } 397 398 bool ArcheopsFile::sameBlockNumAhead() { 399 if (curPos<0) return false; 400 return (numero_block(&blockSet->curBlock) == numero_block(&blockSet->peekBlock)); 401 } 402 353 403 354 404 block_type_param* ArcheopsFile::lastParam() { … … 401 451 switch (curKind) { 402 452 case block_bolo_comprime: { 403 blockSet->setRawBloc( curBlock);453 blockSet->setRawBloc(blockSet->curBlock); 404 454 block_type_bolo blk2; 405 block_type_bolo_comprime* blk = (block_type_bolo_comprime*) & curBlock;455 block_type_bolo_comprime* blk = (block_type_bolo_comprime*) &blockSet->curBlock; 406 456 for(int j=0;j<nb_bolo_util;j++) 407 457 { … … 409 459 } 410 460 valide_block((block_type_modele*)&blk2,block_bolo,numero_block(blk)); 411 memcpy(& curBlock,&blk2,sizeof(blk2));461 memcpy(&blockSet->curBlock,&blk2,sizeof(blk2)); 412 462 curKind = block_bolo; 413 463 break; 414 464 } 465 case block_sst_comprime: { // $CHECK$ TBD 466 } 467 case block_sst : { 468 blockSet->sstHandler.ProcessBlock((block_type_sst*)&blockSet->curBlock); 469 } 415 470 } 416 471 } 417 472 418 473 void ArcheopsFile::saveCurBlock() { 419 blockSet->setBloc( curBlock);474 blockSet->setBloc(blockSet->curBlock); 420 475 } 421 476 422 477 void ArcheopsFile::pushMark() { // push current file position, and "last" blocks` 423 478 fposStack.push(curPos); 479 fposStack.push(peekPos); 424 480 blockStack.push(new BlockSet(*blockSet)); 425 481 } … … 429 485 delete blockSet; 430 486 blockSet = blockStack.top(); 487 blockStack.pop(); 488 peekPos = fposStack.top(); 489 fposStack.pop(); 431 490 curPos = fposStack.top(); 432 blockStack.pop();433 491 fposStack.pop(); 434 492 } 435 493 } 494 495 typedef unsigned int4 uint_4; 496 typedef unsigned short uint_2; 497 498 static inline void bswap4(void* p) 499 { 500 uint_4 tmp = *(uint_4*)p; 501 *(uint_4*)p = ((tmp >> 24) & 0x000000FF) | 502 ((tmp >> 8) & 0x0000FF00) | 503 ((tmp & 0x0000FF00) << 8) | 504 ((tmp & 0x000000FF) << 24); 505 } 506 507 static inline void bswap2(void* p) 508 { 509 uint_2 tmp = *(uint_2*)p; 510 *(uint_2*)p = ((tmp >> 8) & 0x00FF) | 511 ((tmp & 0x00FF) << 8); 512 } 513 514 #ifdef __DECCXX 515 #define SWAP 516 #endif 517 #if defined(Linux) || defined(linux) 518 #define SWAP 519 #endif 520 521 void ArcheopsFile::swapEntete(block_type_modele* blk) { 522 #ifdef SWAP 523 bswap4(&(blk->debut)); 524 bswap4(&(blk->code1)); 525 bswap4(&(blk->code2)); 526 long lg = longueur_block(blk); 527 bswap4(((char*)blk) + lg - 4); 528 #endif 529 } 530 531 void ArcheopsFile::swapContent(block_type_modele* blk) { 532 #ifdef SWAP 533 int typ = type_block(blk); 534 535 if (typ == block_gps) return; // char only, no swap 536 if (typ == block_une_periode) { // une_periode, des shorts 537 block_type_une_periode* b = (block_type_une_periode*) blk; 538 for (int i=0; i<nb_max_bolo; i++) 539 for (int j=0; j<nb_max_mes_per; j++) 540 bswap2(&b->bol_per[i][j]); 541 return; 542 } 543 544 for (int i=0; i<longueur_block(blk)/4-4; i++) 545 bswap4(blk->mot + i); 546 // On deswappe ce qui ne devait pas etre swappe... 547 switch (typ) { 548 case block_param: { 549 block_type_param* b = (block_type_param*) blk; 550 for (int i=0; i<nb_max_bolo; i++) 551 for (int j=0; j<8; j++) 552 bswap4(&b->param.bolo[i].bolo_nom[4*j]); 553 } 554 555 } 556 #endif 557 } 558 559 560 436 561 437 562 static int mlen[] = {31,28,31,30,31,30,31,31,30,31,30,31}; … … 474 599 } 475 600 601 int ArcheopsFile::getBoloBlockNum() { 602 if (!lastBolo()) return -1; 603 return numero_block(lastBolo()); 604 } 605 606 int ArcheopsFile::getSSTBlockNum() { 607 if (!lastSST()) return -1; 608 return numero_block(lastSST()); 609 } 610 611 476 612 // GPS 477 613 // $GPGGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z, … … 484 620 485 621 double ArcheopsFile::getGPSUTC() { // en secondes depuis minuit UTC jour courant 486 if (!lastGPS()) return - 1;622 if (!lastGPS()) return -9.e99; 487 623 char* p = lastGPS()->gps; 488 if (strncmp(p, "$GPGGA,", 7)) return - 1;624 if (strncmp(p, "$GPGGA,", 7)) return -9.e99; 489 625 p += 7; 490 626 double t; … … 506 642 507 643 double ArcheopsFile::getGPSLat() { // degres, + = NORD 508 if (!lastGPS()) return 99999;644 if (!lastGPS()) return -9.e99; 509 645 char* p = lastGPS()->gps; 510 if (strncmp(p, "$GPGGA,", 7)) return 99999;646 if (strncmp(p, "$GPGGA,", 7)) return -9.e99; 511 647 char* fence = p+80; 512 648 p += 7; 513 649 while (*p != ',' && p<fence) p++; 514 if (*p != ',') return 99999;650 if (*p != ',') return -9.e99; 515 651 p++; 516 652 double t; … … 519 655 t = d + t/60; 520 656 while (*p != ',' && p<fence) p++; 521 if (*p != ',') return 99999;657 if (*p != ',') return -9.e99; 522 658 p++; 523 659 if (*p == 'S') t = -t; … … 526 662 527 663 double ArcheopsFile::getGPSLong() { // degres, + = EST 528 if (!lastGPS()) return - 1;664 if (!lastGPS()) return -9.e99; 529 665 char* p = lastGPS()->gps; 530 if (strncmp(p, "$GPGGA,", 7)) return 99999;666 if (strncmp(p, "$GPGGA,", 7)) return -9.e99; 531 667 char* fence = p+80; 532 668 p += 7; 533 669 for (int i=0; i<3; i++) { 534 670 while (*p != ',' && p<fence) p++; 535 if (*p != ',') return 99999;671 if (*p != ',') return -9.e99; 536 672 p++; 537 673 } … … 541 677 t = d + t/60; 542 678 while (*p != ',' && p<fence) p++; 543 if (*p != ',') return 99999;679 if (*p != ',') return -9.e99; 544 680 p++; 545 681 if (*p == 'W') t = -t; … … 570 706 571 707 double ArcheopsFile::getMuVBolo(int ibolo, int imesure) { // microvolts, filtre avec filtre carre 572 double y = (getRawBolo(ibolo, imesure-1) + getRawBolo(ibolo, imesure))/2.; 708 double y = (getRawBolo(ibolo, imesure-1) - getRawBolo(ibolo, imesure))/2.; 709 if (imesure%2) y=-y; 573 710 block_type_reglage* reglage = lastReglage(); 574 return ((1e5*y)/(65536.*gain (reglage->reglage.bolo[ibolo])));711 return ((1e5*y)/(65536.*gain_ampli(reglage->reglage.bolo[ibolo]))); 575 712 } 576 713 577 714 578 715 // SST, gyros... 716 717 void ArcheopsFile::needSSTProcessMask(int mask) { 718 blockSet->sstHandler.NeedProcess(mask); 719 } 720 721 722 long ArcheopsFile::getSSTSignal(int idiode, int imesure) { 723 return blockSet->sstHandler.getSignal(imesure, idiode); 724 } 579 725 // $CHECK$ TBD 580 726 -
trunk/Poubelle/archTOI.old/archeopsfile.h
r310 r315 6 6 #include <stack> 7 7 8 9 #ifndef nb_max_bolo 8 10 #define _archeops // Acquisition Archeops (avec transputer) 9 11 #define programme 10 11 12 extern "C" { 12 13 #include "archeops.h" 13 14 } 15 #endif 16 17 #include "ssthandler.h" 14 18 15 19 enum { … … 42 46 class BlockSet; 43 47 44 class ArchExc : public exception{48 class ArchExc { 45 49 public: 46 50 ArchExc(string s) : msg(s) {} … … 75 79 void pushMark(); // push current file position, and "last" blocks 76 80 void popMark(); // pops last file position and "last" blocks 77 81 78 82 void grabLastBlocs(ArcheopsFile const& oldFile); 79 83 84 block_type_modele* aheadBlock(); // internal buffer 80 85 block_type_modele* currentBlock(); // internal buffer 86 bool sameBlockNumAhead(); 81 87 82 88 block_type_param* lastParam(); // saved blocks, including current … … 101 107 // On travaille en MJD = JD - 2450000.0, = 9 octobre 1995 midi UTC 102 108 // 1er juillet 1999 minuit UTC = JD 2451360.5, MJD 1360.5 109 // Ces fonctions travaillent sur le dernier bloc GPS 103 110 int getGPSBlockNum(); 104 111 double getGPSUTC(); // en secondes depuis minuit UTC … … 106 113 double getGPSLat(); // degres, + = NORD 107 114 double getGPSLong(); // degres, + = EST 108 115 109 116 // Bolo 117 int getBoloBlockNum(); 110 118 long getRawBolo(int ibolo, int imesure); // donnee brute, avec seulement soustraction offset 111 119 double getMuVBolo(int ibolo, int imesure); // microvolts, filtre avec filtre carre 112 120 113 121 // SST, gyros, etc 122 int getSSTBlockNum(); 123 void needSSTProcessMask(int mask); 124 long getSSTSignal(int iDiode, int imesure); 114 125 115 126 double getAzimut(int imesure); … … 119 130 double getAlpha(int imesure); 120 131 double getDelta(int imesure); 121 122 132 123 133 protected: 124 134 BlockSet* blockSet; … … 128 138 void saveCurBlock(); 129 139 void postProcessBlock(); 140 141 void swapEntete(block_type_modele* blk); 142 void swapContent(block_type_modele* blk); 130 143 131 144 void computeMJD(string const& fname); 132 133 block_type_modele curBlock; 145 134 146 int curKind; 135 147 int curRawKind; 136 size_t curPos; 148 long curPos; 149 long peekPos; 137 150 size_t fLen; 138 151 FILE* f; -
trunk/Poubelle/archTOI.old/compress.h
r310 r315 6 6 /************************************************************************/ 7 7 8 #ifndef int4 9 #ifdef __alpha 10 #define int4 int 11 #else 12 #define int4 long 13 #endif 14 #endif 8 15 9 16 … … 17 24 /* pour n = 72 en sortie 19 mots = 76 octets */ 18 25 19 void compress_7_1( long* in,long*out,int n,int pasin);20 void decompress_7_1( long* in,long*out,int n);26 void compress_7_1(int4* in,int4*out,int n,int pasin); 27 void decompress_7_1(int4* in,int4*out,int n); 21 28 22 29 … … 29 36 /* pour n = 72 en sortie 11 mots = 44 octets */ 30 37 31 void compress_4_1( long* in,long*out,int n,int pasin);32 void decompress_4_1( long* in,long*out,int n);38 void compress_4_1(int4* in,int4*out,int n,int pasin); 39 void decompress_4_1(int4* in,int4*out,int n); 33 40 34 41 … … 42 49 43 50 44 void compress_3_1( long* in,long*out,int n,int pasin);45 void decompress_3_1( long* in,long*out,int n);51 void compress_3_1(int4* in,int4*out,int n,int pasin); 52 void decompress_3_1(int4* in,int4*out,int n); 46 53 47 54 /************************************************************************/ … … 63 70 64 71 65 void compress_7_2( long* in,long*out,int n,int pasin);66 void decompress_7_2( long* in,long*out,int n);72 void compress_7_2(int4* in,int4*out,int n,int pasin); 73 void decompress_7_2(int4* in,int4*out,int n); 67 74 68 75 … … 78 85 79 86 80 void compress_4_2( long* in,long*out,int n,int pasin);81 void decompress_4_2( long* in,long*out,int n);87 void compress_4_2(int4* in,int4*out,int n,int pasin); 88 void decompress_4_2(int4* in,int4*out,int n); 82 89 83 90 -
trunk/Poubelle/archTOI.old/decompress.c
r310 r315 8 8 //******************************************************************************************* 9 9 10 void decom_3( long val,long* in,long*out,int n);10 void decom_3(int4 val,int4* in,int4*out,int n); 11 11 12 12 #define kmax_ 15 /* valeur maximum de l'exposant */ … … 24 24 25 25 26 void decompress_3_1( long* in,long*out,int n)27 { 28 longval;26 void decompress_3_1(int4* in,int4*out,int n) 27 { 28 int4 val; 29 29 val= *in; 30 30 decom_3(val,in+1,out,n/9); … … 33 33 34 34 35 void decom_3( long val,long* in,long*out,int n)36 { 37 register longR;38 longec1,ec2,ec3,ec4,ec5,ec6,ec7,ec8,ec9;35 void decom_3(int4 val,int4* in,int4*out,int n) 36 { 37 register int4 R; 38 int4 ec1,ec2,ec3,ec4,ec5,ec6,ec7,ec8,ec9; 39 39 int i,k; 40 40 … … 73 73 //******************************************************************************************* 74 74 75 void decom_4( long val,long* in,long*out,int n);76 void decom_4_paire( long val1,long val2,long* in,long*out,int n);75 void decom_4(int4 val,int4* in,int4*out,int n); 76 void decom_4_paire(int4 val1,int4 val2,int4* in,int4*out,int n); 77 77 78 78 #undef kmax_ … … 96 96 97 97 98 void decompress_4_1( long* in,long*out,int n)99 { 100 longval1,val2;98 void decompress_4_1(int4* in,int4*out,int n) 99 { 100 int4 val1,val2; 101 101 val1= ( (*in & 0xffff0000)>>16 ) & 0x0000ffff; 102 102 val2= ( (*in & 0x0000ffff) ) & 0x0000ffff; … … 108 108 109 109 110 void decom_4( long val,long* in,long*out,int n)111 { 112 register longR;113 longec1,ec2,ec3,ec4,ec5,ec6,ec7;110 void decom_4(int4 val,int4* in,int4*out,int n) 111 { 112 register int4 R; 113 int4 ec1,ec2,ec3,ec4,ec5,ec6,ec7; 114 114 int i,k; 115 115 … … 146 146 147 147 148 void decompress_4_2( long* in,long*out,int n)149 { 150 longval1,val2;148 void decompress_4_2(int4* in,int4*out,int n) 149 { 150 int4 val1,val2; 151 151 val1=in[0]; val2=in[1]; 152 152 out[0]=val1; out[1]=val2; … … 155 155 156 156 157 void decom_4_paire( long val1,long val2,long* in,long*out,int n)158 { 159 register longR;160 longec1,ec2,ec3,ec4,ec5,ec6,ec7;157 void decom_4_paire(int4 val1,int4 val2,int4* in,int4*out,int n) 158 { 159 register int4 R; 160 int4 ec1,ec2,ec3,ec4,ec5,ec6,ec7; 161 161 int i,k; 162 162 … … 213 213 /* 4*n ==> n+1 */ 214 214 215 void decom_7( long val,long* in,long*out,int n);216 217 void decompress_7_1( long* in,long*out,int n)218 { 219 longval;215 void decom_7(int4 val,int4* in,int4*out,int n); 216 217 void decompress_7_1(int4* in,int4*out,int n) 218 { 219 int4 val; 220 220 val=*in; 221 221 *out=val; … … 229 229 /* la valeur val est la valeur de reference du point origine */ 230 230 231 void decom_7( long val,long* in,long*out,int n)232 { 233 register longR;234 longec1,ec2,ec3,ec4;231 void decom_7(int4 val,int4* in,int4*out,int n) 232 { 233 register int4 R; 234 int4 ec1,ec2,ec3,ec4; 235 235 int i,k; 236 236 … … 260 260 /********************************************************************************/ 261 261 262 void decom_7_paire( long val1,long val2,long* in,long*out,int n);263 264 void decompress_7_2( long* in,long*out,int n)265 { 266 longval1,val2;262 void decom_7_paire(int4 val1,int4 val2,int4* in,int4*out,int n); 263 264 void decompress_7_2(int4* in,int4*out,int n) 265 { 266 int4 val1,val2; 267 267 val1= ( (*in & 0xffff0000)>>11 ) & 0x001fffe0; 268 268 val2= ( (*in & 0x0000ffff)<<5 ) & 0x001fffe0; … … 272 272 273 273 274 void decom_7_paire( long val1,long val2,long* in,long*out,int n)275 { 276 register longR;277 longec1,ec2,ec3,ec4;274 void decom_7_paire(int4 val1,int4 val2,int4* in,int4*out,int n) 275 { 276 register int4 R; 277 int4 ec1,ec2,ec3,ec4; 278 278 int i,k; 279 279 -
trunk/Poubelle/archTOI.old/toiiter.cc
r310 r315 1 1 #include "toiiter.h" 2 #include "toiinterpolator.h" 2 3 #include <dirent.h> 3 4 … … 17 18 18 19 tBlock0 = -1; 20 21 rawIter = NULL; 22 interp = NULL; 23 lastSample = -1; 24 maxLookAhead = 1000; 19 25 20 26 } … … 32 38 infos = x.infos; 33 39 34 file = new ArcheopsFile(*x.file); 40 if (x.file) 41 file = new ArcheopsFile(*x.file); 42 else 43 file = NULL; 44 45 if (x.rawIter) { 46 rawIter = new TOIIter(*x.rawIter); 47 interp = new TOIInterpolator[infos.size()]; 48 for (int i=0; i<infos.size(); i++) 49 interp[i] = x.interp[i]; 50 } else { 51 rawIter = NULL; 52 interp = NULL; 53 } 54 55 lastSample = x.lastSample; 56 maxLookAhead = x.maxLookAhead; 35 57 } 36 58 37 59 TOIIter::~TOIIter() { 38 60 delete file; 61 delete rawIter; 62 delete[] interp; 39 63 } 40 64 41 65 void TOIIter::Init() { 66 67 // $CHECK$ a deplacer, pour gerer repertoires... 42 68 if (directory == "") { 43 69 file = new ArcheopsFile(fileName); … … 60 86 // mieux en prenant le min de tous les delta_T. 61 87 62 63 #if 0 88 tBlock0 = file->getStartMJD(); 89 64 90 file->pushMark(); 65 91 if (file->lastGPS() || file->nextBlock(block_gps_mask)) { … … 71 97 } 72 98 file->popMark(); 73 #endif 99 100 bool hasInterp = false; 74 101 75 102 trigMask = 0; 76 103 for (vector<info>::iterator i = infos.begin(); i != infos.end(); i++) { 104 if ((*i).interpolated) hasInterp = true; 77 105 if ((*i).triggering) { 78 106 switch ((*i).kind) { … … 86 114 break; 87 115 case azimut: 116 file->needSSTProcessMask(SSTHandler::findPeriod); 88 117 trigMask |= block_sst_mask; 89 118 break; 90 case alpha: 91 case delta: 119 case sstStarZ: 120 case sstStarF: 121 file->needSSTProcessMask(SSTHandler::findStars); 122 trigMask |= block_sst_mask; 123 break; 124 case sstSignal: 125 file->needSSTProcessMask(SSTHandler::rmveOffset); 126 trigMask |= block_sst_mask; 127 break; 128 case alphaAxis: 129 case deltaAxis: 130 case alphaBolo: 131 case deltaBolo: 132 file->needSSTProcessMask(SSTHandler::findAxis); 92 133 trigMask |= block_sst_mask; 93 134 break; … … 101 142 imes = 0; 102 143 } 144 145 if (hasInterp) { 146 rawIter = new TOIIter(*this); 147 interp = new TOIInterpolator[infos.size()]; 148 for (int i=0; i<infos.size(); i++) { 149 rawIter->infos[i].interpolated = false; 150 } 151 delete file; file = NULL; // on ne travaille plus sur le fichier directement... 152 } 103 153 } 104 154 105 155 bool TOIIter::NextFile() { 156 if (rawIter) 157 return rawIter->NextFile(); 158 106 159 if (directory == "") { 107 160 return false; … … 119 172 120 173 bool TOIIter::Next() { 121 174 if (rawIter) { // Delegation pour interpolation 175 // Trouve prochain sample disponible 176 for (int k=0; k<2; k++) { 177 long smp = 2147483647L; 178 for (int i=0; i<infos.size(); i++) { 179 long ss = interp[i].nextSample(lastSample+1); 180 if (ss > 0 && ss < smp) smp=ss; 181 } 182 if (smp != 2147483647L) { 183 lastSample = smp; 184 break; 185 } 186 if (!fetchAhead()) // tout le monde etait en bout de course, 187 return false; // on lit un echantillon, ca suffit, d'ou le k<2 188 } 189 // Verifie que tous les interpolateurs ont assez de donnees pour 190 // trouver la valeur correspondante 191 for (int i=0; i<infos.size(); i++) { 192 //rif (infos[i].interpolated) 193 while (interp[i].needMoreDataFor(lastSample) && 194 rawIter->getSampleIndex() - lastSample < maxLookAhead) 195 if (!fetchAhead()) return false; 196 } 197 198 // On est pret... 199 return true; 200 } 122 201 123 202 // trigger sur info indexee dans bloc bolo ou bloc sst ? … … 129 208 130 209 // soit pas d'info indexee, soit fin bloc courant... 131 132 if (file->nextBlock(trigMask)) { 133 return true; 134 } 135 if (!NextFile()) return false; 136 return file->nextBlock(trigMask); 137 } 138 139 double TOIIter::getTime() { // MJD 210 while (1) { 211 if (file->nextBlock(trigMask)) { 212 while (file->sameBlockNumAhead()) { // tant que meme numero de bloc, on lit 213 if (!file->nextBlock()) { // fin de fichier ? 214 if (NextFile()) file->nextBlock(); 215 else break; 216 } 217 } 218 return true; 219 } 220 if (!NextFile()) return false; 221 } 222 } 223 224 /* double TOIIter::getTime() { // MJD 140 225 // le temps du bloc courant, en secondes 141 226 double dt = file->blockNum() * file->perBlock(); 142 227 return tBlock0 + dt/86400. + imes*file->perEchant()/86400.; 143 228 } 144 145 double TOIIter::getValue(int column) { 146 if (column < 0 || column >= infos.size()) return -1; 229 */ 230 231 bool TOIIter::canGetValue(int column) { 232 if (column < 0 || column >= infos.size()) return false; 233 if (rawIter) { 234 return interp[column].canGet(lastSample); 235 } 147 236 TOIKind kind = infos[column].kind; 148 237 int index = infos[column].index; 149 238 switch (kind) { 239 case sampleNum: 240 case internalTime: 241 case utc: 242 return true; 243 case boloTens: 244 case boloRaw: 245 return file->lastBolo() != NULL; 246 case sstSignal: 247 return file->lastSST() != NULL; 248 case longitude: 249 case latitude: 250 return file->lastGPS() != NULL; 251 case azimut: 252 case alphaAxis: 253 case deltaAxis: 254 return (file->lastGPS() != NULL && file->lastSST() != NULL); 255 } 256 return false; 257 } 258 259 double TOIIter::getValue(int column) { 260 if (column < 0 || column >= infos.size()) return -1; 261 if (rawIter) { 262 if (infos[column].interpolated) 263 return interp[column].getIValue(lastSample); 264 else 265 return interp[column].getEValue(lastSample); 266 } 267 TOIKind kind = infos[column].kind; 268 int index = infos[column].index; 269 switch (kind) { 270 case sampleNum: 271 return file->blockNum() * file->nEchBlock() + imes; 272 case internalTime: 273 return (file->blockNum() * file->nEchBlock() + imes) * file->perEchant(); 274 case utc: 275 /* printf("utc: %d %d %g %g %g\n",file->blockNum(), 276 (file->blockNum() * file->nEchBlock() + imes), 277 file->perEchant(), 278 (file->blockNum() * file->nEchBlock() + imes) * file->perEchant()/86400., 279 tBlock0+(file->blockNum() * file->nEchBlock() + imes) * file->perEchant()/86400.); */ 280 return tBlock0+(file->blockNum() * file->nEchBlock() + imes) * file->perEchant()/86400.; 150 281 case boloTens: 151 282 return file->getMuVBolo(index, imes); 152 283 case boloRaw: 153 284 return file->getRawBolo(index, imes); 285 case sstSignal: 286 return file->getSSTSignal(index, imes); 154 287 case longitude: 155 288 return file->getGPSLong(); // $CHECK$ TBD gerer interpolation (dans file) 156 289 case latitude: 157 290 return file->getGPSLat(); // $CHECK$ TBD gerer interpolation (dans file) 158 291 case azimut: 159 292 return file->getAzimut(imes); 160 case alpha:293 case alphaAxis: 161 294 return file->getAlpha(imes); 162 case delta:295 case deltaAxis: 163 296 return file->getDelta(imes); 164 297 } 165 298 return -1; 166 167 168 299 } 300 301 bool TOIIter::newValue(int column) { 169 302 if (column < 0 || column >= infos.size()) return false; 170 303 TOIKind kind = infos[column].kind; 171 304 switch (kind) { 305 case sampleNum: 306 case internalTime: 307 case utc: 308 return true; 172 309 case boloTens: 173 return file->block Kind() == block_bolo;310 return file->blockNum() == file->getBoloBlockNum(); 174 311 case boloRaw: 175 return file->blockKind() == block_bolo; 312 return file->blockNum() == file->getBoloBlockNum(); 313 case sstSignal: 314 return file->blockNum() == file->getSSTBlockNum(); 176 315 case longitude: 177 return file->block Kind() == block_gps;316 return file->blockNum() == file->getGPSBlockNum() && imes==0; 178 317 case latitude: 179 return file->block Kind() == block_gps;180 181 return file->blockKind() == block_sst || file->blockKind() == block_bolo;182 case alpha:183 return file->blockKind() == block_sst || file->blockKind() == block_bolo;184 case delta:185 return file->blockKind() == block_sst || file->blockKind() == block_bolo;318 return file->blockNum() == file->getGPSBlockNum() && imes==0; 319 case azimut: 320 return true; // $CHECK$ with SSTHandler 321 case alphaAxis: 322 return true; // $CHECK$ with SSTHandler 323 case deltaAxis: 324 return true; // $CHECK$ with SSTHandler 186 325 } 187 326 return false; 188 189 190 191 return !newValue(column);192 193 194 bool TOIIter::interpValue(int /*column*/) {195 return false; // $CHECK$ TBD gerer interpolation196 197 198 327 } 328 329 bool TOIIter::extendValue(int column) { 330 return (!infos[column].interpolated && !newValue(column)); 331 } 332 333 bool TOIIter::interpValue(int column) { 334 return (infos[column].interpolated && !newValue(column)); 335 } 336 337 TOIKind TOIIter::getKind(int column) { 199 338 if (column < 0 || column >= infos.size()) return (TOIKind)-1; 200 339 return infos[column].kind; 201 202 203 340 } 341 342 int TOIIter::getIndex(int column) { 204 343 if (column < 0 || column >= infos.size()) return (TOIKind)-1; 205 344 return infos[column].index; 206 } 345 } 346 347 int TOIIter::getColTOI(TOIKind kind, int index) { 348 for (int i=0; i<infos.size(); i++) 349 if (infos[i].kind == kind && infos[i].index == index) 350 return i; 351 return -1; 352 } 353 354 bool TOIIter::canGetTOI(TOIKind kind, int index) { 355 int col = getColTOI(kind, index); 356 if (col<0) return false; 357 return canGetValue(col); 358 } 359 360 double TOIIter::getTOI(TOIKind kind, int index) { 361 int col = getColTOI(kind, index); 362 if (col<0) return -9.e99; 363 return getValue(col); 364 } 365 207 366 208 int TOIIter::getSampleIndex() {367 int TOIIter::getBlockSampleIndex() { 209 368 return imes; 210 } 369 } 370 371 int TOIIter::getSampleIndex() { 372 return file->blockNum() * file->nEchBlock() + imes; 373 } 374 375 bool TOIIter::fetchAhead() { // Seulement si delegation 376 if (!rawIter) return false; 377 if (!rawIter->Next()) return false; 378 long sample = rawIter->getSampleIndex(); 379 for (int i=0; i<infos.size(); i++) { 380 if (rawIter->canGetValue(i) && rawIter->newValue(i)) 381 interp[i].enterValue(rawIter->getValue(i), sample); 382 } 383 return true; 384 } 385 -
trunk/Poubelle/archTOI.old/toiiter.h
r310 r315 9 9 10 10 enum TOIKind { 11 sampleNum, // Numero d'echantillon (timer interne transputer) 12 internalTime, // temps transputer depuis debut manip, en secondes. 13 utc, // UTC (en jours, MJD = JD - 2450000). index=0 : premier bloc GPS. 1: + sioux. 11 14 boloTens, // tension en microVolts, filtree avec filtre carre indexe par bolometre 12 15 boloRaw, // tension brute, non filtree indexe par bolometre 13 longitude, // ballon 14 latitude, // ballon 16 sstSignal, // signal brut SST, indice = diode 17 sstStarZ, // numero de diode d'une eventuelle etoile, i=etoile 0..n 18 sstStarF, // flux d'une eventuelle etoile, -1 si moins de i+1 etoiles 19 longitude, // position ballon 20 latitude, // position ballon 21 tsid, // temps sideral en secondes 15 22 azimut, // a preciser, reconstruit SST, magneto, autres... 16 17 alpha, // sur le ciel, indexe par bolometre 18 delta // sur le ciel, indexe par bolometre 19 23 alphaAxis, // 24 deltaAxis, // 25 alphaBolo, // sur le ciel, indexe par bolometre 26 deltaBolo // sur le ciel, indexe par bolometre 27 20 28 }; 21 29 22 30 class TOIInterpolator; 23 31 24 32 class TOIIter { 25 33 public: 26 TOIIter(TOIIter const&); 34 TOIIter(TOIIter const&); // $CHECK$ prevoir operator = ? 27 35 ~TOIIter(); 28 36 bool Next(); 29 37 30 double getTime(); // MJD31 double getValue(int column);32 bool newValue(int column); // a juste change ?33 bool extendValue(int column); // une valeur plus ancienne, etendue ?34 bool interpValue(int column); // une valeur interpolee avec valeur future ?38 bool canGetValue(int column); // data is available for that... 39 double getValue(int column); 40 bool newValue(int column); // a juste change ? 41 bool extendValue(int column); // une valeur plus ancienne, etendue ? 42 bool interpValue(int column); // une valeur interpolee avec valeur future ? 35 43 TOIKind getKind(int column); 36 int getIndex(int column); // si plusieurs, exemple, tension bolo 244 int getIndex(int column); // si plusieurs, exemple, tension bolo 2 37 45 38 int getSampleIndex(); // numero d'echantillon dans dernier bloc bolo 46 bool canGetTOI(TOIKind kind, int index=0); 47 double getTOI(TOIKind kind, int index=0); 48 49 50 int getBlockSampleIndex(); // numero d'echantillon dans dernier bloc bolo 51 int getSampleIndex(); // numero d'echantillon 39 52 40 53 block_type_param* lastParam(); … … 78 91 }; 79 92 93 int getColTOI(TOIKind kind, int index=0); 94 80 95 long trigMask; 81 96 … … 84 99 friend class TOISvr; 85 100 101 // Gestion de l'interpolation, par delegation a un autre iterateur 102 TOIIter* rawIter; // iterateur sans interpolation, qui avance avec retard 103 // en bufferisant les valeurs. S'il existe, on lui delegue 104 // toutes les operations agissant sur le fichier. 105 TOIInterpolator* interp; // interpolateurs pour stocker les valeurs 106 long lastSample; // last interpolated sample 107 long maxLookAhead; 108 bool fetchAhead(); // avance d'une TOI en nourrissant les interpolateurs 109 86 110 private: 87 111 };
Note:
See TracChangeset
for help on using the changeset viewer.