source: Sophya/trunk/AddOn/TAcq/brparam.cc@ 3671

Last change on this file since 3671 was 3671, checked in by ansari, 16 years ago
  • Nettoyage complet des programmes d'acquisition
  • Ajout methode BRPaquet::CopyFrom() pour reduction de paquet
  • Introduction des classes BRParList , BRConfList , BRAcqConfig
  • Introduction du nouveau programme acquisition mfacq.cc (MultiFibresAcq)

Reza, 13/11/2009

File size: 7.3 KB
RevLine 
[3671]1#include "brparam.h"
2#include "strutilxx.h"
3#include "bracqvers.h"
4
5
6// Classe qui memorise tous les parametres importants de l'acquisition
7
8/* --Methode-- */
9BRParList::BRParList(string fibres,unsigned int paqsz ,unsigned int nframeDMA,
10 int nfiles, string acqmod,int nblocfile,int nmxproc ,
11 string outpath, uint_4 nzon , uint_4 npaqzon, bool fgcntlc)
12{
13 FiberListS=fibres;
14 NbFibers=0;
15 for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=0;
16 PaqSize=paqsz;
17 nbFrameDMA=nframeDMA;
18 NbFiles=nfiles;
19 AcqMode=acqmod;
20 NBlocPerFile=nblocfile;
21 NMaxProc=nmxproc;
22 OutPathName=outpath;
23 nZones=nzon;
24 nPaqZone=npaqzon;
25 swapall=BR_Copy;
26 savesigfits=true;
27 fgnulldev4fits=false;
28 fg_hard_ctrlc=fgcntlc;
29 fgnulldev4fits = (OutPathName == "/dev/null") ? true : false;
30
31 fgreducpsize=false;
32 redpqsize=PaqSize;
33 reducoffset=0;
34
35 monothr=false;
36 activate_pattern=false;
37
38 Decode(); // On decode et on complete les parametres
39}
40
41/* --Methode-- */
42BRParList::BRParList(BRParList const & p)
43{
44 Set(p);
45}
46
47/* --Methode-- */
48void BRParList::Set(BRParList const & p)
49{
50 FiberListS=p.FiberListS;
51 NbFibers=p.NbFibers;
52 for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=p.FiberNum[fib];
53 PaqSize=p.PaqSize;
54 nbFrameDMA=p.nbFrameDMA;
55 NbFiles=p.NbFiles;
56 AcqMode=p.AcqMode;
57 NBlocPerFile=p.NBlocPerFile;
58 NMaxProc=p.NMaxProc;
59 OutPathName=p.OutPathName;
60 nZones=p.nZones;
61 nPaqZone=p.nPaqZone;
62 swapall=p.swapall;
63 savesigfits=p.savesigfits;
64 fgnulldev4fits=p.fgnulldev4fits;
65 fg_hard_ctrlc=p.fg_hard_ctrlc;
66 fgnulldev4fits=p.fgnulldev4fits;
67
68 fgreducpsize=p.fgreducpsize;
69 redpqsize=p.redpqsize;
70 reducoffset=p.reducoffset;
71
72 monothr=p.monothr;
73 activate_pattern=p.activate_pattern;
74 return;
75}
76
77/* --Methode-- */
78void BRParList::ReadDCFile(string file)
79{
80 DataCards conf(file);
81 FiberListS= conf.SParam("Fibres",0,"1");
82 PaqSize=(unsigned int)conf.IParam("PaqSZ",0,16424);
83 nbFrameDMA =(unsigned int) conf.IParam("nbFrameDma",0,32);
84 NbFiles=conf.IParam("NbFiles",0,1);
85 NBlocPerFile=conf.IParam("NBlocPerFile",0,10);
86 NMaxProc=conf.IParam("NMaxProc",0,0);
87 OutPathName= conf.SParam("OutPathName",0,"TstAcq");
88 AcqMode =conf.SParam("acqmode",0,"std");
89 nZones=(unsigned int)conf.IParam("nZones",0,4);
90 nPaqZone=(uint_4)conf.IParam("nPaqZone",0,128);
91 fg_hard_ctrlc=conf.HasKey("fg_hard_ctrlc");
92
93 Decode();
94}
95
96/* --Methode-- */
97void BRParList::Decode()
98{
99 vector<string> fiblist;
100 FillVStringFrString(FiberListS, fiblist, ',');
101 NbFibers=fiblist.size();
102 for (int fib=0; fib<fiblist.size(); fib++) {
103 FiberNum[fib]=atoi(fiblist[fib].c_str());
104 }
105 string acqmode = AcqMode;
106 if (acqmode == "std") swapall = BR_Copy ;
107 if (acqmode == "nosw") swapall = BR_Copy ;
108 if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
109 if (acqmode == "fft1c") swapall = BR_FFTOneChan;
110 if (acqmode == "fft2c") swapall = BR_FFTTwoChan;
111 if (acqmode == "fft1cnof") { swapall = BR_FFTOneChan; savesigfits = false; }
112 if (acqmode == "fft2cnof") { swapall = BR_FFTTwoChan; savesigfits = false; }
113 if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
114 if (acqmode == "monodirect") { monothr = true; swapall = BR_CopyHDR;}
115 if (acqmode == "patmonodirect") { monothr = true; swapall = BR_CopyHDR; activate_pattern=true; }
116 if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
117 if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
118 if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
119
120 if (acqmode == "swapall") swapall = BR_SwapAll;
121 if (acqmode == "fft1csw") swapall = BR_FFTOneChanSwapAll;
122 if (acqmode == "fft2csw") swapall = BR_FFTTwoChanSwapAll;
123 if (acqmode == "fft1cswnof") { swapall = BR_FFTOneChanSwapAll; savesigfits = false; }
124 if (acqmode == "fft2cswnof") { swapall = BR_FFTTwoChanSwapAll; savesigfits = false; }
125 if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
126 if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
127 if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
128 if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
129
130 if (acqmode == "swap32") swapall = BR_Swap32 ;
131 if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
132 if (acqmode == "fft1c32") swapall = BR_FFTOneChanSwap32;
133 if (acqmode == "fft2c32") swapall = BR_FFTTwoChanSwap32;
134 if (acqmode == "fft1cnof32") { swapall = BR_FFTOneChanSwap32; savesigfits = false; }
135 if (acqmode == "fft2cnof32") { swapall = BR_FFTTwoChanSwap32; savesigfits = false; }
136}
137
138/* --Methode-- */
139ostream& BRParList::Print(ostream& os)
140{
141 os << " ------ BRParList::Print() ----- " << endl;
142 os << " FiberListS=" << FiberListS ;
143 os << " PaqSize=" <<PaqSize;
144 os << " nbFrameDMA=" <<nbFrameDMA << endl;
145 os << " AcqMode="<<AcqMode;
146 os << " Type of acquisition :" << BRPaquet::FmtConvToString( swapall) << endl;
147 os << " NbFiles="<<NbFiles;
148 os << " NBlocPerFile="<<NBlocPerFile;
149 os << " OutPathName="<<OutPathName << endl;
150 os << " MemMgr: nZones="<<nZones;
151 os << " nPaqZone="<<nPaqZone;
152 os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false");
153 os << " Save to fits " << ((savesigfits)?"true":"false") << endl;
154 os << " monothr y(1)/n(0) " << ((monothr)?"true":"false");
155 os << " ActivatePattern " << ((activate_pattern)?"true":"false") << endl;
156
157 return os;
158}
159
160
161BRParList* BRAcqConfig::param_=NULL;
162
163/* --Methode-- */
164BRAcqConfig::BRAcqConfig()
165{
166 if (param_==NULL) param_ = new BRParList;
167}
168
169/* --Methode-- */
170int BRAcqConfig::CreateOutputDirectories()
171{
172 char cmd[512];
173 if (param_->fgnulldev4fits!=true) {
174 sprintf(cmd,"mkdir %s",param_->OutPathName.c_str());
175 if (system(cmd) < 0) {
176 cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
177 << param_->OutPathName << " -> stop" << endl;
178 return 2;
179 }
180 cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
181
182 memset(cmd,0,512);
183 for (int i= 0; i< NFibers() ; i++) {
184 sprintf(cmd,"mkdir %s/Fibre%d",param_->OutPathName.c_str(),param_->FiberNum[i]);
185 if (system(cmd) < 0) {
186 cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
187 << param_->OutPathName << "/FiberII -> stop" << endl;
188 return 3;
189 }
190 else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
191 }
192 }
193 else {
194 string ProcPathName = "./XZXZXZX/";
195 cout << " Using " << ProcPathName << " for other processed files ... " << endl;
196 char cmd[512];
197 sprintf(cmd,"mkdir %s",ProcPathName.c_str());
198 if (system(cmd) < 0) {
199 cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/"
200 << "-> stop" << endl;
201 return 3;
202 }
203 else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
204
205 sprintf(cmd,"mkdir %s/Fibre1 %s/Fibre2",ProcPathName.c_str(),ProcPathName.c_str());
206 if (system(cmd) < 0) {
207 cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/Fibre1,2"
208 << "-> stop" << endl;
209 return 4;
210 }
211 }
212 return 0;
213}
214
215/* --Methode-- */
216string BRAcqConfig::OutputDirectoryFib(int ifib)
217{
218 char buff[24];
219 sprintf(buff,"/Fiber%d",param_->FiberNum[ifib]);
220 return ( param_->OutPathName + buff );
221}
Note: See TracBrowser for help on using the repository browser.