Ignore:
Timestamp:
Sep 9, 2002, 5:33:16 PM (23 years ago)
Author:
aubourg
Message:

Vivien, limites processors et connect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/Kernel/toimanager.cc

    r2133 r2187  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toimanager.cc,v 1.16 2002-07-26 08:52:43 vfebvre Exp $
     5// $Id: toimanager.cc,v 1.17 2002-09-09 15:33:15 aubourg Exp $
    66
    77#include "toimanager.h"
     
    1010#include <iostream.h>
    1111#include <unistd.h>
     12#include <map>
    1213
    1314#ifndef MAXINT
     
    1819  reqBegin = 0;
    1920  reqEnd = MAXINT;
     21
     22  // -----------ajout cgt vf 19/08/2002
     23  // par defaut TOISegmented
     24  selectTOISegmented(1024, 20);
     25  // ----------- fin ajout cgt
     26
    2027}
    2128
     
    2734}
    2835
     36// ajout vf 26/07/2002
     37
    2938// enregistrement d'un processeur dans la liste des processeurs pour une execution en groupe
    3039
     
    3746
    3847
    39 // demarrage de tous les processeurs
     48// demarrage de tous les processeurs et verification auto des samplenum pour chaque processeur parametre
    4049
    4150void TOIManager::startAll() {
     51  // verification des samplenum
     52  bool samples_ok=checkSamplesLimits(1);
     53  if (samples_ok) {
     54    cout << "All limits ok" << endl << "Starting processors" << endl;
     55  } else {
     56    cout << "One or more limits ajusted for execution" << endl << "Starting processors" << endl;
     57  }
     58
     59  // mise a jour des limites apres verification
     60  checkSamplesLimits(2);
     61  checkSamplesLimits(3);
     62   
     63  // debogage affichage des limites apres calcul
    4264  for (vector<TOIProcessor*>::iterator i = processors.begin();
    4365       i != processors.end(); i++) {
    4466    TOIProcessor* proc = *i;
    45     cout << "******************" <<  endl;
    46     cout << "starting processor  " <<  endl;
    47     cout << "******************" << endl;
     67    proc->printLimits();
     68  }
     69
     70  // demarrage
     71  for (vector<TOIProcessor*>::iterator i = processors.begin();
     72       i != processors.end(); i++) {
     73    TOIProcessor* proc = *i;
     74    cout << "**********************" <<  endl;
     75    cout << "starting processor " <<  endl;
    4876    proc->start();
    4977    cout << "processor started " << endl;
    50     cout << "******************" << endl;
    51   }
    52 }
    53 
    54 
     78  }
     79  cout << "**********************" << endl;
     80}
     81
     82bool TOIManager::checkSamplesLimits(int pass)
     83{
     84  bool processor_ok=true;
     85  bool samples_ok=true;
     86  for (vector<TOIProcessor*>::iterator i = processors.begin();
     87       i != processors.end(); i++) {
     88    TOIProcessor* proc = *i;
     89    cout << "testing processor limits  " <<  endl;
     90    // test du processeur
     91   
     92    // test seulement pour les processor cle
     93    //if (proc->getRequested()) {
     94      processor_ok = proc->checkSampleLimits(pass);
     95    //}
     96   
     97    if (processor_ok) {
     98      cout << "processor limits ok " << endl;
     99    } else {
     100      cout << "processor limits ajusted" << endl;
     101      samples_ok = false;
     102    }
     103  }
     104  return samples_ok;
     105}
     106
     107// fin ajout vf
    55108
    56109void TOIManager::setRequestedSample(int begin, int end) {
     
    85138  }
    86139}
     140
     141
     142// -----------ajout cgt vf 19/08/2002
     143
     144
     145void TOIManager::selectTOISegmented(int bufsz, int maxseg)
     146{
     147  fgSegmented = true;
     148  segBuffsz = bufsz;
     149  segMaxseg = maxseg;
     150}
     151
     152void TOIManager::selectTOISeqBuffered(int wsz)
     153{
     154  fgSegmented = false;
     155  segBuffsz = wsz;
     156}
     157
     158// methode connect de cgt simplifiee et corrigee
     159TOI& TOIManager::connect(TOIProcessor& prout, string& out,
     160                  TOIProcessor& prin, string& in, string nom, int wbsz, bool withFlag)
     161{
     162  TOI* toi;
     163  if (nom.length() < 1) {
     164    char buff[128];
     165    sprintf(buff, "TOI%s_[%s-%s]", nom, in, out);
     166    nom = buff;
     167  }
     168  if (wbsz < 16)   wbsz = segBuffsz;
     169 
     170  // ajout test pour eviter de creer 2 tois en sortie
     171  if ((toi=prout.getOutToi(out)) == NULL) {
     172    //cout << "toi cree" << endl;
     173    if (fgSegmented) toi = new TOISegmented(nom, wbsz, segMaxseg);
     174    else toi = new TOISeqBuffered(nom, wbsz);
     175    // on ajoute le toi de sortie
     176    prout.addOutput(out, toi);
     177  } else {
     178    //cout << "toi deja cree stop" << endl;
     179  }
     180
     181  if (withFlag) { // Si c'est un FITSTOIWriter
     182    FITSTOIWriter* ftw = dynamic_cast< FITSTOIWriter* >(&prin);
     183    if (ftw) ftw->addInput(in, toi, withFlag);
     184    else prin.addInput(in, toi);
     185  }
     186  else prin.addInput(in, toi);
     187  return(*toi);
     188}
     189
     190
     191TOI& TOIManager::connect(TOIProcessor& prout, const char* out,
     192                  TOIProcessor& prin, const char* in, string nom, int wbsz, bool withFlag)
     193{
     194  string outs = out; 
     195  string ins = in;
     196  return connect(prout, outs, prin, ins, nom, wbsz, withFlag);
     197}
     198
     199// ----------- fin ajout cgt
     200
    87201
    88202
     
    164278
    165279}
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
Note: See TracChangeset for help on using the changeset viewer.