Changeset 407 in Sophya for trunk/Poubelle/archTOI.old/archtoi.cc


Ignore:
Timestamp:
Sep 18, 1999, 2:08:23 PM (26 years ago)
Author:
ansari
Message:

apres grenoble

File:
1 edited

Legend:

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

    r406 r407  
    1212#include "archtoi.h"
    1313#include "archparam.h"
    14 #include "asigps.h"
    1514
    1615using namespace std;
     
    3938{
    4039  init();
    41   readReq(str);
     40  svr.readReq(str);
    4241}
    4342
     
    4746  init();
    4847  ifstream str(filename.c_str());
    49   readReq(str);
     48  svr.readReq(str);
    5049}
    5150
     
    5756  fptr = NULL;
    5857  ostr = NULL;
    59 }
    60 
    61 void ArchTOI::readReq(istream& str)
    62 {
    63    string line;
    64    while (str) {
    65      getline(str,line);
    66      if (!str) break;
    67      if (line[0] == '@') processTOIReq(line);
    68      else if (line[0] == '#')
    69        if (!processOption(line)) break;
    70    }
    71 }
    72 
    73 #define tsttoi(toi)   if (key == "@"#toi) kind = toi;
    74 
    75 void ArchTOI::processTOIReq(string line)
    76 {
    77   // find TOI kind, index and options
    78   TOIKind kind= (TOIKind)-1;
    79   int index=-1;
    80   bool interp=false;
    81   bool repet =false;
    82   bool flag  =false;
    83   bool notrig=false;
    84   int x = line.find(' ');
    85   string key = line.substr(0, x);
    86   string opts = (x>0) ? line.substr(x) : string("");
    87   tsttoi(sampleNum)
    88   else tsttoi(internalTime)
    89   else tsttoi(mjd)
    90   else tsttoi(boloTens)
    91   else tsttoi(boloRaw)
    92   else tsttoi(sstDiode)
    93   else tsttoi(sstChannel)
    94   else tsttoi(sstStarCnt)
    95   else tsttoi(sstStarZ)
    96   else tsttoi(sstStarF)
    97   else tsttoi(sstStarT)
    98   else tsttoi(gyroRaw)
    99   else tsttoi(gpsTime)
    100   else tsttoi(longitude)
    101   else tsttoi(latitude)
    102   else tsttoi(altitude)
    103   else tsttoi(tsid)
    104   else tsttoi(azimut)
    105   else tsttoi(alphaAxis)
    106   else tsttoi(deltaAxis)
    107   else tsttoi(alphaBolo)
    108   else tsttoi(deltaBolo)
    109   else {
    110     cerr << "*Warning, unrecognized TOI " << line << endl;
    111     return;
    112   }
    113   if (kind  == sampleNum) notrig = true;
    114   while (opts != "") {
    115     if (opts[0] == ' ') {
    116       opts = opts.substr(opts.find_first_not_of(' '));
    117       if (opts == "") break;
    118     }
    119     x = opts.find(' ');
    120     string opt = opts.substr(0, x);
    121     opts = (x>0) ? opts.substr(x) : string("");
    122     if (opt[0]>='0' && opt[0]<='9') {
    123       index = atoi(opt.c_str());
    124     } else if (opt == "notrig") {
    125       notrig = true;
    126     } else if (opt == "repet") {
    127       repet = true; interp = false;
    128     } else if (opt == "interp") {
    129       interp = true; repet = false;
    130     } else if (opt == "flag") {
    131       flag = true;
    132     }
    133   }
     58  requestVersion = "";
     59  svr.registerReqHandler(this);
     60}
     61
     62
     63bool ArchTOI::processTOIReq(string line, string toiname, TOIKind /*kind*/, int index,
     64                            bool interp, bool repet, bool flag, bool /*notrig*/)
     65{
    13466  headertoi.push_back(line);
    135   string toiname = key.substr(1);
    13667  if (index>=0) {
    13768    char idx[10];
     
    14475  toinames.push_back(toiname);
    14576  toiflags.push_back(flg((flag?hasflag:0)+((!repet&&!interp)?useNA:0)));
    146   if (index<0) index=0;
    147   svr.AddInfo(kind, index, !notrig, interp);
     77  return true;
    14878}
    14979
    150 bool ArchTOI::processOption(string line)
    151 {
    152   int x = line.find(' ');
    153   string key = line.substr(0, x);
    154   string arg = (x>0) ? line.substr(x) : string("");
     80bool ArchTOI::processOption(string key, string arg)
     81{
     82  string line=key; if (arg != "") line = line + " " + arg;
     83  headeropt.push_back(line);
    15584  if (arg.length()>0 && arg[0] == ' ') {
    15685    arg = arg.substr(arg.find_first_not_of(' '));
     
    16089  } else if (key == "#FITS") {
    16190    format = fits_fmt;
    162   } else if (key == "#TRANGE") {
    163     double tmin, tmax;
    164     sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
    165     svr.SetTimeInterval(tmin, tmax);
    166   } else if (key == "#PATH") {
    167     svr.SetDirectory(arg);
    168   } else if (key == "#FILE") {
    169     svr.AddFile(arg);
    17091  } else if (key == "#UNDEF") {
    17192    undef=arg;
    17293  } else if (key == "#ALLBOLOS") {
    17394    allBolos=true;
    174   } else if (key == "#RECORDER") {
    175     svr.OnBoardRecorderFiles(true);
    176   } else if (key == "#MJD0") {
    177     double t0;
    178     sscanf(arg.c_str(), "%lg", &t0);
    179     archParam.acq.tBlock0 = t0;
    180   } else if (key == "#PERECH") {
    181     double t0;
    182     sscanf(arg.c_str(), "%lg", &t0);
    183     archParam.acq.perEch = t0;
    184   } else if (key == "#ASIGPS") {
    185     ASIGPS* gps = new ASIGPS(arg);
    186     gps->FitsDump("GPSDump.fits");
    187     svr.UseAuxGPS(gps);
    188   } else if (key == "#END") {
     95  } else if (key == "#REQVERSION") {
     96    requestVersion = arg;
     97  } else if (key == "#COMMENT") {
     98    comments.push_back(arg);
     99  } else {
    189100    return false;
    190   } else {
    191     cerr << "*Warning, unrecognized option " << line << endl;
    192     return true;
    193   }
    194  
    195   headeropt.push_back(line);
     101  }
     102 
    196103  return true;
    197104}
     
    215122 
    216123  cout << "starting query" << endl;
    217   TOIIter iter = svr.DoQuery();
     124  TOIIter iter = svr.doQuery();
    218125  (this->*openFile)(outfilename);
    219126  (this->*outHeader)(iter);
     
    388295    //fits_write_key(fptr, TINT, "BOLO", &j, NULL, &fitsStatus);
    389296  }
     297  fits_write_key_str(fptr, "TOIVERS", ARCHTOI_VERS, "Archtoi version",&fitsStatus);
     298  fits_write_key_str(fptr, "TOITAG", ARCHTOI_TAG, "Archtoi cvs tag",&fitsStatus);
     299  if (requestVersion != "")
     300    fits_write_key_str(fptr, "REQVERS", (char*) requestVersion.c_str(),
     301                       "Request options version",&fitsStatus);
    390302  fits_write_comment(fptr, "Generated with archtoi " ARCHTOI_VERS, &fitsStatus);
    391303  char line[80];
    392304  sprintf(line, "using archeops.h %d", version_num);
    393305  fits_write_comment(fptr, line, &fitsStatus);
     306  for (list<string>::iterator i = comments.begin(); i!=comments.end(); i++)
     307    fits_write_comment(fptr, (char*)((*i).c_str()), &fitsStatus);
    394308 
    395309  fitsLine = 1;
Note: See TracChangeset for help on using the changeset viewer.