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

Last change on this file since 3639 was 3639, checked in by cmv, 16 years ago

ajout des #include C pour compil sur dernieres versions gcc/g++, cmv 27/05/2009

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