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/toiprocessor.cc

    r2133 r2187  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toiprocessor.cc,v 1.25 2002-07-26 08:52:43 vfebvre Exp $
     5// $Id: toiprocessor.cc,v 1.26 2002-09-09 15:33:15 aubourg Exp $
    66
    77#include "toiprocessor.h"
     
    4646  wontNeedValue = -1;
    4747
     48 
     49  // ajout vf 23/07/2002
     50  cout << "Creating processor" << endl;
    4851  // Pour referencer un TOIProcessor, il faut recuperer le TOIManager correspondant
    4952  TOIManager::getManager()->registerProcessor(this);
     53 
     54  // initialisation des limites du sample (par defaut tout le fichier)
     55  snBegin = 0;
     56  snEnd = MAXINT;
     57  snMin=MAXINT;
     58  snMax=0;
     59  // par defaut aucune condition
     60  requestedSample = false;
    5061
    5162}
     
    8394
    8495int TOIProcessor::getMinOut() {
     96  /*
    8597  //cout << name << "minout" << endl;
    8698  if (minOut < 0)  minOut = calcMinOut();
    8799  //cout << name << "minout=" << minOut << endl;
    88100  return minOut;
     101  */
     102  return snBegin + lowExtra;
    89103}
    90104
    91105int TOIProcessor::getMaxOut() {
     106  /*
    92107  //cout << name << "maxout" << endl;
    93108  if (maxOut < 0) maxOut = calcMaxOut();
    94109  //cout << name << "maxout=" << maxOut << endl;
    95110  return maxOut;
     111  */
     112  return snEnd - upExtra;
    96113}
    97114
     
    105122
    106123int TOIProcessor::getMinIn() {
     124  /*
    107125  int nIn = inIx.size();
    108126  int minIn = 0;
     
    115133  if (forcedMinIn > 0 && forcedMinIn > minIn) minIn = forcedMinIn;
    116134  return minIn;
     135  */
     136  return snBegin;
    117137}
    118138
    119139int TOIProcessor::getMaxIn() {
     140  /*
    120141  int_4 nIn = inIx.size();
    121142  int_4 maxIn = MAXINT;
     
    128149  if (forcedMaxIn > 0 && forcedMaxIn < maxIn) maxIn = forcedMaxIn;
    129150  return maxIn;
     151  */
     152  return snEnd;
    130153}
    131154
     
    447470
    448471
    449 
    450 
    451 
    452 
    453 
    454 
    455 
     472// ajout vf 29/07/2002
     473
     474// parametrage de l'echantillon a produire (sans verification)
     475void TOIProcessor::setRequestedSample(long begin, long end) {
     476  requestedSample = true;
     477  snBegin = begin;
     478  snEnd   = end;
     479  //  snMin = snBegin;
     480  //  snMax = snEnd;
     481}
     482
     483
     484bool TOIProcessor::checkSampleLimits(int pass)
     485{
     486  long minTmp=MAXINT;
     487  long maxTmp=-1;
     488
     489  return checkSampleLimits(minTmp, maxTmp, pass);
     490 
     491  cout << "toiprocessor : limites verifiees : " << snBegin << " , " << snEnd << " : " << endl;
     492}
     493
     494
     495
     496
     497bool TOIProcessor::checkSampleLimits(long& min, long& max, int pass)
     498{
     499  bool sample_input_ok=true;
     500  bool sample_ok=true;
     501
     502  /*  cout << "check " << pass << " " << name << " in  " << min << " - " << max << " ; "
     503       << snMin << " - " << snMax << " ; "
     504       << snBegin << " - " << snEnd << endl;*/
     505
     506  if (pass == 3) {
     507    if (snMin < snMax) {
     508      snBegin = snMin;
     509      snEnd   = snMax;
     510    }
     511    return true;
     512  }
     513
     514  // on verifie qu'on peut effectivement produire
     515
     516  if (min < snBegin) {
     517    min = snBegin;
     518  }
     519
     520  if (max > snEnd) {
     521    max = snEnd;
     522  }
     523
     524  bool noConst = (min>max);
     525
     526  if (pass == 2 && noConst) {
     527    min = snBegin;
     528    max = snEnd;
     529  }
     530
     531 
     532  int n = inIx.size();
     533  // parcours de toutes les entrees et mise a jour au plus restrictif
     534  for (int i=0; i<n; i++) {
     535    TOI* toi = inTOIs[i];
     536    if (toi) {
     537      // mise a jour des limites avec les marges si definies
     538      long min_Input;
     539      long max_Input;
     540      if (min>0) {
     541        min_Input = min - lowExtra;
     542      } else {
     543        min_Input = min;
     544      }
     545      if (max<MAXINT) {
     546        max_Input = max + upExtra;
     547      } else {
     548        max_Input = max;
     549      }
     550      // propagation des limites
     551      sample_input_ok = toi->checkSampleLimits(min_Input, max_Input, pass);
     552
     553      //Ajustement des limites si plus restrictif
     554      if (min < max) {
     555        // On nous a demande des bornes ->
     556        if ((min_Input + lowExtra)  > min) {
     557          min = min_Input + lowExtra;
     558        }
     559        if ((max_Input - upExtra) < max) {
     560          max = max_Input - upExtra;
     561        }
     562      } else {
     563        // On nous demande tout ce qu'on peut faire -> MAJ snBegin
     564        if ((min_Input + lowExtra) > snBegin) {
     565          snBegin = min_Input + lowExtra;
     566        }
     567        if ((max_Input - upExtra) < snEnd) {
     568          snEnd = max_Input - upExtra;
     569        }
     570      }
     571      if (sample_input_ok == false) {
     572        sample_ok = false;
     573      }
     574    }   
     575  } 
     576
     577 
     578 
     579 
     580  //Ajustement des limites si intervalle plus large
     581  if (!noConst) {
     582    if (min < snMin) {
     583      snMin = min;
     584    }
     585    if (max > snMax) {
     586      snMax = max;
     587    }
     588  }
     589 
     590  min=min<snMin?snMin:min;
     591  max=max>snMax?snMax:max;
     592 
     593 
     594  // cas sans contraintes, on retourne nos bornes
     595  if (min>max) {
     596    min = snBegin;
     597    max = snEnd;
     598  }
     599 
     600  /*  cout << "check " << pass << " " << name << " out " << min << " - " << max << " ; "
     601       << snMin << " - " << snMax << " ; "
     602       << snBegin << " - " << snEnd << endl;*/
     603  return sample_ok;
     604}
     605
     606
     607
     608
     609// pour verification si le processeur est parametre
     610bool TOIProcessor::getRequested()
     611{
     612  return requestedSample;
     613}
     614
     615// affichage des limites
     616void TOIProcessor::printLimits()
     617{
     618  cout << "toiprocessor " << name <<" : limites calculees : " << snBegin << " , " << snEnd << endl;
     619}
     620
     621TOI* TOIProcessor::getOutToi(string sortie)
     622{
     623  // recherche du nom de la sortie et verification si le toi existe deja
     624  map<string, int>::iterator i = outIx.find(sortie);
     625  if (i == outIx.end()) {
     626    return NULL;
     627  } else {
     628    return outTOIs[(*i).second];
     629  }
     630}
     631
     632
     633
     634
     635
     636
     637
     638
     639
Note: See TracChangeset for help on using the changeset viewer.