Changeset 407 in Sophya for trunk/Poubelle
- Timestamp:
- Sep 18, 1999, 2:08:23 PM (26 years ago)
- Location:
- trunk/Poubelle/archTOI.old
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Poubelle/archTOI.old/archeopsfile.cc
r405 r407 5 5 #define utilitaires_de_block_archeops 6 6 #include "archeopsfile.h" 7 #include "gyrohandler.h" 8 7 9 extern "C" { 8 10 #include "compress.h" … … 41 43 block_type_modele peekBlock; 42 44 43 SSTHandler sstHandler; 44 GPSParser gpsParser; 45 SSTHandler sstHandler; 46 GyroHandler gyroHandler; 47 GPSParser gpsParser; 45 48 }; 46 49 … … 85 88 86 89 BlockSet::BlockSet(BlockSet const& x) 87 : sstHandler(x.sstHandler) 90 : sstHandler(x.sstHandler), gyroHandler(x.gyroHandler) 88 91 { 89 92 lastParam = NULL; … … 567 570 blockSet->sstHandler.ProcessBlock((block_type_sst*)&blockSet->curBlock); 568 571 } 572 case block_gyro : { 573 blockSet->gyroHandler.ProcessBlock((block_type_gyro*)&blockSet->curBlock); 574 } 569 575 case block_gps : { 570 576 blockSet->gpsParser.ProcessBlock((block_type_gps*)&blockSet->curBlock); … … 673 679 static char* buffer = 0; 674 680 static int4 debswp = debut_block_mesure; 675 static int4 longmax = taille_maxi_block_archeops*20; 681 static int4 longmax = taille_maxi_block_archeops*20; 676 682 if (!buffer) { 677 683 buffer = new char[longmax]; … … 680 686 #endif 681 687 } 682 fseek(f,pos,SEEK_SET); 683 size_t read = fread(buffer,1,taille_maxi_block_archeops*2,f); 684 //if (read<taille_maxi_block_archeops*2) return -1; 685 for (int i=4; i<read; i+=4) { 686 if (*(int4*)(buffer+i) == debswp) { 687 cout << "trying to skip " << i << " bytes to pos="<<pos+i << endl; 688 return pos+i; 688 size_t read = longmax; 689 while (read == longmax) { 690 fseek(f,pos,SEEK_SET); 691 read = fread(buffer,1,longmax,f); 692 //if (read<taille_maxi_block_archeops*2) return -1; 693 // EA 150999 changed i+=4 to i++ -> unaligned, but can lose bytes in flight recorder 694 for (size_t i=4; i<read; i++) { 695 if (*(int4*)(buffer+i) == debswp) { 696 cout << "trying to skip " << i << " bytes to pos="<<pos+i << endl; 697 return pos+i; 698 } 689 699 } 700 pos += read; 690 701 } 691 702 cout << "cannot find block start" << endl; … … 758 769 } 759 770 771 int ArcheopsFile::getReglageBlockNum() { 772 if (!lastReglage()) return -1; 773 return numero_block(lastReglage()); 774 } 775 776 760 777 int ArcheopsFile::getSSTBlockNum() { 761 778 if (!lastSST()) return -1; … … 864 881 } 865 882 883 double ArcheopsFile::getGainAmpli(int ibolo) { 884 return gain_ampli(lastReglage()->reglage.bolo[ibolo]); 885 } 866 886 867 887 // SST, gyros... … … 895 915 } 896 916 897 long ArcheopsFile::getGyro(int igyro, int imesure) { 898 if (igyro<0 || igyro>2) return 0; 899 if (imesure<0 || imesure>= nb_per_block*2) return 0; 900 block_type_gyro* blk = lastGyro() ; 901 if (!blk) return 0; 902 #if version_num<=25 903 return blk->gyros[igyro][imesure]-32768.; 904 #else 905 return blk->gyro[igyro][imesure]-32768.; 906 #endif 907 } 917 long ArcheopsFile::getGyroRaw(int igyro, int imesure) { 918 return blockSet->gyroHandler.getRawSignal(imesure, igyro); 919 } 920 921 double ArcheopsFile::getGyroTens(int igyro, int imesure) { 922 return blockSet->gyroHandler.getSignal(imesure, igyro); 923 } 924 925 double ArcheopsFile::getGyroSpeed(int igyro, int imesure) { 926 return blockSet->gyroHandler.getSpeed(imesure, igyro); 927 } 928 929 908 930 909 931 -
trunk/Poubelle/archTOI.old/archeopsfile.h
r394 r407 127 127 128 128 // Bolo 129 int getReglageBlockNum(); 129 130 int getBoloBlockNum(); 130 131 long getRawBolo(int ibolo, int imesure); // donnee brute, avec seulement soustraction offset 131 132 double getMuVBolo(int ibolo, int imesure); // microvolts, filtre avec filtre carre 133 double getGainAmpli(int ibolo); 132 134 133 135 // SST, gyros, etc … … 142 144 143 145 int getGyroBlockNum(); 144 long getGyro(int iGyro, int imesure); 146 long getGyroRaw(int iGyro, int imesure); 147 double getGyroTens(int iGyro, int imesure); 148 double getGyroSpeed(int iGyro, int imesure); 145 149 146 150 double getAzimut(int imesure); -
trunk/Poubelle/archTOI.old/archtoi.cc
r406 r407 12 12 #include "archtoi.h" 13 13 #include "archparam.h" 14 #include "asigps.h"15 14 16 15 using namespace std; … … 39 38 { 40 39 init(); 41 readReq(str);40 svr.readReq(str); 42 41 } 43 42 … … 47 46 init(); 48 47 ifstream str(filename.c_str()); 49 readReq(str);48 svr.readReq(str); 50 49 } 51 50 … … 57 56 fptr = NULL; 58 57 ostr = NULL; 59 } 60 61 void ArchTOI::readReq(istream& str) 62 { 63 string line; 64 while (str) { 65 getline(str,line); 66 if (!str) break; 67 if (line[0] == '@') processTOIReq(line); 68 else if (line[0] == '#') 69 if (!processOption(line)) break; 70 } 71 } 72 73 #define tsttoi(toi) if (key == "@"#toi) kind = toi; 74 75 void ArchTOI::processTOIReq(string line) 76 { 77 // find TOI kind, index and options 78 TOIKind kind= (TOIKind)-1; 79 int index=-1; 80 bool interp=false; 81 bool repet =false; 82 bool flag =false; 83 bool notrig=false; 84 int x = line.find(' '); 85 string key = line.substr(0, x); 86 string opts = (x>0) ? line.substr(x) : string(""); 87 tsttoi(sampleNum) 88 else tsttoi(internalTime) 89 else tsttoi(mjd) 90 else tsttoi(boloTens) 91 else tsttoi(boloRaw) 92 else tsttoi(sstDiode) 93 else tsttoi(sstChannel) 94 else tsttoi(sstStarCnt) 95 else tsttoi(sstStarZ) 96 else tsttoi(sstStarF) 97 else tsttoi(sstStarT) 98 else tsttoi(gyroRaw) 99 else tsttoi(gpsTime) 100 else tsttoi(longitude) 101 else tsttoi(latitude) 102 else tsttoi(altitude) 103 else tsttoi(tsid) 104 else tsttoi(azimut) 105 else tsttoi(alphaAxis) 106 else tsttoi(deltaAxis) 107 else tsttoi(alphaBolo) 108 else tsttoi(deltaBolo) 109 else { 110 cerr << "*Warning, unrecognized TOI " << line << endl; 111 return; 112 } 113 if (kind == sampleNum) notrig = true; 114 while (opts != "") { 115 if (opts[0] == ' ') { 116 opts = opts.substr(opts.find_first_not_of(' ')); 117 if (opts == "") break; 118 } 119 x = opts.find(' '); 120 string opt = opts.substr(0, x); 121 opts = (x>0) ? opts.substr(x) : string(""); 122 if (opt[0]>='0' && opt[0]<='9') { 123 index = atoi(opt.c_str()); 124 } else if (opt == "notrig") { 125 notrig = true; 126 } else if (opt == "repet") { 127 repet = true; interp = false; 128 } else if (opt == "interp") { 129 interp = true; repet = false; 130 } else if (opt == "flag") { 131 flag = true; 132 } 133 } 58 requestVersion = ""; 59 svr.registerReqHandler(this); 60 } 61 62 63 bool ArchTOI::processTOIReq(string line, string toiname, TOIKind /*kind*/, int index, 64 bool interp, bool repet, bool flag, bool /*notrig*/) 65 { 134 66 headertoi.push_back(line); 135 string toiname = key.substr(1);136 67 if (index>=0) { 137 68 char idx[10]; … … 144 75 toinames.push_back(toiname); 145 76 toiflags.push_back(flg((flag?hasflag:0)+((!repet&&!interp)?useNA:0))); 146 if (index<0) index=0; 147 svr.AddInfo(kind, index, !notrig, interp); 77 return true; 148 78 } 149 79 150 bool ArchTOI::processOption(string line) 151 { 152 int x = line.find(' '); 153 string key = line.substr(0, x); 154 string arg = (x>0) ? line.substr(x) : string(""); 80 bool ArchTOI::processOption(string key, string arg) 81 { 82 string line=key; if (arg != "") line = line + " " + arg; 83 headeropt.push_back(line); 155 84 if (arg.length()>0 && arg[0] == ' ') { 156 85 arg = arg.substr(arg.find_first_not_of(' ')); … … 160 89 } else if (key == "#FITS") { 161 90 format = fits_fmt; 162 } else if (key == "#TRANGE") {163 double tmin, tmax;164 sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax);165 svr.SetTimeInterval(tmin, tmax);166 } else if (key == "#PATH") {167 svr.SetDirectory(arg);168 } else if (key == "#FILE") {169 svr.AddFile(arg);170 91 } else if (key == "#UNDEF") { 171 92 undef=arg; 172 93 } else if (key == "#ALLBOLOS") { 173 94 allBolos=true; 174 } else if (key == "#RECORDER") { 175 svr.OnBoardRecorderFiles(true); 176 } else if (key == "#MJD0") { 177 double t0; 178 sscanf(arg.c_str(), "%lg", &t0); 179 archParam.acq.tBlock0 = t0; 180 } else if (key == "#PERECH") { 181 double t0; 182 sscanf(arg.c_str(), "%lg", &t0); 183 archParam.acq.perEch = t0; 184 } else if (key == "#ASIGPS") { 185 ASIGPS* gps = new ASIGPS(arg); 186 gps->FitsDump("GPSDump.fits"); 187 svr.UseAuxGPS(gps); 188 } else if (key == "#END") { 95 } else if (key == "#REQVERSION") { 96 requestVersion = arg; 97 } else if (key == "#COMMENT") { 98 comments.push_back(arg); 99 } else { 189 100 return false; 190 } else { 191 cerr << "*Warning, unrecognized option " << line << endl; 192 return true; 193 } 194 195 headeropt.push_back(line); 101 } 102 196 103 return true; 197 104 } … … 215 122 216 123 cout << "starting query" << endl; 217 TOIIter iter = svr. DoQuery();124 TOIIter iter = svr.doQuery(); 218 125 (this->*openFile)(outfilename); 219 126 (this->*outHeader)(iter); … … 388 295 //fits_write_key(fptr, TINT, "BOLO", &j, NULL, &fitsStatus); 389 296 } 297 fits_write_key_str(fptr, "TOIVERS", ARCHTOI_VERS, "Archtoi version",&fitsStatus); 298 fits_write_key_str(fptr, "TOITAG", ARCHTOI_TAG, "Archtoi cvs tag",&fitsStatus); 299 if (requestVersion != "") 300 fits_write_key_str(fptr, "REQVERS", (char*) requestVersion.c_str(), 301 "Request options version",&fitsStatus); 390 302 fits_write_comment(fptr, "Generated with archtoi " ARCHTOI_VERS, &fitsStatus); 391 303 char line[80]; 392 304 sprintf(line, "using archeops.h %d", version_num); 393 305 fits_write_comment(fptr, line, &fitsStatus); 306 for (list<string>::iterator i = comments.begin(); i!=comments.end(); i++) 307 fits_write_comment(fptr, (char*)((*i).c_str()), &fitsStatus); 394 308 395 309 fitsLine = 1; -
trunk/Poubelle/archTOI.old/archtoi.h
r359 r407 14 14 using namespace std; 15 15 16 class ArchTOI {16 class ArchTOI : public RequestHandler { 17 17 public: 18 18 ArchTOI(istream& str); … … 24 24 enum flg {hasflag = 1, 25 25 useNA = 2}; 26 27 virtual bool processTOIReq(string line, string toiname, TOIKind toi, int index, 28 bool interp, bool repet, bool flag, bool notrig); 29 virtual bool processOption(string keyw, string args); 26 30 27 31 protected: 28 32 void init(); 29 void readReq(istream& str);30 bool processOption(string line); // false when #END : stop processing...31 void processTOIReq(string line);32 33 TOISvr svr; 33 34 list<string> headertoi; … … 61 62 int fitsLine; 62 63 ostream* ostr; 64 65 string requestVersion; 66 list<string> comments; 63 67 }; 64 68 65 #define ARCHTOI_VERS "1.0" 69 #define ARCHTOI_VERS "1.1" 70 #define ARCHTOI_TAG "notag" 66 71 67 72 #endif -
trunk/Poubelle/archTOI.old/toiiter.cc
r406 r407 1 1 // toiiter.cc 2 2 // Eric Aubourg CEA/DAPNIA/SPP juillet 1999 3 4 #ifndef nb_max_bolo 5 #define _archeops // Acquisition Archeops (avec transputer) 6 #define programme 7 extern "C" { 8 #include "archeops.h" 9 } 10 #endif 3 11 4 12 … … 204 212 switch ((*i).kind) { 205 213 case boloTens: 214 case boloTens2: 206 215 case boloRaw: 207 trigMask |= block_bolo_mask; 208 break; 216 case boloRes: 217 case boloTemp: 218 case boloRawCN: 219 case boloTens2T: 220 trigMask |= block_bolo_mask; 221 break; 222 case boloGainAmpli: 223 trigMask |= block_reglage_mask; 224 break; 209 225 case gpsTime: 210 226 case longitude: 211 227 case latitude: 212 228 case altitude: 213 214 229 trigMask |= block_gps_mask; 230 break; 215 231 case azimut: 216 217 218 232 file->needSSTProcessMask(SSTHandler::findPeriod); 233 trigMask |= block_sst_mask; 234 break; 219 235 case sstStarCnt: 220 236 case sstStarZ: 221 237 case sstStarF: 222 238 case sstStarT: 223 224 225 239 file->needSSTProcessMask(SSTHandler::findStars); 240 trigMask |= block_sst_mask; 241 break; 226 242 case sstDiode: 227 file->needSSTProcessMask(SSTHandler::permDiode); 228 trigMask |= block_sst_mask; 229 break; 243 case sstDiodeCN: 244 file->needSSTProcessMask(SSTHandler::permDiode); 245 trigMask |= block_sst_mask; 246 break; 230 247 case sstChannel: 231 trigMask |= block_sst_mask; 232 break; 248 case sstChannelCN: 249 trigMask |= block_sst_mask; 250 break; 233 251 case gyroRaw: 234 trigMask |= block_gyro_mask; 235 break; 252 case gyroTens: 253 trigMask |= block_gyro_mask; 254 break; 255 case gyroSpeed: 256 trigMask |= block_gyro_mask; // $CHECK$ + info to calibrate gyros 257 break; 236 258 case alphaAxis: 237 259 case deltaAxis: 260 case alphaSst: 261 case deltaSst: 238 262 case alphaBolo: 239 263 case deltaBolo: 240 241 242 264 file->needSSTProcessMask(SSTHandler::findAxis); 265 trigMask |= block_sst_mask; 266 break; 243 267 } 244 268 } … … 407 431 return true; 408 432 case boloTens: 433 case boloTens2: 434 case boloTens2T: 435 case boloRes: 436 case boloRawCN: 409 437 if (imes==0 && file->llastBolo()==NULL) return false; 410 438 return file->lastBolo() != NULL; 411 439 case boloRaw: 412 440 return file->lastBolo() != NULL; 441 case boloGainAmpli: 442 return file->lastReglage() != NULL; 413 443 case sstDiode: 414 444 case sstChannel: 445 case sstDiodeCN: 446 case sstChannelCN: 415 447 return file->lastSST() != NULL; 416 448 case sstStarCnt: … … 423 455 } 424 456 case gyroRaw: 457 case gyroTens: 458 case gyroSpeed: 425 459 return (file->lastGyro() != NULL); 426 460 case gpsTime: … … 450 484 } 451 485 486 452 487 double TOIIter::getValue(int column) { 453 488 if (!initDone) Init(); … … 484 519 case boloRaw: 485 520 return file->getRawBolo(index, imes); 521 case boloGainAmpli: 522 return file->getGainAmpli(index); 486 523 case sstDiode: 487 524 return file->getSSTSignal(index, imes); … … 497 534 return file->getSSTStarT(index, imes); 498 535 case gyroRaw: 499 return file->getGyro(index, imes); 536 return file->getGyroRaw(index, imes); 537 case gyroTens: 538 return file->getGyroTens(index, imes); 539 case gyroSpeed: 540 return file->getGyroSpeed(index, imes); 500 541 case gpsTime: 501 542 return file->getGPSUTC(); … … 540 581 case boloRaw: 541 582 return file->blockNum() == file->getBoloBlockNum(); 583 case boloGainAmpli: 584 return file->blockNum() == file->getReglageBlockNum() && imes==0; 542 585 case sstChannel: 543 586 case sstDiode: … … 548 591 return file->blockNum() == file->getSSTBlockNum(); 549 592 case gyroRaw: 593 case gyroTens: 594 case gyroSpeed: 550 595 return file->blockNum() == file->getGyroBlockNum(); 551 596 case gpsTime: -
trunk/Poubelle/archTOI.old/toiiter.h
r401 r407 15 15 16 16 enum TOIKind { 17 sampleNum, // Numero d''echantillon (timer interne transputer) 18 internalTime, // temps transputer depuis debut manip, en secondes. 19 mjd, // UTC (en jours, MJD = JD - 2450000). index=0 : premier bloc GPS. 1: + sioux. 20 boloTens, // tension en microVolts, filtree avec filtre carre indexe par bolometre 21 boloRaw, // tension brute, non filtree indexe par bolometre 22 boloTemp, // Kelvins 23 sstDiode, // signal brut SST, indice = diode, 0-45 24 sstChannel, // signal brut SST, indice = canal, 0-47 25 sstStarCnt, // nombre d''etoiles detectees durant ce sample 26 sstStarZ, // numero de diode d''une eventuelle etoile, i=etoile 0..n 27 sstStarF, // flux d''une eventuelle etoile, <0 si moins de i+1 etoiles 28 sstStarT, // temps d''une eventuelle etoile, <0 si moins de i+1 etoiles 29 gyroRaw, // valeur brute du gyro, index = 0,1,2 30 gpsTime, // temps fourni par GPS 31 longitude, // position ballon 32 latitude, // position ballon 33 altitude, // position ballon 34 tsid, // temps sideral en secondes 35 azimut, // a preciser, reconstruit SST, magneto, autres... 36 alphaAxis, // 37 deltaAxis, // 38 alphaSst, // 39 deltaSst, // 40 alphaBolo, // sur le ciel, indexe par bolometre 41 deltaBolo // sur le ciel, indexe par bolometre 42 }; 17 sampleNum, // Numero d''echantillon (timer interne transputer) 18 internalTime, // temps transputer depuis debut manip, en secondes. 19 mjd, // UTC (en jours, MJD = JD - 2450000). index=0 : premier bloc GPS. 1: + sioux. 20 boloTens, // tension en microVolts, filtree avec filtre carre indexe par bolometre 21 boloTens2, // tension en microVolts, avec soustraction offset filtre 22 boloRaw, // tension brute en microVolts, non filtree indexe par bolometre, sans chgt signe 23 boloRes, // Resistance, ohms 24 boloTemp, // Kelvins, need R(T) -> N/A 25 boloGainAmpli, // gain de l'ampli du bolo 26 boloRawCN, // compression noise on bolo raw 27 boloTens2T, // total, microVolts, avec consigne DAC 28 sstDiode, // signal brut SST, indice = diode, 0-45 29 sstChannel, // signal brut SST, indice = canal, 0-47 30 sstDiodeCN, // compression noise 31 sstChannelCN, // compression noise 32 sstStarCnt, // nombre d''etoiles detectees durant ce sample 33 sstStarZ, // numero de diode d''une eventuelle etoile, i=etoile 0..n 34 sstStarF, // flux d''une eventuelle etoile, <0 si moins de i+1 etoiles 35 sstStarT, // temps d''une eventuelle etoile, <0 si moins de i+1 etoiles 36 gyroRaw, // valeur brute du gyro, index = 0,1,2 37 gyroTens, // tension gyro, V, index = 0,1,2 38 gyroSpeed, // vitesse gyro, deg/s, index = 0,1,2, calibree... 39 gpsTime, // temps fourni par GPS 40 longitude, // position ballon, degrees 41 latitude, // position ballon, degrees 42 altitude, // position ballon, m 43 tsid, // temps sideral en secondes 44 azimut, // azimut centre optique ??? 45 alphaAxis, // 46 deltaAxis, // 47 alphaSst, // 48 deltaSst, // 49 alphaBolo, // sur le ciel, indexe par bolometre 50 deltaBolo // sur le ciel, indexe par bolometre 51 }; 43 52 44 53 class TOIInterpolator; -
trunk/Poubelle/archTOI.old/toisvr.cc
r394 r407 2 2 // Eric Aubourg CEA/DAPNIA/SPP juillet 1999 3 3 4 4 #include <iostream.h> 5 5 #include "toisvr.h" 6 #include "archparam.h" 7 #include "asigps.h" 6 8 7 9 TOISvr::TOISvr() 8 10 {} 9 11 10 void TOISvr::SetDirectory(string d) { 12 // To avoid special copy constructor handling, we will not 13 // register ourself to us... Special dealing in readReq. 14 15 void TOISvr::setDirectory(string d) { 11 16 iter.directory = d; 12 17 } 13 18 14 void TOISvr:: AddFile(string f) {19 void TOISvr::addFile(string f) { 15 20 iter.files.insert(f); 16 21 } 17 22 18 void TOISvr:: UseAuxGPS(AuxGPS* gps) {23 void TOISvr::useAuxGPS(AuxGPS* gps) { 19 24 if (iter.auxGPS) delete iter.auxGPS; 20 25 iter.auxGPS = gps; … … 22 27 23 28 24 void TOISvr:: OnBoardRecorderFiles(bool x) {29 void TOISvr::onBoardRecorderFiles(bool x) { 25 30 iter.isOnBoardRecorder = x; 26 31 } 27 32 28 33 29 void TOISvr:: SetTimeInterval(double tStart, double tEnd) {34 void TOISvr::setTimeInterval(double tStart, double tEnd) { 30 35 if (tStart>0) iter.tStart = tStart; 31 36 if (tEnd>0) iter.tEnd = tEnd; 32 37 } 33 38 34 void TOISvr:: AddInfo(TOIKind kind, int index, bool triggering, bool interp) {39 void TOISvr::addInfo(TOIKind kind, int index, bool triggering, bool interp) { 35 40 TOIIter::info i; 36 41 i.kind = kind; … … 41 46 } 42 47 43 void TOISvr:: AddInfo(TOIKind kind, bool triggering, bool interp) {44 AddInfo(kind,0,triggering,interp);48 void TOISvr::addInfo(TOIKind kind, bool triggering, bool interp) { 49 addInfo(kind,0,triggering,interp); 45 50 } 46 51 47 TOIIter TOISvr:: DoQuery() {52 TOIIter TOISvr::doQuery() { 48 53 //iter.Init(); 49 54 return iter; 50 55 } 56 57 void TOISvr::registerReqHandler(RequestHandler* h) { 58 handlers.push_back(h); 59 } 60 61 62 void TOISvr::readReq(istream& str) { 63 string line; 64 while (str) { 65 getline(str,line); 66 if (!str) break; 67 if (line.substr(0,4)=="#END") break; 68 if (line[0] != '@' && line[0] != '#') continue; 69 bool handled=processRequest(line); 70 if (!handled) { 71 cerr << "*Warning, unrecognized directive " << line << endl; 72 } 73 } 74 } 75 76 #define tsttoi(toi) if (keyw == "@"#toi) kind = toi; 77 78 bool TOISvr::processRequest(string line) { 79 int x = line.find(' '); 80 string keyw = line.substr(0, x); 81 string args = (x>0) ? line.substr(x) : string(""); 82 if (keyw[0] == '#') { 83 bool handled = processOption(keyw,args); 84 for (list<RequestHandler*>::iterator i = handlers.begin(); 85 i != handlers.end(); i++) { 86 handled |= (*i)->processOption(keyw,args); 87 } 88 return handled; 89 } 90 if (keyw[0] == '@') { 91 // find TOI kind, index and options 92 TOIKind kind= (TOIKind)-1; 93 int index=-1; 94 bool interp=false; 95 bool repet =false; 96 bool flag =false; 97 bool notrig=false; 98 tsttoi(sampleNum) 99 else tsttoi(internalTime) 100 else tsttoi(mjd) 101 else tsttoi(boloTens) 102 else tsttoi(boloTens2) 103 else tsttoi(boloRaw) 104 else tsttoi(boloRes) 105 else tsttoi(boloTemp) 106 else tsttoi(boloGainAmpli) 107 else tsttoi(boloTens2T) 108 else tsttoi(boloRawCN) 109 else tsttoi(sstDiode) 110 else tsttoi(sstChannel) 111 else tsttoi(sstDiodeCN) 112 else tsttoi(sstChannelCN) 113 else tsttoi(sstStarCnt) 114 else tsttoi(sstStarZ) 115 else tsttoi(sstStarF) 116 else tsttoi(sstStarT) 117 else tsttoi(gyroRaw) 118 else tsttoi(gyroTens) 119 else tsttoi(gyroSpeed) 120 else tsttoi(gpsTime) 121 else tsttoi(longitude) 122 else tsttoi(latitude) 123 else tsttoi(altitude) 124 else tsttoi(tsid) 125 else tsttoi(azimut) 126 else tsttoi(alphaAxis) 127 else tsttoi(deltaAxis) 128 else tsttoi(alphaSst) 129 else tsttoi(deltaSst) 130 else tsttoi(alphaBolo) 131 else tsttoi(deltaBolo) 132 else { 133 // cerr << "*Warning, unrecognized TOI " << line << endl; 134 return false; 135 } 136 if (kind == sampleNum || kind == mjd) notrig = true; 137 string toiname = keyw.substr(1); 138 while (args != "") { 139 if (args[0] == ' ') { 140 args = args.substr(args.find_first_not_of(' ')); 141 if (args == "") break; 142 } 143 x = args.find(' '); 144 string opt = args.substr(0, x); 145 args = (x>0) ? args.substr(x) : string(""); 146 if (opt[0]>='0' && opt[0]<='9') { 147 index = atoi(opt.c_str()); 148 } else if (opt == "notrig") { 149 notrig = true; 150 } else if (opt == "repet") { 151 repet = true; interp = false; 152 } else if (opt == "interp") { 153 interp = true; repet = false; 154 } else if (opt == "flag") { 155 flag = true; 156 } 157 } 158 bool handled = processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig); 159 for (list<RequestHandler*>::iterator i = handlers.begin(); 160 i != handlers.end(); i++) { 161 handled |= (*i)->processTOIReq(line, toiname, kind, index, interp, repet, flag, notrig); 162 } 163 return handled; 164 } 165 return false; 166 } 167 168 169 bool TOISvr::processTOIReq(string /*line*/, string /*toiname*/, TOIKind kind, int index, 170 bool interp, bool /*repet*/, bool /*flag*/, bool notrig) 171 { 172 if (index<0) index=0; 173 addInfo(kind, index, !notrig, interp); 174 return true; 175 } 176 177 bool TOISvr::processOption(string key, string arg) 178 { 179 if (arg.length()>0 && arg[0] == ' ') { 180 arg = arg.substr(arg.find_first_not_of(' ')); 181 } 182 if (key == "#TRANGE") { 183 double tmin, tmax; 184 sscanf(arg.c_str(), "%lg %lg", &tmin, &tmax); 185 setTimeInterval(tmin, tmax); 186 } else if (key == "#PATH") { 187 setDirectory(arg); 188 } else if (key == "#FILE") { 189 addFile(arg); 190 } else if (key == "#RECORDER") { 191 onBoardRecorderFiles(true); 192 } else if (key == "#MJD0") { 193 double t0; 194 sscanf(arg.c_str(), "%lg", &t0); 195 archParam.acq.tBlock0 = t0; 196 } else if (key == "#PERECH") { 197 double t0; 198 sscanf(arg.c_str(), "%lg", &t0); 199 archParam.acq.perEch = t0; 200 } else if (key == "#ASIGPS") { 201 ASIGPS* gps = new ASIGPS(arg); 202 gps->FitsDump("GPSDump.fits"); 203 useAuxGPS(gps); 204 } else { 205 // cerr << "*Warning, unrecognized option " << line << endl; 206 return false; 207 } 208 return true; 209 } -
trunk/Poubelle/archTOI.old/toisvr.h
r394 r407 7 7 8 8 #include "toiiter.h" 9 #include <list> 9 10 10 11 class AuxGPS; 11 12 12 class TOISvr { 13 class RequestHandler { 14 public: 15 virtual bool processTOIReq(string line, string toiname, TOIKind toi, int index, 16 bool interp, bool repet, bool flag, bool notrig)=0; 17 virtual bool processOption(string keyw, string args)=0; 18 }; 19 20 class TOISvr : public RequestHandler { 13 21 public: 14 22 TOISvr(); 15 23 16 void SetDirectory(string);17 void AddFile(string);18 void OnBoardRecorderFiles(bool);19 void UseAuxGPS(AuxGPS* gps);24 void setDirectory(string); 25 void addFile(string); 26 void onBoardRecorderFiles(bool); 27 void useAuxGPS(AuxGPS* gps); 20 28 21 void SetTimeInterval(double tStart, double tEnd);29 void setTimeInterval(double tStart, double tEnd); 22 30 23 void AddInfo(TOIKind kind, int index, bool triggering=true, bool interp=false);24 void AddInfo(TOIKind kind, bool triggering=true, bool interp=false);31 void addInfo(TOIKind kind, int index, bool triggering=true, bool interp=false); 32 void addInfo(TOIKind kind, bool triggering=true, bool interp=false); 25 33 26 TOIIter DoQuery();34 void readReq(istream& s); 27 35 36 TOIIter doQuery(); 37 38 bool processRequest(string line); 39 void registerReqHandler(RequestHandler*); 40 virtual bool processTOIReq(string line, string toiname, TOIKind toi, int index, 41 bool interp, bool repet, bool flag, bool notrig); 42 virtual bool processOption(string keyw, string args); 28 43 29 44 protected: 30 45 TOIIter iter; 46 list<RequestHandler*> handlers; 31 47 }; 32 48
Note:
See TracChangeset
for help on using the changeset viewer.