1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
2 | // Eric Aubourg
|
---|
3 | // Christophe Magneville
|
---|
4 | // Reza Ansari
|
---|
5 | // $Id: nooppr.cc,v 1.11 2002-05-31 08:10:58 ansari 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 | if (wsz < 1) wsz = 1;
|
---|
17 | wsize = wsz;
|
---|
18 | delay2 = false;
|
---|
19 | totnscount = 0;
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | void NoOpProcessor::PrintStatus(::ostream & os)
|
---|
25 | {
|
---|
26 | os << "\n ------------------------------------------------------ \n"
|
---|
27 | << " NoOpProcessor::PrintStatus() - WindowSize="
|
---|
28 | << WSize();
|
---|
29 | if (delay2) os << " Delay in2 ---> out2 " << endl;
|
---|
30 | else os << endl;
|
---|
31 | os << " Total number of processed samples= " << ProcessedSampleCount()
|
---|
32 | << endl;
|
---|
33 | TOIProcessor::PrintStatus(os);
|
---|
34 | os << " ------------------------------------------------------ " << endl;
|
---|
35 | }
|
---|
36 |
|
---|
37 | void NoOpProcessor::init() {
|
---|
38 | cout << "NoOpProcessor::init" << endl;
|
---|
39 | declareInput("in");
|
---|
40 | declareInput("in2");
|
---|
41 | declareOutput("out");
|
---|
42 | declareOutput("out2");
|
---|
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 |
|
---|
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)) {
|
---|
62 | cerr << " NoOpProcessor::run() - Input TOI (in) not connected! "
|
---|
63 | << endl;
|
---|
64 | throw ParmError("NoOpProcessor::run() Input TOI (in) not connected!");
|
---|
65 | }
|
---|
66 | bool fgin = checkInputTOIIndex(0);
|
---|
67 | bool fgin2 = checkInputTOIIndex(1);
|
---|
68 |
|
---|
69 | bool fgout = checkOutputTOIIndex(0);
|
---|
70 | bool fgout2 = checkOutputTOIIndex(1);
|
---|
71 |
|
---|
72 | if (fgout2 && (!fgin2 && !acceptnoinput) ) {
|
---|
73 | cerr << " NoOpProcessor::run() - out2 connected without in2!"
|
---|
74 | << endl;
|
---|
75 | throw ParmError("NoOpProcessor::run() out2 connected without in2!");
|
---|
76 | }
|
---|
77 | cout << " NoOpProcessor::run() SNRange=" << snb << " - " << sne << endl;
|
---|
78 |
|
---|
79 | double * vin = NULL;
|
---|
80 | double * vin2 = NULL;
|
---|
81 | uint_8 * vfg = NULL;
|
---|
82 | uint_8 * vfg2 = NULL;
|
---|
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];
|
---|
91 | vfg = new uint_8[wsize];
|
---|
92 | for(i=0; i<wsize; i++) {
|
---|
93 | vin[i] = defval; vfg[i] = defflag;
|
---|
94 | }
|
---|
95 | if (fgin2 || fgout2) {
|
---|
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++) {
|
---|
101 | vin2[i] = defval; vfg2[i] = defflag;
|
---|
102 | }
|
---|
103 | }
|
---|
104 |
|
---|
105 | // Boucle sur les sampleNum
|
---|
106 | // 1er partie, on traite par paquets de wsize
|
---|
107 | int kd2 = 0;
|
---|
108 | int lastk2in = 0;
|
---|
109 | for(k=snb;k<=sne-wsize+1;k+=wsize) {
|
---|
110 | if (fgin)
|
---|
111 | getData(0, k, wsize, vin, vfg);
|
---|
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 | }
|
---|
117 | if (fgout)
|
---|
118 | putData(0, k, wsize, vin, vfg);
|
---|
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 | }
|
---|
124 | klast+=wsize;
|
---|
125 | totnscount+=wsize;
|
---|
126 | totnbblock++;
|
---|
127 | }
|
---|
128 | if (fgout2 && delay2) {
|
---|
129 | int kd2o = (kd2+1)%2;
|
---|
130 | putData(1, lastk2in, wsize, vin2+kd2o*wsize, vfg2+kd2o*wsize);
|
---|
131 |
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | // 2eme partie, on traite la fin du bloc d'echantillons si necessaire
|
---|
136 | double inval = defval;;
|
---|
137 | uint_8 inflg = defflag;
|
---|
138 | double inval2 = defval;;
|
---|
139 | uint_8 inflg2 = defflag;
|
---|
140 | if (klast < sne)
|
---|
141 | for(k=klast+1; k<=sne; k++) {
|
---|
142 | if (fgin)
|
---|
143 | getData(0, k, inval, inflg);
|
---|
144 | if (fgout) putData(0, k, inval, inflg);
|
---|
145 | if (fgin2)
|
---|
146 | getData(1, k, inval2, inflg2);
|
---|
147 | if (fgout2)
|
---|
148 | putData(1, k, inval2, inflg2);
|
---|
149 | totnscount++;
|
---|
150 | }
|
---|
151 | totnbblock++;
|
---|
152 |
|
---|
153 | cout << " NoOpProcessor::run() - End of processing "
|
---|
154 | << " TotNbBlocks= " << totnbblock << " ProcSamples=" << totnscount << endl;
|
---|
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;
|
---|
164 | if (vin2) delete[] vin2;
|
---|
165 | if (vfg2) delete[] vfg2;
|
---|
166 |
|
---|
167 | }
|
---|