Changeset 407 in Sophya for trunk/Poubelle/archTOI.old/toisvr.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/toisvr.cc

    r394 r407  
    22// Eric Aubourg         CEA/DAPNIA/SPP   juillet 1999
    33
    4 
     4#include <iostream.h>
    55#include "toisvr.h"
     6#include "archparam.h"
     7#include "asigps.h"
    68
    79TOISvr::TOISvr()
    810{}
    911
    10 void TOISvr::SetDirectory(string d) {
     12// To avoid special copy constructor handling, we will not
     13// register ourself to us... Special dealing in readReq.
     14
     15void TOISvr::setDirectory(string d) {
    1116  iter.directory = d;
    1217}
    1318
    14 void TOISvr::AddFile(string f) {
     19void TOISvr::addFile(string f) {
    1520  iter.files.insert(f);
    1621}
    1722
    18 void TOISvr::UseAuxGPS(AuxGPS* gps) {
     23void TOISvr::useAuxGPS(AuxGPS* gps) {
    1924  if (iter.auxGPS) delete iter.auxGPS;
    2025  iter.auxGPS = gps;
     
    2227
    2328
    24 void TOISvr::OnBoardRecorderFiles(bool x) {
     29void TOISvr::onBoardRecorderFiles(bool x) {
    2530  iter.isOnBoardRecorder = x;
    2631}
    2732
    2833 
    29 void TOISvr::SetTimeInterval(double tStart, double tEnd) {
     34void TOISvr::setTimeInterval(double tStart, double tEnd) {
    3035  if (tStart>0) iter.tStart = tStart;
    3136  if (tEnd>0)   iter.tEnd = tEnd;
    3237}
    3338 
    34 void TOISvr::AddInfo(TOIKind kind, int index, bool triggering, bool interp) {
     39void TOISvr::addInfo(TOIKind kind, int index, bool triggering, bool interp) {
    3540  TOIIter::info i;
    3641  i.kind = kind;
     
    4146}
    4247
    43 void TOISvr::AddInfo(TOIKind kind, bool triggering, bool interp) {
    44   AddInfo(kind,0,triggering,interp);
     48void TOISvr::addInfo(TOIKind kind, bool triggering, bool interp) {
     49  addInfo(kind,0,triggering,interp);
    4550}
    4651 
    47 TOIIter TOISvr::DoQuery() {
     52TOIIter TOISvr::doQuery() {
    4853  //iter.Init();
    4954  return iter;
    5055}
     56
     57void TOISvr::registerReqHandler(RequestHandler* h) {
     58  handlers.push_back(h);
     59}
     60
     61
     62void TOISvr::readReq(istream& str) {
     63   string line;
     64   while (str) {
     65     getline(str,line);
     66     if (!str) break;
     67     if (line.substr(0,4)=="#END") break;
     68     if (line[0] != '@' && line[0] != '#') continue;
     69     bool handled=processRequest(line);
     70     if (!handled) {
     71        cerr << "*Warning, unrecognized directive " << line << endl;
     72     }
     73   }
     74}
     75
     76#define tsttoi(toi)   if (keyw == "@"#toi) kind = toi;
     77
     78bool TOISvr::processRequest(string line) {
     79  int x = line.find(' ');
     80  string keyw = line.substr(0, x);
     81  string args = (x>0) ? line.substr(x) : string("");
     82  if (keyw[0] == '#') {
     83     bool handled = processOption(keyw,args);
     84     for (list<RequestHandler*>::iterator i = handlers.begin();
     85          i != handlers.end(); i++) {
     86       handled |= (*i)->processOption(keyw,args);
     87     }
     88     return handled;
     89  }
     90  if (keyw[0] == '@') {
     91        // find TOI kind, index and options
     92    TOIKind kind= (TOIKind)-1;
     93    int index=-1;
     94    bool interp=false;
     95    bool repet =false;
     96    bool flag  =false;
     97    bool notrig=false;
     98    tsttoi(sampleNum)
     99    else tsttoi(internalTime)
     100    else tsttoi(mjd)
     101    else tsttoi(boloTens)
     102    else tsttoi(boloTens2)
     103    else tsttoi(boloRaw)
     104    else tsttoi(boloRes)
     105    else tsttoi(boloTemp)
     106    else tsttoi(boloGainAmpli)
     107    else tsttoi(boloTens2T)
     108    else tsttoi(boloRawCN)
     109    else tsttoi(sstDiode)
     110    else tsttoi(sstChannel)
     111    else tsttoi(sstDiodeCN)
     112    else tsttoi(sstChannelCN)
     113    else tsttoi(sstStarCnt)
     114    else tsttoi(sstStarZ)
     115    else tsttoi(sstStarF)
     116    else tsttoi(sstStarT)
     117    else tsttoi(gyroRaw)
     118    else tsttoi(gyroTens)
     119    else tsttoi(gyroSpeed)
     120    else tsttoi(gpsTime)
     121    else tsttoi(longitude)
     122    else tsttoi(latitude)
     123    else tsttoi(altitude)
     124    else tsttoi(tsid)
     125    else tsttoi(azimut)
     126    else tsttoi(alphaAxis)
     127    else tsttoi(deltaAxis)
     128    else tsttoi(alphaSst)
     129    else tsttoi(deltaSst)
     130    else tsttoi(alphaBolo)
     131    else tsttoi(deltaBolo)
     132    else {
     133      // cerr << "*Warning, unrecognized TOI " << line << endl;
     134      return false;
     135    }
     136    if (kind  == sampleNum || kind == mjd) notrig = true;
     137    string toiname = keyw.substr(1);
     138    while (args != "") {
     139      if (args[0] == ' ') {
     140        args = args.substr(args.find_first_not_of(' '));
     141        if (args == "") break;
     142      }
     143      x = args.find(' ');
     144      string opt = args.substr(0, x);
     145      args = (x>0) ? args.substr(x) : string("");
     146      if (opt[0]>='0' && opt[0]<='9') {
     147        index = atoi(opt.c_str());
     148      } else if (opt == "notrig") {
     149        notrig = true;
     150      } else if (opt == "repet") {
     151        repet = true; interp = false;
     152      } else if (opt == "interp") {
     153        interp = true; repet = false;
     154      } else if (opt == "flag") {
     155        flag = true;
     156      }
     157    }
     158    bool handled = processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
     159    for (list<RequestHandler*>::iterator i = handlers.begin();
     160         i != handlers.end(); i++) {
     161      handled |= (*i)->processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig);
     162    }
     163    return handled;
     164  }
     165  return false;
     166}
     167
     168
     169bool TOISvr::processTOIReq(string /*line*/, string /*toiname*/, TOIKind kind, int index,
     170                           bool interp, bool /*repet*/, bool /*flag*/, bool notrig)
     171{
     172  if (index<0) index=0;
     173  addInfo(kind, index, !notrig, interp);
     174  return true;
     175}
     176
     177bool TOISvr::processOption(string key, string arg)
     178{
     179  if (arg.length()>0 && arg[0] == ' ') {
     180    arg = arg.substr(arg.find_first_not_of(' '));
     181  }
     182  if (key == "#TRANGE") {
     183    double tmin, tmax;
     184    sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);
     185    setTimeInterval(tmin, tmax);
     186  } else if (key == "#PATH") {
     187    setDirectory(arg);
     188  } else if (key == "#FILE") {
     189    addFile(arg);
     190  } else if (key == "#RECORDER") {
     191    onBoardRecorderFiles(true);
     192  } else if (key == "#MJD0") {
     193    double t0;
     194    sscanf(arg.c_str(), "%lg", &t0);
     195    archParam.acq.tBlock0 = t0;
     196  } else if (key == "#PERECH") {
     197    double t0;
     198    sscanf(arg.c_str(), "%lg", &t0);
     199    archParam.acq.perEch = t0;
     200  } else if (key == "#ASIGPS") {
     201    ASIGPS* gps = new ASIGPS(arg);
     202    gps->FitsDump("GPSDump.fits");
     203    useAuxGPS(gps);
     204  } else {
     205    // cerr << "*Warning, unrecognized option " << line << endl;
     206    return false;
     207  }
     208  return true;
     209}
Note: See TracChangeset for help on using the changeset viewer.