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

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

Corrections diverses - mfacq.cc OK, Reza

File size: 9.5 KB
RevLine 
[3671]1#include "brparam.h"
2#include "strutilxx.h"
3#include "bracqvers.h"
4
[3672]5/* --Methode-- */
6ADCBoardDesc::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}
[3671]11
[3672]12/* --Methode-- */
13ADCBoardDesc::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-- */
20ADCBoardDesc& 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-- */
31ostream& 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-- */
39BRConfList::BRConfList()
40 : basedir_("./")
41{
42}
43
44/* --Methode-- */
45BRConfList::BRConfList(string basedir)
46 : basedir_(basedir)
47{
48}
49
50/* --Methode-- */
51BRConfList::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-- */
59BRConfList::BRConfList(BRConfList const & cf)
60 : basedir_(cf.basedir_), boards_(cf.boards_)
61{
62}
63
64/* --Methode-- */
65void BRConfList::Set(BRConfList const & cf)
66{
67 basedir_=cf.basedir_;
68 boards_=cf.boards_;
69}
70
71/* --Methode-- */
72ostream& BRConfList::Print(ostream& os)
73{
74 os << " ----- BRConfList:: BaseDir:" << basedir_ << " NBoards= " << boards_.size() << endl;
75 for(size_t k=0; k<boards_.size(); k++) boards_[k].Print(os);
76 return os;
77}
78
79/* --Methode-- */
80void BRConfList::ReadDCFile(string file)
81{
82 // A FAIRE
83}
84
[3671]85// Classe qui memorise tous les parametres importants de l'acquisition
86
87/* --Methode-- */
88BRParList::BRParList(string fibres,unsigned int paqsz ,unsigned int nframeDMA,
89 int nfiles, string acqmod,int nblocfile,int nmxproc ,
90 string outpath, uint_4 nzon , uint_4 npaqzon, bool fgcntlc)
91{
92 FiberListS=fibres;
93 NbFibers=0;
94 for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=0;
95 PaqSize=paqsz;
96 nbFrameDMA=nframeDMA;
97 NbFiles=nfiles;
98 AcqMode=acqmod;
99 NBlocPerFile=nblocfile;
100 NMaxProc=nmxproc;
101 OutPathName=outpath;
102 nZones=nzon;
103 nPaqZone=npaqzon;
104 swapall=BR_Copy;
105 savesigfits=true;
106 fgnulldev4fits=false;
107 fg_hard_ctrlc=fgcntlc;
108 fgreducpsize=false;
109 redpqsize=PaqSize;
110 reducoffset=0;
111
112 monothr=false;
113 activate_pattern=false;
114
115 Decode(); // On decode et on complete les parametres
116}
117
118/* --Methode-- */
119BRParList::BRParList(BRParList const & p)
120{
121 Set(p);
122}
123
124/* --Methode-- */
125void BRParList::Set(BRParList const & p)
126{
127 FiberListS=p.FiberListS;
128 NbFibers=p.NbFibers;
129 for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=p.FiberNum[fib];
130 PaqSize=p.PaqSize;
131 nbFrameDMA=p.nbFrameDMA;
132 NbFiles=p.NbFiles;
133 AcqMode=p.AcqMode;
134 NBlocPerFile=p.NBlocPerFile;
135 NMaxProc=p.NMaxProc;
136 OutPathName=p.OutPathName;
137 nZones=p.nZones;
138 nPaqZone=p.nPaqZone;
139 swapall=p.swapall;
140 savesigfits=p.savesigfits;
141 fgnulldev4fits=p.fgnulldev4fits;
142 fg_hard_ctrlc=p.fg_hard_ctrlc;
143 fgnulldev4fits=p.fgnulldev4fits;
144
145 fgreducpsize=p.fgreducpsize;
146 redpqsize=p.redpqsize;
147 reducoffset=p.reducoffset;
148
149 monothr=p.monothr;
150 activate_pattern=p.activate_pattern;
151 return;
152}
153
154/* --Methode-- */
155void BRParList::ReadDCFile(string file)
156{
157 DataCards conf(file);
158 FiberListS= conf.SParam("Fibres",0,"1");
159 PaqSize=(unsigned int)conf.IParam("PaqSZ",0,16424);
160 nbFrameDMA =(unsigned int) conf.IParam("nbFrameDma",0,32);
161 NbFiles=conf.IParam("NbFiles",0,1);
162 NBlocPerFile=conf.IParam("NBlocPerFile",0,10);
163 NMaxProc=conf.IParam("NMaxProc",0,0);
164 OutPathName= conf.SParam("OutPathName",0,"TstAcq");
165 AcqMode =conf.SParam("acqmode",0,"std");
166 nZones=(unsigned int)conf.IParam("nZones",0,4);
167 nPaqZone=(uint_4)conf.IParam("nPaqZone",0,128);
168 fg_hard_ctrlc=conf.HasKey("fg_hard_ctrlc");
169
170 Decode();
171}
172
173/* --Methode-- */
174void BRParList::Decode()
175{
176 vector<string> fiblist;
177 FillVStringFrString(FiberListS, fiblist, ',');
178 NbFibers=fiblist.size();
179 for (int fib=0; fib<fiblist.size(); fib++) {
180 FiberNum[fib]=atoi(fiblist[fib].c_str());
181 }
[3672]182 if (OutPathName == "/dev/null") {
183 fgnulldev4fits=true;
184 }
185 else {
186 size_t len = OutPathName.length();
187 if ((len>1)&&(OutPathName[len-1]!='/')) OutPathName+='/';
188 fgnulldev4fits=false;
189 }
[3671]190 string acqmode = AcqMode;
191 if (acqmode == "std") swapall = BR_Copy ;
192 if (acqmode == "nosw") swapall = BR_Copy ;
193 if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
194 if (acqmode == "fft1c") swapall = BR_FFTOneChan;
195 if (acqmode == "fft2c") swapall = BR_FFTTwoChan;
196 if (acqmode == "fft1cnof") { swapall = BR_FFTOneChan; savesigfits = false; }
197 if (acqmode == "fft2cnof") { swapall = BR_FFTTwoChan; savesigfits = false; }
198 if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
199 if (acqmode == "monodirect") { monothr = true; swapall = BR_CopyHDR;}
200 if (acqmode == "patmonodirect") { monothr = true; swapall = BR_CopyHDR; activate_pattern=true; }
201 if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
202 if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
203 if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
204
205 if (acqmode == "swapall") swapall = BR_SwapAll;
206 if (acqmode == "fft1csw") swapall = BR_FFTOneChanSwapAll;
207 if (acqmode == "fft2csw") swapall = BR_FFTTwoChanSwapAll;
208 if (acqmode == "fft1cswnof") { swapall = BR_FFTOneChanSwapAll; savesigfits = false; }
209 if (acqmode == "fft2cswnof") { swapall = BR_FFTTwoChanSwapAll; savesigfits = false; }
210 if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
211 if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
212 if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
213 if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
214
215 if (acqmode == "swap32") swapall = BR_Swap32 ;
216 if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
217 if (acqmode == "fft1c32") swapall = BR_FFTOneChanSwap32;
218 if (acqmode == "fft2c32") swapall = BR_FFTTwoChanSwap32;
219 if (acqmode == "fft1cnof32") { swapall = BR_FFTOneChanSwap32; savesigfits = false; }
220 if (acqmode == "fft2cnof32") { swapall = BR_FFTTwoChanSwap32; savesigfits = false; }
221}
222
223/* --Methode-- */
224ostream& BRParList::Print(ostream& os)
225{
226 os << " ------ BRParList::Print() ----- " << endl;
227 os << " FiberListS=" << FiberListS ;
228 os << " PaqSize=" <<PaqSize;
229 os << " nbFrameDMA=" <<nbFrameDMA << endl;
230 os << " AcqMode="<<AcqMode;
231 os << " Type of acquisition :" << BRPaquet::FmtConvToString( swapall) << endl;
232 os << " NbFiles="<<NbFiles;
233 os << " NBlocPerFile="<<NBlocPerFile;
234 os << " OutPathName="<<OutPathName << endl;
235 os << " MemMgr: nZones="<<nZones;
236 os << " nPaqZone="<<nPaqZone;
237 os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false");
238 os << " Save to fits " << ((savesigfits)?"true":"false") << endl;
239 os << " monothr y(1)/n(0) " << ((monothr)?"true":"false");
240 os << " ActivatePattern " << ((activate_pattern)?"true":"false") << endl;
241
242 return os;
243}
244
245
[3672]246//-------------------- Classe BRAcqConfig -----------------------
247
[3671]248BRParList* BRAcqConfig::param_=NULL;
[3672]249BRConfList* BRAcqConfig::config_=NULL;
[3671]250
251/* --Methode-- */
252BRAcqConfig::BRAcqConfig()
253{
254 if (param_==NULL) param_ = new BRParList;
[3672]255 if (config_==NULL) config_ = new BRConfList;
[3671]256}
257
258/* --Methode-- */
[3672]259ostream& BRAcqConfig::Print(ostream& os)
260{
261 os << " ------------ BAORadio Acq Run/Configuration -------- " << endl;
262 config_->Print(os);
263 param_->Print(os);
264 os << " ----------------------------------------------------- " << endl;
265}
266
267/* --Methode-- */
[3671]268int BRAcqConfig::CreateOutputDirectories()
269{
[3672]270 char cmd[1024];
[3671]271 if (param_->fgnulldev4fits!=true) {
[3672]272 sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str());
[3671]273 if (system(cmd) < 0) {
[3672]274 cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
275 << cmd << " -> stop" << endl;
[3671]276 return 2;
277 }
278 cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
279
[3672]280 memset(cmd,0,1024);
[3671]281 for (int i= 0; i< NFibers() ; i++) {
[3672]282 sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->FiberNum[i]);
[3671]283 if (system(cmd) < 0) {
284 cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
[3672]285 << cmd << " -> stop" << endl;
[3671]286 return 3;
287 }
288 else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
289 }
290 }
291 else {
292 string ProcPathName = "./XZXZXZX/";
293 cout << " Using " << ProcPathName << " for other processed files ... " << endl;
294 char cmd[512];
295 sprintf(cmd,"mkdir %s",ProcPathName.c_str());
296 if (system(cmd) < 0) {
297 cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/"
298 << "-> stop" << endl;
299 return 3;
300 }
301 else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
302 }
303 return 0;
304}
305
306/* --Methode-- */
307string BRAcqConfig::OutputDirectoryFib(int ifib)
308{
309 char buff[24];
[3672]310 sprintf(buff,"Fiber%d/",param_->FiberNum[ifib]);
311 return ( config_->BaseDirectory() + param_->OutPathName + buff );
[3671]312}
Note: See TracBrowser for help on using the repository browser.