| [1738] | 1 | // ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL
 | 
|---|
 | 2 | //                               Eric Aubourg
 | 
|---|
 | 3 | //                               Christophe Magneville
 | 
|---|
 | 4 | //                               Reza Ansari
 | 
|---|
| [2037] | 5 | // $Id: nooppr.cc,v 1.11 2002-05-31 08:10:58 ansari Exp $
 | 
|---|
| [1738] | 6 | 
 | 
|---|
| [1732] | 7 | #include <typeinfo>
 | 
|---|
| [1487] | 8 | #include "toimanager.h"
 | 
|---|
 | 9 | #include "nooppr.h"
 | 
|---|
 | 10 | // ----------------------------------------------------------------------
 | 
|---|
 | 11 | //   Classe SimpleFourierFilter : Filtre simple ds le domaine de Fourier
 | 
|---|
 | 12 | // ----------------------------------------------------------------------
 | 
|---|
 | 13 | 
 | 
|---|
 | 14 | NoOpProcessor::NoOpProcessor(int wsz)
 | 
|---|
 | 15 | {
 | 
|---|
| [1994] | 16 |   if (wsz < 1) wsz = 1;
 | 
|---|
| [1487] | 17 |   wsize = wsz;
 | 
|---|
| [2037] | 18 |   delay2 = false;
 | 
|---|
| [1487] | 19 |   totnscount = 0;
 | 
|---|
 | 20 | }
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | 
 | 
|---|
| [1762] | 24 | void NoOpProcessor::PrintStatus(::ostream & os)
 | 
|---|
| [1487] | 25 | {
 | 
|---|
 | 26 |   os << "\n ------------------------------------------------------ \n" 
 | 
|---|
 | 27 |      << " NoOpProcessor::PrintStatus() - WindowSize=" 
 | 
|---|
| [2037] | 28 |      << WSize();
 | 
|---|
 | 29 |   if (delay2) os << " Delay in2 ---> out2 " << endl;
 | 
|---|
 | 30 |   else os << endl;
 | 
|---|
| [1488] | 31 |   os << " Total number of processed samples= " << ProcessedSampleCount()
 | 
|---|
 | 32 |      << endl;
 | 
|---|
| [1487] | 33 |   TOIProcessor::PrintStatus(os);
 | 
|---|
 | 34 |   os << " ------------------------------------------------------ " << endl;
 | 
|---|
 | 35 | }
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | void NoOpProcessor::init() {
 | 
|---|
 | 38 |   cout << "NoOpProcessor::init" << endl;
 | 
|---|
 | 39 |   declareInput("in");
 | 
|---|
| [1488] | 40 |   declareInput("in2");
 | 
|---|
| [1487] | 41 |   declareOutput("out");
 | 
|---|
| [1488] | 42 |   declareOutput("out2");
 | 
|---|
| [1487] | 43 |   name = "NoOpProcessor";
 | 
|---|
 | 44 |   //  upExtra = 1;
 | 
|---|
 | 45 | }
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | 
 | 
|---|
 | 48 | void NoOpProcessor::run() {
 | 
|---|
 | 49 |   //  TOIManager* mgr = TOIManager::getManager();
 | 
|---|
 | 50 |   int snb = getMinIn();
 | 
|---|
 | 51 |   int sne = getMaxIn();
 | 
|---|
 | 52 | 
 | 
|---|
 | 53 | 
 | 
|---|
| [1994] | 54 |   if (!checkInputTOIIndex(0) && !checkInputTOIIndex(1) && 
 | 
|---|
 | 55 |       !checkOutputTOIIndex(0) && !checkOutputTOIIndex(1) ) {
 | 
|---|
 | 56 |     cerr << " NoOpProcessor::run() - No TOI connected! "
 | 
|---|
 | 57 |          << endl;
 | 
|---|
 | 58 |     throw ParmError("NoOpProcessor::run() No TOI connected!");
 | 
|---|
 | 59 |   }
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 |   if (!acceptnoinput && !checkInputTOIIndex(0)) {
 | 
|---|
| [1487] | 62 |     cerr << " NoOpProcessor::run() - Input TOI (in) not connected! "
 | 
|---|
 | 63 |          << endl;
 | 
|---|
 | 64 |     throw ParmError("NoOpProcessor::run() Input TOI (in) not connected!");
 | 
|---|
 | 65 |   }
 | 
|---|
| [1994] | 66 |   bool fgin = checkInputTOIIndex(0);
 | 
|---|
| [1488] | 67 |   bool fgin2 = checkInputTOIIndex(1);
 | 
|---|
| [1487] | 68 | 
 | 
|---|
| [1488] | 69 |   bool fgout = checkOutputTOIIndex(0);
 | 
|---|
 | 70 |   bool fgout2 = checkOutputTOIIndex(1);
 | 
|---|
| [1487] | 71 | 
 | 
|---|
| [1994] | 72 |   if (fgout2 && (!fgin2 && !acceptnoinput) ) {
 | 
|---|
| [1488] | 73 |     cerr << " NoOpProcessor::run() - out2 connected without in2!"
 | 
|---|
 | 74 |          << endl;
 | 
|---|
 | 75 |     throw ParmError("NoOpProcessor::run() out2 connected without in2!");
 | 
|---|
 | 76 |   }
 | 
|---|
| [1487] | 77 |   cout << " NoOpProcessor::run() SNRange=" << snb << " - " << sne << endl; 
 | 
|---|
 | 78 |   
 | 
|---|
 | 79 |   double * vin = NULL;
 | 
|---|
| [1488] | 80 |   double * vin2 = NULL;
 | 
|---|
| [1532] | 81 |   uint_8 * vfg = NULL;
 | 
|---|
 | 82 |   uint_8 * vfg2 = NULL;
 | 
|---|
| [1487] | 83 |   try {
 | 
|---|
 | 84 |     // Le debut
 | 
|---|
 | 85 |     int k,i,klast;
 | 
|---|
 | 86 |     klast = snb-1;
 | 
|---|
 | 87 |     int totnbblock = 0;
 | 
|---|
 | 88 |     
 | 
|---|
 | 89 |     if (wsize > 1) {
 | 
|---|
 | 90 |       vin = new double[wsize];
 | 
|---|
| [1532] | 91 |       vfg = new uint_8[wsize];
 | 
|---|
| [1994] | 92 |       for(i=0; i<wsize; i++) { 
 | 
|---|
 | 93 |         vin[i] = defval; vfg[i] = defflag;
 | 
|---|
 | 94 |       }
 | 
|---|
 | 95 |       if (fgin2 || fgout2) {
 | 
|---|
| [2037] | 96 |         int wsz2 = wsize;
 | 
|---|
 | 97 |         if (delay2) wsz2 *= 2;
 | 
|---|
 | 98 |         vin2 = new double[wsz2];
 | 
|---|
 | 99 |         vfg2 = new uint_8[wsz2];
 | 
|---|
 | 100 |         for(i=0; i<wsz2; i++) { 
 | 
|---|
| [1994] | 101 |           vin2[i] = defval; vfg2[i] = defflag;
 | 
|---|
 | 102 |         }       
 | 
|---|
| [1488] | 103 |       }
 | 
|---|
| [1487] | 104 |     
 | 
|---|
 | 105 |       // Boucle sur les sampleNum
 | 
|---|
 | 106 |       // 1er partie, on traite par paquets de wsize
 | 
|---|
| [2037] | 107 |       int kd2 = 0;
 | 
|---|
 | 108 |       int lastk2in = 0;
 | 
|---|
| [1487] | 109 |       for(k=snb;k<=sne-wsize+1;k+=wsize) {
 | 
|---|
| [1994] | 110 |         if (fgin) 
 | 
|---|
 | 111 |           getData(0, k, wsize, vin, vfg);
 | 
|---|
| [2037] | 112 |         if (fgin2) {
 | 
|---|
 | 113 |           kd2 = (delay2) ? (kd2+1)%2 : 0;
 | 
|---|
 | 114 |           getData(1, k, wsize, vin2+kd2*wsize, vfg2+kd2*wsize);
 | 
|---|
 | 115 |           lastk2in = k;
 | 
|---|
 | 116 |         }
 | 
|---|
| [1994] | 117 |         if (fgout) 
 | 
|---|
 | 118 |           putData(0, k, wsize, vin, vfg);
 | 
|---|
| [2037] | 119 |         if (fgout2 && (!delay2 || totnbblock > 1)) {  
 | 
|---|
 | 120 |           int kd2o = (delay2) ? (kd2+1)%2 : 0;
 | 
|---|
 | 121 |           int nextk2o = (delay2) ? lastk2in-wsize : lastk2in;
 | 
|---|
 | 122 |           putData(1, nextk2o, wsize, vin2+kd2o*wsize, vfg2+kd2o*wsize);
 | 
|---|
 | 123 |         }
 | 
|---|
| [1488] | 124 |         klast+=wsize;
 | 
|---|
| [1489] | 125 |         totnscount+=wsize;
 | 
|---|
| [1994] | 126 |         totnbblock++;
 | 
|---|
| [1487] | 127 |       }
 | 
|---|
| [2037] | 128 |       if (fgout2 && delay2) {
 | 
|---|
 | 129 |         int kd2o = (kd2+1)%2;
 | 
|---|
 | 130 |         putData(1, lastk2in, wsize, vin2+kd2o*wsize, vfg2+kd2o*wsize);
 | 
|---|
 | 131 |         
 | 
|---|
 | 132 |       }
 | 
|---|
| [1487] | 133 |     }
 | 
|---|
 | 134 | 
 | 
|---|
 | 135 |     // 2eme partie, on traite la fin du bloc d'echantillons si necessaire
 | 
|---|
| [1994] | 136 |     double inval = defval;;
 | 
|---|
 | 137 |     uint_8 inflg = defflag;
 | 
|---|
 | 138 |     double inval2 = defval;;
 | 
|---|
 | 139 |     uint_8 inflg2 = defflag;
 | 
|---|
| [1487] | 140 |     if (klast < sne) 
 | 
|---|
 | 141 |       for(k=klast+1; k<=sne; k++) {
 | 
|---|
| [1994] | 142 |         if (fgin) 
 | 
|---|
 | 143 |           getData(0, k, inval, inflg);
 | 
|---|
| [1487] | 144 |         if (fgout) putData(0, k, inval, inflg);
 | 
|---|
| [1994] | 145 |         if (fgin2)  
 | 
|---|
 | 146 |           getData(1, k, inval2, inflg2);
 | 
|---|
 | 147 |         if (fgout2) 
 | 
|---|
 | 148 |             putData(1, k, inval2, inflg2);
 | 
|---|
| [1487] | 149 |         totnscount++;
 | 
|---|
 | 150 |       }
 | 
|---|
| [1994] | 151 |     totnbblock++; 
 | 
|---|
| [1487] | 152 | 
 | 
|---|
 | 153 |     cout << " NoOpProcessor::run() - End of processing " 
 | 
|---|
| [1994] | 154 |          << " TotNbBlocks= " << totnbblock << " ProcSamples=" << totnscount << endl;
 | 
|---|
| [1487] | 155 |   }  // Bloc try 
 | 
|---|
 | 156 | 
 | 
|---|
 | 157 |   catch (PException & exc) {
 | 
|---|
 | 158 |     cerr << "NoOpProcessor: Catched Exception " << (string)typeid(exc).name()
 | 
|---|
 | 159 |          << "\n .... Msg= " << exc.Msg() << endl;
 | 
|---|
 | 160 |   }
 | 
|---|
 | 161 | 
 | 
|---|
 | 162 |   if (vin) delete[] vin; 
 | 
|---|
 | 163 |   if (vfg) delete[] vfg;  
 | 
|---|
| [1488] | 164 |   if (vin2) delete[] vin2; 
 | 
|---|
 | 165 |   if (vfg2) delete[] vfg2;  
 | 
|---|
| [1487] | 166 | 
 | 
|---|
 | 167 | }
 | 
|---|