| [2094] | 1 | //#define TOISEQBUFFERED
 | 
|---|
 | 2 | 
 | 
|---|
| [2099] | 3 | #include <iostream.h>
 | 
|---|
 | 4 | #include <string>
 | 
|---|
| [2094] | 5 | #include <unistd.h>
 | 
|---|
 | 6 | #include <stdlib.h>
 | 
|---|
 | 7 | #include <stdio.h>
 | 
|---|
 | 8 | #include "toi.h"
 | 
|---|
 | 9 | #include "cgt.h"
 | 
|---|
 | 10 | #include "toiprocessor.h"
 | 
|---|
 | 11 | #include "fitstoirdr.h"
 | 
|---|
 | 12 | #include "fitstoiwtr.h"
 | 
|---|
 | 13 | #include "toimanager.h"
 | 
|---|
| [2099] | 14 | #include "toisegment.h"
 | 
|---|
| [2094] | 15 | #include "toiseqbuff.h"
 | 
|---|
 | 16 | #include "sambainit.h"
 | 
|---|
 | 17 | #include "toi2toi_addsp.h"
 | 
|---|
 | 18 | #include "timing.h"
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | #include <stdexcept>
 | 
|---|
| [2104] | 21 | #include <vector>
 | 
|---|
| [2094] | 22 | 
 | 
|---|
 | 23 | void usage(void) {
 | 
|---|
 | 24 |  cout<<"tsttoi2toi_addsp [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
 | 
|---|
 | 25 |      <<"           [-a label_coord1] [-d label_coord2] [-b label_bolomuv]"<<endl
 | 
|---|
 | 26 |      <<"           [-n nlat] [-i c,h] [-o c,h]"<<endl
 | 
|---|
 | 27 |      <<"           [-m vmin] [-M vmax] [-f flag]"<<endl
 | 
|---|
 | 28 |      <<"           fitsin_point fitsin_bolo fitsphout [fitsphwout]"<<endl
 | 
|---|
 | 29 |      <<" -p lp : print level (def=0)"<<endl
 | 
|---|
 | 30 |      <<" -s samplemin,samplemax : sample range to be treated (def=all)"<<endl
 | 
|---|
 | 31 |      <<" -w data_window_size : window size for pipe (def=8192)"<<endl
 | 
|---|
 | 32 |      <<" -a label_coord1 : label fits for alpha/gLong (def=coord1)"<<endl
 | 
|---|
 | 33 |      <<" -d label_coord2 : label fits for delta/gLat (def=coord2)"<<endl
 | 
|---|
 | 34 |      <<"          coord1 = alpha or gLong ; coord2 = delta or gLat"<<endl
 | 
|---|
| [2099] | 35 |      <<" -b label_bolo_in : label fits for bolo value (def=boloMuV)"<<endl
 | 
|---|
 | 36 |      <<" -n label_bolo_out : label fits for bolo value (def=boloMuV_sp)"<<endl
 | 
|---|
 | 37 |      <<" -u label_out : label fits for utc (def=UTC)"<<endl
 | 
|---|
 | 38 |      <<" -l label_out : label fits for longitude (def=longitude)"<<endl
 | 
|---|
 | 39 |      <<" -L label_out : label fits for latitude (def=latitude)"<<endl
 | 
|---|
| [2094] | 40 |      <<" -m vmin : samples are good if sample value >= vmin"<<endl
 | 
|---|
 | 41 |      <<" -M vmax : samples are good if sample value <= vmax"<<endl
 | 
|---|
 | 42 |      <<" -f flag : samples are bad if match flag"<<endl
 | 
|---|
 | 43 |      <<" fitsin_point : fits file for pointing"<<endl
 | 
|---|
 | 44 |      <<" fitsin_bolo : fits file for bolo values"<<endl
 | 
|---|
| [2099] | 45 |      <<" fitsin_utc : fits file for UTC values"<<endl
 | 
|---|
 | 46 |      <<" fitsin_lon : fits file for longitude values"<<endl
 | 
|---|
 | 47 |      <<" fitsin_lat : fits file for latitude values"<<endl
 | 
|---|
 | 48 |      <<" fitsout_bolo : fits file for output bolo value"<<endl;
 | 
|---|
| [2094] | 49 | }
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 | ////////////////////////////////////////////////////////////////
 | 
|---|
 | 52 | int main(int narg, char** arg) {
 | 
|---|
 | 53 | 
 | 
|---|
| [2099] | 54 | int_4 ns = 10;
 | 
|---|
 | 55 | 
 | 
|---|
| [2094] | 56 | TOIManager* mgr = TOIManager::getManager();
 | 
|---|
| [2099] | 57 | int wsize = 512; /// Segment size for TOISegmented 
 | 
|---|
 | 58 | bool fgsegmented = true;
 | 
|---|
| [2094] | 59 | 
 | 
|---|
 | 60 | //-- Decodage arguments
 | 
|---|
 | 61 | int lp = 0, width = 8192;
 | 
|---|
 | 62 | bool tflg=false, tmin=false, tmax=false;
 | 
|---|
 | 63 | r_8 vmin=-1.e30, vmax=1.e30; uint_8 badflg=0;
 | 
|---|
| [2099] | 64 | char * label_coord1 = "coord1";
 | 
|---|
 | 65 | char * label_coord2 = "coord2";
 | 
|---|
 | 66 | char * label_bolo_in = "boloMuV";
 | 
|---|
 | 67 | char * label_bolo_out = "boloMuV_sp";
 | 
|---|
 | 68 | char * label_utc= "UTC";
 | 
|---|
 | 69 | char * label_lon = "longitude";
 | 
|---|
 | 70 | char * label_lat = "latitude";
 | 
|---|
| [2094] | 71 | double equi=2000.;
 | 
|---|
 | 72 | char *tcoorin="gdcdl", *tcoormap="g";
 | 
|---|
 | 73 | long sdeb,sfin;
 | 
|---|
| [2099] | 74 | 
 | 
|---|
| [2094] | 75 | int c;
 | 
|---|
 | 76 | while((c = getopt(narg,arg,"hIp:s:w:a:d:b:n:i:o:m:M:f:e:")) != -1) {
 | 
|---|
 | 77 |   switch (c) {
 | 
|---|
 | 78 |   case 's' :
 | 
|---|
 | 79 |     sscanf(optarg,"%ld,%ld",&sdeb,&sfin);
 | 
|---|
 | 80 |     cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
 | 
|---|
 | 81 |     if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
 | 
|---|
 | 82 |     //else {cout<<"Bad sample interval "<<endl; exit(2);}
 | 
|---|
 | 83 |     break;
 | 
|---|
 | 84 |   case 'w' :
 | 
|---|
 | 85 |     sscanf(optarg,"%d",&width);
 | 
|---|
 | 86 |     if(width<=0) width=8192;
 | 
|---|
 | 87 |     cout<<"Data window size "<<width<<endl;
 | 
|---|
 | 88 |     break;
 | 
|---|
 | 89 |   case 'p' :
 | 
|---|
 | 90 |     sscanf(optarg,"%d",&lp);
 | 
|---|
 | 91 |     if(lp<0) lp=0;
 | 
|---|
 | 92 |     break;
 | 
|---|
 | 93 |   case 'a' :
 | 
|---|
 | 94 |     label_coord1 = optarg;
 | 
|---|
 | 95 |     break;
 | 
|---|
 | 96 |   case 'd' :
 | 
|---|
 | 97 |     label_coord2 = optarg;
 | 
|---|
 | 98 |     break;
 | 
|---|
 | 99 |   case 'b' :
 | 
|---|
 | 100 |     label_bolo_in = optarg;
 | 
|---|
 | 101 |     break;
 | 
|---|
 | 102 |   case 'n' :
 | 
|---|
 | 103 |     label_bolo_out = optarg;
 | 
|---|
 | 104 |     break;
 | 
|---|
 | 105 |   case 'u' :
 | 
|---|
 | 106 |     label_utc = optarg;
 | 
|---|
 | 107 |     break;
 | 
|---|
 | 108 |   case 'l' :
 | 
|---|
 | 109 |     label_lon = optarg;
 | 
|---|
 | 110 |     break;
 | 
|---|
 | 111 |   case 'L' :
 | 
|---|
 | 112 |     label_lat = optarg;
 | 
|---|
 | 113 |     break;
 | 
|---|
 | 114 |   case 'i' :
 | 
|---|
 | 115 |     tcoorin=optarg;
 | 
|---|
 | 116 |     break;
 | 
|---|
 | 117 |   case 'o' :
 | 
|---|
 | 118 |     tcoormap=optarg;
 | 
|---|
 | 119 |     break;
 | 
|---|
 | 120 |   case 'e' :
 | 
|---|
 | 121 |     sscanf(optarg,"%lf",&equi);
 | 
|---|
 | 122 |     break;
 | 
|---|
 | 123 |   case 'm' :
 | 
|---|
 | 124 |     sscanf(optarg,"%lf",&vmin);
 | 
|---|
 | 125 |     tmin = true;
 | 
|---|
 | 126 |     break;
 | 
|---|
 | 127 |   case 'M' :
 | 
|---|
 | 128 |     sscanf(optarg,"%lf",&vmax);
 | 
|---|
 | 129 |     tmax = true;
 | 
|---|
 | 130 |     break;
 | 
|---|
 | 131 |   case 'f' :
 | 
|---|
 | 132 |     sscanf(optarg,"%ul",&badflg);
 | 
|---|
 | 133 |     tflg = true;
 | 
|---|
 | 134 |     break;
 | 
|---|
 | 135 |   case 'h' :
 | 
|---|
 | 136 |   default:
 | 
|---|
 | 137 |     usage(); exit(1);
 | 
|---|
 | 138 |     break;
 | 
|---|
 | 139 |   }
 | 
|---|
 | 140 | }
 | 
|---|
 | 141 | if(optind+5>=narg) {usage(); exit(3);}
 | 
|---|
 | 142 |  
 | 
|---|
 | 143 | char * fitsin_point = arg[optind];
 | 
|---|
 | 144 | char * fitsin_bolo = arg[optind+1];
 | 
|---|
 | 145 | char * fitsin_utc = arg[optind+2];
 | 
|---|
 | 146 | char * fitsin_lon = arg[optind+3];
 | 
|---|
 | 147 | char * fitsin_lat = arg[optind+4];
 | 
|---|
| [2099] | 148 | char * fitsout = arg[optind+5];
 | 
|---|
| [2094] | 149 | 
 | 
|---|
 | 150 | cout<<">>>> tsttoi2toi_addsp:"<<endl
 | 
|---|
 | 151 |     <<"Pipe Window Size "<<width<<endl
 | 
|---|
 | 152 |     <<"Fits Infile Bolo "<<fitsin_bolo<<endl
 | 
|---|
| [2099] | 153 |     <<"  ...label_bolo_in "<<label_bolo_in<<endl
 | 
|---|
 | 154 |     <<"Fits Infile Utc "<<fitsin_utc<<endl
 | 
|---|
 | 155 |     <<"  ...label_utc "<<label_utc<<endl
 | 
|---|
 | 156 |     <<"Fits Infile Lon "<<fitsin_lon<<endl
 | 
|---|
 | 157 |     <<"  ...label_lon "<<label_lon<<endl
 | 
|---|
 | 158 |     <<"Fits Infile Lat "<<fitsin_lat<<endl
 | 
|---|
 | 159 |     <<"  ...label_lat "<<label_lat<<endl;
 | 
|---|
| [2094] | 160 | cout<<"Fits Infile Pointing "<<fitsin_point<<endl
 | 
|---|
 | 161 |     <<"  ...label_coord1 "<<label_coord1<<endl
 | 
|---|
 | 162 |     <<"  ...label_coord2 "<<label_coord2<<endl
 | 
|---|
 | 163 |     <<"  ...... ctype="<<tcoorin<<endl;
 | 
|---|
| [2099] | 164 | cout<<"Fits Outfile Bolo "<<fitsout<<endl
 | 
|---|
| [2094] | 165 |     <<"  ...label_bolo_out "<<label_bolo_out<<endl;
 | 
|---|
 | 166 | 
 | 
|---|
 | 167 | SophyaInit();
 | 
|---|
 | 168 | InitTim();
 | 
|---|
 | 169 | 
 | 
|---|
 | 170 | //--------------------------------------------------------------------
 | 
|---|
 | 171 | try {
 | 
|---|
 | 172 | //--------------------------------------------------------------------
 | 
|---|
| [2102] | 173 |   cout << wsize << " ok ! " << endl;
 | 
|---|
 | 174 |   
 | 
|---|
| [2099] | 175 |   CGT plombier(fgsegmented,wsize);
 | 
|---|
 | 176 |   plombier.SetDebugLevel(99);
 | 
|---|
| [2094] | 177 |   
 | 
|---|
 | 178 |  // FITS reader
 | 
|---|
| [2102] | 179 |   FITSTOIReader rfitsb(fitsin_bolo);
 | 
|---|
 | 180 |   FITSTOIReader rfitsp(fitsin_point);
 | 
|---|
 | 181 |   FITSTOIReader rfitsu(fitsin_utc);
 | 
|---|
 | 182 |   FITSTOIReader rfitsl(fitsin_lon);
 | 
|---|
 | 183 |   FITSTOIReader rfitsL(fitsin_lat);
 | 
|---|
 | 184 |   FITSTOIWriter wfits(fitsout);
 | 
|---|
| [2099] | 185 |  
 | 
|---|
| [2094] | 186 |  // TOI Processor
 | 
|---|
| [2104] | 187 | //   Toi2toi_Addsp toi2t_sp(ns);
 | 
|---|
| [2102] | 188 | //   cout<<"Toi2toi_Addsp created"<<endl;
 | 
|---|
| [2099] | 189 | 
 | 
|---|
| [2102] | 190 | //   toi2t_sp.SetEquinox(equi);
 | 
|---|
 | 191 | //   toi2t_sp.SetCoorIn(tcoorin);
 | 
|---|
 | 192 | //   toi2t_sp.SetCoorMap(tcoormap);
 | 
|---|
 | 193 | //   toi2t_sp.SetTestFlag(tflg,badflg);
 | 
|---|
 | 194 | //   toi2t_sp.SetTestMin(tmin,vmin);
 | 
|---|
 | 195 | //   toi2t_sp.SetTestMax(tmax,vmax);
 | 
|---|
 | 196 | //   toi2t_sp.Print(cout);
 | 
|---|
| [2094] | 197 | 
 | 
|---|
 | 198 |  // Definition des tuyaux
 | 
|---|
| [2099] | 199 |  
 | 
|---|
 | 200 |  // pb dans  prout.addOutput(out, toi);
 | 
|---|
| [2102] | 201 |  cout << " tout va bien " <<label_coord2 << endl;
 | 
|---|
 | 202 | 
 | 
|---|
 | 203 |  plombier.Connect(rfitsp,label_coord1,wfits,label_bolo_out);
 | 
|---|
 | 204 | 
 | 
|---|
| [2099] | 205 |  //pb dans chkinit(); dans  afterinit()
 | 
|---|
| [2102] | 206 | //   plombier.Connect(rfitsp,label_coord2,toi2t_sp,"Coord2In");
 | 
|---|
 | 207 | //   plombier.Connect(rfitsp,label_coord1,toi2t_sp,"Coord1In");
 | 
|---|
| [2099] | 208 | 
 | 
|---|
| [2102] | 209 | //   plombier.Connect(rfitsb,label_bolo_in,toi2t_sp,"BoloIn");
 | 
|---|
| [2094] | 210 | 
 | 
|---|
| [2102] | 211 | //   plombier.Connect(rfitsu,label_utc,toi2t_sp,"utc");
 | 
|---|
 | 212 | //   plombier.Connect(rfitsl,label_lon,toi2t_sp,"lon");
 | 
|---|
 | 213 | //   plombier.Connect(rfitsL,label_lat,toi2t_sp,"lat");
 | 
|---|
| [2094] | 214 | 
 | 
|---|
| [2102] | 215 | //   plombier.Connect(toi2t_sp,"BoloOut",wfits,label_bolo_out);
 | 
|---|
 | 216 |  // plombier.Connect(rfitsp,label_coord1,wfits,label_bolo_out);
 | 
|---|
 | 217 |  cout << " tout va bien " <<label_coord2 << endl;
 | 
|---|
| [2094] | 218 | 
 | 
|---|
 | 219 |  // Run
 | 
|---|
 | 220 |  cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
 | 
|---|
 | 221 | 
 | 
|---|
 | 222 |  plombier.Start();
 | 
|---|
 | 223 |  plombier.ListTOIs(cout, 1);
 | 
|---|
 | 224 |  cout << "Joining ..." << endl;
 | 
|---|
 | 225 |  mgr->joinAll();
 | 
|---|
 | 226 |  PrtTim("End threads");
 | 
|---|
 | 227 | 
 | 
|---|
 | 228 | 
 | 
|---|
 | 229 | 
 | 
|---|
 | 230 | //--------------------------------------------------------------------
 | 
|---|
 | 231 | } catch (PThrowable & exc) {
 | 
|---|
 | 232 |  cout<<"\ntsttoi2toi_addsp: Catched Exception \n"<<(string)typeid(exc).name() 
 | 
|---|
 | 233 |      <<" - Msg= "<<exc.Msg()<<endl;
 | 
|---|
 | 234 | } catch (const std::exception & sex) {
 | 
|---|
 | 235 |  cout<<"\ntsttoi2toi_addsp: Catched std::exception \n" 
 | 
|---|
 | 236 |      <<(string)typeid(sex).name()<<endl; 
 | 
|---|
 | 237 | } catch (...) {
 | 
|---|
 | 238 |  cout<<"\ntsttoi2toi_addsp: some other exception was caught ! "<<endl;
 | 
|---|
 | 239 | }
 | 
|---|
 | 240 | //--------------------------------------------------------------------
 | 
|---|
 | 241 | 
 | 
|---|
 | 242 | exit(0);
 | 
|---|
 | 243 | }
 | 
|---|
| [2099] | 244 | 
 | 
|---|