Changeset 1437 in Sophya for trunk/ArchTOIPipe
- Timestamp:
- Mar 12, 2001, 7:00:28 PM (25 years ago)
- Location:
- trunk/ArchTOIPipe
- Files:
-
- 7 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/fitstoirdr.cc
r1367 r1437 103 103 // if (sn < mgr->getRequestedBegin()+10) cout << "rdr out " << sn << endl; 104 104 for (int j=1; j<=ncols; j++) { 105 if ( !checkOutputTOIIndex(j-1) ) continue; // Reza - Si TOI non connecte 105 106 fits_lock(); 106 107 fits_read_col_dbl(fptr,j+1,i+1,1,1,0,&y,&anyNul,&fstatus); -
trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc
r1410 r1437 92 92 fits_unlock(); 93 93 for (int i=0; i<ndata; i++) { 94 double x = getData(i, sn); 94 double x = -9.e19; // $CHECK$ - Reza valeur par defaut ! 95 if (checkInputTOIIndex(i)) x = getData(i, sn); 95 96 fits_lock(); 96 97 if (outFlags) { 97 98 fits_write_col_dbl(fptr, 2*i+2, fitsLine, 1, 1, &x, &fstatus); 98 x = getFlag(i, sn); 99 if (checkInputTOIIndex(i)) x = getFlag(i, sn); 100 else x = -9.e19; // $CHECK$ - Reza valeur par defaut ! 99 101 fits_write_col_dbl(fptr, 2*i+3, fitsLine, 1, 1, &x, &fstatus); 100 102 } else { -
trunk/ArchTOIPipe/Kernel/toi.cc
r1370 r1437 25 25 void TOI::TOIInit() { 26 26 pthread_mutex_init(&mutex, NULL); 27 // ----- Rajouts Reza 12/3/2001 28 pthread_cond_init(&condv, NULL); 29 fgwaitput = fgwaitget = false; 30 fgsigput = fgsigget = false; 31 countwaitput = countwaitget = 0; 32 // Fin rajouts Reza 12/3/2001 ------ 27 33 // pthread_mutex_setname_np(&mutex, (name + "_toi_mutex").c_str(), 0); 28 34 defaultValue = 0; … … 35 41 } 36 42 43 void TOI::PrintStatus(ostream & os) const 44 { 45 os << "TOI::PrintStatus() - Name=" << getName() << endl; 46 os << " WaitStatus: Put/" ; 47 if (isPutWaiting()) os << "Waiting " ; 48 else os << "Running "; 49 os << " PutCountWait= " << getCountWaitPut() << endl; 50 os << " WaitStatus: Get/" ; 51 if (isGetWaiting()) os << "Waiting " ; 52 else os << "Running "; 53 os << " GetCountWait= " << getCountWaitGet() << endl; 54 } 55 56 37 57 void TOI::setProducer(TOIProcessor* p) { 38 58 if (producer) … … 76 96 Array a = doGetData(iStart, iEnd); 77 97 unlock(); 98 if (fgsigput) { fgsigput = false; broadcast(); } 78 99 return a; 79 100 } … … 84 105 double dat = doGetData(i); 85 106 unlock(); 107 if (fgsigput) { fgsigput = false; broadcast(); } 86 108 return dat; 87 109 } … … 93 115 TArray<int_4> a = doGetFlag(iStart, iEnd); 94 116 unlock(); 117 if (fgsigput) { fgsigput = false; broadcast(); } 95 118 return a; 96 119 } … … 101 124 int_4 f = doGetFlag(i); 102 125 unlock(); 126 if (fgsigput) { fgsigput = false; broadcast(); } 103 127 return f; 104 128 } … … 110 134 doPutData(i, value, flag); 111 135 unlock(); 136 if (fgsigget) { fgsigget = false; broadcast(); } 112 137 } 113 138 -
trunk/ArchTOIPipe/Kernel/toi.h
r1365 r1437 26 26 TOI(string name); 27 27 virtual ~TOI(); 28 29 // ----- Rajouts Reza 12/3/2001 30 virtual void PrintStatus(ostream & os) const; 31 // Fin rajouts Reza 12/3/2001 ------ 28 32 29 33 #ifdef WITH_SOPHYA … … 55 59 56 60 void setName(string n) {name =n;} 57 string getName() {return name;}61 string getName() const {return name;} 58 62 59 63 protected: 60 64 TOI* errorTOI; 61 65 pthread_mutex_t mutex; 66 // ----- Rajouts Reza 12/3/2001 67 pthread_cond_t condv; 68 bool fgwaitput; 69 bool fgwaitget; 70 bool fgsigput; 71 bool fgsigget; 72 int countwaitput; 73 int countwaitget; 74 // Fin rajouts Reza 12/3/2001 ------ 75 62 76 TOIProcessor* producer; 63 77 vector<TOIProcessor*> consumers; … … 86 100 void TOIInit(); 87 101 102 // Il faut faire attention avec mutex et condv, si TOI cree sur le stack ! 103 // Il faut donc faire new TOI - Reza 11/3/2001 88 104 void lock() {pthread_mutex_lock(&mutex);} 89 105 void unlock() {pthread_mutex_unlock(&mutex);} 90 106 107 // ----- Rajouts Reza 12/3/2001 108 void wait() {pthread_cond_wait(&condv, &mutex);} 109 void signal() {pthread_cond_signal(&condv);} 110 void broadcast() {pthread_cond_broadcast(&condv);} 111 inline void waitPut() 112 {fgwaitput=true; countwaitput++; pthread_cond_wait(&condv, &mutex);} 113 inline void waitGet() 114 {fgwaitget=true; countwaitget++; pthread_cond_wait(&condv, &mutex);} 115 inline bool isPutWaiting() const { return fgwaitput; } 116 inline bool isGetWaiting() const { return fgwaitget; } 117 inline void signalPut() {fgsigput=true;} 118 inline void signalGet() {fgsigget=true;} 119 inline void cleanWaitPut() { fgsigput = fgwaitput = false; } 120 inline void cleanWaitGet() { fgsigget = fgwaitget = false; } 121 122 public: 123 inline int getCountWaitPut() const { return countwaitput; } 124 inline int getCountWaitGet() const { return countwaitget; } 125 // Fin rajouts Reza 12/3/2001 ------ 126 91 127 }; 128 129 inline ostream & operator << (ostream & os, TOI const & toi) 130 { toi.PrintStatus(os); return os; } 92 131 93 132 class TOIRegular : public TOI { … … 101 140 TOIRegularWindow(); 102 141 TOIRegularWindow(string nm); 103 ~TOIRegularWindow();142 virtual ~TOIRegularWindow(); 104 143 105 144 virtual DataStatus isDataAvailNL(int iStart, int iEnd); … … 112 151 long i0; 113 152 double defaultValue; 114 153 115 154 #ifdef WITH_SOPHYA 116 155 virtual Array doGetData(int iStart, int iEnd); -
trunk/ArchTOIPipe/Kernel/toiprocessor.cc
r1367 r1437 44 44 45 45 void TOIProcessor::afterinit() { 46 int i; 46 47 inTOIs = new (TOI*[inIx.size()]); 48 for(i=0; i<inIx.size(); i++) 49 inTOIs[i] = NULL; 47 50 outTOIs = new (TOI*[outIx.size()]); 51 for(i=0; i<outIx.size(); i++) 52 outTOIs[i] = NULL; 48 53 } 49 54 … … 123 128 } 124 129 130 // Methodes rajoutees par Reza 11/3/2001 131 TOI* 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 141 TOI* 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 151 bool TOIProcessor::checkInputTOIIndex(int toiIndex) { 152 if (toiIndex >= inIx.size()) return false; 153 if (inTOIs[toiIndex] == NULL) return false; 154 return true; 155 } 156 157 bool TOIProcessor::checkOutputTOIIndex(int toiIndex) { 158 if (toiIndex >= outIx.size()) return false; 159 if (outTOIs[toiIndex] == NULL) return false; 160 return true; 161 } 162 163 void 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 125 188 void TOIProcessor::addInput(string name, TOI* toi) { 126 189 chkinit(); … … 143 206 if (i > outIx.size()) throw RangeCheckError("TOIProcessor::getOutName " 144 207 " 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 !"); 148 213 } 149 214 … … 151 216 if (i > inIx.size()) throw RangeCheckError("TOIProcessor::getInName " 152 217 " 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 !"); 156 223 } 157 224 … … 189 256 #ifndef NO_SOPHYA 190 257 Array TOIProcessor::getData(int toiIndex, int iStart, int iEnd) { 191 TOI* toi = inTOIs[toiIndex];258 TOI* toi = getInputTOI(toiIndex); 192 259 toi->waitForData(iStart, iEnd); 193 260 return toi->getData(iStart, iEnd); … … 195 262 196 263 Array TOIProcessor::getError(int toiIndex, int iStart, int iEnd) { 197 TOI* toi = inTOIs[toiIndex];264 TOI* toi = getInputTOI(toiIndex); 198 265 toi->waitForData(iStart, iEnd); 199 266 return toi->getError(iStart, iEnd); … … 201 268 202 269 TArray<int_4> TOIProcessor::getFlag(int toiIndex, int iStart, int iEnd) { 203 TOI* toi = inTOIs[toiIndex];270 TOI* toi = getInputTOI(toiIndex); 204 271 toi->waitForData(iStart, iEnd); 205 272 return toi->getFlag(iStart, iEnd); … … 208 275 209 276 double TOIProcessor::getData(int toiIndex, int i) { 210 TOI* toi = inTOIs[toiIndex];277 TOI* toi = getInputTOI(toiIndex); 211 278 toi->waitForData(i); 212 279 return toi->getData(i); … … 214 281 215 282 double TOIProcessor::getError(int toiIndex, int i) { 216 TOI* toi = inTOIs[toiIndex];283 TOI* toi = getInputTOI(toiIndex); 217 284 toi->waitForData(i); 218 285 return toi->getError(i); … … 220 287 221 288 int_4 TOIProcessor::getFlag(int toiIndex, int i) { 222 TOI* toi = inTOIs[toiIndex];289 TOI* toi = getInputTOI(toiIndex); 223 290 toi->waitForData(i); 224 291 return toi->getFlag(i); … … 257 324 258 325 void TOIProcessor::putData(int toiIndex, int i, double value, int_4 flg) { 259 TOI* toi = outTOIs[toiIndex];326 TOI* toi = getOutputTOI(toiIndex); 260 327 toi->putData(i, value, flg); 261 328 autoWontNeed(i); … … 266 333 void TOIProcessor::putDataError(int toiIndex, int i, double value, 267 334 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 !"); 269 338 toi->putDataError(i, value, error, flg); 270 339 autoWontNeed(i); -
trunk/ArchTOIPipe/Kernel/toiprocessor.h
r1410 r1437 83 83 int getInputTOIIndex(string toi); 84 84 int getOutputTOIIndex(string toi); 85 86 // Methodes rajoutees par Reza 11/3/2001 87 TOI* getInputTOI(int toiIndex); 88 TOI* getOutputTOI(int toiIndex); 89 bool checkInputTOIIndex(int toiIndex); 90 bool checkOutputTOIIndex(int toiIndex); 91 92 // Fin rajout Reza 11/3/2001 93 85 94 void autoWontNeed(int iCur); 86 95 int lastAWN; … … 96 105 string getOutName(int i); 97 106 string getInName(int i); 107 108 // Methodes rajoutees par Reza 11/3/2001 109 void PrintStatus(ostream & os) ; // const plus tard 110 // Fin rajout Reza 11/3/2001 98 111 99 112 virtual void start(); … … 136 149 }; 137 150 151 inline ostream & operator << (ostream & os, TOIProcessor /*const*/ & toip) 152 { toip.PrintStatus(os); return os; } 153 154 138 155 #endif 156 -
trunk/ArchTOIPipe/TestPipes/fits2asc.cc
r1368 r1437 5 5 #include "asciitoiwtr.h" 6 6 7 voidmain(int argc, char** argv) {7 int main(int argc, char** argv) { 8 8 TOIManager* mgr = TOIManager::getManager(); 9 9 // mgr->setRequestedSample(11680920,11710584); … … 26 26 27 27 mgr->joinAll(); 28 29 return(0); 28 30 } -
trunk/ArchTOIPipe/TestPipes/tsttoi.cc
r1365 r1437 33 33 cout << "joining" << endl; 34 34 mgr->joinAll(); 35 return(0); 35 36 } -
trunk/ArchTOIPipe/TestPipes/tsttoi2.cc
r1370 r1437 6 6 #include "toimanager.h" 7 7 8 voidmain(int argc, char** argv) {8 int main(int argc, char** argv) { 9 9 cout << "tsttoi starting" << endl; 10 10 TOIManager* mgr = TOIManager::getManager(); … … 23 23 24 24 mgr->joinAll(); 25 26 return(0); 25 27 }
Note:
See TracChangeset
for help on using the changeset viewer.