Changeset 3623 in Sophya for trunk/AddOn/TAcq/pciewrap.cc


Ignore:
Timestamp:
May 22, 2009, 9:59:38 AM (16 years ago)
Author:
ansari
Message:

Modifications et ameliorations diverses pour programme acquisition/traitement multifibres

Reza 22/05/2009

1- Extension/amelioration classe BRPaquet et BRPaqChecker
2- Correction BUG dans RAcqMemZoneMgr bloquant l'utilisation a une seule zone memoire
3- Classe PCIEWrapper devenue virtuelle pure et introduction de la classe TestPCIWrapperNODMA
pour les smulations.

File:
1 edited

Legend:

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

    r3538 r3623  
    11#include "pciewrap.h"
     2#include "brpaqu.h"
     3
     4#include "racqumem.h"
    25
    36#include <stdlib.h>
    47#include <stdio.h>
    58#include <math.h>
    6 
    79#include <iostream>
    810
    9 PCIEWrapper::PCIEWrapper()
     11TestPCIWrapperNODMA::TestPCIWrapperNODMA(UInt32 sz)
     12  : PCIEWrapper() , size_(sz)
    1013{
    11 // Faire l'initialisation PCI-Express ici
     14  data_ = new Byte[size_];
     15  frame_counter_ = 0;
     16  timetag_ = 0;
     17  tottransfer_ = 0;     
    1218}
    1319
    14 PCIEWrapper::~PCIEWrapper()
     20TestPCIWrapperNODMA::~TestPCIWrapperNODMA()
    1521{
    16 // Faire le nettoyage (liberer memoire ...)
     22  delete[] data_;       
    1723}
    1824
    19 
    20 // Variables pour tests
    21 static uint_4 NBytes = 0;
    22 static uint_4 Choix = 0;
    23 
    24 uint_4  PCIEWrapper::NBytesToRead()
     25UInt32 TestPCIWrapperNODMA::TransferSize()
    2526{
    26 // Lire le registre indiquant le nombre de mots prets a etre lus
    27 // cad transfere en memoire du PC
    28 int choix = rand()%5;
    29 if (choix < 2) {
    30   Choix = choix;
    31   if (choix == 0)  NBytes = 4096;
    32   else NBytes = 5000;
    33 }
    34 else {
    35   NBytes = 0;
    36   Choix = 0;
    37 }
    38 return NBytes; 
     27  return size_;
    3928}
    4029
    41 uint_4  PCIEWrapper::Read(uint_1* buff, uint_4 nbytes)
     30UInt64 TestPCIWrapperNODMA::TotTransferBytes()
    4231{
    43   if (NBytes == 0)  throw PCIEWException("PCIEWrapper::Read()/Error NBytes==0");
    44   if (nbytes > NBytes)  nbytes = NBytes;
    45   double dx = (rand()%8+1)*0.05;
    46   for(int k=0; k<nbytes; k++)  buff[k] = (uint_1)((1.+sin(dx*k))*100.);
    47   if ((Choix == 1) && (nbytes>2000))
    48     for(int k=1600; k<1900; k++) buff[k] = (uint_1)(128);
    49   return nbytes;
     32  return tottransfer_;
    5033}
     34
     35Byte* TestPCIWrapperNODMA::DoTransferData(int numbuff)
     36{
     37  frame_counter_ ++;
     38  timetag_ = frame_counter_ * size_ / 2;
     39  BRPaquet paq(data_, size_);
     40  paq.SetHDRMarker64(pchk_.HDRTag());
     41  paq.SetTRLMarker64(pchk_.TRLTag());
     42  paq.SetFrameCounter(frame_counter_);
     43  paq.SetTimeTag(timetag_);
     44  paq.SetPaqLen((UInt16)((size_ - BRHDRSIZE - BRTRLSIZE)/4));
     45  Byte* bp = paq.Data1();
     46  for(UInt32 kk=0; kk<paq.DataSize(); kk++)
     47    bp[kk] = (Byte)(sin(0.0345*kk)*78.+127.5);
     48  tottransfer_ += size_;
     49  return data_;
     50}
     51
     52void TestPCIWrapperNODMA::PrintStatus(ostream& os)
     53{
     54  os << "TestPCIWrapperNODMA::Status, FrameCounter=" << frame_counter_
     55     << " TimeTag=" << timetag_ << endl;
     56}
Note: See TracChangeset for help on using the changeset viewer.