source: Sophya/trunk/ArchTOIPipe/Kernel/toiprocessor.h@ 2314

Last change on this file since 2314 was 2187, checked in by aubourg, 23 years ago

Vivien, limites processors et connect

File size: 5.3 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2
3// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
4// Eric Aubourg
5// Christophe Magneville
6// Reza Ansari
7// $Id: toiprocessor.h,v 1.20 2002-09-09 15:33:15 aubourg Exp $
8
9
10
11#ifndef TOIPROCESSOR_H
12#define TOIPROCESSOR_H
13
14#include "config.h"
15
16#include <pthread.h>
17
18#include <string>
19#include <map>
20#include <iostream.h>
21
22#ifndef NO_SOPHYA
23#include "tarray.h"
24using namespace SOPHYA;
25#endif
26
27#include "toi.h"
28
29
30class TOIProcessor {
31public:
32 virtual void init();
33 // Les methodes qui suivent peuvent etre appelees par init
34protected:
35 int declareInput(string toi);
36 int declareOutput(string toi);
37
38 // void declareMultInput(string toi);
39 // Question : multiple output ?
40
41 void chkinit() {
42 if (!inited) {init(); afterinit(); inited=true;}
43 }
44 bool inited;
45 virtual void afterinit();
46
47public:
48 virtual void run();
49
50 virtual int getMinOut();
51 virtual int getMaxOut();
52
53 // rajout vf 29/07/2002
54 virtual void setRequestedSample(long begin, long end);
55 virtual bool getRequested();
56 virtual bool checkSampleLimits(int pass);
57 virtual void printLimits();
58
59// rajout vf 29/07/2002
60protected:
61 bool requestedSample;
62 long snBegin;
63 long snEnd;
64 long snMin;
65 long snMax;
66 virtual bool checkSampleLimits(long &min, long &max, int pass);
67
68
69 // Les methodes qui suivent peut etre appelees par run
70protected:
71#ifndef NO_SOPHYA
72 /* ---- l'interface va etre modifiee, NE PAS UTILISER
73 Array getData(int toiIndex, int iStart, int iEnd);
74 Array getError(int toiIndex, int iStart, int iEnd);
75 TArray<int_4> getFlag(int toiIndex, int iStart, int iEnd);
76 l'interface va etre modifiee, NE PAS UTILISER ---- */
77#endif
78 // si multiple input (indexed input), tableau 2D.
79
80 // Les methodes qui suivent ne peuvent etre
81 // utilisees que sur des entrees simples
82 double getData(int toiIndex, int i);
83 void getData(int toiIndex, int i, double &data, uint_8 &flag);
84
85 void getData(int toiIndex, int i, int n, double* d);
86 void getData(int toiIndex, int i, int n, double* d, uint_8* f);
87
88 //RZCMV double getError(int toiIndex, int i);
89 //RZCMV int_4 getFlag(int toiIndex, int i);
90
91 void wontNeedBefore(int i);
92 int wontNeedValue;
93 void setNeededHistory(int nsamples); // -1 : disable
94
95 void putData(int toiIndex, int i, double value, uint_8 flag=0);
96 //RZCMV void putDataError(int toiIndex, int i, double value,
97 //RZCMV double error, int_4 flag=0);
98
99 void putData(int toiIndex, int i, int n, double const* val,
100 uint_8 const* flg=0);
101
102 // Gestion des bornes pour les transformations de TOIs...
103public:
104 // Methodes passees en public par Reza, 14/5/2002
105 virtual int calcMinOut(); // Protected ?
106 virtual int calcMaxOut(); // Protected ?
107
108 virtual int getMinIn();
109 virtual int getMaxIn();
110protected:
111 // Implementation par defaut
112 int minOut; // Cache for calcMinOut() value. Protected ?
113 int maxOut; // Cache for calcMaxOut() value. Protected ?
114
115 int upExtra; // MaxIn - MaxOut : extra samples for processing
116 int lowExtra; // MinOut - MinIn : extra samples for processing
117
118 int forcedMinIn; // to process a subset of data
119 int forcedMaxIn; // to process a subset of data
120 void setSampleSubset(int min, int max);
121
122 int neededHistory;
123
124protected:
125 int getInputTOIIndex(string toi);
126 int getOutputTOIIndex(string toi);
127
128 // Methodes rajoutees par Reza 11/3/2001
129 TOI* getInputTOI(int toiIndex);
130 TOI* getOutputTOI(int toiIndex);
131 bool checkInputTOIIndex(int toiIndex);
132 bool checkOutputTOIIndex(int toiIndex);
133
134 // Fin rajout Reza 11/3/2001
135
136 void autoWontNeed(int iCur);
137 int lastAWN;
138
139
140public:
141 // Appele par les assembleurs de pipeline
142 virtual void addInput(string name, TOI* toi);
143 virtual void addOutput(string name, TOI* toi);
144
145
146 int getNIn() {chkinit(); return inIx.size();}
147 int getNOut() {chkinit(); return outIx.size();}
148 string getOutName(int i);
149 string getInName(int i);
150
151 // Methodes rajoutees par Reza 11/3/2001
152 virtual void PrintStatus(::ostream & os) ; // const plus tard
153 // Fin rajout Reza 11/3/2001
154
155 virtual void start();
156
157 TOIProcessor();
158 virtual ~TOIProcessor();
159
160 void setMinSn(int n) {forcedMinIn = n;}
161 void setMaxSn(int n) {forcedMaxIn = n;}
162
163 // ajout vf 23/08/2002
164 TOI* getOutToi(string sortie);
165
166 virtual void setName(string n) {name=n;}
167
168protected:
169
170 map<string, int> inIx;
171 map<string, int> outIx;
172 TOI** inTOIs;
173 TOI** outTOIs;
174
175 string name;
176 // Thread handling
177 pthread_t thread;
178 pthread_cond_t dataReady;
179 pthread_mutex_t mutex;
180 pthread_mutexattr_t mutattr;
181
182 void lock() {
183 pthread_mutex_lock(&mutex);
184 }
185
186 void unlock() {
187 pthread_mutex_unlock(&mutex);
188 }
189
190 void wait() {
191 pthread_cond_wait(&dataReady, &mutex);
192 }
193
194 void notify();
195
196
197 friend class TOI;
198
199 static void* ThreadStart(void *);
200 void warnPutDone();
201};
202
203inline ::ostream & operator << (::ostream & os, TOIProcessor /*const*/ & toip)
204{ toip.PrintStatus(os); return os; }
205
206
207#endif
208
209
210
211
212
213
214
215
Note: See TracBrowser for help on using the repository browser.