| 1 | // ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL | 
|---|
| 2 | //                               Eric Aubourg | 
|---|
| 3 | //                               Christophe Magneville | 
|---|
| 4 | //                               Reza Ansari | 
|---|
| 5 | // $Id: nooppr.cc,v 1.9 2001-11-13 16:22:47 aubourg Exp $ | 
|---|
| 6 |  | 
|---|
| 7 | #include <typeinfo> | 
|---|
| 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 | { | 
|---|
| 16 | wsize = wsz; | 
|---|
| 17 | totnscount = 0; | 
|---|
| 18 | } | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 |  | 
|---|
| 22 | void NoOpProcessor::PrintStatus(::ostream & os) | 
|---|
| 23 | { | 
|---|
| 24 | os << "\n ------------------------------------------------------ \n" | 
|---|
| 25 | << " NoOpProcessor::PrintStatus() - WindowSize=" | 
|---|
| 26 | << WSize() << endl; | 
|---|
| 27 | os << " Total number of processed samples= " << ProcessedSampleCount() | 
|---|
| 28 | << endl; | 
|---|
| 29 | TOIProcessor::PrintStatus(os); | 
|---|
| 30 | os << " ------------------------------------------------------ " << endl; | 
|---|
| 31 | } | 
|---|
| 32 |  | 
|---|
| 33 | void NoOpProcessor::init() { | 
|---|
| 34 | cout << "NoOpProcessor::init" << endl; | 
|---|
| 35 | declareInput("in"); | 
|---|
| 36 | declareInput("in2"); | 
|---|
| 37 | declareOutput("out"); | 
|---|
| 38 | declareOutput("out2"); | 
|---|
| 39 | name = "NoOpProcessor"; | 
|---|
| 40 | //  upExtra = 1; | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 |  | 
|---|
| 44 | void NoOpProcessor::run() { | 
|---|
| 45 | //  TOIManager* mgr = TOIManager::getManager(); | 
|---|
| 46 | int snb = getMinIn(); | 
|---|
| 47 | int sne = getMaxIn(); | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 | if (!checkInputTOIIndex(0)) { | 
|---|
| 51 | cerr << " NoOpProcessor::run() - Input TOI (in) not connected! " | 
|---|
| 52 | << endl; | 
|---|
| 53 | throw ParmError("NoOpProcessor::run() Input TOI (in) not connected!"); | 
|---|
| 54 | } | 
|---|
| 55 | bool fgin2 = checkInputTOIIndex(1); | 
|---|
| 56 |  | 
|---|
| 57 | bool fgout = checkOutputTOIIndex(0); | 
|---|
| 58 | bool fgout2 = checkOutputTOIIndex(1); | 
|---|
| 59 |  | 
|---|
| 60 | if (fgout2 && !fgin2) { | 
|---|
| 61 | cerr << " NoOpProcessor::run() - out2 connected without in2!" | 
|---|
| 62 | << endl; | 
|---|
| 63 | throw ParmError("NoOpProcessor::run() out2 connected without in2!"); | 
|---|
| 64 | } | 
|---|
| 65 | cout << " NoOpProcessor::run() SNRange=" << snb << " - " << sne << endl; | 
|---|
| 66 |  | 
|---|
| 67 | double * vin = NULL; | 
|---|
| 68 | double * vin2 = NULL; | 
|---|
| 69 | uint_8 * vfg = NULL; | 
|---|
| 70 | uint_8 * vfg2 = NULL; | 
|---|
| 71 | try { | 
|---|
| 72 | // Le debut | 
|---|
| 73 | int k,i,klast; | 
|---|
| 74 | klast = snb-1; | 
|---|
| 75 | int totnbblock = 0; | 
|---|
| 76 |  | 
|---|
| 77 | if (wsize > 1) { | 
|---|
| 78 | vin = new double[wsize]; | 
|---|
| 79 | vfg = new uint_8[wsize]; | 
|---|
| 80 | if (fgin2) { | 
|---|
| 81 | vin2 = new double[wsize]; | 
|---|
| 82 | vfg2 = new uint_8[wsize]; | 
|---|
| 83 | } | 
|---|
| 84 |  | 
|---|
| 85 | // Boucle sur les sampleNum | 
|---|
| 86 | // 1er partie, on traite par paquets de wsize | 
|---|
| 87 | for(k=snb;k<=sne-wsize+1;k+=wsize) { | 
|---|
| 88 | for(i=0; i<wsize; i++) { | 
|---|
| 89 | getData(0, k+i, vin[i], vfg[i]); | 
|---|
| 90 | if (fgin2) | 
|---|
| 91 | getData(1, k+i, vin2[i], vfg2[i]); | 
|---|
| 92 | } | 
|---|
| 93 | totnbblock++; | 
|---|
| 94 | for(i=0; i<wsize; i++) { | 
|---|
| 95 | if (fgout) | 
|---|
| 96 | putData(0,k+i,vin[i],vfg[i]); | 
|---|
| 97 | if (fgout2) | 
|---|
| 98 | putData(1, k+i, vin2[i], vfg2[i]); | 
|---|
| 99 | } | 
|---|
| 100 | klast+=wsize; | 
|---|
| 101 | totnscount+=wsize; | 
|---|
| 102 | } | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 | // 2eme partie, on traite la fin du bloc d'echantillons si necessaire | 
|---|
| 106 | double inval; | 
|---|
| 107 | uint_8 inflg; | 
|---|
| 108 | if (klast < sne) | 
|---|
| 109 | for(k=klast+1; k<=sne; k++) { | 
|---|
| 110 | getData(0, k, inval, inflg); | 
|---|
| 111 | if (fgout) putData(0, k, inval, inflg); | 
|---|
| 112 | if (fgin2) { | 
|---|
| 113 | getData(1, k, inval, inflg); | 
|---|
| 114 | if (fgout2) | 
|---|
| 115 | putData(1, k, inval, inflg); | 
|---|
| 116 | } | 
|---|
| 117 | totnscount++; | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | totnbblock++; | 
|---|
| 121 |  | 
|---|
| 122 | cout << " NoOpProcessor::run() - End of processing " | 
|---|
| 123 | << " TotNbBlocks= " << totnbblock << endl; | 
|---|
| 124 | }  // Bloc try | 
|---|
| 125 |  | 
|---|
| 126 | catch (PException & exc) { | 
|---|
| 127 | cerr << "NoOpProcessor: Catched Exception " << (string)typeid(exc).name() | 
|---|
| 128 | << "\n .... Msg= " << exc.Msg() << endl; | 
|---|
| 129 | } | 
|---|
| 130 |  | 
|---|
| 131 | if (vin) delete[] vin; | 
|---|
| 132 | if (vfg) delete[] vfg; | 
|---|
| 133 | if (vin2) delete[] vin2; | 
|---|
| 134 | if (vfg2) delete[] vfg2; | 
|---|
| 135 |  | 
|---|
| 136 | } | 
|---|