Index: trunk/Poubelle/archTOI.old/archeopsfile.cc
===================================================================
--- trunk/Poubelle/archTOI.old/archeopsfile.cc	(revision 406)
+++ trunk/Poubelle/archTOI.old/archeopsfile.cc	(revision 407)
@@ -5,4 +5,6 @@
 #define utilitaires_de_block_archeops
 #include "archeopsfile.h"
+#include "gyrohandler.h"
+
 extern "C" {
 #include "compress.h"
@@ -41,6 +43,7 @@
   block_type_modele         peekBlock;
   
-  SSTHandler sstHandler;
-  GPSParser  gpsParser;
+  SSTHandler   sstHandler;
+  GyroHandler  gyroHandler;
+  GPSParser    gpsParser;
 };
 
@@ -85,5 +88,5 @@
 
 BlockSet::BlockSet(BlockSet const& x) 
-: sstHandler(x.sstHandler)
+: sstHandler(x.sstHandler), gyroHandler(x.gyroHandler)
 {
   lastParam      = NULL;
@@ -567,4 +570,7 @@
        blockSet->sstHandler.ProcessBlock((block_type_sst*)&blockSet->curBlock);
      }
+     case block_gyro : {
+       blockSet->gyroHandler.ProcessBlock((block_type_gyro*)&blockSet->curBlock);
+     }
      case block_gps : {
        blockSet->gpsParser.ProcessBlock((block_type_gps*)&blockSet->curBlock);
@@ -673,5 +679,5 @@
   static char* buffer = 0;
   static int4  debswp = debut_block_mesure;
-  static int4  longmax = taille_maxi_block_archeops*20;
+  static int4  longmax = taille_maxi_block_archeops*20; 
   if (!buffer) {
     buffer = new char[longmax];
@@ -680,12 +686,17 @@
 #endif
   }
-  fseek(f,pos,SEEK_SET);
-  size_t read = fread(buffer,1,taille_maxi_block_archeops*2,f);
-  //if (read<taille_maxi_block_archeops*2) return -1;
-  for (int i=4; i<read; i+=4) {
-    if (*(int4*)(buffer+i) == debswp) {
-      cout << "trying to skip " << i << " bytes to pos="<<pos+i << endl;
-      return pos+i;
+  size_t read = longmax;
+  while (read == longmax) {
+    fseek(f,pos,SEEK_SET);
+    read = fread(buffer,1,longmax,f);
+    //if (read<taille_maxi_block_archeops*2) return -1; 
+    // EA 150999 changed i+=4 to i++ -> unaligned, but can lose bytes in flight recorder
+    for (size_t i=4; i<read; i++) {
+      if (*(int4*)(buffer+i) == debswp) {
+	cout << "trying to skip " << i << " bytes to pos="<<pos+i << endl;
+	return pos+i;
+      }
     }
+    pos += read;
   }
   cout << "cannot find block start" << endl;
@@ -758,4 +769,10 @@
 }
 
+int ArcheopsFile::getReglageBlockNum() {
+  if (!lastReglage()) return -1;
+  return numero_block(lastReglage());
+}
+
+
 int ArcheopsFile::getSSTBlockNum() {
   if (!lastSST()) return -1;
@@ -864,4 +881,7 @@
 }
 
+double ArcheopsFile::getGainAmpli(int ibolo) {
+     return gain_ampli(lastReglage()->reglage.bolo[ibolo]);
+}
 
 // SST, gyros...
@@ -895,15 +915,17 @@
 }
 
-long ArcheopsFile::getGyro(int igyro, int imesure) {   
-  if (igyro<0 || igyro>2) return 0;
-  if (imesure<0 || imesure>= nb_per_block*2) return 0;
-  block_type_gyro* blk = lastGyro() ;
-  if (!blk) return 0;
-#if version_num<=25
-  return blk->gyros[igyro][imesure]-32768.;
-#else
-  return blk->gyro[igyro][imesure]-32768.;
-#endif
-}
+long ArcheopsFile::getGyroRaw(int igyro, int imesure) {   
+  return blockSet->gyroHandler.getRawSignal(imesure, igyro);
+}
+
+double ArcheopsFile::getGyroTens(int igyro, int imesure) {   
+  return blockSet->gyroHandler.getSignal(imesure, igyro);
+}
+
+double ArcheopsFile::getGyroSpeed(int igyro, int imesure) {   
+  return blockSet->gyroHandler.getSpeed(imesure, igyro);
+}
+
+
 
 
Index: trunk/Poubelle/archTOI.old/archeopsfile.h
===================================================================
--- trunk/Poubelle/archTOI.old/archeopsfile.h	(revision 406)
+++ trunk/Poubelle/archTOI.old/archeopsfile.h	(revision 407)
@@ -127,7 +127,9 @@
     
   // Bolo
+  int getReglageBlockNum();
   int getBoloBlockNum();
   long getRawBolo(int ibolo, int imesure);   // donnee brute, avec seulement soustraction offset
   double getMuVBolo(int ibolo, int imesure); // microvolts, filtre avec filtre carre
+  double getGainAmpli(int ibolo);
   
   // SST, gyros, etc
@@ -142,5 +144,7 @@
   
   int getGyroBlockNum();
-  long getGyro(int iGyro, int imesure);
+  long getGyroRaw(int iGyro, int imesure);
+  double getGyroTens(int iGyro, int imesure);
+  double getGyroSpeed(int iGyro, int imesure);
   
   double getAzimut(int imesure);
Index: trunk/Poubelle/archTOI.old/archtoi.cc
===================================================================
--- trunk/Poubelle/archTOI.old/archtoi.cc	(revision 406)
+++ trunk/Poubelle/archTOI.old/archtoi.cc	(revision 407)
@@ -12,5 +12,4 @@
 #include "archtoi.h"
 #include "archparam.h"
-#include "asigps.h"
 
 using namespace std; 
@@ -39,5 +38,5 @@
 {
   init();
-  readReq(str);
+  svr.readReq(str);
 }
 
@@ -47,5 +46,5 @@
   init();
   ifstream str(filename.c_str());
-  readReq(str);
+  svr.readReq(str);
 }
 
@@ -57,81 +56,13 @@
   fptr = NULL;
   ostr = NULL;
-}
-
-void ArchTOI::readReq(istream& str)
-{
-   string line;
-   while (str) {
-     getline(str,line);
-     if (!str) break;
-     if (line[0] == '@') processTOIReq(line);
-     else if (line[0] == '#') 
-       if (!processOption(line)) break;
-   }
-}
-
-#define tsttoi(toi)   if (key == "@"#toi) kind = toi;
-
-void ArchTOI::processTOIReq(string line)
-{
-  // find TOI kind, index and options
-  TOIKind kind= (TOIKind)-1;
-  int index=-1;
-  bool interp=false;
-  bool repet =false;
-  bool flag  =false;
-  bool notrig=false;
-  int x = line.find(' ');
-  string key = line.substr(0, x);
-  string opts = (x>0) ? line.substr(x) : string("");
-  tsttoi(sampleNum)
-  else tsttoi(internalTime)
-  else tsttoi(mjd)
-  else tsttoi(boloTens)
-  else tsttoi(boloRaw)
-  else tsttoi(sstDiode)
-  else tsttoi(sstChannel)
-  else tsttoi(sstStarCnt)
-  else tsttoi(sstStarZ)
-  else tsttoi(sstStarF)
-  else tsttoi(sstStarT)
-  else tsttoi(gyroRaw)
-  else tsttoi(gpsTime)
-  else tsttoi(longitude)
-  else tsttoi(latitude)
-  else tsttoi(altitude)
-  else tsttoi(tsid)
-  else tsttoi(azimut)
-  else tsttoi(alphaAxis)
-  else tsttoi(deltaAxis)
-  else tsttoi(alphaBolo)
-  else tsttoi(deltaBolo)
-  else {
-    cerr << "*Warning, unrecognized TOI " << line << endl;
-    return;
-  }
-  if (kind  == sampleNum) notrig = true;
-  while (opts != "") {
-    if (opts[0] == ' ') {
-      opts = opts.substr(opts.find_first_not_of(' '));
-      if (opts == "") break;
-    }
-    x = opts.find(' ');
-    string opt = opts.substr(0, x);
-    opts = (x>0) ? opts.substr(x) : string("");
-    if (opt[0]>='0' && opt[0]<='9') {
-      index = atoi(opt.c_str());
-    } else if (opt == "notrig") {
-      notrig = true;
-    } else if (opt == "repet") {
-      repet = true; interp = false;
-    } else if (opt == "interp") {
-      interp = true; repet = false;
-    } else if (opt == "flag") {
-      flag = true;
-    }
-  }
+  requestVersion = "";
+  svr.registerReqHandler(this);
+}
+
+
+bool ArchTOI::processTOIReq(string line, string toiname, TOIKind /*kind*/, int index, 
+                            bool interp, bool repet, bool flag, bool /*notrig*/)
+{
   headertoi.push_back(line);
-  string toiname = key.substr(1); 
   if (index>=0) {
     char idx[10]; 
@@ -144,13 +75,11 @@
   toinames.push_back(toiname);
   toiflags.push_back(flg((flag?hasflag:0)+((!repet&&!interp)?useNA:0)));
-  if (index<0) index=0;
-  svr.AddInfo(kind, index, !notrig, interp);
+  return true;
 } 
 
-bool ArchTOI::processOption(string line)
-{
-  int x = line.find(' ');
-  string key = line.substr(0, x);
-  string arg = (x>0) ? line.substr(x) : string("");
+bool ArchTOI::processOption(string key, string arg)
+{
+  string line=key; if (arg != "") line = line + " " + arg;
+  headeropt.push_back(line);
   if (arg.length()>0 && arg[0] == ' ') {
     arg = arg.substr(arg.find_first_not_of(' '));
@@ -160,38 +89,16 @@
   } else if (key == "#FITS") {
     format = fits_fmt;
-  } else if (key == "#TRANGE") {
-    double tmin, tmax;
-    sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
-    svr.SetTimeInterval(tmin, tmax);
-  } else if (key == "#PATH") {
-    svr.SetDirectory(arg);
-  } else if (key == "#FILE") {
-    svr.AddFile(arg);
   } else if (key == "#UNDEF") {
     undef=arg;
   } else if (key == "#ALLBOLOS") {
     allBolos=true;
-  } else if (key == "#RECORDER") {
-    svr.OnBoardRecorderFiles(true);
-  } else if (key == "#MJD0") {
-    double t0;
-    sscanf(arg.c_str(), "%lg", &t0);
-    archParam.acq.tBlock0 = t0;
-  } else if (key == "#PERECH") {
-    double t0;
-    sscanf(arg.c_str(), "%lg", &t0);
-    archParam.acq.perEch = t0;
-  } else if (key == "#ASIGPS") {
-    ASIGPS* gps = new ASIGPS(arg);
-    gps->FitsDump("GPSDump.fits");
-    svr.UseAuxGPS(gps);
-  } else if (key == "#END") {
+  } else if (key == "#REQVERSION") {
+    requestVersion = arg;
+  } else if (key == "#COMMENT") {
+    comments.push_back(arg);
+  } else {
     return false;
-  } else {
-    cerr << "*Warning, unrecognized option " << line << endl;
-    return true;
-  }
-  
-  headeropt.push_back(line);
+  }
+  
   return true;
 }
@@ -215,5 +122,5 @@
   
   cout << "starting query" << endl;
-  TOIIter iter = svr.DoQuery();
+  TOIIter iter = svr.doQuery();
   (this->*openFile)(outfilename);
   (this->*outHeader)(iter);
@@ -388,8 +295,15 @@
     //fits_write_key(fptr, TINT, "BOLO", &j, NULL, &fitsStatus);
   }
+  fits_write_key_str(fptr, "TOIVERS", ARCHTOI_VERS, "Archtoi version",&fitsStatus);
+  fits_write_key_str(fptr, "TOITAG", ARCHTOI_TAG, "Archtoi cvs tag",&fitsStatus);
+  if (requestVersion != "")
+    fits_write_key_str(fptr, "REQVERS", (char*) requestVersion.c_str(), 
+                       "Request options version",&fitsStatus);
   fits_write_comment(fptr, "Generated with archtoi " ARCHTOI_VERS, &fitsStatus);
   char line[80];
   sprintf(line, "using archeops.h %d", version_num);
   fits_write_comment(fptr, line, &fitsStatus);
+  for (list<string>::iterator i = comments.begin(); i!=comments.end(); i++)
+    fits_write_comment(fptr, (char*)((*i).c_str()), &fitsStatus);
   
   fitsLine = 1;
Index: trunk/Poubelle/archTOI.old/archtoi.h
===================================================================
--- trunk/Poubelle/archTOI.old/archtoi.h	(revision 406)
+++ trunk/Poubelle/archTOI.old/archtoi.h	(revision 407)
@@ -14,5 +14,5 @@
 using namespace std; 
 
-class ArchTOI {
+class ArchTOI : public RequestHandler {
 public:
   ArchTOI(istream& str);
@@ -24,10 +24,11 @@
   enum flg {hasflag = 1,
             useNA   = 2};
+            
+  virtual bool processTOIReq(string line, string toiname, TOIKind toi, int index, 
+                             bool interp, bool repet, bool flag, bool notrig);
+  virtual bool processOption(string keyw, string args);
   
 protected:
   void init();
-  void readReq(istream& str);
-  bool processOption(string line); // false when #END : stop processing...
-  void processTOIReq(string line);
   TOISvr svr;
   list<string> headertoi;
@@ -61,7 +62,11 @@
   int fitsLine;
   ostream* ostr;
+  
+  string requestVersion;
+  list<string> comments;
 };
 
-#define ARCHTOI_VERS "1.0"
+#define ARCHTOI_VERS "1.1"
+#define ARCHTOI_TAG  "notag"
 
 #endif
Index: trunk/Poubelle/archTOI.old/gyrohandler.cc
===================================================================
--- trunk/Poubelle/archTOI.old/gyrohandler.cc	(revision 407)
+++ trunk/Poubelle/archTOI.old/gyrohandler.cc	(revision 407)
@@ -0,0 +1,42 @@
+// gyrohandler.cc
+// Eric Aubourg         CEA/DAPNIA/SPP   septembre 1999
+
+#include <string.h>
+#include "gyrohandler.h"
+
+
+GyroHandler::GyroHandler() {
+ memset(gyro, 0, 3*nb_per_block*2*sizeof(int4));
+}
+
+  
+GyroHandler::GyroHandler(GyroHandler const& x) {
+  memcpy(gyro, x.gyro, 3*nb_per_block*2*sizeof(int4));
+}
+
+GyroHandler& GyroHandler::operator = (GyroHandler const& x) {
+  memcpy(gyro, x.gyro, 3*nb_per_block*2*sizeof(int4));
+  return *this;
+}
+
+GyroHandler::~GyroHandler() {
+
+}
+
+void GyroHandler::ProcessBlock(block_type_gyro* blk) {
+  memcpy(gyro, blk->gyro, 3*nb_per_block*2*sizeof(int4));
+}
+
+int4  GyroHandler::getRawSignal(int imesure, int igyro) {
+  if (igyro<0 || igyro>=3) return 0;
+  if (imesure<0 || imesure>=nb_per_block*2) return 0;
+  return gyro[igyro][imesure]-32768;
+}
+
+double GyroHandler::getSignal(int imesure, int igyro) {  // V
+  return getRawSignal(imesure, igyro) * 2. / 32768.; // +- 2V dynamique sur 16 bits
+}
+
+double GyroHandler::getSpeed(int imesure, int igyro) {
+  return getSignal(imesure, igyro) * 10;
+}
Index: trunk/Poubelle/archTOI.old/gyrohandler.h
===================================================================
--- trunk/Poubelle/archTOI.old/gyrohandler.h	(revision 407)
+++ trunk/Poubelle/archTOI.old/gyrohandler.h	(revision 407)
@@ -0,0 +1,35 @@
+// gyrohandler.h
+// Eric Aubourg         CEA/DAPNIA/SPP   septembre 1999
+
+#ifndef GYROHANDLER_H
+#define GYROHANDLER_H
+
+
+#ifndef nb_max_bolo
+#define _archeops		//  Acquisition Archeops (avec transputer) 
+#define programme
+extern "C" {
+#include "archeops.h"
+}
+#endif
+
+class GyroHandler {
+public:
+  GyroHandler();
+  GyroHandler(GyroHandler const&);
+  GyroHandler& operator = (GyroHandler const&);
+  virtual ~GyroHandler();
+
+  void ProcessBlock(block_type_gyro*);
+  int4 getRawSignal(int imesure, int igyro); // for last block
+  double getSignal(int imesure, int igyro);    // for last block, mV
+  double getSpeed(int imesure, int igyro);    // for last block, deg/s
+
+protected:
+  int4  gyro[3][nb_per_block*2];
+};
+
+
+// To be done : handle calibration, through stellar sensor, temperature, etc.
+
+#endif
Index: trunk/Poubelle/archTOI.old/toiiter.cc
===================================================================
--- trunk/Poubelle/archTOI.old/toiiter.cc	(revision 406)
+++ trunk/Poubelle/archTOI.old/toiiter.cc	(revision 407)
@@ -1,4 +1,12 @@
 // toiiter.cc
 // Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
+
+#ifndef nb_max_bolo
+#define _archeops		//  Acquisition Archeops (avec transputer) 
+#define programme
+extern "C" {
+#include "archeops.h"
+}
+#endif
 
 
@@ -204,41 +212,57 @@
       switch ((*i).kind) {
       case boloTens:
+      case boloTens2:
       case boloRaw:
-	trigMask |= block_bolo_mask;
-	break;
+      case boloRes:
+      case boloTemp:
+      case boloRawCN:
+      case boloTens2T:
+        trigMask |= block_bolo_mask;
+        break;
+      case boloGainAmpli:
+        trigMask |= block_reglage_mask;
+        break;
       case gpsTime:
       case longitude:
       case latitude:
       case altitude:
-	trigMask |= block_gps_mask;
-	break;
+        trigMask |= block_gps_mask;
+        break;
       case azimut:
-	file->needSSTProcessMask(SSTHandler::findPeriod);
-	trigMask |= block_sst_mask;
-	break;
+        file->needSSTProcessMask(SSTHandler::findPeriod);
+        trigMask |= block_sst_mask;
+        break;
       case sstStarCnt:
       case sstStarZ:
       case sstStarF:
       case sstStarT:
-	file->needSSTProcessMask(SSTHandler::findStars);
-	trigMask |= block_sst_mask;
-	break;
+        file->needSSTProcessMask(SSTHandler::findStars);
+        trigMask |= block_sst_mask;
+        break;
       case sstDiode:
-	file->needSSTProcessMask(SSTHandler::permDiode);
-	trigMask |= block_sst_mask;
-	break;
+      case sstDiodeCN:
+        file->needSSTProcessMask(SSTHandler::permDiode);
+        trigMask |= block_sst_mask;
+        break;
       case sstChannel:
-	trigMask |= block_sst_mask;
-	break;
+      case sstChannelCN:
+        trigMask |= block_sst_mask;
+        break;
       case gyroRaw:
-	trigMask |= block_gyro_mask;
-	break;
+      case gyroTens:
+        trigMask |= block_gyro_mask;
+        break;
+      case gyroSpeed:
+        trigMask |= block_gyro_mask; // $CHECK$ + info to calibrate gyros
+        break;
       case alphaAxis:
       case deltaAxis:
+      case alphaSst:
+      case deltaSst:
       case alphaBolo:
       case deltaBolo:
-	file->needSSTProcessMask(SSTHandler::findAxis);
-	trigMask |= block_sst_mask;
-	break;
+        file->needSSTProcessMask(SSTHandler::findAxis);
+        trigMask |= block_sst_mask;
+        break;
       }
     }
@@ -407,10 +431,18 @@
      return true;
    case boloTens:
+   case boloTens2:
+   case boloTens2T:
+   case boloRes:
+   case boloRawCN:
      if (imes==0 && file->llastBolo()==NULL) return false;
      return file->lastBolo() != NULL;
    case boloRaw:
      return file->lastBolo() != NULL;
+   case boloGainAmpli:
+     return file->lastReglage() != NULL;
    case sstDiode:
    case sstChannel:
+   case sstDiodeCN:
+   case sstChannelCN:
      return file->lastSST() != NULL;
    case sstStarCnt:
@@ -423,4 +455,6 @@
    }
    case gyroRaw:
+   case gyroTens:
+   case gyroSpeed:
      return (file->lastGyro() != NULL);
    case gpsTime:
@@ -450,4 +484,5 @@
 }
 
+
 double TOIIter::getValue(int column) {
   if (!initDone) Init();
@@ -484,4 +519,6 @@
    case boloRaw:
      return file->getRawBolo(index, imes);
+   case boloGainAmpli:
+     return file->getGainAmpli(index);
    case sstDiode:
      return file->getSSTSignal(index, imes);
@@ -497,5 +534,9 @@
      return file->getSSTStarT(index, imes);
    case gyroRaw:
-     return file->getGyro(index, imes);
+     return file->getGyroRaw(index, imes);
+   case gyroTens:
+     return file->getGyroTens(index, imes);
+   case gyroSpeed:
+     return file->getGyroSpeed(index, imes);
    case gpsTime:
      return file->getGPSUTC();
@@ -540,4 +581,6 @@
      case boloRaw:
        return file->blockNum() == file->getBoloBlockNum();
+     case boloGainAmpli:
+       return file->blockNum() == file->getReglageBlockNum() && imes==0;
      case sstChannel:
      case sstDiode:
@@ -548,4 +591,6 @@
        return file->blockNum() == file->getSSTBlockNum();
      case gyroRaw:
+     case gyroTens:
+     case gyroSpeed:
        return file->blockNum() == file->getGyroBlockNum();
      case gpsTime:
Index: trunk/Poubelle/archTOI.old/toiiter.h
===================================================================
--- trunk/Poubelle/archTOI.old/toiiter.h	(revision 406)
+++ trunk/Poubelle/archTOI.old/toiiter.h	(revision 407)
@@ -15,30 +15,39 @@
 
 enum TOIKind {
-  sampleNum,  // Numero d''echantillon (timer interne transputer)
-  internalTime, // temps transputer depuis debut manip, en secondes.
-  mjd,        // UTC (en jours, MJD = JD - 2450000). index=0 : premier bloc GPS. 1: + sioux.
-  boloTens,   // tension en microVolts, filtree avec filtre carre indexe par bolometre
-  boloRaw,    // tension brute, non filtree indexe par bolometre
-  boloTemp,   // Kelvins
-  sstDiode,   // signal brut SST, indice = diode, 0-45
-  sstChannel, // signal brut SST, indice = canal, 0-47
-  sstStarCnt, // nombre d''etoiles detectees durant ce sample
-  sstStarZ,   // numero de diode d''une eventuelle etoile,   i=etoile 0..n
-  sstStarF,   // flux d''une eventuelle etoile,             <0 si moins de i+1 etoiles
-  sstStarT,   // temps d''une eventuelle etoile,            <0 si moins de i+1 etoiles
-  gyroRaw,    // valeur brute du gyro, index = 0,1,2
-  gpsTime,    // temps fourni par GPS
-  longitude,  // position ballon
-  latitude,   // position ballon
-  altitude,   // position ballon
-  tsid,       // temps sideral en secondes
-  azimut,     // a preciser, reconstruit SST, magneto, autres...
-  alphaAxis,  // 
-  deltaAxis,  //
-  alphaSst,  // 
-  deltaSst,  //
-  alphaBolo,  // sur le ciel, indexe par bolometre
-  deltaBolo   // sur le ciel, indexe par bolometre
-};
+  sampleNum,     // Numero d''echantillon (timer interne transputer)
+  internalTime,  // temps transputer depuis debut manip, en secondes.
+  mjd,           // UTC (en jours, MJD = JD - 2450000). index=0 : premier bloc GPS. 1: + sioux.
+  boloTens,      // tension en microVolts, filtree avec filtre carre indexe par bolometre
+  boloTens2,     // tension en microVolts, avec soustraction offset filtre
+  boloRaw,       // tension brute en microVolts, non filtree indexe par bolometre, sans chgt signe
+  boloRes,       // Resistance, ohms
+  boloTemp,      // Kelvins, need R(T) -> N/A
+  boloGainAmpli, // gain de l'ampli du bolo
+  boloRawCN,     // compression noise on bolo raw
+  boloTens2T,    // total, microVolts, avec consigne DAC
+  sstDiode,      // signal brut SST, indice = diode, 0-45
+  sstChannel,    // signal brut SST, indice = canal, 0-47
+  sstDiodeCN,    // compression noise
+  sstChannelCN,  // compression noise
+  sstStarCnt,    // nombre d''etoiles detectees durant ce sample
+  sstStarZ,      // numero de diode d''une eventuelle etoile,   i=etoile 0..n
+  sstStarF,      // flux d''une eventuelle etoile,             <0 si moins de i+1 etoiles
+  sstStarT,      // temps d''une eventuelle etoile,            <0 si moins de i+1 etoiles
+  gyroRaw,       // valeur brute du gyro, index = 0,1,2
+  gyroTens,      // tension gyro, V, index = 0,1,2
+  gyroSpeed,     // vitesse gyro, deg/s, index = 0,1,2, calibree...
+  gpsTime,       // temps fourni par GPS
+  longitude,     // position ballon, degrees
+  latitude,      // position ballon, degrees
+  altitude,      // position ballon, m
+  tsid,          // temps sideral en secondes
+  azimut,        // azimut centre optique ??? 
+  alphaAxis,     // 
+  deltaAxis,     //
+  alphaSst,      // 
+  deltaSst,      //
+  alphaBolo,     // sur le ciel, indexe par bolometre
+  deltaBolo      // sur le ciel, indexe par bolometre
+}; 
 
 class TOIInterpolator;
Index: trunk/Poubelle/archTOI.old/toisvr.cc
===================================================================
--- trunk/Poubelle/archTOI.old/toisvr.cc	(revision 406)
+++ trunk/Poubelle/archTOI.old/toisvr.cc	(revision 407)
@@ -2,19 +2,24 @@
 // Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
 
-
+#include <iostream.h>
 #include "toisvr.h"
+#include "archparam.h"
+#include "asigps.h"
 
 TOISvr::TOISvr()
 {}
 
-void TOISvr::SetDirectory(string d) {
+// To avoid special copy constructor handling, we will not
+// register ourself to us... Special dealing in readReq.
+
+void TOISvr::setDirectory(string d) {
   iter.directory = d;
 }
 
-void TOISvr::AddFile(string f) {
+void TOISvr::addFile(string f) {
   iter.files.insert(f);
 }
 
-void TOISvr::UseAuxGPS(AuxGPS* gps) {
+void TOISvr::useAuxGPS(AuxGPS* gps) {
   if (iter.auxGPS) delete iter.auxGPS;
   iter.auxGPS = gps;
@@ -22,15 +27,15 @@
 
 
-void TOISvr::OnBoardRecorderFiles(bool x) {
+void TOISvr::onBoardRecorderFiles(bool x) {
   iter.isOnBoardRecorder = x;
 }
 
   
-void TOISvr::SetTimeInterval(double tStart, double tEnd) {
+void TOISvr::setTimeInterval(double tStart, double tEnd) {
   if (tStart>0) iter.tStart = tStart;
   if (tEnd>0)   iter.tEnd = tEnd;
 }
   
-void TOISvr::AddInfo(TOIKind kind, int index, bool triggering, bool interp) {
+void TOISvr::addInfo(TOIKind kind, int index, bool triggering, bool interp) {
   TOIIter::info i;
   i.kind = kind; 
@@ -41,10 +46,164 @@
 }
 
-void TOISvr::AddInfo(TOIKind kind, bool triggering, bool interp) {
-  AddInfo(kind,0,triggering,interp);
+void TOISvr::addInfo(TOIKind kind, bool triggering, bool interp) {
+  addInfo(kind,0,triggering,interp);
 }
   
-TOIIter TOISvr::DoQuery() {
+TOIIter TOISvr::doQuery() {
   //iter.Init();
   return iter;
 }
+
+void TOISvr::registerReqHandler(RequestHandler* h) {
+  handlers.push_back(h);
+}
+
+
+void TOISvr::readReq(istream& str) {
+   string line;
+   while (str) {
+     getline(str,line);
+     if (!str) break;
+     if (line.substr(0,4)=="#END") break;
+     if (line[0] != '@' && line[0] != '#') continue;
+     bool handled=processRequest(line); 
+     if (!handled) {
+        cerr << "*Warning, unrecognized directive " << line << endl;
+     }
+   }
+}
+
+#define tsttoi(toi)   if (keyw == "@"#toi) kind = toi;
+
+bool TOISvr::processRequest(string line) {
+  int x = line.find(' ');
+  string keyw = line.substr(0, x);
+  string args = (x>0) ? line.substr(x) : string("");
+  if (keyw[0] == '#') {
+     bool handled = processOption(keyw,args);
+     for (list<RequestHandler*>::iterator i = handlers.begin(); 
+          i != handlers.end(); i++) {
+       handled |= (*i)->processOption(keyw,args);
+     }
+     return handled;
+  }
+  if (keyw[0] == '@') {
+	// find TOI kind, index and options
+    TOIKind kind= (TOIKind)-1;
+    int index=-1;
+    bool interp=false;
+    bool repet =false;
+    bool flag  =false;
+    bool notrig=false;
+    tsttoi(sampleNum)
+    else tsttoi(internalTime)
+    else tsttoi(mjd)
+    else tsttoi(boloTens)
+    else tsttoi(boloTens2)
+    else tsttoi(boloRaw)
+    else tsttoi(boloRes)
+    else tsttoi(boloTemp)
+    else tsttoi(boloGainAmpli)
+    else tsttoi(boloTens2T)
+    else tsttoi(boloRawCN)
+    else tsttoi(sstDiode)
+    else tsttoi(sstChannel)
+    else tsttoi(sstDiodeCN)
+    else tsttoi(sstChannelCN)
+    else tsttoi(sstStarCnt)
+    else tsttoi(sstStarZ)
+    else tsttoi(sstStarF)
+    else tsttoi(sstStarT)
+    else tsttoi(gyroRaw)
+    else tsttoi(gyroTens)
+    else tsttoi(gyroSpeed)
+    else tsttoi(gpsTime)
+    else tsttoi(longitude)
+    else tsttoi(latitude)
+    else tsttoi(altitude)
+    else tsttoi(tsid)
+    else tsttoi(azimut)
+    else tsttoi(alphaAxis)
+    else tsttoi(deltaAxis)
+    else tsttoi(alphaSst)
+    else tsttoi(deltaSst)
+    else tsttoi(alphaBolo)
+    else tsttoi(deltaBolo)
+    else {
+      // cerr << "*Warning, unrecognized TOI " << line << endl;
+      return false;
+    }
+    if (kind  == sampleNum || kind == mjd) notrig = true;
+    string toiname = keyw.substr(1); 
+    while (args != "") {
+      if (args[0] == ' ') {
+        args = args.substr(args.find_first_not_of(' '));
+        if (args == "") break;
+      }
+      x = args.find(' ');
+      string opt = args.substr(0, x);
+      args = (x>0) ? args.substr(x) : string("");
+      if (opt[0]>='0' && opt[0]<='9') {
+        index = atoi(opt.c_str());
+      } else if (opt == "notrig") {
+        notrig = true;
+      } else if (opt == "repet") {
+        repet = true; interp = false;
+      } else if (opt == "interp") {
+        interp = true; repet = false;
+      } else if (opt == "flag") {
+        flag = true;
+      }
+    }
+    bool handled = processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
+    for (list<RequestHandler*>::iterator i = handlers.begin(); 
+         i != handlers.end(); i++) {
+      handled |= (*i)->processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
+    }
+    return handled;
+  }
+  return false;
+}
+
+
+bool TOISvr::processTOIReq(string /*line*/, string /*toiname*/, TOIKind kind, int index, 
+                           bool interp, bool /*repet*/, bool /*flag*/, bool notrig)
+{
+  if (index<0) index=0;
+  addInfo(kind, index, !notrig, interp);
+  return true;
+} 
+
+bool TOISvr::processOption(string key, string arg)
+{
+  if (arg.length()>0 && arg[0] == ' ') {
+    arg = arg.substr(arg.find_first_not_of(' '));
+  }
+  if (key == "#TRANGE") {
+    double tmin, tmax;
+    sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
+    setTimeInterval(tmin, tmax);
+  } else if (key == "#PATH") {
+    setDirectory(arg);
+  } else if (key == "#FILE") {
+    addFile(arg);
+  } else if (key == "#RECORDER") {
+    onBoardRecorderFiles(true);
+  } else if (key == "#MJD0") {
+    double t0;
+    sscanf(arg.c_str(), "%lg", &t0);
+    archParam.acq.tBlock0 = t0;
+  } else if (key == "#PERECH") {
+    double t0;
+    sscanf(arg.c_str(), "%lg", &t0);
+    archParam.acq.perEch = t0;
+  } else if (key == "#ASIGPS") {
+    ASIGPS* gps = new ASIGPS(arg);
+    gps->FitsDump("GPSDump.fits");
+    useAuxGPS(gps);
+  } else {
+    // cerr << "*Warning, unrecognized option " << line << endl;
+    return false;
+  }
+  return true;
+}
Index: trunk/Poubelle/archTOI.old/toisvr.h
===================================================================
--- trunk/Poubelle/archTOI.old/toisvr.h	(revision 406)
+++ trunk/Poubelle/archTOI.old/toisvr.h	(revision 407)
@@ -7,26 +7,42 @@
 
 #include "toiiter.h"
+#include <list>
 
 class AuxGPS;
 
-class TOISvr {
+class RequestHandler {
+public:
+  virtual bool processTOIReq(string line, string toiname, TOIKind toi, int index, 
+                             bool interp, bool repet, bool flag, bool notrig)=0;
+  virtual bool processOption(string keyw, string args)=0;
+};
+
+class TOISvr : public RequestHandler {
 public:
   TOISvr();
   
-  void SetDirectory(string);
-  void AddFile(string);
-  void OnBoardRecorderFiles(bool);
-  void UseAuxGPS(AuxGPS* gps);
+  void setDirectory(string);
+  void addFile(string);
+  void onBoardRecorderFiles(bool);
+  void useAuxGPS(AuxGPS* gps);
   
-  void SetTimeInterval(double tStart, double tEnd);
+  void setTimeInterval(double tStart, double tEnd);
   
-  void AddInfo(TOIKind kind, int index, bool triggering=true, bool interp=false);
-  void AddInfo(TOIKind kind, bool triggering=true, bool interp=false);
+  void addInfo(TOIKind kind, int index, bool triggering=true, bool interp=false);
+  void addInfo(TOIKind kind, bool triggering=true, bool interp=false);
   
-  TOIIter DoQuery();
+  void readReq(istream& s);
   
+  TOIIter doQuery();
+
+  bool processRequest(string line);
+  void registerReqHandler(RequestHandler*);
+  virtual bool processTOIReq(string line, string toiname, TOIKind toi, int index, 
+                             bool interp, bool repet, bool flag, bool notrig);
+  virtual bool processOption(string keyw, string args);
   
 protected:
   TOIIter iter;
+  list<RequestHandler*> handlers;
 };
 
