1 | #include "brparam.h"
|
---|
2 | #include "strutilxx.h"
|
---|
3 | #include "bracqvers.h"
|
---|
4 |
|
---|
5 | /* --Methode-- */
|
---|
6 | ADCBoardDesc::ADCBoardDesc(int id, string sbid, string cyc_firmw, string str1_firmw, string str2_firmw)
|
---|
7 | : id_(id), sbid_(sbid), cyclone_firmware_(cyc_firmw), stratix1_firmware_(str1_firmw), stratix2_firmware_(str2_firmw)
|
---|
8 | {
|
---|
9 |
|
---|
10 | }
|
---|
11 |
|
---|
12 | /* --Methode-- */
|
---|
13 | ADCBoardDesc::ADCBoardDesc(ADCBoardDesc const& bdes)
|
---|
14 | : id_(bdes.id_), sbid_(bdes.sbid_), cyclone_firmware_(bdes.cyclone_firmware_),
|
---|
15 | stratix1_firmware_(bdes.stratix1_firmware_), stratix2_firmware_(bdes.stratix2_firmware_)
|
---|
16 | {
|
---|
17 | }
|
---|
18 |
|
---|
19 | /* --Methode-- */
|
---|
20 | ADCBoardDesc& ADCBoardDesc::Set(ADCBoardDesc const & bdes)
|
---|
21 | {
|
---|
22 | id_ = bdes.id_;
|
---|
23 | sbid_ = bdes.sbid_;
|
---|
24 | cyclone_firmware_ = bdes.cyclone_firmware_;
|
---|
25 | stratix1_firmware_ = bdes.stratix1_firmware_;
|
---|
26 | stratix2_firmware_ = bdes.stratix2_firmware_;
|
---|
27 | return(*this);
|
---|
28 | }
|
---|
29 |
|
---|
30 | /* --Methode-- */
|
---|
31 | ostream& ADCBoardDesc::Print(ostream& os)
|
---|
32 | {
|
---|
33 | os << "ADCBoard#" << id_ << "(" << sbid_ << ") Cyclone:" << cyclone_firmware_
|
---|
34 | << " Stratix1: " << stratix1_firmware_ << " Stratix2: " << stratix2_firmware_ << endl;
|
---|
35 | return os;
|
---|
36 | }
|
---|
37 |
|
---|
38 | /* --Methode-- */
|
---|
39 | BRConfList::BRConfList()
|
---|
40 | : basedir_("./")
|
---|
41 | {
|
---|
42 | }
|
---|
43 |
|
---|
44 | /* --Methode-- */
|
---|
45 | BRConfList::BRConfList(string basedir)
|
---|
46 | : basedir_(basedir)
|
---|
47 | {
|
---|
48 | }
|
---|
49 |
|
---|
50 | /* --Methode-- */
|
---|
51 | BRConfList::BRConfList(string basedir, vector<ADCBoardDesc> boards)
|
---|
52 | : basedir_(basedir), boards_(boards)
|
---|
53 | {
|
---|
54 | size_t len = basedir_.length();
|
---|
55 | if ((len>1)&&(basedir_[len-1]!='/')) basedir_ += '/';
|
---|
56 | }
|
---|
57 |
|
---|
58 | /* --Methode-- */
|
---|
59 | BRConfList::BRConfList(BRConfList const & cf)
|
---|
60 | : basedir_(cf.basedir_), boards_(cf.boards_)
|
---|
61 | {
|
---|
62 | }
|
---|
63 |
|
---|
64 | /* --Methode-- */
|
---|
65 | void BRConfList::SetBaseDirectory(string basedir)
|
---|
66 | {
|
---|
67 | basedir_=basedir;
|
---|
68 | size_t len = basedir_.length();
|
---|
69 | if ((len>1)&&(basedir_[len-1]!='/')) basedir_ += '/';
|
---|
70 | }
|
---|
71 |
|
---|
72 | /* --Methode-- */
|
---|
73 | void BRConfList::Set(BRConfList const & cf)
|
---|
74 | {
|
---|
75 | basedir_=cf.basedir_;
|
---|
76 | boards_=cf.boards_;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /* --Methode-- */
|
---|
80 | ostream& BRConfList::Print(ostream& os)
|
---|
81 | {
|
---|
82 | os << " ----- BRConfList:: BaseDir:" << basedir_ << " NBoards= " << boards_.size() << endl;
|
---|
83 | for(size_t k=0; k<boards_.size(); k++) boards_[k].Print(os);
|
---|
84 | return os;
|
---|
85 | }
|
---|
86 |
|
---|
87 | /* --Methode-- */
|
---|
88 | void BRConfList::ReadDCFile(string file)
|
---|
89 | {
|
---|
90 | // A FAIRE
|
---|
91 | }
|
---|
92 |
|
---|
93 | // Classe qui memorise tous les parametres importants de l'acquisition
|
---|
94 |
|
---|
95 | /* --Methode-- */
|
---|
96 | BRParList::BRParList(string acqmod, string fibres,unsigned int paqsz,
|
---|
97 | unsigned int dmaszkb, int nfiles, int nblocfile,
|
---|
98 | string outpath, uint_4 nzon , uint_4 npaqzon)
|
---|
99 | {
|
---|
100 | AcqMode=acqmod;
|
---|
101 | fgdatafft=false;
|
---|
102 | fgsinglechannel=false;
|
---|
103 |
|
---|
104 | FiberListS=fibres;
|
---|
105 | NbFibers=0;
|
---|
106 | for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=0;
|
---|
107 | PaqSize=paqsz;
|
---|
108 | dmasizekb=dmaszkb;
|
---|
109 |
|
---|
110 | NbFiles=nfiles;
|
---|
111 | NBlocPerFile=nblocfile;
|
---|
112 | OutPathName=outpath;
|
---|
113 |
|
---|
114 | nZones=nzon;
|
---|
115 | nPaqZone=npaqzon;
|
---|
116 |
|
---|
117 | swapall=BR_Copy;
|
---|
118 | savesigfits=true;
|
---|
119 | fgnulldev4fits=false;
|
---|
120 |
|
---|
121 | fg_hard_ctrlc=false;
|
---|
122 |
|
---|
123 | fgreducpsize=false;
|
---|
124 | reducneedcopy=false;
|
---|
125 | pqreducmode=BR_CopyRA;
|
---|
126 | redpqsize=PaqSize;
|
---|
127 | reducoffset=0;
|
---|
128 |
|
---|
129 | skysource="";
|
---|
130 |
|
---|
131 | fgdoProc=false;
|
---|
132 | nmeanProc=512;
|
---|
133 | stepProc=5;
|
---|
134 | nmaxProc=0;
|
---|
135 |
|
---|
136 | monothr=false;
|
---|
137 | activate_pattern=false;
|
---|
138 | nopciLossRate=0.;
|
---|
139 |
|
---|
140 | Decode(); // On decode et on complete les parametres
|
---|
141 | }
|
---|
142 |
|
---|
143 | /* --Methode-- */
|
---|
144 | BRParList::BRParList(BRParList const & p)
|
---|
145 | {
|
---|
146 | Set(p);
|
---|
147 | }
|
---|
148 |
|
---|
149 | /* --Methode-- */
|
---|
150 | void BRParList::Set(BRParList const & p)
|
---|
151 | {
|
---|
152 | AcqMode=p.AcqMode;
|
---|
153 | fgdatafft=p.fgdatafft;
|
---|
154 | fgsinglechannel=p.fgsinglechannel;
|
---|
155 |
|
---|
156 | FiberListS=p.FiberListS;
|
---|
157 | NbFibers=p.NbFibers;
|
---|
158 | for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=p.FiberNum[fib];
|
---|
159 |
|
---|
160 | PaqSize=p.PaqSize;
|
---|
161 | dmasizekb=p.dmasizekb;
|
---|
162 |
|
---|
163 | NbFiles=p.NbFiles;
|
---|
164 | NBlocPerFile=p.NBlocPerFile;
|
---|
165 | OutPathName=p.OutPathName;
|
---|
166 |
|
---|
167 | nZones=p.nZones;
|
---|
168 | nPaqZone=p.nPaqZone;
|
---|
169 |
|
---|
170 | swapall=p.swapall;
|
---|
171 | savesigfits=p.savesigfits;
|
---|
172 | fgnulldev4fits=p.fgnulldev4fits;
|
---|
173 | fg_hard_ctrlc=p.fg_hard_ctrlc;
|
---|
174 | fgnulldev4fits=p.fgnulldev4fits;
|
---|
175 |
|
---|
176 | fgreducpsize=p.fgreducpsize;
|
---|
177 | reducneedcopy=p.reducneedcopy;
|
---|
178 | pqreducmode=p.pqreducmode;
|
---|
179 | redpqsize=p.redpqsize;
|
---|
180 | reducoffset=p.reducoffset;
|
---|
181 |
|
---|
182 | skysource=p.skysource;
|
---|
183 |
|
---|
184 | fgdoProc=p.fgdoProc;
|
---|
185 | nmeanProc=p.nmeanProc;
|
---|
186 | stepProc=p.stepProc;
|
---|
187 | nmaxProc=p.nmaxProc;
|
---|
188 |
|
---|
189 | monothr=p.monothr;
|
---|
190 | activate_pattern=p.activate_pattern;
|
---|
191 |
|
---|
192 | nopciLossRate=p.nopciLossRate;
|
---|
193 | return;
|
---|
194 | }
|
---|
195 |
|
---|
196 | /* --Methode-- */
|
---|
197 | void BRParList::ReadDCFile(string file)
|
---|
198 | {
|
---|
199 | DataCards conf(file);
|
---|
200 | FiberListS= conf.SParam("fibres",0,"1");
|
---|
201 | OutPathName= conf.SParam("outpathname",0,"TstAcq");
|
---|
202 | skysource= conf.SParam("skysource",0,"");
|
---|
203 | PaqSize=(uint_4)conf.IParam("paqsize",0,16424);
|
---|
204 | dmasizekb =(uint_4) conf.IParam("dmasizekb",0,32);
|
---|
205 | NbFiles=conf.IParam("nbfiles",0,1);
|
---|
206 | NBlocPerFile=conf.IParam("nblocperfile",0,10);
|
---|
207 | AcqMode =conf.SParam("acqmode",0,"std");
|
---|
208 | nZones=(uint_4)conf.IParam("memmgr",0,4);
|
---|
209 | nPaqZone=(uint_4)conf.IParam("memmgr",1,128);
|
---|
210 | if (conf.HasKey("reducpaqsz")) { // reduction des tailles de paquets
|
---|
211 | fgreducpsize=true;
|
---|
212 | redpqsize=(uint_4)conf.IParam("reducpaqsz",0,PaqSize/4);
|
---|
213 | reducoffset=(uint_4)conf.IParam("reducpaqsz",1,0);
|
---|
214 | }
|
---|
215 | if (conf.HasKey("monitor")) {
|
---|
216 | fgdoProc=true;
|
---|
217 | nmeanProc=conf.IParam("monitor",0,512);
|
---|
218 | stepProc=conf.IParam("monitor",1,10);
|
---|
219 | nmaxProc=conf.IParam("monitor",2,0);
|
---|
220 | }
|
---|
221 | nopciLossRate=conf.DParam("nopcilossrate",0,0.);
|
---|
222 |
|
---|
223 | fg_hard_ctrlc=conf.HasKey("hard_ctrlc");
|
---|
224 | if (conf.HasKey("nosavesigfits")) savesigfits=false;
|
---|
225 | Decode();
|
---|
226 | }
|
---|
227 |
|
---|
228 | /* --Methode-- */
|
---|
229 | void BRParList::Decode()
|
---|
230 | {
|
---|
231 | vector<string> fiblist;
|
---|
232 | FillVStringFrString(FiberListS, fiblist, ',');
|
---|
233 | NbFibers=fiblist.size();
|
---|
234 | for (int fib=0; fib<fiblist.size(); fib++) {
|
---|
235 | FiberNum[fib]=atoi(fiblist[fib].c_str());
|
---|
236 | }
|
---|
237 | if (OutPathName == "/dev/null") {
|
---|
238 | fgnulldev4fits=true;
|
---|
239 | }
|
---|
240 | else {
|
---|
241 | size_t len = OutPathName.length();
|
---|
242 | if ((len>1)&&(OutPathName[len-1]!='/')) OutPathName+='/';
|
---|
243 | fgnulldev4fits=false;
|
---|
244 | }
|
---|
245 | string acqmode = AcqMode;
|
---|
246 | fgdatafft=false; fgsinglechannel=false;
|
---|
247 | reducneedcopy=false; pqreducmode=BR_TwoChanReduc;
|
---|
248 | if ((acqmode == "std")||(acqmode=="raw2c")) swapall = BR_Copy ;
|
---|
249 | if (acqmode == "nosw") swapall = BR_Copy ;
|
---|
250 | if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
|
---|
251 | if (acqmode == "fft1c") { swapall = BR_FFTOneChan; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
---|
252 | if (acqmode == "fft2c") { swapall = BR_FFTTwoChan; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
---|
253 | if (acqmode == "fft1cnof")
|
---|
254 | { swapall = BR_FFTOneChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
---|
255 | if (acqmode == "fft2cnof")
|
---|
256 | { swapall = BR_FFTTwoChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
---|
257 | if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
|
---|
258 | if (acqmode == "monodirect") { monothr = true; swapall = BR_CopyHDR;}
|
---|
259 | if (acqmode == "patmonodirect") { monothr = true; swapall = BR_CopyHDR; activate_pattern=true; }
|
---|
260 | if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
|
---|
261 | if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
|
---|
262 | if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
|
---|
263 |
|
---|
264 | if (acqmode == "swapall") swapall = BR_SwapAll;
|
---|
265 | if (acqmode == "fft1csw")
|
---|
266 | { swapall = BR_FFTOneChanSwapAll; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
---|
267 | if (acqmode == "fft2csw")
|
---|
268 | { swapall = BR_FFTTwoChanSwapAll; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
---|
269 | if (acqmode == "fft1cswnof")
|
---|
270 | { swapall = BR_FFTOneChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
---|
271 | if (acqmode == "fft2cswnof")
|
---|
272 | { swapall = BR_FFTTwoChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
---|
273 | if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
|
---|
274 | if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
|
---|
275 | if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
|
---|
276 | if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
|
---|
277 |
|
---|
278 | if (acqmode == "swap32") swapall = BR_Swap32 ;
|
---|
279 | if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
|
---|
280 | if (acqmode == "fft1c32")
|
---|
281 | { swapall = BR_FFTOneChanSwap32; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
---|
282 | if (acqmode == "fft2c32")
|
---|
283 | { swapall = BR_FFTTwoChanSwap32; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
---|
284 | if (acqmode == "fft1cnof32")
|
---|
285 | { swapall = BR_FFTOneChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
---|
286 | if (acqmode == "fft2cnof32")
|
---|
287 | { swapall = BR_FFTTwoChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
---|
288 |
|
---|
289 | if ((swapall==BR_FFTTwoChan)||(swapall==BR_FFTTwoChanSwapAll)||(swapall==BR_FFTTwoChanSwap32)) {
|
---|
290 | fgdatafft=true;
|
---|
291 | }
|
---|
292 | if ((swapall==BR_FFTOneChan)||(swapall==BR_FFTOneChanSwapAll)||(swapall==BR_FFTOneChanSwap32)) {
|
---|
293 | fgdatafft=true; fgsinglechannel=true;
|
---|
294 | }
|
---|
295 |
|
---|
296 | if (fgreducpsize) {
|
---|
297 | if (redpqsize>=PaqSize) fgreducpsize=false;
|
---|
298 | else {
|
---|
299 | if(reducoffset>(PaqSize-redpqsize)/2) reducoffset=(PaqSize-redpqsize)/2;
|
---|
300 | }
|
---|
301 | }
|
---|
302 | }
|
---|
303 |
|
---|
304 | /* --Methode-- */
|
---|
305 | ostream& BRParList::Print(ostream& os)
|
---|
306 | {
|
---|
307 | os << " ------ BRParList::Print() ----- " << endl;
|
---|
308 | os << " FiberListS=" << FiberListS ;
|
---|
309 | os << " PaqSize=" <<PaqSize;
|
---|
310 | os << " DMA_Size_kb=" <<dmasizekb << endl;
|
---|
311 | os << " AcqMode="<<AcqMode;
|
---|
312 | os << " Type of acquisition :" << BRPaquet::FmtConvToString( swapall) << endl;
|
---|
313 | os << " SkySource=" << skysource;
|
---|
314 | os << " NbFiles="<<NbFiles;
|
---|
315 | os << " NBlocPerFile="<<NBlocPerFile;
|
---|
316 | os << " OutPathName="<<OutPathName << endl;
|
---|
317 | os << " MemMgr: nZones="<<nZones;
|
---|
318 | os << " nPaqZone="<<nPaqZone<<endl;
|
---|
319 | if (fgreducpsize) {
|
---|
320 | os << " PaquetSize Reduction, ReducedSize=" << redpqsize << " Offset=" << reducoffset << endl;
|
---|
321 | }
|
---|
322 | if (fgdoProc>0)
|
---|
323 | os << " Monitoring NMeanProc=" << nmeanProc << " StepProc=" << stepProc << " NMaxProc=" << nmaxProc << endl;
|
---|
324 | else os << " No monotoring thread " << endl;
|
---|
325 | os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false");
|
---|
326 | os << " Save to fits " << ((savesigfits)?"true":"false") << endl;
|
---|
327 | os << " monothr y(1)/n(0) " << ((monothr)?"true":"false");
|
---|
328 | os << " ActivatePattern " << ((activate_pattern)?"true":"false") << endl;
|
---|
329 |
|
---|
330 | return os;
|
---|
331 | }
|
---|
332 |
|
---|
333 |
|
---|
334 | //-------------------- Classe BRAcqConfig -----------------------
|
---|
335 |
|
---|
336 | BRParList* BRAcqConfig::param_=NULL;
|
---|
337 | BRConfList* BRAcqConfig::config_=NULL;
|
---|
338 |
|
---|
339 | /* --Methode-- */
|
---|
340 | BRAcqConfig::BRAcqConfig()
|
---|
341 | {
|
---|
342 | if (param_==NULL) param_ = new BRParList;
|
---|
343 | if (config_==NULL) config_ = new BRConfList;
|
---|
344 | }
|
---|
345 |
|
---|
346 | /* --Methode-- */
|
---|
347 | ostream& BRAcqConfig::Print(ostream& os)
|
---|
348 | {
|
---|
349 | os << " ------------ BAORadio Acq Run/Configuration -------- " << endl;
|
---|
350 | config_->Print(os);
|
---|
351 | param_->Print(os);
|
---|
352 | os << " ----------------------------------------------------- " << endl;
|
---|
353 | }
|
---|
354 |
|
---|
355 | /* --Methode-- */
|
---|
356 | int BRAcqConfig::CreateOutputDirectories()
|
---|
357 | {
|
---|
358 | char cmd[1024];
|
---|
359 | if (param_->fgnulldev4fits!=true) {
|
---|
360 | sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str());
|
---|
361 | if (system(cmd) < 0) {
|
---|
362 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
---|
363 | << cmd << " -> stop" << endl;
|
---|
364 | return 2;
|
---|
365 | }
|
---|
366 | cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
---|
367 |
|
---|
368 | memset(cmd,0,1024);
|
---|
369 | for (int i= 0; i< NFibers() ; i++) {
|
---|
370 | sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->FiberNum[i]);
|
---|
371 | if (system(cmd) < 0) {
|
---|
372 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
---|
373 | << cmd << " -> stop" << endl;
|
---|
374 | return 3;
|
---|
375 | }
|
---|
376 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
---|
377 | }
|
---|
378 | }
|
---|
379 | else {
|
---|
380 | string ProcPathName = "./XZXZXZX/";
|
---|
381 | cout << " Using " << ProcPathName << " for other processed files ... " << endl;
|
---|
382 | char cmd[512];
|
---|
383 | sprintf(cmd,"mkdir %s",ProcPathName.c_str());
|
---|
384 | if (system(cmd) < 0) {
|
---|
385 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/"
|
---|
386 | << "-> stop" << endl;
|
---|
387 | return 3;
|
---|
388 | }
|
---|
389 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
---|
390 | }
|
---|
391 | return 0;
|
---|
392 | }
|
---|
393 |
|
---|
394 | /* --Methode-- */
|
---|
395 | string BRAcqConfig::OutputDirectoryFib(int ifib)
|
---|
396 | {
|
---|
397 | char buff[24];
|
---|
398 | sprintf(buff,"Fiber%d/",param_->FiberNum[ifib]);
|
---|
399 | return ( config_->BaseDirectory() + param_->OutPathName + buff );
|
---|
400 | }
|
---|