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


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

V2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.