Changeset 534 in Sophya for trunk/Poubelle/archTOI.old/archtoi.cc
- Timestamp:
- Nov 1, 1999, 10:59:29 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Poubelle/archTOI.old/archtoi.cc
r436 r534 9 9 10 10 #include "archeopsfile.h" 11 #include "toisvr.h" 11 #include "toiiter.h" 12 #include "toimanager.h" 12 13 #include "archtoi.h" 13 14 #include "archparam.h" … … 39 40 { 40 41 init(); 41 svr.readReq(str);42 iter.readReq(str); 42 43 } 43 44 … … 47 48 init(); 48 49 ifstream str(filename.c_str()); 49 svr.readReq(str);50 iter.readReq(str); 50 51 } 51 52 … … 59 60 ostr = NULL; 60 61 requestVersion = ""; 61 svr.registerReqHandler(this); 62 } 63 64 65 bool ArchTOI::processTOIReq(string line, string toiname, TOIKind /*kind*/, int index, 66 bool interp, bool repet, bool flag, bool /*notrig*/) 62 iter.registerReqHandler(this); 63 64 TOIManager::registerDefaultProducers(); 65 } 66 67 68 bool ArchTOI::processTOIReq(TOI const& toi, string line) 67 69 { 68 70 headertoi.push_back(line); 69 if (index>=0) { 70 char idx[10]; 71 sprintf(idx,"_%d",index); 72 toiname += idx; 73 } 74 if (flag) { 75 toinames.push_back("flg_"+toiname); 76 } 77 toinames.push_back(toiname); 78 toiflags.push_back(flg((flag?hasflag:0)+((!repet&&!interp)?useNA:0))); 71 tois.push_back(toi); 79 72 return true; 80 73 } … … 130 123 131 124 cout << "starting query" << endl; 132 TOIIter iter = svr.doQuery();125 iter.init(); 133 126 (this->*openFile)(outfilename); 134 127 (this->*outHeader)(iter); 135 128 136 129 cout << "processing" << endl; 137 while (iter. Next()) {138 int nn = iter.getSample Index() / iter.getUnderSampling(); // Only for tick mark...130 while (iter.next()) { 131 int nn = iter.getSampleNum() / iter.getUnderSample(); // Only for tick mark... 139 132 #ifdef __MWERKS__ 140 133 yield(); … … 145 138 if (nn%(200*80) == 0) cout << endl; 146 139 // Si rien de dispo parmi les triggering, alors on passe au suivant 147 bool hasValue = false; 148 for (int i=0; i<toiflags.size(); i++) { 149 if (!iter.isTrig(i)) continue; 150 if (iter.canGetValue(i)) {hasValue=true; break;} 151 } 152 if (!hasValue) continue; 140 // normalement, c'est gere par le toiiter... 141 //bool hasValue = false; 142 //for (int i=0; i<toiflags.size(); i++) { 143 // if (!iter.isTrig(i)) continue; 144 // if (iter.canGetValue(i)) {hasValue=true; break;} 145 //} 146 //if (!hasValue) continue; 153 147 int icol=0; 154 for (int i=0; i<toi flags.size(); i++) {148 for (int i=0; i<tois.size(); i++) { 155 149 double value = iter.getValue(i); 156 150 bool ok = iter.canGetValue(i); 157 bool isnew = iter.newValue(i); 158 flg flag = toiflags[i]; 159 if (flag & hasflag) { 160 (this->*outValue)(icol, (ok && isnew ? 1 : 0)); 161 icol++; 162 } 163 if (((flag & useNA)!=0 && !isnew) || !ok) 151 // bool isnew = iter.newValue(i); 152 // flg flag = toiflags[i]; 153 // if (flag & hasflag) { 154 // (this->*outValue)(icol, (ok && isnew ? 1 : 0)); 155 // icol++; 156 // } 157 //if (((flag & useNA)!=0 && !isnew) || !ok) 158 if (!ok) 164 159 (this->*outValue)(icol, 0, true); 165 160 else … … 184 179 for (list<string>::iterator i = headeropt.begin(); i != headeropt.end(); i++) 185 180 *ostr << (*i) << '\n';; 186 block_type_param* blk = iter. lastParam();181 block_type_param* blk = iter.getFSet().lastParam(); 187 182 if (blk) { 188 183 int nb = blk->param.n_max_bolo; … … 227 222 } 228 223 224 list<string> ArchTOI::buildNames() { 225 list<string> toinames; 226 map<string,int> namecount; 227 228 for (list<TOI>::iterator i = tois.begin(); i != tois.end(); i++) { 229 namecount[(*i).name]++; 230 } 231 232 map<string,int> curcount; 233 for (list<TOI>::iterator i = tois.begin(); i != tois.end(); i++) { 234 string toiname = (*i).name; 235 if (namecount[(*i).name]>1) { 236 char s[10]; 237 sprintf(s,"_%d",curcount[(*i).name]++); 238 toiname += s; 239 } 240 if ((*i).index != TOI::unspec) { 241 char s[10]; 242 sprintf(s,"_%d",(*i).index); 243 toiname += s; 244 } 245 toinames.push_back(toiname); 246 } 247 return toinames; 248 } 229 249 230 250 void ArchTOI::openFile_F(string const& filename) { … … 237 257 } 238 258 259 239 260 void ArchTOI::outHeader_F(TOIIter& iter) { 261 list<string> toinames = buildNames(); 262 240 263 int ncols=toinames.size(); 241 264 … … 244 267 char** colunits = new (char*[ncols]); 245 268 int j=0; 246 for (list<string>::iterator i = toinames.begin(); i != toinames.end(); i++,j++) { 269 list<TOI>::iterator kk = tois.begin(); 270 for (list<string>::iterator i = toinames.begin(); i != toinames.end(); i++,j++,kk++) { 247 271 colnames[j] = const_cast<char*>((*i).c_str()); // should work for most STL implementations... Check... 248 272 coltypes[j] = "1D"; 249 colunits[j] = " "; 273 colunits[j] = const_cast<char*>((*kk).unit.c_str()); 274 cout << (*i).c_str() << " " << ((*kk).unit.c_str()) << endl; 250 275 } 251 276 … … 261 286 int ntoireq = headertoi.size(); 262 287 fits_write_key(fptr, TINT, "TOIREQ", &ntoireq, NULL, &fitsStatus); 263 for (list<string>::iterator i = headertoi.begin(); i != headertoi.end(); i++,j++) { 288 list<string>::iterator kkk = toinames.begin(); 289 for (list<string>::iterator i = headertoi.begin(); i != headertoi.end(); i++,j++,kkk++) { 264 290 char line[80]; 265 291 strcpy(line, (*i).c_str()); 266 292 char* pline = line; 267 fits_write_keys_str(fptr, "TOIREQ", j, 1, &pline, (char**) NULL, &fitsStatus); 293 char* cmt = const_cast<char*>((*kkk).c_str()); 294 fits_write_keys_str(fptr, "TOIREQ", j, 1, &pline, &cmt, &fitsStatus); 268 295 } 269 296 j=1; … … 278 305 279 306 // Noms des bolos 280 block_type_param* blk = iter. lastParam();307 block_type_param* blk = iter.getFSet().lastParam(); 281 308 if (blk) { 282 309 int nb = blk->param.n_max_bolo; … … 338 365 fits_report_error(stderr, fitsStatus); /* print out any error messages */ 339 366 } 367 368
Note:
See TracChangeset
for help on using the changeset viewer.