Changeset 3645 in Sophya for trunk/AddOn/TAcq/mcrd.cc
- Timestamp:
- Jun 1, 2009, 10:24:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/mcrd.cc
r3640 r3645 39 39 #include "brfitsrd.h" 40 40 #include "brproc.h" 41 #include "racqurw.h" 41 42 42 43 … … 53 54 } 54 55 56 //-- Parametres globaux 57 static int NZones=4; 58 static int NPaqinZone=128; 59 static int NMean=1024; 60 static int NGenZ=100; 61 static int GPaqSz=16424; 62 static double LossRate=0.1; 63 // ---- 64 int Usage(bool fgshort=true); 65 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW) 66 int Proc1FRawA(string& outname, string& inpath, int jf1, int jf2, bool fgnotrl=false, 67 bool fgrdfile=true); 68 // Pour traitement (calcul FFT et visibilites (ProcA,ProcB) 2 fibre, 4 voies RAW) 69 int Proc2FRawAB(string& outname, string& path1, string& path2, int jf1, int jf2, 70 bool fgnotrl=false, bool fgrdfile=true); 71 55 72 //---------------------------------------------------- 56 73 //---------------------------------------------------- 57 74 int main(int narg, char* arg[]) 58 75 { 59 if (narg < 4) { 60 cout << " --- Reading/Processing BAORadio FITS files" << endl; 61 cout << " Usage: mcrd ACT OutPPF -infits DirName Imin Imax [NZones,NbPaqinZone] " << endl; 62 cout << " ACT= notrl FITS files without frame trailer \n" 63 << " OutPPF : Output PPF file name (without .ppf)" << endl; 64 cout << " -infiles DirName Imin Imax : Input fits directory and sequence numbers \n" 65 << " FileNames=DirName/signalII.fits Imin<=II<=Imax \n" 66 << " - NZones,NbPaqinZone : Number of Zones and number of paquets in one zone\n" 67 << " of the RAcqMemZoneMgr memory manager (default = 4,128) " << endl; 68 return 1; 69 } 76 if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false); 77 if (narg<5) return Usage(true); 70 78 71 79 TArrayInitiator _inia; … … 74 82 try { 75 83 string act = arg[1]; 76 string outname = arg[2]; 77 vector<string> infiles; 78 if ((strcmp(arg[3],"-infits")!=0) || (narg<7)) { 79 cout << " mcrd/Error arguments - type mcrd for help" << endl; 80 return 2; 81 } 82 char nbuff[1024]; 83 char* dirname = arg[4]; 84 int imin = atoi(arg[5]); 85 int imax = atoi(arg[6]); 86 for(int ii=imin; ii<=imax; ii++) { 87 sprintf(nbuff,"%s/signal%d.fits",dirname,ii); 88 infiles.push_back(nbuff); 89 } 90 int nzones = 4; 91 int npaqz = 128; 92 if (narg>7) sscanf(arg[7],"%d,%d",&nzones,&npaqz); 84 bool fg4c=false; // true -> 4 channels (2 fibers) 85 bool fgrdfits=false; // false -> Don't read fits files, generate paquets 86 bool fgnotrl=false; // true -> fichier fits SANS Trailer de frame (< mai 2009) 87 if (act.substr(0,2)=="-4") fg4c=true; 88 if (act.substr(2)=="g") fgrdfits=false; 89 else if (act.substr(2)=="nt") fgnotrl=true; 90 if (fg4c && (narg<6)) return Usage(true); 91 92 string outname = arg[2]; 93 string inpath2; 94 string inpath = arg[3]; 95 int offa=4; 96 if(fg4c) { 97 inpath2=arg[4]; offa=5; 98 } 99 int imin=0; 100 int imax=0; 101 sscanf(arg[offa],"%d,%d",&imin,&imax); 102 if (narg>offa+1) sscanf(arg[offa+1],"%d,%d",&NZones,&NPaqinZone); 103 if (narg>offa+2) NMean=atoi(arg[offa+2]); 104 if (narg>offa+3) sscanf(arg[offa+3],"%d,%d,%lg",&GPaqSz,&NGenZ,&LossRate); 93 105 94 106 cout << " ---------- mcrd.cc Start - ACT= " << act << " ------------- " << endl; 95 107 ResourceUsage resu; 96 bool fgnotrl=false; // fichier fits avec Trailer de frame (> mai 2009) 97 if (act=="notrl") fgnotrl=true; // fichier fits SANS trailer 98 99 uint_4 paqsz, npaqf; 100 DecodeMiniFitsHeader(infiles[0],paqsz, npaqf, fgnotrl); 101 102 cout << " mcrd: NZones=" << nzones << " NbPaq=" << npaqz << "(in file=" << npaqf 103 << " ) PaqSz=" << paqsz << endl; 104 105 RAcqMemZoneMgr mmgr(nzones, npaqz, paqsz, sizeof(complex<r_4>)*paqsz); 106 mmgr.SetFinalizedMask((uint_4)MemZS_ProcA); 107 108 BRFitsReader reader(mmgr, infiles, fgnotrl); 109 BRProcARaw2C proc(mmgr, outname, npaqf, 1, npaqf*infiles.size()/npaqz); 110 111 cout << " mcrd.cc : Starting threads (reader, proc) ... " << endl; 112 reader.start(); 113 proc.start(); 114 sleep(1); 115 cout << " mcrd.cc : Waiting for reader thread to finish ... " << endl; 116 reader.join(); 117 cout << " mcrd.cc : Reader finished, waiting for process thread to finish ... " << endl; 118 sleep(2); 119 mmgr.Stop(); 120 proc.join(); 121 mmgr.Print(cout); 108 if (fg4c) 109 rc = Proc2FRawAB(outname, inpath, inpath2, imin, imax, fgnotrl, fgrdfits); 110 else 111 rc = Proc1FRawA(outname, inpath, imin, imax, fgnotrl, fgrdfits); 122 112 cout << resu ; 123 113 } … … 137 127 } 138 128 139 cout << ">>>> mcrd.cc ------- FIN----------- RC=" << rc << endl;129 cout << ">>>> mcrd.cc ------- END ----------- RC=" << rc << endl; 140 130 return rc; 141 131 142 132 } 133 134 135 136 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW) 137 int Proc1FRawA(string& outname, string& inpath, int imin, int imax, 138 bool fgnotrl, bool fgrdfile) 139 { 140 vector<string> infiles; 141 char nbuff[1024]; 142 for(int ii=imin; ii<=imax; ii++) { 143 sprintf(nbuff,"%s/signal%d.fits",inpath.c_str(),ii); 144 infiles.push_back(nbuff); 145 } 146 uint_4 nmaxz; 147 uint_4 paqsz, npaqf; 148 if (fgrdfile) { 149 DecodeMiniFitsHeader(infiles[0],paqsz, npaqf, fgnotrl); 150 nmaxz = infiles.size()*npaqf/NPaqinZone; 151 cout << " mcrd/Proc1FRawA/ReadFits: NZones=" << NZones << " NbPaq=" << NPaqinZone 152 << " NPaq in file=" << npaqf 153 << " PaqSz=" << paqsz << " NMaxZ=" << nmaxz << " NMean=" << NMean << endl; 154 } 155 else { 156 paqsz = GPaqSz; 157 nmaxz = NGenZ; 158 cout << " mcrd/Proc1FRawA/GeneratePaquets: NZones=" << NZones << " NbPaq=" << NPaqinZone 159 << " PaqSz=" << paqsz << " NMean=" << NMean << endl; 160 } 161 RAcqMemZoneMgr mmgr(NZones, NPaqinZone, paqsz, sizeof(complex<r_4>)*paqsz); 162 mmgr.SetFinalizedMask((uint_4)MemZS_ProcA); 163 164 BRFitsReader reader(mmgr, infiles, fgnotrl); 165 TestPCIWrapperNODMA pciw(paqsz,LossRate); 166 PCIEReader pcird(pciw, paqsz, paqsz, mmgr, nmaxz, BR_Copy); 167 168 outname += "/Ch12"; 169 BRProcARaw2C proc(mmgr, outname, NMean, nmaxz, fgnotrl); 170 171 cout << " mcrd/Proc1FRawA: Starting threads (reader, proc) ... " << endl; 172 173 if (fgrdfile) reader.start(); 174 else pcird.start(); 175 176 proc.start(); 177 sleep(1); 178 cout << " mcrd/Proc1FRawA: Waiting for reader thread to finish ... " << endl; 179 if (fgrdfile) reader.join(); 180 else pcird.join(); 181 cout << " mcrd/Proc1FRawA: Reader finished, waiting for process thread to finish ... " << endl; 182 sleep(2); 183 mmgr.Stop(); 184 proc.join(); 185 mmgr.Print(cout); 186 return 0; 187 } 188 189 190 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW) 191 int Proc2FRawAB(string& outname, string& path1, string& path2, int imin, int imax, 192 bool fgnotrl, bool fgrdfile) 193 { 194 vector<string> infiles1; 195 vector<string> infiles2; 196 char nbuff[1024]; 197 for(int ii=imin; ii<=imax; ii++) { 198 sprintf(nbuff,"%s/signal%d.fits",path1.c_str(),ii); 199 infiles1.push_back(nbuff); 200 sprintf(nbuff,"%s/signal%d.fits",path2.c_str(),ii); 201 infiles2.push_back(nbuff); 202 } 203 uint_4 nmaxz; 204 uint_4 paqsz, npaqf; 205 if (fgrdfile) { 206 DecodeMiniFitsHeader(infiles1[0],paqsz, npaqf, fgnotrl); 207 nmaxz = infiles1.size()*npaqf/NPaqinZone; 208 cout << " mcrd/Proc2FRawAB/ReadFits: NZones=" << NZones << " NbPaq=" << NPaqinZone 209 << " NPaq in file=" << npaqf 210 << " PaqSz=" << paqsz << " NMaxZ=" << nmaxz << " NMean=" << NMean << endl; 211 } 212 else { 213 paqsz = GPaqSz; 214 nmaxz = NGenZ; 215 cout << " mcrd/Proc2FRawAB/GeneratePaquets: NZones=" << NZones << " NbPaq=" << NPaqinZone 216 << " PaqSz=" << paqsz << " NMean=" << NMean << endl; 217 } 218 RAcqMemZoneMgr mmgr1(NZones, NPaqinZone, paqsz, sizeof(complex<r_4>)*paqsz); 219 mmgr1.SetFinalizedMask((uint_4)(MemZS_ProcA)|(uint_4)(MemZS_ProcB)); 220 // mmgr1.SetFinalizedMask((uint_4)(MemZS_ProcA)); 221 RAcqMemZoneMgr mmgr2(NZones, NPaqinZone, paqsz, sizeof(complex<r_4>)*paqsz); 222 mmgr2.SetFinalizedMask((uint_4)(MemZS_ProcA)|(uint_4)(MemZS_ProcB)); 223 // mmgr2.SetFinalizedMask((uint_4)(MemZS_ProcA)); 224 225 BRFitsReader reader1(mmgr1, infiles1, fgnotrl); 226 BRFitsReader reader2(mmgr1, infiles2, fgnotrl); 227 228 TestPCIWrapperNODMA pciw1(paqsz,LossRate); 229 PCIEReader pcird1(pciw1, paqsz, paqsz, mmgr1, nmaxz, BR_Copy); 230 TestPCIWrapperNODMA pciw2(paqsz,LossRate); 231 PCIEReader pcird2(pciw2, paqsz, paqsz, mmgr2, nmaxz, BR_Copy); 232 233 string outname1 = outname; 234 outname1 += "/Ch12"; 235 BRProcARaw2C proc1(mmgr1, outname1, NMean, nmaxz, fgnotrl); 236 string outname2 = outname; 237 outname2 += "/Ch34"; 238 BRProcARaw2C proc2(mmgr2, outname2, NMean, nmaxz, fgnotrl,2); 239 string outname12 = outname; 240 outname12 += "/Ch1234"; 241 BRProcBRaw4C proc12(mmgr1, mmgr2, outname12, NMean, nmaxz, fgnotrl); 242 243 cout << " mcrd/Proc2FRawAB: Starting threads (reader1,2, procA1,2, procAB) ... " << endl; 244 245 if (fgrdfile) { 246 reader1.start(); 247 reader2.start(); 248 } 249 else { 250 pcird1.start(); 251 pcird2.start(); 252 } 253 proc1.start(); 254 proc2.start(); 255 proc12.start(); 256 257 sleep(1); 258 cout << " mcrd/Proc2FRawAB: Waiting for reader threads to finish ... " << endl; 259 if (fgrdfile) { 260 reader1.join(); 261 reader2.join(); 262 } 263 else { 264 pcird1.join(); 265 pcird2.join(); 266 } 267 cout << " mcrd/Proc2FRawAB: Readers finished, waiting for process thread to finish ... " << endl; 268 sleep(2); 269 mmgr1.Stop(); 270 mmgr2.Stop(); 271 proc1.join(); 272 proc2.join(); 273 proc12.join(); 274 mmgr1.Print(cout); 275 mmgr2.Print(cout); 276 return 0; 277 } 278 279 280 /* --Fonction-- */ 281 int Usage(bool fgshort) 282 { 283 cout << " --- mcrd.cc : Reading/Processing BAORadio FITS files" << endl; 284 cout << " Usage: mcrd ACT OutPath InPath [InPath2] Imin,Imax\n" 285 << " [NZones,NPaqinZone] [NMean] [GPaqSz,NGenZones,LossRate]" << endl; 286 if (fgshort) { 287 cout << " mcrd -h for detailed instructions" << endl; 288 return 1; 289 } 290 cout << " ACT= -2 , -2g , -2nt -> 1 fiber, 2 raw channel processing (ProcA)\n" 291 << " ACT= -4 , -4g , -4g , -4nt -> 2 fibers, 4 raw channels (ProcA, ProcB)\n" 292 << " nt (notrl) -> FITS files without frame trailer \n" 293 << " g (generate paquets) -> generate paquets instead of reading fits files" <<endl; 294 cout << " OutPath : Output directory name " << endl; 295 cout << " InPath [InPath2] Imin,Imax: Input fits files directory name(s)\n" 296 << " (Inpath=Fiber1, InPath2=Fiber2) and sequence numbers \n" 297 << " FileNames=InPath/signalII.fits Imin<=II<=Imax \n" 298 << " NZones,NbPaqinZone : Number of Zones and number of paquets in one zone\n" 299 << " of the RAcqMemZoneMgr memory manager (default = 4,128)\n" 300 << " NMean: Number of packet used for spectra/visibility computation (def=1024)\n" 301 << " GPaqSz,NGenZones,LossRate: Paquet Size, Number of memory zones filled and\n" 302 << " loss rate (-2g,-4g) , default=16424,100,0.1" << endl; 303 return 1; 304 }
Note:
See TracChangeset
for help on using the changeset viewer.