Ignore:
Timestamp:
Mar 12, 2001, 7:00:28 PM (25 years ago)
Author:
ansari
Message:

Protections diverses dans TOIProcessor et FITSTOIReader/Writer
Ajout d'un TOI (TOISeqBuffered) avec gestion d'un buffer entre put/get
Ajout de processeurs de test (RZTOIProc...) , programme test associe
et SMakefile (pour compil avec SOPHYA)

Reza 12/3/2001

File:
1 edited

Legend:

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

    r1367 r1437  
    4444
    4545void TOIProcessor::afterinit() {
     46  int i;
    4647  inTOIs = new (TOI*[inIx.size()]);
     48  for(i=0; i<inIx.size(); i++)
     49    inTOIs[i] = NULL;
    4750  outTOIs = new (TOI*[outIx.size()]);
     51  for(i=0; i<outIx.size(); i++)
     52    outTOIs[i] = NULL;
    4853}
    4954
     
    123128}
    124129
     130//  Methodes rajoutees par Reza 11/3/2001
     131TOI* TOIProcessor::getInputTOI(int toiIndex) {
     132  //  chkinit();
     133  if (toiIndex >= inIx.size())
     134    throw RangeCheckError("TOIProcessor::getInputTOI() out of bound toiIndex");
     135  TOI* toi = inTOIs[toiIndex];
     136  if (toi == NULL)
     137    throw NullPtrError("TOIProcessor::getInputTOI() - Not assigned TOI !");
     138  return(toi);
     139}
     140
     141TOI* TOIProcessor::getOutputTOI(int toiIndex) {
     142  //  chkinit();
     143  if (toiIndex >= outIx.size())
     144    throw RangeCheckError("TOIProcessor::getOutputTOI() out of bound toiIndex");
     145  TOI* toi = outTOIs[toiIndex];
     146  if (toi == NULL)
     147    throw NullPtrError("TOIProcessor::getOutputTOI() - Not assigned TOI !");
     148  return(toi);
     149}
     150
     151bool TOIProcessor::checkInputTOIIndex(int toiIndex) {
     152  if (toiIndex >= inIx.size()) return false;
     153  if (inTOIs[toiIndex] == NULL) return false;
     154  return true;
     155}
     156
     157bool TOIProcessor::checkOutputTOIIndex(int toiIndex) {
     158  if (toiIndex >= outIx.size()) return false;
     159  if (outTOIs[toiIndex] == NULL) return false;
     160  return true;
     161}
     162
     163void TOIProcessor::PrintStatus(ostream & os)
     164{
     165  os << " TOIProcessor::PrintStatus() - Name= " << name
     166     << " MinIn=" << getMinIn() << " MaxIn=" << getMaxIn() << endl;
     167  os << " --- Inputs N= " << inIx.size() << endl;
     168  int k;
     169  for(k=0; k<inIx.size(); k++) {
     170    os << "Input[" << k << "] : " <<  getInName(k) ;
     171    if (inTOIs[k] != NULL)
     172      os << " Connected TOI " << inTOIs[k]->getName() << endl;
     173    else os << " NO TOI " << endl;
     174  }
     175  os << " --- Outputs N= " << outIx.size() << endl;
     176  for(k=0; k<outIx.size(); k++) {
     177    os << "Output[" << k << "] : " <<  getOutName(k) ;
     178    if (outTOIs[k] != NULL)
     179      os << " Connected TOI " << outTOIs[k]->getName() << endl;
     180    else os << " NO TOI " << endl;
     181  }
     182  os << endl;
     183  return;
     184}
     185
     186//  Fin rajout Reza 11/3/2001
     187
    125188void TOIProcessor::addInput(string name, TOI* toi) {
    126189  chkinit();
     
    143206  if (i > outIx.size()) throw RangeCheckError("TOIProcessor::getOutName "
    144207                                             " out of bound");
    145   map<string, int>::iterator j = outIx.begin();
    146   while (i) {i--; j++;};
    147   return (*j).first;
     208  map<string, int>::iterator j;
     209  for(j=outIx.begin(); j!= outIx.end(); j++)
     210    if ((*j).second == i)  return (*j).first;
     211
     212  throw RangeCheckError("TOIProcessor::getOutName  Not found index !");
    148213}
    149214
     
    151216  if (i > inIx.size()) throw RangeCheckError("TOIProcessor::getInName "
    152217                                             " out of bound");
    153   map<string, int>::iterator j = inIx.begin();
    154   while (i) {i--; j++;};
    155   return (*j).first;
     218  map<string, int>::iterator j;
     219  for(j=inIx.begin(); j!= inIx.end(); j++)
     220    if ((*j).second == i)  return (*j).first;
     221
     222  throw RangeCheckError("TOIProcessor::getOutName  Not found index !");
    156223}
    157224
     
    189256#ifndef NO_SOPHYA
    190257Array TOIProcessor::getData(int toiIndex, int iStart, int iEnd) {
    191   TOI* toi = inTOIs[toiIndex];
     258  TOI* toi = getInputTOI(toiIndex);
    192259  toi->waitForData(iStart, iEnd);
    193260  return toi->getData(iStart, iEnd);
     
    195262
    196263Array TOIProcessor::getError(int toiIndex, int iStart, int iEnd) {
    197   TOI* toi = inTOIs[toiIndex];
     264  TOI* toi = getInputTOI(toiIndex);
    198265  toi->waitForData(iStart, iEnd);
    199266  return toi->getError(iStart, iEnd);
     
    201268
    202269TArray<int_4> TOIProcessor::getFlag(int toiIndex, int iStart, int iEnd) {
    203   TOI* toi = inTOIs[toiIndex];
     270  TOI* toi = getInputTOI(toiIndex);
    204271  toi->waitForData(iStart, iEnd);
    205272  return toi->getFlag(iStart, iEnd);
     
    208275
    209276double TOIProcessor::getData(int toiIndex, int i) {
    210   TOI* toi = inTOIs[toiIndex];
     277  TOI* toi = getInputTOI(toiIndex);
    211278  toi->waitForData(i);
    212279  return toi->getData(i);
     
    214281
    215282double TOIProcessor::getError(int toiIndex, int i) {
    216   TOI* toi = inTOIs[toiIndex];
     283  TOI* toi = getInputTOI(toiIndex);
    217284  toi->waitForData(i);
    218285  return toi->getError(i);
     
    220287
    221288int_4 TOIProcessor::getFlag(int toiIndex, int i) {
    222   TOI* toi = inTOIs[toiIndex];
     289  TOI* toi = getInputTOI(toiIndex);
    223290  toi->waitForData(i);
    224291  return toi->getFlag(i);
     
    257324
    258325void TOIProcessor::putData(int toiIndex, int i, double value, int_4 flg) {
    259   TOI* toi = outTOIs[toiIndex];
     326  TOI* toi = getOutputTOI(toiIndex);
    260327  toi->putData(i, value, flg);
    261328  autoWontNeed(i);
     
    266333void TOIProcessor::putDataError(int toiIndex, int i, double value,
    267334                                double error, int_4 flg) {
    268   TOI* toi = outTOIs[toiIndex];
     335  TOI* toi = getOutputTOI(toiIndex);
     336  if (toi == NULL)
     337    throw NullPtrError("TOIProcessor::putDataError() - Not assigned TOI !");
    269338  toi->putDataError(i, value, error, flg);
    270339  autoWontNeed(i);
Note: See TracChangeset for help on using the changeset viewer.