Changeset 407 in Sophya for trunk/Poubelle/archTOI.old/archtoi.cc
- Timestamp:
- Sep 18, 1999, 2:08:23 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.