Changeset 3672 in Sophya for trunk/AddOn


Ignore:
Timestamp:
Nov 13, 2009, 6:39:58 PM (16 years ago)
Author:
ansari
Message:

Corrections diverses - mfacq.cc OK, Reza

Location:
trunk/AddOn/TAcq
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/brparam.cc

    r3671 r3672  
    33#include "bracqvers.h"
    44
     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}
     11
     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}
    584
    685// Classe qui memorise tous les parametres importants de l'acquisition
     
    27106  fgnulldev4fits=false;
    28107  fg_hard_ctrlc=fgcntlc;
    29   fgnulldev4fits = (OutPathName == "/dev/null") ? true : false;
    30 
    31108  fgreducpsize=false;
    32109  redpqsize=PaqSize;
     
    102179  for (int fib=0; fib<fiblist.size(); fib++) {
    103180    FiberNum[fib]=atoi(fiblist[fib].c_str());
     181  }
     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;
    104189  }
    105190  string acqmode = AcqMode;
     
    159244
    160245
     246//-------------------- Classe BRAcqConfig -----------------------
     247
    161248BRParList* BRAcqConfig::param_=NULL;
     249BRConfList* BRAcqConfig::config_=NULL;
    162250
    163251/* --Methode-- */
     
    165253{
    166254  if (param_==NULL)  param_ = new BRParList; 
     255  if (config_==NULL) config_ = new BRConfList;
     256}
     257
     258/* --Methode-- */
     259ostream& BRAcqConfig::Print(ostream& os)
     260{
     261  os << " ------------  BAORadio Acq Run/Configuration -------- " << endl;
     262  config_->Print(os);
     263  param_->Print(os);
     264  os << " ----------------------------------------------------- " << endl;
    167265}
    168266
     
    170268int BRAcqConfig::CreateOutputDirectories()
    171269{
    172   char cmd[512];
     270  char cmd[1024];
    173271  if (param_->fgnulldev4fits!=true) {
    174     sprintf(cmd,"mkdir %s",param_->OutPathName.c_str());
     272    sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str());
    175273    if (system(cmd) < 0) {
    176       cout << "CreateOutputDirectories()/Error: Can not create  subdirectory "
    177            << param_->OutPathName << " -> stop" << endl;
     274      cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
     275           << cmd << " -> stop" << endl;
    178276      return 2;
    179277    }
    180278    cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
    181279   
    182     memset(cmd,0,512);
     280    memset(cmd,0,1024);
    183281    for (int  i= 0; i< NFibers() ; i++)  {
    184       sprintf(cmd,"mkdir %s/Fibre%d",param_->OutPathName.c_str(),param_->FiberNum[i]);
     282      sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->FiberNum[i]);
    185283      if (system(cmd) < 0) {
    186284        cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
    187              << param_->OutPathName << "/FiberII -> stop" << endl;
     285             << cmd << " -> stop" << endl;
    188286        return 3;
    189287      }
     
    202300    }
    203301    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     }
    211302  }
    212303  return 0;
     
    217308{
    218309  char buff[24];
    219   sprintf(buff,"/Fiber%d",param_->FiberNum[ifib]);
    220   return ( param_->OutPathName + buff );
    221 }
     310  sprintf(buff,"Fiber%d/",param_->FiberNum[ifib]);
     311  return ( config_->BaseDirectory() + param_->OutPathName + buff );
     312}
  • trunk/AddOn/TAcq/brparam.h

    r3671 r3672  
    88
    99//---------------------------------------------------------------
    10 //  Classes BRParList , BRConfList , BRAcqConfig
    11 //  BRParList : Liste de parametres pour un run d'acquisition
    12 //  BRConfList : Liste des parametres caracterisant une configuration
     10//  Classes ADCBoardDesc , BRParList , BRConfList , BRAcqConfig
     11//  + ADCBoardDesc : Description d'une carte ADC
     12//  + BRParList : Liste de parametres pour un run d'acquisition
     13//  + BRConfList : Liste des parametres caracterisant une configuration
    1314//       (nombre de cartes, versions firwares ...)
    14 //  BRAcqConfig : Classe donnant acces a un objet global BRParList et
     15//  + BRAcqConfig : Classe donnant acces a un objet global BRParList et
    1516//         un objet global BRConfList
    1617//---------------------------------------------------------------
     
    1819#include "machdefs.h"
    1920#include <string>
     21#include <vector>
     22#include <iostream>
    2023#include "brpaqu.h"
    2124#include "datacards.h"
     
    2427using namespace std;
    2528using namespace SOPHYA;
     29
     30//-----------------------------------------------------------------------------
     31//---- Classe Caracterisant un board ADC
     32class ADCBoardDesc {
     33public:
     34  ADCBoardDesc(int id, string sbid, string cyc_firmw, string str1_firmw, string str2_firmw);
     35  ADCBoardDesc(ADCBoardDesc const& bdes);
     36
     37  inline int& getId() { return id_; }
     38  inline string& getSId() { return sbid_; }
     39  inline string& CycloneFirmwareId() { return cyclone_firmware_; }
     40  inline string& Stratix1FirmwareId() { return stratix1_firmware_; }
     41  inline string& Stratix2FirmwareId() { return stratix2_firmware_; }
     42  ostream& Print(ostream& os);
     43
     44  ADCBoardDesc& Set(ADCBoardDesc const & bdes);
     45  inline ADCBoardDesc& operator = (ADCBoardDesc const & bdes) { return Set(bdes); }
     46protected:
     47  int id_;
     48  string sbid_;
     49  string cyclone_firmware_;
     50  string stratix1_firmware_;
     51  string stratix2_firmware_; 
     52};
     53
     54//-----------------------------------------------------------------------------
     55//---- Classe de liste des parametres de configuration BAORadio
     56class BRConfList {
     57public:
     58  BRConfList();
     59  BRConfList(string basedir);
     60  BRConfList(string basedir, vector<ADCBoardDesc> boards);
     61  BRConfList(BRConfList const & cf);
     62  void Set(BRConfList const & cf);
     63  ostream& Print(ostream& os) ;
     64  void ReadDCFile(string file);
     65  inline string& BaseDirectory() { return basedir_; }
     66//.......................................
     67  string basedir_;
     68  vector<ADCBoardDesc> boards_;
     69};
    2670
    2771#define PMAXNBFIBRES 6
     
    110154  BRAcqConfig();
    111155
    112   inline void ReadDCFile(string file)
     156  inline void ReadParamFile(string file)
    113157    { param_->ReadDCFile(file); }
    114158  inline void Set(BRParList& par)
    115159    { param_->Set(par); }
    116   inline ostream& Print(ostream& os)
    117     { return param_->Print(os); }
     160  inline void ReadConfigFile(string file)
     161    { config_->ReadDCFile(file); }
     162  inline void Set(BRConfList& conf)
     163    { config_->Set(conf); }
     164
     165  ostream& Print(ostream& os);
    118166
    119167  int CreateOutputDirectories();
     
    121169  static inline double AcqVersion()  { return BAOR_ACQ_VER ; }
    122170  static inline const char* AcqVersionS() { return BAOR_ACQ_VER_STR ; }
    123  
     171
    124172  inline BRParList&  GetParams() { return (*param_) ;};
     173  inline BRConfList&  GetConfig() { return (*config_) ;};
     174 
    125175  inline BRDataFmtConv GetSwapall() { return param_->swapall; };
    126176  inline bool GetPattern() { return param_->activate_pattern; };
     
    150200
    151201  // repertoire d'acquisition
    152   inline string& OutputDirectory() { param_->OutPathName; }
     202  inline string OutputDirectory() { return (config_->BaseDirectory()+param_->OutPathName); }
    153203  string OutputDirectoryFib(int fib);
    154204
    155205 protected:
    156206  static BRParList* param_;
     207  static BRConfList* config_;
    157208};
    158209
  • trunk/AddOn/TAcq/mfacq.cc

    r3671 r3672  
    4949    // Creation/initialisation parametres Acq
    5050    BRAcqConfig acpar;
    51     acpar.ReadDCFile(arg[1]);
     51    acpar.ReadParamFile(arg[1]);
     52#ifndef NOPCIECARD 
     53    BRConfList conf("/Raid");
     54#else
     55    BRConfList conf("./");
     56#endif
     57    acpar.Set(conf);
    5258    // Creation des repertoires
    5359    if (acpar.CreateOutputDirectories()!=0)  return 9;
     
    139145
    140146  cout <<"mfacq[3] Creating DataSaver and DataProc2C objects ... " << endl;
    141   MultiDataSaver DsThr(mmgr, bpar.OutputDirectory(), bpar.MaxNbFiles(),
    142                        bpar.BlocPerFile(), bpar.GetSaveFits());
     147  MultiDataSaver DsThr(mmgr);   //   Utilise les parametres globaux BRAcqConfig
    143148  string ppath=bpar.OutputDirectory();
    144149  DataProc2C PrThr(mmgr, ppath, 1280, stepproc, acpar.NMaxProc);
     
    146151  for  (int i=0 ;i<bpar.NFibers();i++)  vec_pciw.push_back( pciwp[i]);
    147152  cout << "mfacq[3] Creating   PCIEMultiReader       " << endl;
    148   PCIEMultiReader PcierThr(vec_pciw,bpar.DMASizeBytes(),bpar.RecvPaquetSize(),
    149                            mmgr, bpar.MaxNbBlocs(), bpar.GetDataConvFg());
     153  PCIEMultiReader PcierThr(vec_pciw, mmgr, bpar.GetParams());
    150154  usleep(200);  // attente au cas ou ...
    151155  pPcierThr=&PcierThr;
  • trunk/AddOn/TAcq/racqurw.cc

    r3671 r3672  
    332332//----------------------------------------------------------------------------------------------------------
    333333
    334 PCIEReaderChecker::PCIEReaderChecker(PCIEWrapperInterface &pciw,uint_4 sizeFrame,uint_4 packSize ,RAcqMemZoneMgr& mem,
    335                                      uint_4 nmax, BRDataFmtConv swapall)
     334PCIEReaderChecker::PCIEReaderChecker(PCIEWrapperInterface &pciw, uint_4 sizeFrame,uint_4 packSize, RAcqMemZoneMgr& mem,
     335                                     uint_4 nmax, BRDataFmtConv swapall) 
    336336  :   memgr(mem) , pciw_ (pciw)
    337337{
     
    464464
    465465/* --Methode-- */
    466 PCIEMultiReader::PCIEMultiReader(vector<PCIEWrapperInterface*> vec_pciw,uint_4 sizeFrame,uint_4 packSize ,RAcqMemZoneMgr& mem, uint_4 nmax, BRDataFmtConv swapall)
    467   :   memgr(mem) , vec_pciw_ (vec_pciw)
    468 {
    469   nmax_ = nmax;
    470   swapall_ = swapall;   // select data swap/format conversion for BRPaquet
     466PCIEMultiReader::PCIEMultiReader(vector<PCIEWrapperInterface*> vec_pciw, RAcqMemZoneMgr& mem, BRParList const& par)
     467  :   memgr(mem), par_(par), vec_pciw_ (vec_pciw)
     468{
     469  nmax_ = par_.MaxNbBlocs();   
     470  swapall_ = par_.GetDataConvFg();      // select data swap/format conversion for BRPaquet
    471471  stop_ = false;
    472   packSize_ = packSize;
     472  packSize_ = par_.RecvPaquetSize();
    473473  packSizeInMgr_=memgr.PaqSize();
    474   sizeFr_ =sizeFrame;
     474  sizeFr_=par_.DMASizeBytes();
    475475  if (vec_pciw.size() != memgr.NbFibres()) {
    476476    cout << " PCIEMultiReader()PbArgs: vec_pciw.size()= " << vec_pciw.size() << " memgr.NbFibres()=" <<memgr.NbFibres()<< endl;
     
    688688//--------------------------------------------------------------------
    689689
    690 MultiDataSaver::MultiDataSaver(RAcqMemZoneMgr& mem, string path, uint_4 nfiles, uint_4 nblocperfile, bool savesig)
     690/* --Methode-- */
     691MultiDataSaver::MultiDataSaver(RAcqMemZoneMgr& mem)
    691692  :  memgr(mem)
    692 {
    693   nfiles_ = nfiles;
    694   nblocperfile_ = nblocperfile;
     693
     694  BRAcqConfig bpar;
     695  nfiles_ = bpar.MaxNbFiles();
     696  nblocperfile_ = bpar.BlocPerFile();
    695697  nmax_ = nblocperfile_*nfiles_;
    696   savesig_ = savesig;  // Si false, pas d'ecriture des fichiers FITS du signal 
     698  savesig_ = bpar.GetSaveFits();  // Si false, pas d'ecriture des fichiers FITS du signal       
    697699  stop_ = false;       
    698   path_ = path;
    699 }
     700}
     701
     702/* --Methode-- */
    700703void MultiDataSaver::Stop()
    701704{
    702705  // cout<< " MultiDataSaver:Stop ........ " << endl;
    703706  stop_=true;
    704 
    705 }
     707}
     708
     709/* --Methode-- */
    706710void MultiDataSaver::run()
    707711{
     
    715719    char fname[512];
    716720
    717     sprintf(fname,"%s/msaver.log",path_.c_str());
     721    sprintf(fname,"%s/msaver.log",bpar.OutputDirectory().c_str());
    718722    ofstream filog(fname);
    719723    filog << " MultiDataSaver::run() - starting log file " << ts << " NFibres= " << memgr.NbFibres() << endl;                 
     
    727731    uint_4 paqsz = memgr.PaqSize();
    728732    cout << " ============================ MultiDataSaver::run() PaqSize " << paqsz <<endl;
    729     bool fgnulldev = false;
    730     if (path_ == "/dev/null") {
     733    bool fgnulldev = bpar.GetFileDevNull();
     734    if (fgnulldev) {
    731735      cout << " MultiDataSaver::run()/Warning /dev/null path specified, filenames=/dev/null" << endl;
    732736      fgnulldev = true;
     
    740744        for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
    741745          if (fgnulldev) strcpy(fname,"/dev/null");
    742           else sprintf(fname,"%s/Fibre%d/HDRfits%d.txt",path_.c_str(),fib+1,fnum);
     746          else sprintf(fname,"%sHDRfits%d.txt",bpar.OutputDirectoryFib(fib).c_str(),fnum);
    743747          header[fib].open(fname);
    744748        }
     
    749753        for(uint_4 fib=0; fib<memgr.NbFibres(); fib++)    {
    750754          if (fgnulldev) strcpy(fname,"/dev/null");
    751           else sprintf(fname,"%s/Fibre%d/signal%d.fits",path_.c_str(),fib+1,(int)fnum);
     755          else sprintf(fname,"%ssignal%d.fits",bpar.OutputDirectoryFib(fib).c_str(),(int)fnum);
     756          //      cout << " ***DBG** Opening file " << fname << endl;
    752757          mff[fib].Open(fname,MF_Write);  //Reza - Ouverture conditionnel fichier
    753758          // Entete correspondant a l'ecriture tout le paquet - trailer compris (modif Mai 2009)
     
    797802        if (savesig_) {
    798803          if (fgnulldev) strcpy(fname,"/dev/null");
    799           else sprintf(fname,"%s/Fibre%d/signal%d.fits",path_.c_str(),fib+1,(int)fnum-1);
     804          else sprintf(fname,"%ssignal%d.fits",bpar.OutputDirectoryFib(fib).c_str(),(int)fnum);
    800805        }
    801806        else sprintf(fname,"MemDataBloc[%d]-NoDataFile",(int)fnum-1);
  • trunk/AddOn/TAcq/racqurw.h

    r3671 r3672  
    114114class PCIEMultiReader : public ZThread {
    115115public:
    116   PCIEMultiReader( vector<PCIEWrapperInterface*> vec_pciw , uint_4 sizeFrame,uint_4 paqSize, RAcqMemZoneMgr& mem,
    117                    uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll); 
     116  PCIEMultiReader(vector<PCIEWrapperInterface*> vec_pciw , RAcqMemZoneMgr& mem, BRParList const& par);
    118117  virtual void run();
    119118   void Stop();
     
    134133  }
    135134  bool MZoneManage(bool clean=false);  // Renvoie true si probleme
     135 
     136  RAcqMemZoneMgr& memgr;
     137  BRParList par_;   // Parametres divers d'acquisition
    136138
    137   RAcqMemZoneMgr& memgr;
    138139  uint_4 nmax_;  // Nombre maxi de blocs MemZone traites
    139140  BRDataFmtConv swapall_;  // select data swap/format conversion for BRPaquet
     
    158159//----------------------------------------------------------------------------------------
    159160
     161// --- Cette classe utilise les parametres globaux d'acquisition BRAcqConfig
    160162class MultiDataSaver : public ZThread {
    161163public:
    162   MultiDataSaver(RAcqMemZoneMgr& mem, string path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true);
     164  MultiDataSaver(RAcqMemZoneMgr& mem);
    163165
    164166  virtual void run();
     
    169171
    170172  RAcqMemZoneMgr& memgr;
     173
    171174  uint_4 nfiles_;  // Nombre maxi de fichiers cree
    172175  uint_4 nblocperfile_;  // Nombre de bloc (zone memoire) mis dans un fichier
     
    174177  bool savesig_; // Si false, pas d'ecriture des fichiers FITS du signal
    175178  bool stop_; 
    176   string path_; 
    177   struct sigaction act;
    178179};
    179180
Note: See TracChangeset for help on using the changeset viewer.