source: Sophya/trunk/AddOn/TAcq/mcrd.cc@ 3635

Last change on this file since 3635 was 3635, checked in by ansari, 16 years ago

Amelioration/ correction diverses, introduction du programme de lecture / traitement multi-thread mcrd.cc - Reza 26/05/2009

File size: 3.8 KB
Line 
1// Utilisation de SOPHYA pour faciliter les tests ...
2#include "sopnamsp.h"
3#include "machdefs.h"
4
5/* ----------------------------------------------------------
6 Programme de lecture multi canaux pour BAORadio
7 R. Ansari, C. Magneville
8 V : Mai 2009
9 ---------------------------------------------------------- */
10
11// include standard c/c++
12#include <math.h>
13#include <stdio.h>
14
15#include <iostream>
16#include <string>
17
18#include "pexceptions.h"
19#include "tvector.h"
20#include "fioarr.h"
21#include "tarrinit.h"
22#include "timestamp.h"
23#include "fftpserver.h"
24#include "fftwserver.h"
25
26#include "FFTW/fftw3.h"
27
28// include sophya mesure ressource CPU/memoire ...
29#include "resusage.h"
30#include "ctimer.h"
31#include "timing.h"
32
33
34// include mini-fits lib , et structure paquet BAORadio
35#include "minifits.h"
36#include "brpaqu.h"
37#include "brfitsrd.h"
38#include "brproc.h"
39
40
41//--- Fonctions de ce fichier
42int DecodeMiniFitsHeader(string& filename, uint_4& paqsz, uint_4& npaq, bool fgnotrl=false)
43{
44 MiniFITSFile mff(filename, MF_Read);
45 cout << "DecodeMiniFitsHeader()... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1()
46 << " NAxis2=" << mff.NAxis2() << endl;
47 paqsz = mff.NAxis1();
48 npaq = mff.NAxis2();
49 if (fgnotrl) paqsz += 16;
50 return 0;
51}
52
53//----------------------------------------------------
54//----------------------------------------------------
55int main(int narg, char* arg[])
56{
57 if (narg < 4) {
58 cout << " --- Reading/Processing BAORadio FITS files" << endl;
59 cout << " Usage: mcrd ACT OutPPF -infits DirName Imin Imax " << endl;
60 cout << " ACT= notrl FITS files without frame trailer \n"
61 << " OutPPF : Output PPF file name (without .ppf)" << endl;
62 cout << " -infiles DirName Imin Imax : Input fits directory and sequence numbers \n"
63 << " FileNames=DirName/signalII.fits Imin<=II<=Imax " << endl;
64 return 1;
65 }
66
67 TArrayInitiator _inia;
68
69 int rc = 0;
70 try {
71 string act = arg[1];
72 string outname = arg[2];
73 vector<string> infiles;
74 if ((strcmp(arg[3],"-infits")!=0) || (narg<7)) {
75 cout << " mcrd/Error arguments - type mcrd for help" << endl;
76 return 2;
77 }
78 char nbuff[1024];
79 char* dirname = arg[4];
80 int imin = atoi(arg[5]);
81 int imax = atoi(arg[6]);
82 for(int ii=imin; ii<=imax; ii++) {
83 sprintf(nbuff,"%s/signal%d.fits",dirname,ii);
84 infiles.push_back(nbuff);
85 }
86
87 cout << " ---------- mcrd.cc Start - ACT= " << act << " ------------- " << endl;
88 ResourceUsage resu;
89 bool fgnotrl=false; // fichier fits avec Trailer de frame (> mai 2009)
90 if (act=="notrl") fgnotrl=true; // fichier fits SANS trailer
91
92 uint_4 paqsz, npaq;
93 DecodeMiniFitsHeader(infiles[0],paqsz, npaq, fgnotrl);
94
95 int nzones = 3;
96 RAcqMemZoneMgr mmgr(nzones, npaq, paqsz, sizeof(complex<r_4>)*paqsz);
97 mmgr.SetFinalizedMask((uint_4)MemZS_ProcA);
98
99 BRFitsReader reader(mmgr, infiles, fgnotrl);
100 BRProcARaw2C proc(mmgr, outname, npaq, 1, npaq*infiles.size());
101
102 cout << " mcrd.cc : Starting threads (reader, proc) ... " << endl;
103 reader.start();
104 proc.start();
105 sleep(1);
106 cout << " mcrd.cc : Waiting for reader thread to finish ... " << endl;
107 reader.join();
108 cout << " mcrd.cc : Reader finished, waiting for process thread to finish ... " << endl;
109 sleep(2);
110 mmgr.Stop();
111 proc.join();
112 mmgr.Print(cout);
113 cout << resu ;
114 }
115 catch (MiniFITSException& exc) {
116 cerr << " mcrd.cc catched MiniFITSException " << exc.Msg() << endl;
117 rc = 77;
118 }
119 catch (std::exception& sex) {
120 cerr << "\n mcrd.cc std::exception :"
121 << (string)typeid(sex).name() << "\n msg= "
122 << sex.what() << endl;
123 rc = 78;
124 }
125 catch (...) {
126 cerr << " mcrd.cc catched unknown (...) exception " << endl;
127 rc = 79;
128 }
129
130 cout << ">>>> mcrd.cc ------- FIN ----------- RC=" << rc << endl;
131 return rc;
132
133}
Note: See TracBrowser for help on using the repository browser.