Changeset 534 in Sophya for trunk


Ignore:
Timestamp:
Nov 1, 1999, 10:59:29 AM (26 years ago)
Author:
ansari
Message:

V2

Location:
trunk/Poubelle/archTOI.old
Files:
50 added
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/Poubelle/archTOI.old/archeopsfile.cc

    r442 r534  
    55#define utilitaires_de_block_archeops
    66#include "archeopsfile.h"
    7 #include "gyrohandler.h"
    87
    98extern "C" {
     
    4342  block_type_modele         curBlock;
    4443  block_type_modele         peekBlock;
    45  
    46   SSTHandler   sstHandler;
    47   GyroHandler  gyroHandler;
    48   GPSParser    gpsParser;
    4944};
    5045
     
    8984
    9085BlockSet::BlockSet(BlockSet const& x)
    91 : sstHandler(x.sstHandler), gyroHandler(x.gyroHandler)
    9286{
    9387  lastParam      = NULL;
     
    255249  }
    256250}
     251
     252#ifdef __MWERKS__
     253#pragma mark -
     254#endif
     255#ifdef __MWERKS__
     256#pragma mark -
     257#endif
     258
    257259
    258260ArcheopsFile::ArcheopsFile(string const& fname) {
     
    404406}
    405407
    406 #define  bitmot                 24              // nb de bit horloge dans un mot ADC
    407 
    408 double ArcheopsFile::perEchant() { // periode d'echantillonage pour le dernier bloc reglage
    409   double p,f1,f2,f3;
    410   int pp;
    411   if (!lastReglage()) return -1;
    412   pp=lastReglage()->reglage.horloge.periode;
    413   p=pp/5.;
    414   f1=1000/p;f2=f1/bitmot;f3=f2*1000./(double)(lastReglage()->reglage.horloge.nb_mesures);
    415   return 0.5/f3;                                        //  2 fois la frequence de modulation
    416 }
    417 
    418 double ArcheopsFile::perBlock() {  // duree (en secondes) correspondant a un bloc bolo
    419   return perEchant() * (double)lastParam()->param.n_per_block*2.;
    420 }
    421 
    422 int ArcheopsFile::nEchBlock() {  // Nb d'echantillons dans un bloc
    423   return lastParam()->param.n_per_block*2;
    424 }
    425408
    426409string  ArcheopsFile::blockKdName() {
     
    448431}
    449432
    450 
    451 block_type_param* ArcheopsFile::lastParam() {
    452   return blockSet->lastParam;
    453 }
    454 block_type_journal* ArcheopsFile::lastJournal() {
    455   return blockSet->lastJournal;
    456 }
    457 block_type_reglage* ArcheopsFile::lastReglage() {
    458   return blockSet->lastReglage;
    459 }
    460 block_type_dilution* ArcheopsFile::lastDilution() {
    461   return blockSet->lastDilution;
    462 }
    463 block_type_gps* ArcheopsFile::lastGPS() {
    464   return blockSet->lastGPS;
    465 }
    466 block_type_une_periode* ArcheopsFile::lastUnePeriode() {
    467   return blockSet->lastUnePeriode;
    468 }
    469 block_type_synchro_sol* ArcheopsFile::lastSynchroSol() {
    470   return blockSet->lastSynchroSol;
    471 }
    472 block_type_pointage_sol* ArcheopsFile::lastPointageSol() {
    473   return blockSet->lastPointageSol;
    474 }
    475 block_type_bolo* ArcheopsFile::lastBolo() {
    476   return blockSet->lastBolo;
    477 }
    478 block_type_bolo* ArcheopsFile::llastBolo() {
    479   return blockSet->llastBolo;
    480 }
    481 block_type_gyro* ArcheopsFile::lastGyro() {
    482   return blockSet->lastGyro;
    483 }
    484 block_type_sst* ArcheopsFile::lastSST() {
    485   return blockSet->lastSST;
    486 }
    487 block_type_bolo_comprime* ArcheopsFile::lastBoloComp() {
    488   return blockSet->lastBoloComp;
    489 }
    490 block_type_gyro_comprime* ArcheopsFile::lastGyroComp() {
    491   return blockSet->lastGyroComp;
    492 }
    493 block_type_sst_comprime* ArcheopsFile::lastSSTComp() {
    494   return blockSet->lastSSTComp;
    495 }
    496 
    497433void ArcheopsFile::forceBlock(block_type_modele* blk) {
    498434  blockSet->setBloc(*blk);
     435}
     436
     437long ArcheopsFile::searchNextBlock(long pos) {
     438  static char* buffer = 0;
     439  static int4  debswp = debut_block_mesure;
     440  static int4  longmax = taille_maxi_block_archeops*20;
     441  if (!buffer) {
     442    buffer = new char[longmax];
     443#ifdef SWAP
     444    bswap4(&debswp);
     445#endif
     446  }
     447  long read = longmax;
     448  while (read == longmax) {
     449    fseek(f,pos,SEEK_SET);
     450    read = fread(buffer,1,longmax,f);
     451    //if (read<taille_maxi_block_archeops*2) return -1;
     452    // EA 150999 changed i+=4 to i++ -> unaligned, but can lose bytes in flight recorder
     453#ifndef __DECCXX
     454#define __unaligned
     455#endif
     456     for (long i=4; i<read; i++) {
     457      if (*(__unaligned int4*)(buffer+i) == debswp) {
     458        cout << "trying to skip " << i << " bytes to pos="<<pos+i << endl;
     459            return pos+i;
     460      }
     461    }
     462    pos += read;
     463  }
     464  cout << "cannot find block start" << endl;
     465  return -1;
    499466}
    500467
     
    531498       memcpy(&blockSet->curBlock,&blk2,sizeof(blk2));
    532499       curKind = block_bolo;
     500       postProcessBlock();
    533501       break;
    534502     }
    535503     case block_sst_comprime: { 
    536504       blockSet->setRawBloc(blockSet->curBlock);
    537        if (!blockSet->sstHandler.NeedBlocks()) break; // inutile de decompresser
    538505       block_type_sst blk2;
    539506       block_type_sst_comprime* blk = (block_type_sst_comprime*) &blockSet->curBlock;
     
    566533       memcpy(&blockSet->curBlock,&blk2,sizeof(blk2));
    567534       curKind = block_sst;
    568        //       cout << "process " << numero_block(&blockSet->curBlock) << "\n";
    569        blockSet->sstHandler.ProcessBlock((block_type_sst*)&blockSet->curBlock);
     535       postProcessBlock();
    570536       break;
    571537     }
    572      case block_sst : {
    573        //       cout << "process " << numero_block(&blockSet->curBlock) << "\n";
    574        blockSet->sstHandler.ProcessBlock((block_type_sst*)&blockSet->curBlock);
    575      }
    576      case block_gyro : {
    577        blockSet->gyroHandler.ProcessBlock((block_type_gyro*)&blockSet->curBlock);
    578      }
    579      case block_gps : {
    580        blockSet->gpsParser.ProcessBlock((block_type_gps*)&blockSet->curBlock);
    581      }
    582   }
    583 }
     538// Delegation a tous les producers qui traitent des blocs bruts
     539  }
     540}
     541
     542
     543
     544#ifdef __MWERKS__
     545#pragma mark -
     546#endif
     547
     548block_type_param* ArcheopsFile::lastParam() {
     549  return blockSet->lastParam;
     550}
     551block_type_journal* ArcheopsFile::lastJournal() {
     552  return blockSet->lastJournal;
     553}
     554block_type_reglage* ArcheopsFile::lastReglage() {
     555  return blockSet->lastReglage;
     556}
     557block_type_dilution* ArcheopsFile::lastDilution() {
     558  return blockSet->lastDilution;
     559}
     560block_type_gps* ArcheopsFile::lastGPS() {
     561  return blockSet->lastGPS;
     562}
     563block_type_une_periode* ArcheopsFile::lastUnePeriode() {
     564  return blockSet->lastUnePeriode;
     565}
     566block_type_synchro_sol* ArcheopsFile::lastSynchroSol() {
     567  return blockSet->lastSynchroSol;
     568}
     569block_type_pointage_sol* ArcheopsFile::lastPointageSol() {
     570  return blockSet->lastPointageSol;
     571}
     572block_type_bolo* ArcheopsFile::lastBolo() {
     573  return blockSet->lastBolo;
     574}
     575block_type_bolo* ArcheopsFile::llastBolo() {
     576  return blockSet->llastBolo;
     577}
     578block_type_gyro* ArcheopsFile::lastGyro() {
     579  return blockSet->lastGyro;
     580}
     581block_type_sst* ArcheopsFile::lastSST() {
     582  return blockSet->lastSST;
     583}
     584block_type_bolo_comprime* ArcheopsFile::lastBoloComp() {
     585  return blockSet->lastBoloComp;
     586}
     587block_type_gyro_comprime* ArcheopsFile::lastGyroComp() {
     588  return blockSet->lastGyroComp;
     589}
     590block_type_sst_comprime* ArcheopsFile::lastSSTComp() {
     591  return blockSet->lastSSTComp;
     592}
     593
     594#ifdef __MWERKS__
     595#pragma mark -
     596#endif
     597
     598
    584599
    585600void ArcheopsFile::saveCurBlock() {
     
    680695#endif
    681696
    682 long ArcheopsFile::searchNextBlock(long pos) {
    683   static char* buffer = 0;
    684   static int4  debswp = debut_block_mesure;
    685   static int4  longmax = taille_maxi_block_archeops*20;
    686   if (!buffer) {
    687     buffer = new char[longmax];
    688 #ifdef SWAP
    689     bswap4(&debswp);
    690 #endif
    691   }
    692   size_t read = longmax;
    693   while (read == longmax) {
    694     fseek(f,pos,SEEK_SET);
    695     read = fread(buffer,1,longmax,f);
    696     //if (read<taille_maxi_block_archeops*2) return -1;
    697     // EA 150999 changed i+=4 to i++ -> unaligned, but can lose bytes in flight recorder
    698 #ifndef __DECCXX
    699 #define __unaligned
    700 #endif
    701      for (size_t i=4; i<read; i++) {
    702       if (*(__unaligned int4*)(buffer+i) == debswp) {
    703         cout << "trying to skip " << i << " bytes to pos="<<pos+i << endl;
    704         return pos+i;
    705       }
    706     }
    707     pos += read;
    708   }
    709   cout << "cannot find block start" << endl;
    710   return -1;
    711 }
    712 
    713 
     697#ifdef __MWERKS__
     698#pragma mark -
     699#endif
    714700
    715701
     
    762748}
    763749
    764 void ArcheopsFile::setUTCOffset(int UTCOffset) {
     750void ArcheopsFile::setUTCOffset(double UTCOffset) {
    765751  utcOffset = UTCOffset;
    766752  startMJD = rawMJD - utcOffset/24.;
     
    771757}
    772758
    773 int ArcheopsFile::getBoloBlockNum() {
    774   if (!lastBolo()) return -1;
    775   return numero_block(lastBolo());
    776 }
    777 
    778 int ArcheopsFile::getBoloCompBlockNum() {
    779   if (!lastBolo()) return -1;
    780   return numero_block(lastBoloComp());
    781 }
    782 
    783 int ArcheopsFile::getReglageBlockNum() {
    784   if (!lastReglage()) return -1;
    785   return numero_block(lastReglage());
    786 }
    787 
    788 int ArcheopsFile::getDilutionBlockNum() {
    789   if (!lastDilution()) return -1;
    790   return numero_block(lastDilution());
    791 }
    792 
    793 
    794 int ArcheopsFile::getSSTBlockNum() {
    795   if (!lastSST()) return -1;
    796   return numero_block(lastSST());
    797 }
    798 
    799 int ArcheopsFile::getSSTCompBlockNum() {
    800   if (!lastSST()) return -1;
    801   return numero_block(lastSSTComp());
    802 }
    803 
    804 
    805 
    806 int ArcheopsFile::getGyroBlockNum() {
    807   if (!lastGyro()) return -1;
    808   return numero_block(lastGyro());
    809 }
    810 
    811 
    812 // GPS
    813 // $GPGGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e,q,ss,y.y,a.a,z,
    814 
    815 
    816 int ArcheopsFile::getGPSBlockNum() {
    817   if (!lastGPS()) return -1;
    818   return numero_block(lastGPS());
    819 }
    820 
    821 double ArcheopsFile::getGPSUTC() {  // en secondes depuis minuit UTC jour courant
    822   if (!lastGPS()) return -9.e99;
    823   return blockSet->gpsParser.getUTC();
    824 }
    825 
    826 double ArcheopsFile::getGPSMJD() {  // modified julian day du dernier bloc GPS, JD - 2450000
    827   double t = getGPSUTC()/86400. - 0.5;
    828   if (t<0) return t;
    829   if (t > (startMJD - int(startMJD))) {
    830     return int(startMJD) + t;
    831   } else {
    832     return int(startMJD) + 1. + t;
    833   }
    834 }
    835 
    836 double ArcheopsFile::getGPSLat() {  // degres, +  = NORD
    837   if (!lastGPS()) return -9.e99;
    838   return blockSet->gpsParser.getLatitude();
    839 }
    840 
    841 
    842 double ArcheopsFile::getGPSLong() { // degres, +  = EST
    843   if (!lastGPS()) return -9.e99;
    844   return blockSet->gpsParser.getLongitude();
    845 }
    846 
    847 double ArcheopsFile::getGPSAlt() { // meters from sea level
    848   if (!lastGPS()) return -9.e99;
    849   return blockSet->gpsParser.getAltitude();
    850 }
    851 
    852 bool ArcheopsFile::hasGPSTime() {
    853   if (!lastGPS()) return false;
    854  // return blockSet->gpsParser.hasGPSTime();
    855   return blockSet->gpsParser.hasTime();
    856 }
    857 
    858 bool ArcheopsFile::hasGPSPos() {
    859   if (!lastGPS()) return false;
    860   return blockSet->gpsParser.hasPosition();
    861 }
    862 
    863 bool ArcheopsFile::hasGPSAlt() {
    864   if (!lastGPS()) return false;
    865   return blockSet->gpsParser.hasAltitude();
    866 }
    867 
    868 
    869 // Bolo
    870 #define  val_DS(j,i)  (blk->data_bolo[j][i]&0x1fffff)
    871 
    872 
    873 double ArcheopsFile::getBoloRawMuV(int ibolo, int imesure) {    // microvolts bruts
    874   block_type_bolo* blk = imesure >= 0 ? lastBolo() : llastBolo();
    875   if (imesure < 0) imesure += nEchBlock();
    876   block_type_reglage* reglage = lastReglage();
    877   block_type_param*   param = lastParam();
    878   if (!blk) return 0;
    879   if (!reglage) return 0;
    880   if (!param) return 0;
    881 
    882   int s = imesure % 2 ? 1 : -1;
    883    
    884   return s*bolo_muV(&param->param, &reglage->reglage, val_DS(ibolo,imesure), ibolo);
    885 }
    886 
    887 double ArcheopsFile::getBoloRawMuVCN(int ibolo, int imesure) {   
    888   // Si pas bloc comprime -> 1 bit
    889   int lastbit = 1;
    890   if (!(lastBoloComp() == NULL) &&
    891       (numero_block(lastBoloComp()) != numero_block(lastBolo()))) {
    892     unsigned int4* data = lastBoloComp()->data_bolo[ibolo];
    893     // Les deux premieres valeurs sont codees directement...
    894     if (imesure>=2) {
    895       int iExp = (imesure-2)/4 + 1;
    896       int expo = data[iExp] & 0xf;
    897       lastbit = 1 << expo;
    898     }
    899   }
    900   block_type_reglage* reglage = lastReglage();
    901   block_type_param*   param = lastParam();
    902   if (!reglage) return 0;
    903   if (!param) return 0;
    904   double noise = (
    905     bolo_muV(&param->param, &reglage->reglage, lastbit, ibolo) -
    906     bolo_muV(&param->param, &reglage->reglage, 0, ibolo)) /2.;
    907 
    908   return noise;
    909 }
    910 
    911 
    912 
    913 def_gains
    914 
    915 double ArcheopsFile::getBoloMuV(int ibolo, int imesure) { // microvolts, filtre avec filtre carre
    916   double y = (getBoloRawMuV(ibolo, imesure-1) + getBoloRawMuV(ibolo, imesure))/2.;
    917   return y;
    918 }
    919 
    920 double ArcheopsFile::getBoloMuV2(int ibolo, int imesure) { // microvolts, filtre
    921   // On commence par trouver la valeur d'offset, en fittant une droite sur les soustractions
    922   if (!lastBolo() || !llastBolo()) return 0;
    923   //block_type_reglage* reglage = lastReglage();
    924   //block_type_param*   param = lastParam();
    925   //if (!reglage) return 0;
    926   //if (!param) return 0;
    927   double sumx=0, sumy=0, sumxy=0, sumx2=0;
    928   int n=20;
    929   int s = imesure % 2 ? 1 : -1;
    930   for (int i=1; i<=n; i++) {
    931     double x = -i;
    932     double y = s*(getBoloRawMuV(ibolo, imesure-i+1) - getBoloRawMuV(ibolo, imesure-i))/2;
    933     s = -s;
    934     sumx += x;
    935     sumy += y;
    936     sumxy += x*y;
    937     sumx2 += x*x;
    938   }
    939   double a = (sumxy/n - (sumx/n)*(sumy/n)) / (sumx2/n - (sumx/n)*(sumx/n));
    940   double b = (sumy/n) - a*(sumx/n);
    941   s = imesure % 2 ? 1 : -1;
    942   double y = getBoloRawMuV(ibolo, imesure);
    943   y = y-s*b;
    944   return y;
    945 }
    946 
    947 /*
    948 double ArcheopsFile::getBoloMuV2(int ibolo, int imesure) { // microvolts, filtre
    949   // On commence par trouver la valeur d'offset, en fittant une droite sur les soustractions
    950   if (!lastBolo() || !llastBolo()) return 0;
    951   double sumx=0, sumy=0, sumxy=0, sumx2=0;
    952   int n=20;
    953   int s = (imesure-n) % 2 ? 1 : -1;
    954   static double* data = NULL;
    955   if (!data) data = new double[n+1];
    956   for (int i=0; i<=n; i++) {
    957     data[i] = getBoloRawMuV(ibolo, imesure-n+i);
    958   }
    959   for (int i=0; i<=n; i++) {
    960    
    961   }
    962   for (int i=1; i<=n; i++) {
    963     double x = -i;
    964     double y = s*(getBoloRawMuV(ibolo, imesure-i+1) - getBoloRawMuV(ibolo, imesure-i))/2;
    965     s = -s;
    966     sumx += x;
    967     sumy += y;
    968     sumxy += x*y;
    969     sumx2 += x*x;
    970   }
    971   double a = (sumxy/n - (sumx/n)*(sumy/n)) / (sumx2/n - (sumx/n)*(sumx/n));
    972   double b = (sumy/n) - a*(sumx/n);
    973   s = imesure % 2 ? 1 : -1;
    974   double y = getBoloRawMuV(ibolo, imesure);
    975   y = y-s*b;
    976   return y;
    977 }
    978 */
    979 
    980 
    981 double ArcheopsFile::getGainAmpli(int ibolo) {
    982      return gain_ampli(lastReglage()->reglage.bolo[ibolo]);
    983 }
    984 
    985 
    986 double ArcheopsFile::getDACV(int ibolo) {
    987   block_type_reglage* reglage = lastReglage();
    988   block_type_param*   param = lastParam();
    989   if (!reglage) return 0;
    990   if (!param) return 0;
    991   return DAC_muV(&param->param, &reglage->reglage, ibolo);
    992 }
    993 
    994 double ArcheopsFile::getDACI(int ibolo) {
    995   block_type_reglage* reglage = lastReglage();
    996   block_type_param*   param = lastParam();
    997   if (!reglage) return 0;
    998   if (!param) return 0;
    999   return DAC_muA(&param->param, &reglage->reglage, ibolo);
    1000 }
    1001 
    1002 double ArcheopsFile::getBoloMuV2T(int ibolo, int imesure) {
    1003   return getDACV(ibolo) - getBoloMuV2(ibolo, imesure) ;
    1004 }
    1005 
    1006 double ArcheopsFile::getBoloRes(int ibolo, int imesure) {
    1007   double i = getDACI(ibolo); // microAmps
    1008   double v = getBoloMuV2T(ibolo, imesure); // microVolts
    1009   double r = v/i; // Ohms
    1010   return r;
    1011 }
    1012 
    1013 double ArcheopsFile::getBoloTemp(int ibolo, int imesure) {
    1014   double r = getBoloRes(ibolo, imesure);
    1015   block_type_reglage* reglage = lastReglage();
    1016   block_type_param*   param = lastParam();
    1017   if (!reglage) return 0;
    1018   if (!param) return 0;
    1019   return bolo_temp(&param->param, &reglage->reglage, r, ibolo);
    1020 }
    1021 
    1022 
    1023 // Dilution
    1024 
    1025 int4 ArcheopsFile::getADCDil(int iADC) {
    1026   block_type_dilution* blk = lastDilution();
    1027   if (!blk) return 0;
    1028   if (iADC < 0 || iADC > 47) return 0;
    1029   return blk->ADC_dil[iADC];
    1030 }
    1031 
    1032 int4 ArcheopsFile::getSwitchDil() {
    1033   block_type_dilution* blk = lastDilution();
    1034   if (!blk) return 0;
    1035   return blk->switch_dil;
    1036 }
    1037 
    1038 
    1039 // SST, gyros...
    1040 
    1041 void ArcheopsFile::needSSTProcessMask(int mask) {
    1042   blockSet->sstHandler.NeedProcess(mask);
    1043 }
    1044 
    1045 long ArcheopsFile::getSSTSignal(int idiode, int imesure) {
    1046   return blockSet->sstHandler.getSignal(imesure, idiode);
    1047 }
    1048 
    1049 long ArcheopsFile::getSSTRawSignal(int idiode, int imesure) {
    1050   return blockSet->sstHandler.getRawSignal(imesure, idiode);
    1051 }
    1052 
    1053 double ArcheopsFile::getSSTSignalCN(int idiode, int imesure) {
    1054   return getSSTRawSignalCN(SSTHandler::getDiodPermut(idiode),imesure);
    1055 }
    1056 
    1057 double ArcheopsFile::getSSTRawSignalCN(int ichannel, int imesure) {
    1058   // Si pas bloc comprime -> 0.5
    1059   if (lastSSTComp() == NULL) return .5;
    1060   if (numero_block(lastSSTComp()) != numero_block(lastSST())) return 0.5;
    1061  
    1062   // Attention, on ne transmet pas les canaux 0 et 4....
    1063   if (ichannel == 0 || ichannel == 4) return 0;
    1064   int i = ichannel - 1;
    1065   if (i >= 4) i--;
    1066   unsigned int4* data = lastSSTComp()->sst[i];
    1067   // Les deux premieres valeurs sont codees directement...
    1068   if (imesure<2) return 0.5;
    1069   int iExp = (imesure-2)/7 + 1;
    1070   int expo = data[iExp] & 0xf;
    1071   int noise = 1 << expo;
    1072   return noise/2.;
    1073 }
    1074 
    1075 
    1076 
    1077 double ArcheopsFile::getSSTStarZ(int istar, int imesure) {
    1078   return blockSet->sstHandler.getStarZ(imesure+getSSTBlockNum()*nb_per_block*2, istar);
    1079 }
    1080 
    1081 double ArcheopsFile::getSSTStarF(int istar, int imesure) {
    1082   return blockSet->sstHandler.getStarF(imesure+getSSTBlockNum()*nb_per_block*2, istar);
    1083 }
    1084 
    1085 double ArcheopsFile::getSSTStarT(int istar, int imesure) {
    1086   return blockSet->sstHandler.getStarTime(imesure+getSSTBlockNum()*nb_per_block*2, istar);
    1087 }
    1088 
    1089 int ArcheopsFile::getNumbStar(int imesure) {
    1090   return blockSet->sstHandler.getNumbStar(imesure+getSSTBlockNum()*nb_per_block*2);
    1091 }
    1092 
    1093 long ArcheopsFile::getGyroRaw(int igyro, int imesure) {   
    1094   return blockSet->gyroHandler.getRawSignal(imesure, igyro);
    1095 }
    1096 
    1097 double ArcheopsFile::getGyroTens(int igyro, int imesure) {   
    1098   return blockSet->gyroHandler.getSignal(imesure, igyro);
    1099 }
    1100 
    1101 double ArcheopsFile::getGyroSpeed(int igyro, int imesure) {   
    1102   return blockSet->gyroHandler.getSpeed(imesure, igyro);
    1103 }
    1104 
    1105 
    1106 
    1107 
    1108 
    1109 // $CHECK$ TBD
    1110 
    1111 
    1112 double ArcheopsFile::getAzimut(int /*imesure*/) {return 0;}
    1113 double ArcheopsFile::getPendDirect(int /*imesure*/) {return 0;}
    1114 double ArcheopsFile::getPendOrth(int /*imesure*/) {return 0;}
    1115 double ArcheopsFile::getAlphaAxis(int /*imesure*/) {return 0;}
    1116 double ArcheopsFile::getDeltaAxis(int /*imesure*/) {return 0;}
  • trunk/Poubelle/archTOI.old/archeopsfile.h

    r436 r534  
    99#include <stack>
    1010
     11using namespace std;
    1112
    12 #ifndef nb_max_bolo
    13 #define _archeops               //  Acquisition Archeops (avec transputer)
    14 #define programme
    15 extern "C" {
    16 #include "archeops.h"
    17 }
    18 #endif
    19 
    20 #include "ssthandler.h"
    21 #include "gpsparser.h"
     13#include "ark.h"
     14#include "archexc.h"
    2215
    2316enum {
     
    5043class BlockSet;
    5144
    52 class ArchExc {
    53 public:
    54   ArchExc(string s) : msg(s) {}
    55   string Msg() {return msg;}
    56 protected:
    57   string msg;
    58 };
    5945
    6046class ArcheopsFile {
     
    6450  virtual ~ArcheopsFile();
    6551 
    66   void setUTCOffset(int UTCOffset=2); // StartMJD : decodage a partir du nom du bloc...
     52  void setUTCOffset(double UTCOffset=2); // StartMJD : decodage a partir du nom du bloc...
    6753  double getStartMJD();
    6854 
     
    7662  string blockRawKdName();
    7763  string filename() {return fn;}
    78  
    79   double perEchant(); // periode d'echantillonage pour le dernier bloc reglage
    80   double perBlock();  // duree (en secondes) correspondant a un bloc bolo
    81                       // utilise infos dernier bloc param et dernier bloc reglage.
    82   int nEchBlock(); // Nb d'echantillons dans un bloc bolo
    8364 
    8465 
     
    10990 
    11091  void forceBlock(block_type_modele* blk);
    111  
    112   // Decodage des derniers blocs..
    113  
    114   // GPS
    115   // On travaille en MJD = JD - 2450000.0, = 9 octobre 1995 midi UTC
    116   // 1er juillet 1999 minuit UTC = JD 2451360.5,   MJD 1360.5
    117   // Ces fonctions travaillent sur le dernier bloc GPS
    118   int getGPSBlockNum();
    119   bool   hasGPSTime();
    120   bool   hasGPSPos();
    121   bool   hasGPSAlt();
    122   double getGPSUTC();  // en secondes depuis minuit UTC
    123   double getGPSMJD();  // modified julian day du dernier bloc GPS, JD - 2450000
    124   double getGPSLat();  // degres, +  = NORD
    125   double getGPSLong(); // degres, +  = EST
    126   double getGPSAlt();  // meters from sea level
    12792   
    128   // Bolo
    129   int getReglageBlockNum();
    130   int getBoloBlockNum();
    131   int getBoloCompBlockNum();
    132   double getBoloRawMuV(int ibolo, int imesure);   // donnee brute en microvolts et signe change.
    133   double getBoloRawMuVCN(int ibolo, int imesure);  // bruit de compression, en microVolts
    134   double getBoloMuV(int ibolo, int imesure); // microvolts, filtre avec filtre carre
    135   double getBoloMuV2(int ibolo, int imesure); // microvolts, filtre +sioux
    136   double getGainAmpli(int ibolo);
    137   double getDACV(int ibolo); // offset en microvolt
    138   double getDACI(int ibolo); // courant en microAmps
    139   double getBoloMuV2T(int ibolo, int imesure); // avec soustraction dacV
    140   double getBoloRes(int ibolo, int imesure); // Ohms
    141   double getBoloTemp(int ibolo, int imesure); // K
    142  
    143   // Dilution
    144   int getDilutionBlockNum();
    145   int4 getADCDil(int iADC);
    146   int4 getSwitchDil();
    147  
    148   // SST, gyros, etc
    149   int getSSTBlockNum();
    150   int getSSTCompBlockNum();
    151   void needSSTProcessMask(int mask);
    152   long getSSTRawSignal(int iDiode, int imesure);
    153   long getSSTSignal(int iDiode, int imesure);
    154   double getSSTRawSignalCN(int iDiode, int imesure);
    155   double getSSTSignalCN(int iDiode, int imesure);
    156   double getSSTStarZ(int iStar, int imesure);
    157   double getSSTStarF(int iStar, int imesure);
    158   double getSSTStarT(int iStar, int imesure);
    159   int getNumbStar(int imesure);
    160  
    161   int getGyroBlockNum();
    162   long getGyroRaw(int iGyro, int imesure);
    163   double getGyroTens(int iGyro, int imesure);
    164   double getGyroSpeed(int iGyro, int imesure);
    165  
    166   double getAzimut(int imesure);
    167   double getPendDirect(int imesure);
    168   double getPendOrth(int imesure);
    169  
    170   double getAlphaAxis(int imesure);
    171   double getDeltaAxis(int imesure);
    172  
    17393  static double decodeMJD(string const& dateString); // sans tenir compte de TU-TLeg
    17494   
     
    17696  BlockSet*                 blockSet;
    17797  stack<BlockSet*>          blockStack;
    178   stack<size_t>             fposStack;
     98  stack<long>               fposStack;
    17999 
    180100  void saveCurBlock();
     
    193113  long                      curPos;
    194114  long                      peekPos;
    195   size_t                    fLen;
     115  long                      fLen;
    196116  FILE* f;
    197117  string fn;
  • trunk/Poubelle/archTOI.old/archparam.cc

    r432 r534  
    3838  cout << "***END" << endl;
    3939}
     40
     41double ArchParam::AcqParam::SN2MJD(double sample) {
     42  return tBlock0 + sample*perEch/86400.;
     43}
     44
     45
     46double ArchParam::AcqParam::MJD2UTC(double mjd) {
     47  return (mjd - utcOrigin)*24. ;
     48}
     49
     50double ArchParam::AcqParam::UTC2MJD(double utc) {
     51  return utc/24 + utcOrigin;
     52}
     53
     54double ArchParam::AcqParam::SN2UTC(double sample) {
     55  return MJD2UTC(SN2MJD(sample));
     56}
     57
     58
     59double ArchParam::AcqParam::MJD2SN(double mjd) {
     60  return (mjd - tBlock0)/perEch*86400.;
     61}
     62
  • trunk/Poubelle/archTOI.old/archparam.h

    r432 r534  
    1111    double utcOrigin;
    1212    AcqParam();
     13    double SN2MJD(double snum);
     14    double SN2UTC(double snum);
     15    double MJD2UTC(double mjd);
     16    double UTC2MJD(double utc);
     17    double MJD2SN(double mjd);
    1318  };
    1419 
  • trunk/Poubelle/archTOI.old/archtoi.cc

    r436 r534  
    99
    1010#include "archeopsfile.h"
    11 #include "toisvr.h"
     11#include "toiiter.h"
     12#include "toimanager.h"
    1213#include "archtoi.h"
    1314#include "archparam.h"
     
    3940{
    4041  init();
    41   svr.readReq(str);
     42  iter.readReq(str);
    4243}
    4344
     
    4748  init();
    4849  ifstream str(filename.c_str());
    49   svr.readReq(str);
     50  iter.readReq(str);
    5051}
    5152
     
    5960  ostr = NULL;
    6061  requestVersion = "";
    61   svr.registerReqHandler(this);
    62 }
    63 
    64 
    65 bool ArchTOI::processTOIReq(string line, string toiname, TOIKind /*kind*/, int index,
    66                             bool interp, bool repet, bool flag, bool /*notrig*/)
     62  iter.registerReqHandler(this);
     63 
     64  TOIManager::registerDefaultProducers();
     65}
     66
     67
     68bool ArchTOI::processTOIReq(TOI const& toi, string line)
    6769{
    6870  headertoi.push_back(line);
    69   if (index>=0) {
    70     char idx[10];
    71     sprintf(idx,"_%d",index);
    72     toiname += idx;
    73   }
    74   if (flag) {
    75     toinames.push_back("flg_"+toiname);
    76   }
    77   toinames.push_back(toiname);
    78   toiflags.push_back(flg((flag?hasflag:0)+((!repet&&!interp)?useNA:0)));
     71  tois.push_back(toi);
    7972  return true;
    8073}
     
    130123 
    131124  cout << "starting query" << endl;
    132   TOIIter iter = svr.doQuery();
     125  iter.init();
    133126  (this->*openFile)(outfilename);
    134127  (this->*outHeader)(iter);
    135128 
    136129  cout << "processing" << endl;
    137   while (iter.Next()) {
    138     int nn = iter.getSampleIndex() / iter.getUnderSampling(); // Only for tick mark...
     130  while (iter.next()) {
     131    int nn = iter.getSampleNum() / iter.getUnderSample(); // Only for tick mark...
    139132    #ifdef __MWERKS__
    140133    yield();
     
    145138     if (nn%(200*80) == 0) cout << endl;
    146139    // Si rien de dispo parmi les triggering, alors on passe au suivant
    147     bool hasValue = false;
    148     for (int i=0; i<toiflags.size(); i++) {
    149        if (!iter.isTrig(i)) continue;
    150        if (iter.canGetValue(i)) {hasValue=true; break;}
    151     }
    152     if (!hasValue) continue;
     140    // normalement, c'est gere par le toiiter...
     141    //bool hasValue = false;
     142    //for (int i=0; i<toiflags.size(); i++) {
     143    //   if (!iter.isTrig(i)) continue;
     144    //   if (iter.canGetValue(i)) {hasValue=true; break;}
     145    //}
     146    //if (!hasValue) continue;
    153147    int icol=0;
    154     for (int i=0; i<toiflags.size(); i++) {
     148    for (int i=0; i<tois.size(); i++) {
    155149      double value = iter.getValue(i);
    156150      bool   ok    = iter.canGetValue(i);
    157       bool   isnew = iter.newValue(i);
    158       flg    flag  = toiflags[i];
    159       if (flag & hasflag) {
    160         (this->*outValue)(icol,  (ok && isnew ? 1 : 0));
    161         icol++;
    162       }
    163       if (((flag & useNA)!=0 && !isnew) || !ok)
     151     // bool   isnew = iter.newValue(i);
     152     // flg    flag  = toiflags[i];
     153     // if (flag & hasflag) {
     154     //   (this->*outValue)(icol,  (ok && isnew ? 1 : 0));
     155     //   icol++;
     156     // }
     157     //if (((flag & useNA)!=0 && !isnew) || !ok)
     158      if (!ok)
    164159        (this->*outValue)(icol,  0, true);
    165160      else
     
    184179  for (list<string>::iterator i = headeropt.begin(); i != headeropt.end(); i++)
    185180    *ostr << (*i) << '\n';;
    186   block_type_param* blk = iter.lastParam();
     181  block_type_param* blk = iter.getFSet().lastParam();
    187182  if (blk) {
    188183    int nb = blk->param.n_max_bolo;
     
    227222}
    228223
     224list<string> ArchTOI::buildNames() {
     225  list<string> toinames;
     226  map<string,int> namecount;
     227 
     228  for (list<TOI>::iterator i = tois.begin(); i != tois.end(); i++) {
     229    namecount[(*i).name]++;
     230  }
     231 
     232  map<string,int> curcount;
     233  for (list<TOI>::iterator i = tois.begin(); i != tois.end(); i++) {
     234    string toiname = (*i).name;
     235    if (namecount[(*i).name]>1) {
     236      char s[10];
     237      sprintf(s,"_%d",curcount[(*i).name]++);
     238      toiname += s;
     239    }
     240    if ((*i).index != TOI::unspec) {
     241      char s[10];
     242      sprintf(s,"_%d",(*i).index);
     243      toiname += s;
     244    }
     245    toinames.push_back(toiname);
     246  }
     247  return toinames;
     248}
    229249
    230250void ArchTOI::openFile_F(string const& filename) {
     
    237257}
    238258
     259
    239260void ArchTOI::outHeader_F(TOIIter& iter) { 
     261  list<string> toinames = buildNames();
     262
    240263  int ncols=toinames.size();
    241264 
     
    244267  char** colunits = new (char*[ncols]);
    245268  int j=0;
    246   for (list<string>::iterator i = toinames.begin(); i != toinames.end(); i++,j++) {
     269  list<TOI>::iterator kk = tois.begin();
     270  for (list<string>::iterator i = toinames.begin(); i != toinames.end(); i++,j++,kk++) {
    247271    colnames[j] = const_cast<char*>((*i).c_str()); // should work for most STL implementations... Check...
    248272    coltypes[j] = "1D";
    249     colunits[j] = " ";
     273    colunits[j] = const_cast<char*>((*kk).unit.c_str());
     274    cout << (*i).c_str() << " " << ((*kk).unit.c_str()) << endl;
    250275  }
    251276 
     
    261286  int ntoireq = headertoi.size();
    262287  fits_write_key(fptr, TINT, "TOIREQ", &ntoireq, NULL, &fitsStatus);
    263   for (list<string>::iterator i = headertoi.begin(); i != headertoi.end(); i++,j++) {
     288  list<string>::iterator kkk = toinames.begin();
     289  for (list<string>::iterator i = headertoi.begin(); i != headertoi.end(); i++,j++,kkk++) {
    264290    char line[80];
    265291    strcpy(line, (*i).c_str());
    266292    char* pline = line;
    267     fits_write_keys_str(fptr, "TOIREQ", j, 1, &pline, (char**) NULL, &fitsStatus);
     293    char* cmt   = const_cast<char*>((*kkk).c_str());
     294    fits_write_keys_str(fptr, "TOIREQ", j, 1, &pline, &cmt, &fitsStatus);
    268295  }
    269296  j=1;
     
    278305
    279306  // Noms des bolos
    280   block_type_param* blk = iter.lastParam();
     307  block_type_param* blk = iter.getFSet().lastParam();
    281308  if (blk) {
    282309    int nb = blk->param.n_max_bolo;
     
    338365  fits_report_error(stderr, fitsStatus);  /* print out any error messages */
    339366}
     367
     368
  • trunk/Poubelle/archTOI.old/archtoi.h

    r432 r534  
    99#include <list>
    1010#include <vector>
    11 #include "toisvr.h"
     11#include "toiiter.h"
    1212#include "fitsio.h"
    1313
     
    2525            useNA   = 2};
    2626           
    27   virtual bool processTOIReq(string line, string toiname, TOIKind toi, int index,
    28                              bool interp, bool repet, bool flag, bool notrig);
     27  virtual bool processTOIReq(TOI const& toi, string line);
    2928  virtual bool processOption(string keyw, string args);
    3029 
    3130protected:
    3231  void init();
    33   TOISvr svr;
     32  TOIIter iter;
    3433  list<string> headertoi;
    3534  list<string> headeropt;
    36   list<string> toinames;
    37   vector<flg>  toiflags;
     35  list<TOI> tois;
    3836  fmt format;
    3937  string undef;
     
    4644  void (ArchTOI::*endLine)();
    4745  void (ArchTOI::*closeFile)();
     46 
     47  list<string> buildNames();
    4848 
    4949  void openFile_A(string const& filename);
  • trunk/Poubelle/archTOI.old/archtoimain.cc

    r436 r534  
    77
    88#include "archeopsfile.h"
     9
    910#include "archtoi.h"
    10 #include "toisvr.h"
     11#include "toimanager.h"
    1112
    1213//#include <profiler.h>
     
    2324    argc = ccommand(&argv);
    2425#endif
     26
     27
    2528    if (argc != 3) {
    2629      cerr << "usage: archtoi reqfile datafile" << endl;
     30      cerr << "or:    archtoi -h reqfile" << endl;
    2731      return(-1);
    2832    }
     
    3034//   ProfilerInit(collectDetailed, bestTimeBase, 10000, 200);
    3135
     36    if (argv[1] == string("-h")) {
     37      ArchTOI toi(argv[2]);
     38      TOIManager::dumpAvailTOIs(cout);
     39      exit(0);
     40    }
     41
    3242   
    33     ArchTOI toi(argv[1]);
    34     toi.run(argv[2]);
     43    try {
     44      ArchTOI toi(argv[1]);
     45      toi.run(argv[2]);
     46    } catch (ArchExc exc) {
     47      cerr << exc.Msg() << endl;
     48      exit(-1);
     49    }
    3550   
    3651//    ProfilerDump("\pprofiler.data");
    3752    return(0);
    3853}
     54
  • trunk/Poubelle/archTOI.old/archvers.h

    r503 r534  
    22#define ARCHVERS_H
    33
    4 #define ARCHTOI_VERS "1.3"
    5 #define ARCHTOI_TAG  "V_241099"
     4#define ARCHTOI_VERS "2.0"
     5#define ARCHTOI_TAG  "V_011199"
    66
    77#endif
  • trunk/Poubelle/archTOI.old/auxgps.h

    r363 r534  
    1010
    1111  virtual int getLocation(double mjd, double& lat, double& lon, double& alt)=0;
     12  virtual bool canGetLocation(double mjd)=0;
     13  virtual double getStartMJD()=0;
     14  virtual double getEndMJD()=0;
    1215  virtual AuxGPS* clone()=0;
    1316
  • trunk/Poubelle/archTOI.old/auxinterpgps.cc

    r416 r534  
    1818  ilast = elems.upper_bound(elem(mjd,0,0,0));
    1919  ilastok = (ilast != elems.end() && ilast != elems.begin());
     20}
     21
     22bool AuxInterpGPS::canGetLocation(double mjd) {
     23  return (mjd > (*elems.begin()).mjd && mjd < (*--elems.end()).mjd);
     24}
     25
     26double AuxInterpGPS::getStartMJD() {
     27  return (*elems.begin()).mjd;
     28}
     29
     30double AuxInterpGPS::getEndMJD() {
     31  return (*--elems.end()).mjd;
    2032}
    2133
  • trunk/Poubelle/archTOI.old/auxinterpgps.h

    r363 r534  
    1515  AuxInterpGPS();
    1616  virtual int getLocation(double mjd, double& lat, double& lon, double& alt);
     17  virtual bool canGetLocation(double mjd);
     18  virtual double getStartMJD();
     19  virtual double getEndMJD();
    1720 
    1821  void FitsDump(string const& filename);
  • trunk/Poubelle/archTOI.old/dyffttools.cc

    r394 r534  
    11#include "dyffttools.h"
    22
     3// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    34
    45//      Librairie FFTMayer enrobée pour etre utilisable facilement en C++
  • trunk/Poubelle/archTOI.old/dyffttools.h

    r394 r534  
    11#ifndef DYFFTTOOLS_SEEN
    2 #define DYFFTTOOLS
     2#define DYFFTTOOLS_SEEN
     3
     4// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
     5
    36double DYWindow(double index, double indexMax);
    47
  • trunk/Poubelle/archTOI.old/formepulse.cc

    r394 r534  
    22#include <fstream.h>
    33
     4// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    45
    56#include <math.h>
     
    1314#include "ssthardware.h"
    1415
    15 
    1616#define LTab (2048)
    17 #define LSave (128)
     17#define LSave (256)
    1818#define Tpas (5.e-4)
    1919//float PulseOptOrigin=LTab/16.*Tpas;
     
    2222//#define DYTestRun
    2323
    24 
     24/*
     25FormePulse::FormePulse() {
     26        gainElec=0.;
     27        FullwidthHalfMax=0;
     28        ShapeArr=new double[LSave];
     29        for(int i=0; i<LSave; i++)  ShapeArr[i]=0.;
     30}
     31*/
    2532
    2633FormePulse::FormePulse(TransFuncElec TF) {
     
    129136        for(int i=0; i<LSave; i++)  ShapeArr[i]=PulseInReel[i]/Max;
    130137
    131 #ifdef DYTestRun       
     138//#ifdef DYTestRun     
    132139                //On ecrit le resultat dans un fichier
    133140                char s2[32]="Resultatfiltrage.txt";
     
    139146
    140147                dlout<<"Impulsion courant de: "<<SSTFPulseCourant<<" Ampères"<<endl;
    141                 dlout<<"Maximum d'amplitude: "<<max<< " Volts"<<endl;
    142                 dlout<<" gain chaine preampli: "<<gainElec<<endl<<endl;
     148                dlout<<"Maximum d'amplitude: "<<Max<< " Volts"<<endl;
     149                dlout<<" gain chaine preampli: "<<gainElec<<endl;
     150                dlout<<"largueur a mi hauteur: "<<FullwidthHalfMax<<endl<<endl;
    143151                dlout<<"Temps"<<"\tPartie Reelle"<<endl;
    144152
     
    146154                        dlout<<k*Tpas<<"\t"<<ShapeArr[k]<<endl;
    147155                }       
    148 #endif
     156//#endif
    149157
    150158
     
    163171        return *this;
    164172}
    165        
     173
    166174FormePulse::~FormePulse() {
    167175        delete[] ShapeArr;
     
    174182
    175183double FormePulse::PulseShape(double temps) {
     184        double returnValue;
    176185        int ientier=(int)(temps/Tpas);
    177         double returnValue;
    178186        if (ientier<0) returnValue=0.;
    179         else if (ientier>=LSave) returnValue= ShapeArr[127];
     187        else if (ientier>=LSave) returnValue= ShapeArr[LSave-1];
    180188        else {
    181189                double Min=ShapeArr[ientier];
     
    193201        //en secondes
    194202        return returnVal;
     203//      return returnVal=30.e-3;                        //Gros BUGG!!!!!
    195204}
    196205       
  • trunk/Poubelle/archTOI.old/formepulse.h

    r394 r534  
    22#define FORMEPULSE_SEEN
    33
     4// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    45
    56#define  SSTFPulseCourant 1.E-9         
     
    1112class FormePulse {
    1213public:
    13         FormePulse(TransFuncElec);
     14        FormePulse(TransFuncElec TF);
     15        FormePulse();                                           // Cas zero lecture
    1416        FormePulse& operator =(const FormePulse&);
    1517        ~FormePulse();
  • trunk/Poubelle/archTOI.old/pisteetoile.cc

    r400 r534  
    88FormePulse    PisteEtoile::FPulse(Trapani);
    99
    10 
    11 
    12 int SSTnbPasFit= (int) (2*TFExcursion/TPasTFit);
     10// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    1311
    1412PisteEtoile::PisteEtoile(short NoPhotDiod) {
    15         PasTempsEch=0.005836818076;                     
     13        PasTempsEch=archParam.acq.perEch;                       
    1614                //BUGG doit changer     !!!!! Doit etre extrait d'un serveur de param d'acquisition
    1715        NoPhDiod=NoPhotDiod;
    1816        DiodVivante=true;
     17       
     18        SSTnbPasFit= (int) (2*TFExcursion/TPasTFit);
     19       
    1920        AmplNorm=0.;
    20 //      On echantillonne dix fois plus fin pour avoir une bonne estimation de AmplNorm
    21 //      Eviter les systematiques
    2221        for(int i=0; i<SSTLongIndexEvt()*10; i++){
    23                 AmplNorm+=FPulse.PulseShape(i/10.*TPasTFit)*FPulse.PulseShape(i/10.*TPasTFit);
     22                AmplNorm+=FPulse.PulseShape(i*PasTempsEch/10.)*FPulse.PulseShape(i*PasTempsEch/10.);
    2423        }
    2524        AmplNorm/=10.;
     
    3938PisteEtoile& PisteEtoile::operator =(PisteEtoile const & x) {
    4039        PasTempsEch=x.PasTempsEch;             
    41                 //BUGG doit changer     !!!!! Doit etre extrait d'un serveur de param d'acquisition
    4240        NoPhDiod=x.NoPhDiod;
    4341        DiodVivante=x.DiodVivante;
     
    115113void PisteEtoile::fill(int* pData, int InDebutPiste, int nData) {
    116114//      if(!isAlive()) return;
    117         indexDebutPiste=InDebutPiste;
    118         int* PhDiod=PhDiodArray;
     115        indexDebutPiste=InDebutPiste - PhDiodTabLong + nData;
     116        int* PhDiod=PhDiodArray + PhDiodTabLong - nData;
    119117        int* pDataC=pData;
    120118        for(int k=0;k<nData;k++,pDataC++, PhDiod++) (*PhDiod)=(*pDataC);
     
    152150       
    153151                if(testEtoile) {
    154                 // On emballe une etoile.
     152                // On emballe une etoile
     153                        LastEtoile.InpCurrent= AmplRes/FPulse.GainElectrique();
     154                        LastEtoile.InpCurFin= AmplFin/FPulse.GainElectrique();
     155                        LastEtoile.TEchan=TIndex;
     156                        LastEtoile.TFin=Tfin;
     157                        LastEtoile.InpCurrNoisRMS=Vrms/FPulse.GainElectrique();
     158                        LastEtoile.X2Calc=X2Min;
     159                        LastEtoile.NoDiode=NoPhDiod;
    155160                        LastEtoile.FitForme=SuccesAFine;
    156                         LastEtoile.X2Calc=X2Min;
    157                         LastEtoile.InpCurrNoisRMS=Vrms/FPulse.GainElectrique();
    158                         LastEtoile.TEchan=TIndex;
    159                         LastEtoile.InpCurrent= AmplRes/FPulse.GainElectrique();
    160                         LastEtoile.NoDiode=NoPhDiod;
    161161                        LastEtoile.LargMiHauteur=widthHalfMax;
     162                       
     163/*                      cout<<setprecision(9);
     164                        cout<<TIndex<<" "<<Tfin<<" "<<AmplRes<<" "<<AmplFin<<endl;
     165                        cout<<TIndex-Tfin<<" "<<(AmplRes-AmplFin)/AmplFin<<endl;
     166*/
    162167                }
    163168        }
     
    199204// On calcule le Vrms sur le prepulse
    200205        Vrms=0.;
    201         for (int i=0; i<Prepulselong; i++) Vrms+=PhDiodPiste[i]*PhDiodPiste[i];
    202         Vrms=sqrt(Vrms)/Prepulselong;
     206        for (int i=0; i<Prepulselong; i++) {
     207                Vrms+=PhDiodPiste[i]*PhDiodPiste[i];
     208        }
     209        Vrms=sqrt(Vrms/Prepulselong);
    203210        if(Vrms<SSTLsbVal) Vrms=SSTLsbVal;              // Pour eviter les VRMS=0.
    204211       
     
    281288// Maintenant que l'on se doute que il y a une etoile
    282289// On veut connaitre son flux et son temps de passage
    283 // Nécessite d'avoir un ordre d'idee de la vitesse de rotation du ballon.
     290// Nécessite de connaitre la vitesse de rotation du ballon.
    284291
    285292                // BUGG devra etre extrait des headers acquisition. Ca peut changer!!!!!!
    286 
    287        
    288293                       
    289294        int IndexDebutEvt=MaxIndex-SSTLargEvtIndex();
     
    292297                // Pointeur origine du tableau d'echantillon sur lequel sera calculé le fit
    293298        double DeltaTemps=0.;
    294 // Pour chaque decalage en temps, on estime un amplitude et calcule le X2
     299       
     300// Pour chaque decalage en temps, on estime une amplitude et calcule le X2
    295301        for(int k=0; k<SSTnbPasFit; k++) {
    296302                DeltaTemps=TFExcursion-k*TPasTFit;
     
    314320        X2Min=1.e99;
    315321        int X2MinIndex=-1;
    316         for(int k=0; k<SSTnbPasFit; k++)
     322        for(int k=0; k<SSTnbPasFit; k++) {
    317323                if (X2[k]<X2Min) {
    318324                        X2Min=X2[k];
    319325                        X2MinIndex=k;
    320326                }
    321 
     327        }
     328       
    322329        if((X2MinIndex>0)&&(X2MinIndex<(SSTnbPasFit-1))) {
    323330       
    324331// On fitte une parabole sur les trois X2 qui encadrent le min
    325         double Di;      // Index (non entier) du minimum du X2
     332                double Di;      // Index (non entier) du minimum du X2
    326333                double X=(X2[X2MinIndex+1]-X2Min)/(X2Min-X2[X2MinIndex-1]);             
    327334                Di=0.5*(X+1)/(X-1);
    328335
     336// Le X2 est mimimum pour le n° de pas de fit X2MinIndex+Di
    329337// On calcule l'amplitude estimee a ce temps
    330338                double Som1=0.; pFitArray=pFitArray0;
    331339                DeltaTemps=TFExcursion-(X2MinIndex-Di)*TPasTFit;
    332340                for(int i=0; i<SSTLongIndexEvt(); i++, pFitArray++)
    333                         Som1+=(*pFitArray)*FPulse.PulseShape(i*PasTempsEch-DeltaTemps);
    334                 AmplRes=Som1/AmplNorm;
    335                
    336 //Le X2 est mimimum pour le n° de pas de fit X2MinIndex+Di
     341                                Som1+=(*pFitArray)*FPulse.PulseShape(i*PasTempsEch-DeltaTemps);
     342                AmplFin=Som1/AmplNorm;
     343                       
     344
    337345
    338346#ifdef PEtoileDebug
    339                 double* PulseTrak=new double [SSTLongIndexEvt()];
     347                double *PulseTrak=new double [SSTLongIndexEvt()];
    340348#endif
    341 
     349// On calcule le X2 correspondant
    342350                double X2Som1=0.; double dummy=0.;pFitArray=pFitArray0;
    343351                for(int i=0;i<SSTLongIndexEvt();i++,pFitArray++) {     
     352               
    344353#ifdef PEtoileDebug
    345354                        PulseTrak[i]=FPulse.PulseShape(i*PasTempsEch-DeltaTemps);
    346355#endif
    347                         dummy=(*pFitArray)-AmplRes*FPulse.PulseShape(i*PasTempsEch-DeltaTemps);         // Différence
     356                        dummy=(*pFitArray)-AmplFin*FPulse.PulseShape(i*PasTempsEch-DeltaTemps);         // Différence
    348357                        X2Som1+=dummy*dummy;                                                                                                            // Au carré
    349358                }
    350                                        
     359                                               
    351360                X2Min=X2Som1/(SSTLongIndexEvt()*Vrms*Vrms);
    352        
    353                 TIndex=indexDebutPiste+IndexDebutEvt+DeltaTemps/PasTempsEch;
    354                                         //Ouff!!!!
     361               
     362                Tfin= indexDebutPiste+IndexDebutEvt+DeltaTemps/PasTempsEch;
     363                        //Ouff!!!!
     364/*                     
     365                cout<<setprecision(9)<<endl;                   
     366                cout<<Tfin<<" "<<indexDebutPiste<<" "<<IndexDebutEvt<<" "<<DeltaTemps/PasTempsEch<<endl;
     367*/             
    355368                SuccesAFine=true;
     369               
     370#ifdef PEtoileDebug
     371                delete[] PulseTrak;
     372#endif
    356373        }
    357374        else {                          // Echec, c'est tres bizarre! On doit etre dans le bruit
  • trunk/Poubelle/archTOI.old/pisteetoile.h

    r394 r534  
    55#include "formepulse.h"
    66
    7 /*      // D. Yvon, CE Saclay, 08/99
     7/*      // D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    88
    99        // Analyse the Photodiode track to find star pulse.
    1010        // Caracterise the time and amplitude of the star Pulse
    1111
    12         We analyse a set of 32 samples. The 16 first are considered as prepulse sample.
     12        We analyse a set of 48 samples. The 32 first are considered as prepulse sample.
    1313        On the prepulse:
    1414                We compute baseline and substract it.
     
    1717                Look for trigger
    1818        If triggered :
    19                 Look for maximum. If max found 20< Max< 28
     19                Look for maximum.
     20                Compute Full width half maximum
     21                Fit a paroabole on max of the pulse
     22                return max fitte and time of max fitte
     23        if analfine
    2024                Iterate time fit on pulse area and compute amplitude and X2
    2125                Find best X2.
     
    2327                Build SSTStar.
    2428               
    25         That's it. Test code tstpisteetoile.cc can be found in tstroutines folder.
     29        That's it.
    2630        When  done push the track eigth samples forward and iterate analysis.
    2731*/
     
    3943//      Parametrisation du Trigger
    4044#define SeuilGachette (6.)                              // On déclenche à SeuilGachette sigmas
    41 #define SSTLsbVal (10./4096)
     45#define SSTLsbVal (10./4096.)
    4246
    4347//      Parametrisation Analyse Fine
    4448#define TFExcursion (15.e-3)                    // Secondes: Excursion du fit autour de MaxIndex
    45 #define TPasTFit (2.5e-3)                               // Secondes:
     49#define TPasTFit (1.5e-3)                               // Secondes:
    4650                        // Secondes:
    4751
     
    7074        inline int SSTLargEvtIndex();
    7175        inline int SSTLongIndexEvt();
     76        static TransFuncElec Trapani;
     77        static FormePulse FPulse;
     78       
    7279protected:
    7380        double PasTempsEch;     //Secondes
    7481// Idendificateur, repères et gestion
    7582        short NoPhDiod;
    76         int indexDebutPiste;    // A actualiser dans push() et Fill()! BUGG!!!!
     83        long indexDebutPiste;   // A actualiser dans push() et Fill()
    7784        bool DiodVivante;               // Si false, On ne fait rien
    7885       
     
    8895        double Vrms;
    8996        short MaxIndex;                 // Index de l'amplitude Max en analyse Trig()
     97        double TIndex;
    9098        double AmplMax;
     99        double AmplRes;
    91100        int widthHalfMax;
     101        int SSTnbPasFit;
    92102//      double integ;
    93103// Variables Resultat d'analyse fine
    94        
    95         double AmplRes;
    96         double TIndex;
     104        double AmplFin;
     105        double Tfin;
    97106        double X2Min;
    98107        bool SuccesAFine;
     
    109118        double* X2;             //Tableau des X2 calculés
    110119       
    111         static TransFuncElec Trapani;
    112         static FormePulse FPulse;
     120
    113121       
    114122};
  • trunk/Poubelle/archTOI.old/sstetoile.cc

    r394 r534  
    11#include "sstetoile.h"
     2
     3// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    24
    35void SSTEtoile::print(ofstream& str) {
    46        str<<setprecision(11);
    5         str<<InpCurrent<<'\t'<<TEchan<<'\t'<<NoDiode<<'\t'<<LargMiHauteur;
    6         str<<'\t'<<InpCurrNoisRMS<<endl;
    7         //      <<'\t'<<X2Calc<<'\t'<<FitForme
     7        str<<InpCurrent<<'\t'<<InpCurFin<<'\t'<<TEchan<<'\t'<<TFin<<'\t'<<NoDiode<<'\t'<<LargMiHauteur;
     8        str<<'\t'<<InpCurrNoisRMS<<'\t'<<X2Calc<<'\t'<<FitForme<<endl;
    89        return;
    910}
    1011
    1112string SSTEtoile::printHeader() {
    12         string a("InpCurrent\tTempsEchan\tNoDiode\tLarMiHauteur\tICurrRMS\tX2Calc\tFitForme");
     13        string a("InpCurrent\tInpCurFin\tTempsEchan\tTFin\tNoDiode\tLarMiHauteur\tICurrRMS\tX2Calc\tFitForme");
    1314        return a;
    1415}
  • trunk/Poubelle/archTOI.old/sstetoile.h

    r394 r534  
    11#ifndef SSTEtoile_H
    22#define SSTEtoile_H
     3
     4// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    35
    46#include <stdio.h>
     
    1113public:
    1214        double InpCurrent;              // En Ampère
     15        double InpCurFin;               // En ampère,   Analyse fine
    1316//      double IInteg;                  // En Ampère
    14         double TEchan;                  // Temps en indexEchantillon
     17        double TEchan;                  // Temps en indexEchantillon analyse trig
     18        double TFin;                    // Temps en indexEchantillon analyse fine
    1519        double InpCurrNoisRMS;  // Bruit en Ampère
    16         double X2Calc;                  // Sans dimension
     20        double X2Calc;                  // Sans dimension, analyse fine
    1721        int NoDiode;
    1822        bool FitForme;                  // Fit de forme?
     
    2024       
    2125        void print(ofstream& str);
    22         string printHeader();
     26        static string printHeader();
    2327};
    2428
  • trunk/Poubelle/archTOI.old/ssthandler.cc

    r416 r534  
    1212
    1313#include <math.h>
     14#include <iostream>
    1415#include "ssthandler.h"
    1516#include "pisteetoile.h"
    1617
    17 #ifdef SST_DUMPLOG
     18
    1819ofstream SSTHandler::sstchass("SSTChassLogFile");
    1920bool     SSTHandler::sstchassinit=false;
    20 #endif
    2121
    2222// diodpermut[i] = channel de la diode i
     
    180180}
    181181
     182
     183// D. Yvon, CEA/DAPNIA/SPP Saclay, 08/99
     184
     185
     186#ifdef SSTStatLog
     187        static ofstream sststat("SSTStatLog");
     188        static int compteurBlock=0;
     189        static int nbStar=0;
     190        #include "ssthardware.h"
     191        #include "archparam.h"
     192#endif
     193
     194
    182195int SSTHandler::FindStars(block_type_sst* blk) {
    183196        NbStarInBlock=0;
     
    224237                                        //On empile sur la map.
    225238                                NbStarInBlock++;
    226 #ifdef SST_DEBUG                       
     239#ifdef SSTDUMP                 
    227240                        // On écrit les pistes ayant déclénchées
    228241                                int NoDiodeEvt=LastStar.NoDiode;
    229                                 if(pPisteDump[NoDiodeEvt]->is_open())   
    230                                         for(int noSamp=0; noSamp<NbSampleBlock;noSamp++)
    231                                                 (*pPisteDump[NoDiodeEvt])<<noStarDet<<'\t'<<NoDiode<<'\t'<<NoFirstSpInBlock+noSamp<<'\t'<<Diodedata[noSamp]<<endl;
     242                                if(NoDiodeEvt<NbChanDump) {
     243                                        if(pPisteDump[NoDiodeEvt]->is_open())   
     244                                                for(int noSamp=0; noSamp<NbSampleBlock;noSamp++)
     245                                                        (*pPisteDump[NoDiodeEvt])<<noStarDet<<'\t'<<NoDiode<<'\t'<<NoFirstSpInBlock+noSamp<<'\t'<<Diodedata[noSamp]<<endl;
     246                                }
    232247#endif
    233248                                noStarDet++;
     
    257272                LastBlockStarVec.push_back((*StarHistReIter).second);
    258273       
    259 #ifdef SST_DUMPLOG
    260         if(NbStarInBlock>0) {
    261                        
     274#ifdef SSTChassLog
     275        if(NbStarInBlock>0) {                   
    262276        // On écrit les étoiles detectées
    263277                vector<SSTEtoile>::reverse_iterator StarVecRevIter;
     
    266280                        (*StarVecRevIter).print(sstchass);
    267281        }
    268                
     282#endif
     283
     284#ifdef SSTStatLog
     285        int nbBlockincircle=(int) (PeriodRotTeles/(archParam.acq.perEch*72.));
     286//      if((compteurBlock%nbBlockincircle)==0)
     287        {
     288//      if((compteurBlock%5)==0) {
     289                sststat<<numero_block(blk)<<'\t'<<nbStar<<'\t'<<noStarDet<<endl;
     290                nbStar=0;
     291        }
     292                nbStar+=NbStarInBlock;
     293                compteurBlock++;
    269294#endif
    270295
     
    276301        for(int i=0; i<NbPhotDiodBarette; i++) PisteBar[i]=new PisteEtoile(i);
    277302        StarHistoryMap.clear();
    278 #ifdef SST_DUMPLOG
    279303        if (!sstchassinit) {
    280304          sstchass<<LastStar.printHeader()<<endl;
    281305          sstchassinit = true;
    282306        }
    283 #endif
    284        
    285 #ifdef SST_DEBUG       
     307       
     308#ifdef SSTDUMP 
    286309        char s[32];
    287310        string fileName;
     
    301324                }
    302325*/                     
    303                 pPisteDump[pistNumb]=new ofstream(fileName.c_str(),ios::out|ios::trunc);
     326                pPisteDump[pistNumb]=new ofstream(fileName.c_str(),ios::out|ios::app);
    304327               
    305328                if(!(*pPisteDump[pistNumb]).is_open()) {
     
    317340        delete[] PisteBar;
    318341               
    319 #ifdef SST_DEBUG       
     342#ifdef SSTDUMP 
    320343        for (int pistNumb=0; pistNumb<NbChanDump; pistNumb++) {
    321344                pPisteDump[pistNumb]->close();
    322345                delete pPisteDump[pistNumb];
    323346        }
    324         delete  pPisteDump;
     347        delete[] pPisteDump;
    325348#endif
    326349
     
    377400{
    378401  lastBlkNum = numero_block(blk);
    379   if (prcTodo != 0) {
    380     for (int i = 0; i<nb_per_block*2; i++) {
    381       DecodeTMBlock(blk, i, diodeRaw[i]);
    382     }
     402  for (int i = 0; i<nb_per_block*2; i++) {
     403    DecodeTMBlock(blk, i, diodeRaw[i]);
    383404  }
    384405  if (prcTodo & permDiode) {
  • trunk/Poubelle/archTOI.old/ssthandler.h

    r416 r534  
    2424
    2525//#define SST_DEBUG
    26 //#define SST_DUMPLOG
    27 #define NbChanDump (10)
     26//#define SSTDUMP
     27#define SSTChassLog
     28//#define SSTStatLog
     29
     30#define NbChanDump (3)
    2831#define NbPhotDiodBarette (46)
    2932#define NbEtInMapMax    (100)
    30 #define SSTChassLog (true)
    3133#define NbSampleBlock (2*nb_per_block)
    3234// Fin Zone findStar
     
    4648  void NeedProcess(int prcMask);
    4749  void ProcessBlock(block_type_sst*);
    48   bool NeedBlocks() {return prcTodo != 0;}
    4950
    5051  static void Has2Bars(bool, int elecOffset=0); // elecOffset : which wired together
     
    6364  double getStarTime(int iSampl, int istar);
    6465                        // return star time in this sample
    65                        
    66   static int getDiodPermut(int i) {return diodpermut[i];}
    6766
    6867protected:
     
    9291  PisteEtoile** PisteBar;
    9392       
    94 #ifdef SST_DEBUG
     93#ifdef SSTDUMP
    9594        ofstream** pPisteDump;
    9695#endif
     
    111110  int noStarDet;
    112111  int FirstSplNb(block_type_sst* blk); // Calcule l'index du premier echantillon du block analysé
     112 
    113113  static ofstream sstchass;
    114114  static bool     sstchassinit;
  • trunk/Poubelle/archTOI.old/ssthardware.h

    r394 r534  
    11#ifndef SSTHARDWARE_SEEN
    22#define SSTHARDWARE_SEEN
     3
     4// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    35
    46// Telescope SST
     
    1113
    1214// Paramètres du Vol
    13 #define PeriodRotTeles (20.)                                            // Periode de rotation du telescope en seconde
    14 
     15#define PeriodRotTeles (20.)                                    // Periode de rotation du telescope en seconde
     16//#define PeriodRotTeles (30.)                                  // version Kiruna
    1517
    1618#endif
  • trunk/Poubelle/archTOI.old/templocator.cc

    r436 r534  
    77#include "fitsio.h"
    88#include "plgalcross.h"
     9#include "archparam.h"
    910
    1011#ifndef M_PI
     
    7879 
    7980  // On trouve les croisements juste avant et juste apres notre sampleNum
    80   int icross;
    8181  for (icross=0; icross<nGalCross; icross++) {
    8282    if (crossings[icross] > sampleNum) break;
     
    9898  if (fabs(azCr2-220) < fabs(azCr1-220)) azCross = azCr2;
    9999 
    100   double rotSpeed = 360./(crossings[icross] - crossings[icross-1]); // °/sample
     100  rotSpeed = 360./(crossings[icross] - crossings[icross-1]); // °/sample
    101101 
    102102  azimBolGC = azCross - (sampleNum - (crossings[icross-1]+12))*rotSpeed;
     
    104104  if (azimBolGC > 360) azimBolGC -= 360;
    105105}
     106
     107double TempLocator::getRotSpeed(int sampleNum) {
     108  findGeomFromGC(sampleNum);
     109  return rotSpeed / archParam.acq.perEch;
     110}
     111
     112int  TempLocator::getCrossSamples(int sampleNum, int& SN1, int& SN2) {
     113  findGeomFromGC(sampleNum);
     114  if (icross == 0 || icross >= nGalCross) return -1;
     115  SN1 = crossings[icross-1];
     116  SN2 = crossings[icross];
     117  return 0;
     118}
     119
    106120
    107121void TempLocator::getAltAzBolo(int sampleNum, int ibolo, double& elv, double& az) {
     
    166180  aa_hadec (lat * M_PI/180, elv * M_PI/180, az * M_PI/180, &ha, &dec);
    167181  ra = - (ha * 180. / M_PI / 15) + (ts/3600.);
     182  while (ra>24) ra -= 24;
     183  while (ra<0) ra += 24;
    168184  dec = dec * 180. / M_PI;
    169185  return ra;
     
    187203double TempLocator::getDeltaCenter(int sampleNum) {
    188204  return getDeltaBolo(sampleNum, 11);
     205}
     206
     207double TempLocator::getAzimutCenter(int sampleNum) {
     208  return getAzimutBolo(sampleNum, 11);
     209}
     210
     211double TempLocator::getElvCenter(int sampleNum) {
     212  return getElvBolo(sampleNum, 11);
    189213}
    190214
  • trunk/Poubelle/archTOI.old/templocator.h

    r436 r534  
    1919  double getAlphaBolo(int sampleNum, int ibolo);
    2020  double getDeltaBolo(int sampleNum, int ibolo);
     21  double getAzimutCenter(int sampleNum);
     22  double getElvCenter(int sampleNum);
    2123  double getAlphaCenter(int sampleNum);
    2224  double getDeltaCenter(int sampleNum);
     25  double getRotSpeed(int sampleNum); // deg/sec
     26  int    getCrossSamples(int sampleNum, int& SN1, int& SN2);
    2327 
    2428  void getAltAzBolo(int sampleNum, int ibolo, double& elv, double& az);
     
    3640  int xSampleNum; // pour le dernier calcul
    3741  double azimBolGC;
     42  double rotSpeed;
     43  int icross;
    3844 
    3945  void findGeomFromGC(int sampleNum); // pour le bolo qui voit les xing
  • trunk/Poubelle/archTOI.old/toiiter.cc

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

    r436 r534  
    11// toiiter.h
    2 // Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
     2// Eric Aubourg         CEA/DAPNIA/SPP   septembre 1999
    33
    44#ifndef TOIITER_H
    55#define TOIITER_H
    66
    7 
    87#include <vector>
     8#include <list>
    99#include <set>
    1010#include <map>
    1111#include <string>
    12 #include "archeopsfile.h"
    13 #include "auxgps.h"
    14 #include "tsid.h"
    1512
    16 enum TOIKind {
    17   sampleNum,     // Numero d''echantillon (timer interne transputer)
    18   internalTime,  // temps transputer depuis debut manip, en secondes.
    19   mjd,           // UTC (en jours, MJD = JD - 2450000).
    20   mutc,          // UTC en heure, avec soustraction d'origine
    21   boloMuV,       // tension en microVolts, filtree avec filtre carre indexe par bolometre
    22   boloMuV2,      // tension en microVolts, avec soustraction offset filtre
    23   boloRawMuV,    // tension brute en microVolts, non filtree indexe par bolometre, sans chgt signe
    24   boloTemp,      // Kelvins, need R(T) -> N/A
    25   boloDACV,      // tension de reference du DAC (microVolts)
    26   boloDACI,      // courant (microAmps)
    27   boloRawMuVCN,  // compression noise on bolo (microVolts), no filter
    28   boloMuV2T,     // total, microVolts, avec consigne DAC
    29   boloRes,       // Resistance, ohms
    30   boloGainAmpli, //
    31   dilDAC,        // dilution DAC, index = 0-47
    32   dilSwitch,     // dilution, mot de 32 bits
    33   serviceTemp,   // service temperature, K
    34   sstDiode,      // signal brut SST, indice = diode, 0-45
    35   sstChannel,    // signal brut SST, indice = canal, 0-47
    36   sstDiodeCN,    // compression noise
    37   sstChannelCN,  // compression noise
    38   sstStarCnt,    // nombre d''etoiles detectees durant ce sample
    39   sstStarZ,      // numero de diode d''une eventuelle etoile,   i=etoile 0..n
    40   sstStarF,      // flux d''une eventuelle etoile,             <0 si moins de i+1 etoiles
    41   sstStarT,      // temps d''une eventuelle etoile,            <0 si moins de i+1 etoiles
    42   gyroRaw,       // valeur brute du gyro, index = 0,1,2
    43   gyroV,         // tension gyro, V, index = 0,1,2
    44   gyroSpeed,     // vitesse gyro, deg/s, index = 0,1,2, calibree...
    45   gpsTime,       // temps fourni par GPS
    46   longitude,     // position ballon, degrees  +=EST
    47   latitude,      // position ballon, degrees  +=NORD
    48   altitude,      // position ballon, m
    49   tsid,          // temps sideral en secondes
    50   azimuthBolo,   // azimut
    51   alphaRotAxis,  //
    52   deltaRotAxis,  //
    53   alphaZenith,   //
    54   deltaZenith,   //
    55   alphaSst,      //
    56   deltaSst,      //
    57   alphaFPAxis,   //
    58   deltaFPAxis,   //
    59   alphaBolo,     // sur le ciel, indexe par bolometre
    60   deltaBolo,     // sur le ciel, indexe par bolometre
    61   voyantEVO,
    62   voyantEVF,
    63   commandeEV0,
    64   commandeEVF,
    65   commandeEVB,
    66   commandeEVV,
    67   pressEnt3He,
    68   debit3He,
    69   pressSor3He,
    70   pressEnt4He,
    71   debit4He,
    72   pressSor4He,
    73   pressAirVanne,
    74   pressPompChar,
    75   pressMembrane,
    76   pressExterne,
    77   tensPile10T,
    78   tensPileP18D,
    79   tensPileM18D,
    80   tensPile10B,
    81   tensPileP18B,
    82   tensPileM18B,
    83   tensPileCh,
    84   swPile5,
    85   swPile15,
    86   tempCaissH1,
    87   tempCaissH2,
    88   tempCaissB1,
    89   tempCaissB2,
    90   tempCaissTHe,
    91   tempCaissPiles,
    92   tempCaissDrv,
    93   pressHeBain,
    94   pressPirani
    95 };
     13#include "toiabsorber.h"
     14#include "requesthandler.h"
     15#include "archfileset.h"
    9616
    97 class TOIInterpolator;
     17class AuxGPS;
    9818
    99 class TOIIter {
     19template <class T1, class T2, class T3>
     20struct triple {
     21    T1 first;
     22    T2 second;
     23    T3 third;
     24        triple() : first(T1()), second(T2()), third(T3()) {}
     25    triple (const T1& a, const T2& b, const T3& c) :
     26           first (a), second (b), third (c) {}
     27};
     28
     29class TOIIter : public TOIAbsorber /*, public RequestHandler*/ {
    10030public:
    101    TOIIter(TOIIter const&);   // $CHECK$ prevoir operator = ?
    102    ~TOIIter();
    103    bool Next();
     31  TOIIter();
     32  // ~TOIIter();
     33 
     34  void readReq(istream& s);
     35  void defaultInclude();
     36
     37  bool processRequest(string line);
     38  void registerReqHandler(RequestHandler*);
     39
     40  virtual bool processTOIReq(TOI& toi, string);
     41  virtual bool processOption(string keyw, string args);
     42
     43  void addDirectory(string);
     44  void addFile(string);
     45  //void useAuxGPS(AuxGPS* gps);
    10446   
    105    bool    canGetValue(int column);  // data is available for that...
    106    double  getValue(int column);
    107    bool    newValue(int column);     // a juste change ?
    108    bool    extendValue(int column);  // une valeur plus ancienne, etendue ?
    109    bool    interpValue(int column);  // une valeur interpolee avec valeur future ?
    110    bool    isTrig(int column); 
    111    TOIKind getKind(int column);
    112    int     getIndex(int column);     // si plusieurs, exemple, tension bolo 2
     47  void setMJDInterval(double tStart, double tEnd);
     48  void setUTCInterval(double tStart, double tEnd);
     49  void setSNInterval(long sStart, long sEnd);
     50  void setUnderSample(int n);
     51  int  getUnderSample();
     52
     53  void addTOI(TOI& toi, bool triggering=true);
     54
     55  void init();
     56 
     57  bool next();
    11358   
    114    bool    canGetTOI(TOIKind kind, int index=0);
    115    double  getTOI(TOIKind kind, int index=0);
     59  long    getSampleNum();
     60  bool    canGetValue(int column);  // data is available for that...
     61  double  getValue(int column);
     62  bool    canGetValue(TOI const& toi);  // data is available for that...
     63  double  getValue(TOI const& toi);
     64  bool    newValue(int column);     // a juste change ?
     65  bool    extendValue(int column);  // une valeur plus ancienne, etendue ?
     66  bool    interpValue(int column);  // une valeur interpolee avec valeur future ?
     67  bool    isTrig(int column); 
     68  TOI     getKind(int column);
     69 
     70  ArchFileSet& getFSet() {return fset;}
     71     
     72protected:   
     73  ArchFileSet fset;
     74  list<RequestHandler*> handlers;
     75  enum {triggering = 1};
     76  typedef ::triple<TOI,TOIProducer*,long> TOIInfo;
     77  vector<TOIInfo> request;
    11678   
     79  double mjdStart, mjdEnd;  // MJD
     80  double utcStart, utcEnd;  // UTC, will be converted towards tStart tEnd at init
     81  long   sStart, sEnd;      // samplenum
     82       
     83  int underSample;
     84  long curSample;
    11785   
    118    int    getBlockSampleIndex();        // numero d''echantillon dans dernier bloc bolo
    119    int    getSampleIndex();             // numero d''echantillon
    120    int    getUnderSampling();           
    121    double getMJD();           
     86  int getColTOI(TOI const& toi);
     87  bool next1();
    12288
    123    block_type_param*         lastParam(); 
    124    block_type_journal*       lastJournal();
    125    block_type_reglage*       lastReglage();
    126    block_type_dilution*      lastDilution();
    127    block_type_gps*           lastGPS();
    128    block_type_une_periode*   lastUnePeriode();
    129    block_type_synchro_sol*   lastSynchroSol();
    130    block_type_pointage_sol*  lastPointageSol();
    131    block_type_bolo*          lastBolo();   
    132    block_type_gyro*          lastGyro();
    133    block_type_sst*           lastSST();
    134    block_type_bolo_comprime* lastBoloComp();   
    135    block_type_gyro_comprime* lastGyroComp();
    136    block_type_sst_comprime*  lastSSTComp();
    137    
    138    ArcheopsFile* currentFile() {if (!initDone) Init(); return file;}
    139 
    140 protected:
    141    TOIIter();
    142    void Init(); // After setting the options, opens the first file.
    143    void ScanFiles(); // Parcourt tous les fichiers, cherche le premier echantillon...
    144    
    145    bool Next1();
    146    bool NextSample(); // no test of trange
    147    bool NextFile();
    148    
    149    ArcheopsFile* file;
    150    string directory;   // If directory scanning
    151    set<string> files;  // list of files to be read...
    152    map<string, long> file1stSamp; // premier echantillon de chaque fichier
    153    set<string>::iterator curFile;
    154    bool  isOnBoardRecorder;
    155    
    156    int imes;
    157    
    158    double tStart, tEnd;      // MJD
    159    double utcStart, utcEnd;  // UTC, will be converted towards tStart tEnd at init
    160    long   sStart, sEnd;      // samplenum
    161    
    162    //double tBlock0;  // MJD du bloc numero zero...
    163    //double perEch;   // periode d''echantillonage en secondes
    164    
    165    struct info {
    166      TOIKind kind;
    167      int index;
    168      bool triggering;
    169      bool interpolated;
    170    };
    171    
    172    int getColTOI(TOIKind kind, int index=0);
    173    
    174    long trigMask;
    175    
    176    vector<info>   infos;
    177    
    178    friend class TOISvr;
    179    
    180    // Gestion de l''interpolation, par delegation a un autre iterateur
    181    TOIIter* rawIter; // iterateur sans interpolation, qui avance avec retard
    182                      // en bufferisant les valeurs. S''il existe, on lui delegue
    183                      // toutes les operations agissant sur le fichier.
    184    TOIInterpolator* interp; // interpolateurs pour stocker les valeurs
    185    long lastSample;  // last interpolated sample
    186    long maxLookAhead;
    187    bool fetchAhead(); // avance d''une TOI en nourrissant les interpolateurs
    188    
    189    AuxGPS* auxGPS;
    190    TSid tSid;
    191    
    192    int underSample;
    193    
    194    private:
    195    bool initDone;
     89private:
     90  bool initDone;
     91  bool incDone;
    19692};
    19793
  • trunk/Poubelle/archTOI.old/toisvr.cc

    r465 r534  
    162162    else tsttoi(alphaBolo)
    163163    else tsttoi(deltaBolo)
    164     else tsttoi(voyantEVO)
    165     else tsttoi(voyantEVF)
    166     else tsttoi(commandeEV0)
    167     else tsttoi(commandeEVF)
    168     else tsttoi(commandeEVB)
    169     else tsttoi(commandeEVV)
    170     else tsttoi(pressEnt3He)
    171     else tsttoi(debit3He)
    172     else tsttoi(pressSor3He)
    173     else tsttoi(pressEnt4He)
    174     else tsttoi(debit4He)
    175     else tsttoi(pressSor4He)
    176     else tsttoi(pressAirVanne)
    177     else tsttoi(pressPompChar)
    178     else tsttoi(pressMembrane)
    179     else tsttoi(pressExterne)
    180     else tsttoi(tensPile10T)
    181     else tsttoi(tensPileP18D)
    182     else tsttoi(tensPileM18D)
    183     else tsttoi(tensPile10B)
    184     else tsttoi(tensPileP18B)
    185     else tsttoi(tensPileM18B)
    186     else tsttoi(tensPileCh)
    187     else tsttoi(swPile5)
    188     else tsttoi(swPile15)
    189     else tsttoi(tempCaissH1)
    190     else tsttoi(tempCaissH2)
    191     else tsttoi(tempCaissB1)
    192     else tsttoi(tempCaissB2)
    193     else tsttoi(tempCaissTHe)
    194     else tsttoi(tempCaissPiles)
    195     else tsttoi(tempCaissDrv)
    196     else tsttoi(pressHeBain)
    197     else tsttoi(pressPirani)
    198164    else {
    199165      // cerr << "*Warning, unrecognized TOI " << line << endl;
  • trunk/Poubelle/archTOI.old/transfelec.cc

    r394 r534  
    11#include "transfelec.h"
    22
     3// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
    34
    45// Parametres du circuit electrique de lecture SST
  • trunk/Poubelle/archTOI.old/transfelec.h

    r394 r534  
    33
    44//#include <math.h>
     5
     6// D. Yvon, CE Saclay, DAPNIA/SPP, 08/99
     7
    58
    69#ifdef __MWERKS__
Note: See TracChangeset for help on using the changeset viewer.